]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
irqdomain: Add firmware info reporting interface
authorMarc Zyngier <maz@kernel.org>
Mon, 20 Oct 2025 12:29:18 +0000 (13:29 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 27 Oct 2025 16:16:32 +0000 (17:16 +0100)
Add an irqdomain callback to report firmware-provided information that is
otherwise not available in a generic way. This is reported using a new data
structure (struct irq_fwspec_info).

This callback is optional and the only information that can be reported
currently is the affinity of an interrupt. However, the containing
structure is designed to be extensible, allowing other potentially relevant
information to be reported in the future.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Will Deacon <will@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Link: https://patch.msgid.link/20251020122944.3074811-2-maz@kernel.org
include/linux/irqdomain.h
kernel/irq/irqdomain.c

index 4a86e6b915dd69309d046379e9cf5ad1ff83036f..9d6a5e99394fac565952f03c25d2c7f20c9f8743 100644 (file)
@@ -44,6 +44,23 @@ struct irq_fwspec {
        u32                     param[IRQ_DOMAIN_IRQ_SPEC_PARAMS];
 };
 
+/**
+ * struct irq_fwspec_info - firmware provided IRQ information structure
+ *
+ * @flags:             Information validity flags
+ * @cpumask:           Affinity mask for this interrupt
+ *
+ * This structure reports firmware-specific information about an
+ * interrupt. The only significant information is the affinity of a
+ * per-CPU interrupt, but this is designed to be extended as required.
+ */
+struct irq_fwspec_info {
+       unsigned long           flags;
+       const struct cpumask    *affinity;
+};
+
+#define IRQ_FWSPEC_INFO_AFFINITY_VALID BIT(0)
+
 /* Conversion function from of_phandle_args fields to fwspec  */
 void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
                               unsigned int count, struct irq_fwspec *fwspec);
@@ -69,6 +86,9 @@ void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
  * @translate: Given @fwspec, decode the hardware irq number (@out_hwirq) and
  *             linux irq type value (@out_type). This is a generalised @xlate
  *             (over struct irq_fwspec) and is preferred if provided.
+ * @get_fwspec_info:
+ *             Given @fwspec, report additional firmware-provided information in
+ *             @info. Optional.
  * @debug_show:        For domains to show specific data for an interrupt in debugfs.
  *
  * Functions below are provided by the driver and called whenever a new mapping
@@ -96,6 +116,7 @@ struct irq_domain_ops {
        void    (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
        int     (*translate)(struct irq_domain *d, struct irq_fwspec *fwspec,
                             unsigned long *out_hwirq, unsigned int *out_type);
+       int     (*get_fwspec_info)(struct irq_fwspec *fwspec, struct irq_fwspec_info *info);
 #endif
 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
        void    (*debug_show)(struct seq_file *m, struct irq_domain *d,
@@ -602,6 +623,8 @@ void irq_domain_free_irqs_parent(struct irq_domain *domain, unsigned int irq_bas
 
 int irq_domain_disconnect_hierarchy(struct irq_domain *domain, unsigned int virq);
 
+int irq_populate_fwspec_info(struct irq_fwspec *fwspec, struct irq_fwspec_info *info);
+
 static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
 {
        return domain->flags & IRQ_DOMAIN_FLAG_HIERARCHY;
@@ -685,6 +708,10 @@ static inline bool irq_domain_is_msi_device(struct irq_domain *domain)
        return false;
 }
 
+static inline int irq_populate_fwspec_info(struct irq_fwspec *fwspec, struct irq_fwspec_info *info)
+{
+       return -EINVAL;
+}
 #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
 
 #ifdef CONFIG_GENERIC_MSI_IRQ
index dc473faadcc812ca01b0bde820b1f8bf562b124c..2652c4cfd877f2ea20d502d7047f3c3d7efa2638 100644 (file)
@@ -867,13 +867,9 @@ void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
 }
 EXPORT_SYMBOL_GPL(of_phandle_args_to_fwspec);
 
-unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
+static struct irq_domain *fwspec_to_domain(struct irq_fwspec *fwspec)
 {
        struct irq_domain *domain;
-       struct irq_data *irq_data;
-       irq_hw_number_t hwirq;
-       unsigned int type = IRQ_TYPE_NONE;
-       int virq;
 
        if (fwspec->fwnode) {
                domain = irq_find_matching_fwspec(fwspec, DOMAIN_BUS_WIRED);
@@ -883,6 +879,32 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
                domain = irq_default_domain;
        }
 
+       return domain;
+}
+
+#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
+int irq_populate_fwspec_info(struct irq_fwspec *fwspec, struct irq_fwspec_info *info)
+{
+       struct irq_domain *domain = fwspec_to_domain(fwspec);
+
+       memset(info, 0, sizeof(*info));
+
+       if (!domain || !domain->ops->get_fwspec_info)
+               return 0;
+
+       return domain->ops->get_fwspec_info(fwspec, info);
+}
+#endif
+
+unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
+{
+       unsigned int type = IRQ_TYPE_NONE;
+       struct irq_domain *domain;
+       struct irq_data *irq_data;
+       irq_hw_number_t hwirq;
+       int virq;
+
+       domain = fwspec_to_domain(fwspec);
        if (!domain) {
                pr_warn("no irq domain found for %s !\n",
                        of_node_full_name(to_of_node(fwspec->fwnode)));