]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
nvme-pci: cap queue creation to used queues
authorKeith Busch <kbusch@kernel.org>
Tue, 10 Feb 2026 19:00:12 +0000 (11:00 -0800)
committerKeith Busch <kbusch@kernel.org>
Fri, 13 Feb 2026 14:47:41 +0000 (06:47 -0800)
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>
drivers/nvme/host/pci.c

index 4ee4d7ead5a920b75ae2d51b86263e63a475e9f8..c63efa49132f9da9a4e2b012f0eeeb116ef966bc 100644 (file)
@@ -2902,7 +2902,13 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
        dev->nr_write_queues = write_queues;
        dev->nr_poll_queues = poll_queues;
 
-       nr_io_queues = dev->nr_allocated_queues - 1;
+       /*
+        * The initial number of allocated queue slots may be too large if the
+        * user reduced the special queue parameters. Cap the value to the
+        * number we need for this round.
+        */
+       nr_io_queues = min(nvme_max_io_queues(dev),
+                          dev->nr_allocated_queues - 1);
        result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues);
        if (result < 0)
                return result;