Skip to content

Commit db29eb0

Browse files
committed
nvme: fix handling of EINVAL on pci_alloc_irq_vectors_affinity()
At least on SPARC, if MSI/MSI-X isn't supported, we get EINVAL if we ask for more than one vector. This isn't covered by our ENOSPC check. If we get EINVAL, decrease our ask to just one vector, instead of bailing out in error. Fixes: 3b6592f ("nvme: utilize two queue maps, one for reads and one for writes") Reported-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e815f40 commit db29eb0

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎drivers/nvme/host/pci.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,29 +2088,31 @@ static int nvme_setup_irqs(struct nvme_dev *dev, int nr_io_queues)
20882088
affd.nr_sets = 1;
20892089

20902090
/*
2091-
* Need IRQs for read+write queues, and one for the admin queue.
2092-
* If we can't get more than one vector, we have to share the
2093-
* admin queue and IO queue vector. For that case, don't add
2094-
* an extra vector for the admin queue, or we'll continue
2095-
* asking for 2 and get -ENOSPC in return.
2091+
* If we got a failure and we're down to asking for just
2092+
* 1 + 1 queues, just ask for a single vector. We'll share
2093+
* that between the single IO queue and the admin queue.
20962094
*/
2097-
if (result == -ENOSPC && nr_io_queues == 1)
2098-
nr_io_queues = 1;
2099-
else
2095+
if (!(result < 0 && nr_io_queues == 1))
21002096
nr_io_queues = irq_sets[0] + irq_sets[1] + 1;
21012097

21022098
result = pci_alloc_irq_vectors_affinity(pdev, nr_io_queues,
21032099
nr_io_queues,
21042100
PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY, &affd);
21052101

21062102
/*
2107-
* Need to reduce our vec counts
2103+
* Need to reduce our vec counts. If we get ENOSPC, the
2104+
* platform should support mulitple vecs, we just need
2105+
* to decrease our ask. If we get EINVAL, the platform
2106+
* likely does not. Back down to ask for just one vector.
21082107
*/
21092108
if (result == -ENOSPC) {
21102109
nr_io_queues--;
21112110
if (!nr_io_queues)
21122111
return result;
21132112
continue;
2113+
} else if (result == -EINVAL) {
2114+
nr_io_queues = 1;
2115+
continue;
21142116
} else if (result <= 0)
21152117
return -EIO;
21162118
break;

0 commit comments

Comments
 (0)