svn commit: r248834 - head/sys/dev/nvme

Jim Harris jimharris at FreeBSD.org
Thu Mar 28 16:54:20 UTC 2013


Author: jimharris
Date: Thu Mar 28 16:54:19 2013
New Revision: 248834
URL: http://svnweb.freebsd.org/changeset/base/248834

Log:
  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

Modified:
  head/sys/dev/nvme/nvme_ctrlr.c

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- head/sys/dev/nvme/nvme_ctrlr.c	Thu Mar 28 15:04:03 2013	(r248833)
+++ head/sys/dev/nvme/nvme_ctrlr.c	Thu Mar 28 16:54:19 2013	(r248834)
@@ -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_co
 
 	/*
 	 * 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) {
-		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.
+		/*
+		 * 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;
 	}
 
 	return (0);


More information about the svn-src-all mailing list