From bb852ae89b6f945fbf7b08d96fd8a8ea8ca248e8 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 28 Mar 2013 16:54:19 +0000 Subject: [PATCH] Delete extra IO qpairs allocated based on number of MSI-X vectors, but later found to not be usable because the controller doesn't support the same number of queues. This is not the normal case, but does occur with the Chatham prototype board. Sponsored by: Intel --- sys/dev/nvme/nvme_ctrlr.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index 91122c44003..d0f9c320006 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -489,7 +489,7 @@ static int nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrlr) { struct nvme_completion_poll_status status; - int cq_allocated, sq_allocated; + int cq_allocated, i, sq_allocated; status.done = FALSE; nvme_ctrlr_cmd_set_num_queues(ctrlr, ctrlr->num_io_queues, @@ -511,16 +511,24 @@ nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrlr) /* * Check that the controller was able to allocate the number of - * queues we requested. If not, revert to one IO queue. + * queues we requested. If not, revert to one IO queue pair. */ if (sq_allocated < ctrlr->num_io_queues || cq_allocated < ctrlr->num_io_queues) { + + /* + * Destroy extra IO queue pairs that were created at + * controller construction time but are no longer + * needed. This will only happen when a controller + * supports fewer queues than MSI-X vectors. This + * is not the normal case, but does occur with the + * Chatham prototype board. + */ + for (i = 1; i < ctrlr->num_io_queues; i++) + nvme_io_qpair_destroy(&ctrlr->ioq[i]); + ctrlr->num_io_queues = 1; ctrlr->per_cpu_io_queues = 0; - - /* TODO: destroy extra queues that were created - * previously but now found to be not needed. - */ } return (0);