Skip to content

Commit 4735b51

Browse files
committed
nvme-pci: cap queue creation to used queues
If the user reduces the special queue count at runtime and resets the controller, we need to reduce the number of queues and interrupts requested accordingly rather than start with the pre-allocated queue count. Tested-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 166e31d commit 4735b51

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

drivers/nvme/host/pci.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,13 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
29022902
dev->nr_write_queues = write_queues;
29032903
dev->nr_poll_queues = poll_queues;
29042904

2905-
nr_io_queues = dev->nr_allocated_queues - 1;
2905+
/*
2906+
* The initial number of allocated queue slots may be too large if the
2907+
* user reduced the special queue parameters. Cap the value to the
2908+
* number we need for this round.
2909+
*/
2910+
nr_io_queues = min(nvme_max_io_queues(dev),
2911+
dev->nr_allocated_queues - 1);
29062912
result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues);
29072913
if (result < 0)
29082914
return result;

0 commit comments

Comments
 (0)