From nobody Tue Jan 04 02:01:57 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 53E21191D40C; Tue, 4 Jan 2022 02:01:58 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JSbTL0GPKz58Hx; Tue, 4 Jan 2022 02:01:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DEA4F10B88; Tue, 4 Jan 2022 02:01:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20421vhY040883; Tue, 4 Jan 2022 02:01:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20421vmw040882; Tue, 4 Jan 2022 02:01:57 GMT (envelope-from git) Date: Tue, 4 Jan 2022 02:01:57 GMT Message-Id: <202201040201.20421vmw040882@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: bb8441184bab - main - cam: don't lock while handling an AC_UNIT_ATTENTION List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb8441184bab60cd8a07c2b94bd6c4ae8b56ec25 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641261718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vGY6YP/QWuFWT3mmhaH1moZ+MUX/eSDNb+Cf8Uf4iXc=; b=Sy7X3sbiTlRtpJzkElEe3AR9lATPx/6bd8bZ6m7UEfK3eEujTLfhJlkO1a98IAxv+DVOPb xhJnylBppEfPG8cardpa60CoTZOWqBsi2H39L/fEUZ7tMF05v/biWkkHWx+B3L2bdnZS7Z /RIoh+Qro3HWJhfpVMSf2zHNGvxHgg9xTuDaST37YeIXtCVAb+bbWv46g/HNihF7O0WB7g ka9IX1VW5H46BKHgpGuiyZAYPayX4w6M+E+GnRbbaq+/trtBZpOeCCMksTQyC+xz7bfjIG cDcczD8B9LJD7U1ouJzpD57kWV9eXRrlhNXgOB4WwotHFIclVROLs4JdYrONug== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641261718; a=rsa-sha256; cv=none; b=RXOGDjoXxZBODlTFpWlQnBpLYo/DPIapX10/F+74iAMK5mpvZa33tsYoFpSJqVgyq1LkCC T4Kb8qEjm2nTwnFdc1XBEnmE2y1EpYEKv0scqFpvASTU/HHZPdTWt+99SJpROKttMagGTE gDTONqqrPF6hsDDYzC3u5aMt593FgSK9tusXAMWOuoluJHV4DV2PXbHqK93shl7pJu0gWt VhTI2LD9ckJvhC3YC0z+QJXoRWw19Y271u6zYQVZZ2mYPyZEw7SPjkBY+Vi+Zhh5CNBlOn bbP678CuPjgMr+JO8yodeDD+u/LqZUx7mI0Oxr26UO6TJiO6UiR1Jzi5xuiT2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=bb8441184bab60cd8a07c2b94bd6c4ae8b56ec25 commit bb8441184bab60cd8a07c2b94bd6c4ae8b56ec25 Author: Robert Wing AuthorDate: 2022-01-04 01:21:58 +0000 Commit: Robert Wing CommitDate: 2022-01-04 01:56:48 +0000 cam: don't lock while handling an AC_UNIT_ATTENTION Don't take the device_mtx lock in daasync() when handling an AC_UNIT_ATTENTION. Instead, assert the lock is held before modifying the periph's softc flags. The device_mtx lock is taken in xptdevicetraverse() before daasync() is eventually called in xpt_async_bcast(). PR: 240917, 226510, 226578 Reviewed by: imp MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D27735 --- sys/cam/scsi/scsi_da.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 243e86d18caa..df8791e4b23e 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2158,7 +2158,7 @@ daasync(void *callback_arg, u_int32_t code, } break; } - case AC_UNIT_ATTENTION: + case AC_UNIT_ATTENTION: /* Called for this path: periph locked */ { union ccb *ccb; int error_code, sense_key, asc, ascq; @@ -2168,9 +2168,7 @@ daasync(void *callback_arg, u_int32_t code, /* * Handle all UNIT ATTENTIONs except our own, as they will be - * handled by daerror(). Since this comes from a different periph, - * that periph's lock is held, not ours, so we have to take it ours - * out to touch softc flags. + * handled by daerror(). */ if (xpt_path_periph(ccb->ccb_h.path) != periph && scsi_extract_sense_ccb(ccb, @@ -2178,22 +2176,19 @@ daasync(void *callback_arg, u_int32_t code, if (asc == 0x2A && ascq == 0x09) { xpt_print(ccb->ccb_h.path, "Capacity data has changed\n"); - cam_periph_lock(periph); + cam_periph_assert(periph, MA_OWNED); softc->flags &= ~DA_FLAG_PROBED; dareprobe(periph); - cam_periph_unlock(periph); } else if (asc == 0x28 && ascq == 0x00) { - cam_periph_lock(periph); + cam_periph_assert(periph, MA_OWNED); softc->flags &= ~DA_FLAG_PROBED; - cam_periph_unlock(periph); disk_media_changed(softc->disk, M_NOWAIT); } else if (asc == 0x3F && ascq == 0x03) { xpt_print(ccb->ccb_h.path, "INQUIRY data has changed\n"); - cam_periph_lock(periph); + cam_periph_assert(periph, MA_OWNED); softc->flags &= ~DA_FLAG_PROBED; dareprobe(periph); - cam_periph_unlock(periph); } } break;