From owner-svn-src-all@FreeBSD.ORG Thu Mar 28 16:54:20 2013 Return-Path: <owner-svn-src-all@FreeBSD.ORG> Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 83BAB2E9; Thu, 28 Mar 2013 16:54:20 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5CFE65FA; Thu, 28 Mar 2013 16:54:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2SGsKxd022378; Thu, 28 Mar 2013 16:54:20 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2SGsKhc022377; Thu, 28 Mar 2013 16:54:20 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303281654.r2SGsKhc022377@svn.freebsd.org> From: Jim Harris <jimharris@FreeBSD.org> Date: Thu, 28 Mar 2013 16:54:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248834 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" <svn-src-all.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-all>, <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all> List-Post: <mailto:svn-src-all@freebsd.org> List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>, <mailto:svn-src-all-request@freebsd.org?subject=subscribe> X-List-Received-Date: Thu, 28 Mar 2013 16:54:20 -0000 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);