From owner-svn-src-all@freebsd.org Sun May 3 04:22:27 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AF95B2D326C; Sun, 3 May 2020 04:22:27 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49FCWR43NFz4CYJ; Sun, 3 May 2020 04:22:27 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 864DB54D1; Sun, 3 May 2020 04:22:27 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0434MR73055620; Sun, 3 May 2020 04:22:27 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0434MRLN055619; Sun, 3 May 2020 04:22:27 GMT (envelope-from imp@FreeBSD.org) Message-Id: <202005030422.0434MRLN055619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sun, 3 May 2020 04:22:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360600 - head/sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam/nvme X-SVN-Commit-Revision: 360600 X-SVN-Commit-Repository: base 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.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 04:22:27 -0000 Author: imp Date: Sun May 3 04:22:27 2020 New Revision: 360600 URL: https://svnweb.freebsd.org/changeset/base/360600 Log: We need to hold the periph lock when we release the ccb (and when we run it). Make sure that we do. Simplify the flow a bit, and fix a comment since we do need to do these things. Noticed by: cperciva (not sure why my invariants kernel didn't trigger) Modified: head/sys/cam/nvme/nvme_da.c Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Sun May 3 04:03:05 2020 (r360599) +++ head/sys/cam/nvme/nvme_da.c Sun May 3 04:22:27 2020 (r360600) @@ -426,26 +426,26 @@ ndaioctl(struct disk *dp, u_long cmd, void *data, int */ memset(&mapinfo, 0, sizeof(mapinfo)); error = cam_periph_mapmem(ccb, &mapinfo, maxmap); - if (error) { - xpt_release_ccb(ccb); - return (error); - } + if (error) + goto out; /* - * Lock the periph and run the command. XXX do we need - * to lock the periph? + * Lock the periph and run the command. */ cam_periph_lock(periph); - cam_periph_runccb(ccb, NULL, CAM_RETRY_SELTO, SF_RETRY_UA | SF_NO_PRINT, - NULL); - cam_periph_unlock(periph); + cam_periph_runccb(ccb, NULL, CAM_RETRY_SELTO, + SF_RETRY_UA | SF_NO_PRINT, NULL); /* * Tear down mapping and return status. */ + cam_periph_unlock(periph); cam_periph_unmapmem(ccb, &mapinfo); error = (ccb->ccb_h.status == CAM_REQ_CMP) ? 0 : EIO; +out: + cam_periph_lock(periph); xpt_release_ccb(ccb); + cam_periph_unlock(periph); return (error); } default: