]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
genirq/affinity: Add is_managed to struct irq_affinity_desc
authorDou Liyang <douliyangs@gmail.com>
Tue, 4 Dec 2018 15:51:21 +0000 (23:51 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 19 Dec 2018 10:32:08 +0000 (11:32 +0100)
Devices which use managed interrupts usually have two classes of
interrupts:

  - Interrupts for multiple device queues
  - Interrupts for general device management

Currently both classes are treated the same way, i.e. as managed
interrupts. The general interrupts get the default affinity mask assigned
while the device queue interrupts are spread out over the possible CPUs.

Treating the general interrupts as managed is both a limitation and under
certain circumstances a bug. Assume the following situation:

 default_irq_affinity = 4..7

So if CPUs 4-7 are offlined, then the core code will shut down the device
management interrupts because the last CPU in their affinity mask went
offline.

It's also a limitation because it's desired to allow manual placement of
the general device interrupts for various reasons. If they are marked
managed then the interrupt affinity setting from both user and kernel space
is disabled. That limitation was reported by Kashyap and Sumit.

Expand struct irq_affinity_desc with a new bit 'is_managed' which is set
for truly managed interrupts (queue interrupts) and cleared for the general
device interrupts.

[ tglx: Simplify code and massage changelog ]

Reported-by: Kashyap Desai <kashyap.desai@broadcom.com>
Reported-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Dou Liyang <douliyangs@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-pci@vger.kernel.org
Cc: shivasharan.srikanteshwara@broadcom.com
Cc: ming.lei@redhat.com
Cc: hch@lst.de
Cc: bhelgaas@google.com
Cc: douliyang1@huawei.com
Link: https://lkml.kernel.org/r/20181204155122.6327-3-douliyangs@gmail.com
include/linux/interrupt.h
kernel/irq/affinity.c
kernel/irq/irqdesc.c

index c44b7844dc8312990295241309364e069d08fa86..c672f34235e74bd47334f5bc97586ca0c42d20f5 100644 (file)
@@ -263,6 +263,7 @@ struct irq_affinity {
  */
 struct irq_affinity_desc {
        struct cpumask  mask;
+       unsigned int    is_managed : 1;
 };
 
 #if defined(CONFIG_SMP)
index c0fe591b0dc952c78b21e02b24f359e2d338a6df..45b68b4ea48b81a5ae6046cb322d8e6ac17f0a51 100644 (file)
@@ -289,6 +289,10 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
        for (; curvec < nvecs; curvec++)
                cpumask_copy(&masks[curvec].mask, irq_default_affinity);
 
+       /* Mark the managed interrupts */
+       for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++)
+               masks[i].is_managed = 1;
+
 outnodemsk:
        free_node_to_cpumask(node_to_cpumask);
        return masks;
index cb401d6c5040ccfc021b731344ad5f51e32ca82d..ee062b7939d3fce9f2813e2bb8f37c5159448631 100644 (file)
@@ -453,27 +453,30 @@ static int alloc_descs(unsigned int start, unsigned int cnt, int node,
                       struct module *owner)
 {
        struct irq_desc *desc;
-       unsigned int flags;
        int i;
 
        /* Validate affinity mask(s) */
        if (affinity) {
-               for (i = 0; i < cnt; i++) {
+               for (i = 0; i < cnt; i++, i++) {
                        if (cpumask_empty(&affinity[i].mask))
                                return -EINVAL;
                }
        }
 
-       flags = affinity ? IRQD_AFFINITY_MANAGED | IRQD_MANAGED_SHUTDOWN : 0;
-
        for (i = 0; i < cnt; i++) {
                const struct cpumask *mask = NULL;
+               unsigned int flags = 0;
 
                if (affinity) {
-                       node = cpu_to_node(cpumask_first(affinity));
+                       if (affinity->is_managed) {
+                               flags = IRQD_AFFINITY_MANAGED |
+                                       IRQD_MANAGED_SHUTDOWN;
+                       }
                        mask = &affinity->mask;
+                       node = cpu_to_node(cpumask_first(mask));
                        affinity++;
                }
+
                desc = alloc_desc(start + i, node, flags, mask, owner);
                if (!desc)
                        goto err;