]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
PCI/MSI: Ignore affinity if pre/post vector count is more than min_vecs
authorMichael Hernandez <michael.hernandez@cavium.com>
Thu, 18 May 2017 17:47:47 +0000 (10:47 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 22 May 2017 20:06:05 +0000 (15:06 -0500)
min_vecs is the minimum amount of vectors needed to operate in MSI-X mode
which may just include the vectors that don't need affinity.

Disabling affinity settings causes the qla2xxx driver scsi_add_host() to fail
when blk_mq is enabled as the blk_mq_pci_map_queues() expects affinity masks
on each vector.

Fixes: dfef358bd1be ("PCI/MSI: Don't apply affinity if there aren't enough vectors left")
Signed-off-by: Michael Hernandez <michael.hernandez@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org # v4.10+
drivers/pci/msi.c
include/linux/interrupt.h
kernel/irq/affinity.c

index ba44fdfda66bb5caba6c74d9ad056b34a2d01068..9e1569107cd69bef405991990d056158a594214b 100644 (file)
@@ -1058,7 +1058,7 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
 
        for (;;) {
                if (affd) {
-                       nvec = irq_calc_affinity_vectors(nvec, affd);
+                       nvec = irq_calc_affinity_vectors(minvec, nvec, affd);
                        if (nvec < minvec)
                                return -ENOSPC;
                }
@@ -1097,7 +1097,7 @@ static int __pci_enable_msix_range(struct pci_dev *dev,
 
        for (;;) {
                if (affd) {
-                       nvec = irq_calc_affinity_vectors(nvec, affd);
+                       nvec = irq_calc_affinity_vectors(minvec, nvec, affd);
                        if (nvec < minvec)
                                return -ENOSPC;
                }
@@ -1165,16 +1165,6 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
        if (flags & PCI_IRQ_AFFINITY) {
                if (!affd)
                        affd = &msi_default_affd;
-
-               if (affd->pre_vectors + affd->post_vectors > min_vecs)
-                       return -EINVAL;
-
-               /*
-                * If there aren't any vectors left after applying the pre/post
-                * vectors don't bother with assigning affinity.
-                */
-               if (affd->pre_vectors + affd->post_vectors == min_vecs)
-                       affd = NULL;
        } else {
                if (WARN_ON(affd))
                        affd = NULL;
index a6fba4804672858b87430b81c0af52378bd7ed89..0991f973f8caf3f9d7b6866e067d1fd9d5529c61 100644 (file)
@@ -291,7 +291,7 @@ extern int
 irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
 
 struct cpumask *irq_create_affinity_masks(int nvec, const struct irq_affinity *affd);
-int irq_calc_affinity_vectors(int maxvec, const struct irq_affinity *affd);
+int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity *affd);
 
 #else /* CONFIG_SMP */
 
@@ -331,7 +331,7 @@ irq_create_affinity_masks(int nvec, const struct irq_affinity *affd)
 }
 
 static inline int
-irq_calc_affinity_vectors(int maxvec, const struct irq_affinity *affd)
+irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity *affd)
 {
        return maxvec;
 }
index e2d356dd75812df8e42dfac3feb132edd5612e33..9b71406d2eec551c48a02a7291c0975f6141e39a 100644 (file)
@@ -66,6 +66,13 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
        struct cpumask *masks;
        cpumask_var_t nmsk;
 
+       /*
+        * If there aren't any vectors left after applying the pre/post
+        * vectors don't bother with assigning affinity.
+        */
+       if (!affv)
+               return NULL;
+
        if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL))
                return NULL;
 
@@ -140,15 +147,19 @@ out:
 
 /**
  * irq_calc_affinity_vectors - Calculate the optimal number of vectors
+ * @minvec:    The minimum number of vectors available
  * @maxvec:    The maximum number of vectors available
  * @affd:      Description of the affinity requirements
  */
-int irq_calc_affinity_vectors(int maxvec, const struct irq_affinity *affd)
+int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity *affd)
 {
        int resv = affd->pre_vectors + affd->post_vectors;
        int vecs = maxvec - resv;
        int cpus;
 
+       if (resv > minvec)
+               return 0;
+
        /* Stabilize the cpumasks */
        get_online_cpus();
        cpus = cpumask_weight(cpu_online_mask);