From owner-svn-src-head@FreeBSD.ORG Tue Mar 26 18:20:11 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C8C6EED8; Tue, 26 Mar 2013 18:20:11 +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 A35D32FF; Tue, 26 Mar 2013 18:20:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2QIKB3T058785; Tue, 26 Mar 2013 18:20:11 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2QIKBvx058784; Tue, 26 Mar 2013 18:20:11 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201303261820.r2QIKBvx058784@svn.freebsd.org> From: Jim Harris Date: Tue, 26 Mar 2013 18:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248731 - 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-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Mar 2013 18:20:11 -0000 Author: jimharris Date: Tue Mar 26 18:20:11 2013 New Revision: 248731 URL: http://svnweb.freebsd.org/changeset/base/248731 Log: Add an internal _nvme_qpair_submit_request function, which performs the submit action assuming the qpair lock has already been acquired. Also change nvme_qpair_submit_request to just lock/unlock the mutex around a call to this new function. This fixes a recursive mutex acquisition in the retry path. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:16:30 2013 (r248730) +++ head/sys/dev/nvme/nvme_qpair.c Tue Mar 26 18:20:11 2013 (r248731) @@ -34,6 +34,9 @@ __FBSDID("$FreeBSD$"); #include "nvme_private.h" +static void _nvme_qpair_submit_request(struct nvme_qpair *qpair, + struct nvme_request *req); + static boolean_t nvme_completion_check_retry(const struct nvme_completion *cpl) { @@ -149,7 +152,7 @@ nvme_qpair_process_completions(struct nv if (!STAILQ_EMPTY(&qpair->queued_req)) { req = STAILQ_FIRST(&qpair->queued_req); STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); - nvme_qpair_submit_request(qpair, req); + _nvme_qpair_submit_request(qpair, req); } } @@ -410,13 +413,13 @@ nvme_qpair_submit_cmd(struct nvme_qpair qpair->num_cmds++; } -void -nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) +static void +_nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) { struct nvme_tracker *tr; int err; - mtx_lock(&qpair->lock); + mtx_assert(&qpair->lock, MA_OWNED); tr = SLIST_FIRST(&qpair->free_tr); @@ -427,7 +430,7 @@ nvme_qpair_submit_request(struct nvme_qp * via a command completion. */ STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq); - goto ret; + return; } SLIST_REMOVE_HEAD(&qpair->free_tr, slist); @@ -450,7 +453,13 @@ nvme_qpair_submit_request(struct nvme_qp if (err != 0) panic("bus_dmamap_load returned non-zero!\n"); } +} -ret: +void +nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) +{ + + mtx_lock(&qpair->lock); + _nvme_qpair_submit_request(qpair, req); mtx_unlock(&qpair->lock); }