genirq: Add default_affinity argument to __irq_alloc_descs()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Sun, 4 Oct 2020 15:51:38 +0000 (16:51 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Oct 2020 10:17:46 +0000 (11:17 +0100)
It already takes an array of affinities for each individual irq being
allocated but that's awkward to allocate and populate in the case
where they're all the same and inherited from the irqdomain, so pass
the default in separately as a simple cpumask.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
include/linux/irq.h
kernel/irq/devres.c
kernel/irq/irqdesc.c
kernel/irq/irqdomain.c

index 1b7f4dfee35b3977501deff96fd99732cbda3f51..6e119594d35de1d385ed057507ab1da59ffe4828 100644 (file)
@@ -897,15 +897,17 @@ unsigned int arch_dynirq_lower_bound(unsigned int from);
 
 int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
                      struct module *owner,
-                     const struct irq_affinity_desc *affinity);
+                     const struct irq_affinity_desc *affinity,
+                     const struct cpumask *default_affinity);
 
 int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
                           unsigned int cnt, int node, struct module *owner,
-                          const struct irq_affinity_desc *affinity);
+                          const struct irq_affinity_desc *affinity,
+                          const struct cpumask *default_affinity);
 
 /* use macros to avoid needing export.h for THIS_MODULE */
 #define irq_alloc_descs(irq, from, cnt, node)  \
-       __irq_alloc_descs(irq, from, cnt, node, THIS_MODULE, NULL)
+       __irq_alloc_descs(irq, from, cnt, node, THIS_MODULE, NULL, NULL)
 
 #define irq_alloc_desc(node)                   \
        irq_alloc_descs(-1, 0, 1, node)
@@ -920,7 +922,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
        irq_alloc_descs(-1, from, cnt, node)
 
 #define devm_irq_alloc_descs(dev, irq, from, cnt, node)                \
-       __devm_irq_alloc_descs(dev, irq, from, cnt, node, THIS_MODULE, NULL)
+       __devm_irq_alloc_descs(dev, irq, from, cnt, node, THIS_MODULE, NULL, NULL)
 
 #define devm_irq_alloc_desc(dev, node)                         \
        devm_irq_alloc_descs(dev, -1, 0, 1, node)
index f6e5515ee0774346c8bd8bcebc93f5b0e38f7230..079339decc23662b14e379e5447f92f21d837612 100644 (file)
@@ -170,6 +170,8 @@ static void devm_irq_desc_release(struct device *dev, void *res)
  * @affinity:  Optional pointer to an irq_affinity_desc array of size @cnt
  *             which hints where the irq descriptors should be allocated
  *             and which default affinities to use
+ * @default_affinity: Optional pointer to a cpumask indicating the default
+ *              affinity to use where not specified by the @affinity array
  *
  * Returns the first irq number or error code.
  *
@@ -177,7 +179,8 @@ static void devm_irq_desc_release(struct device *dev, void *res)
  */
 int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
                           unsigned int cnt, int node, struct module *owner,
-                          const struct irq_affinity_desc *affinity)
+                          const struct irq_affinity_desc *affinity,
+                          const struct cpumask *default_affinity)
 {
        struct irq_desc_devres *dr;
        int base;
@@ -186,7 +189,8 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
        if (!dr)
                return -ENOMEM;
 
-       base = __irq_alloc_descs(irq, from, cnt, node, owner, affinity);
+       base = __irq_alloc_descs(irq, from, cnt, node, owner, affinity,
+                                default_affinity);
        if (base < 0) {
                devres_free(dr);
                return base;
index 4ac91b9fc618ed6b0cbca9139152dce4fefc253e..fcc3b8a1fe01c940d166117040af5879571d77ef 100644 (file)
@@ -770,15 +770,21 @@ EXPORT_SYMBOL_GPL(irq_free_descs);
  * @affinity:  Optional pointer to an affinity mask array of size @cnt which
  *             hints where the irq descriptors should be allocated and which
  *             default affinities to use
+ * @default_affinity: Optional pointer to a cpumask indicating the default
+ *              affinity where not specified in the @affinity array
  *
  * Returns the first irq number or error code
  */
 int __ref
 __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
-                 struct module *owner, const struct irq_affinity_desc *affinity)
+                 struct module *owner, const struct irq_affinity_desc *affinity,
+                 const struct cpumask *default_affinity)
 {
        int start, ret;
 
+       if (!default_affinity)
+               default_affinity = irq_default_affinity;
+
        if (!cnt)
                return -EINVAL;
 
@@ -808,7 +814,7 @@ __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
                if (ret)
                        goto unlock;
        }
-       ret = alloc_descs(start, cnt, node, affinity, irq_default_affinity, owner);
+       ret = alloc_descs(start, cnt, node, affinity, default_affinity, owner);
 unlock:
        mutex_unlock(&sparse_irq_lock);
        return ret;
index 76cd7ebd1178c15e24437435d420960192d88fc5..c93e00ca11d864994c425001fcc2d97fced7be09 100644 (file)
@@ -1017,16 +1017,16 @@ int irq_domain_alloc_descs(int virq, unsigned int cnt, irq_hw_number_t hwirq,
 
        if (virq >= 0) {
                virq = __irq_alloc_descs(virq, virq, cnt, node, THIS_MODULE,
-                                        affinity);
+                                        affinity, NULL);
        } else {
                hint = hwirq % nr_irqs;
                if (hint == 0)
                        hint++;
                virq = __irq_alloc_descs(-1, hint, cnt, node, THIS_MODULE,
-                                        affinity);
+                                        affinity, NULL);
                if (virq <= 0 && hint > 1) {
                        virq = __irq_alloc_descs(-1, 1, cnt, node, THIS_MODULE,
-                                                affinity);
+                                                affinity, NULL);
                }
        }