From nobody Tue Mar 08 07:12:29 2022 X-Original-To: dev-commits-src-branches@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 F17A819FBA2C; Tue, 8 Mar 2022 07:12:29 +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 4KCRNY6XXrz4X6c; Tue, 8 Mar 2022 07:12:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646723549; 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=mafuPLfLw7N7mAF/a70BYjXOJkcKpcWRoEb+EvpnbZs=; b=fpF/fob8tz+Sno9BTs7sqjtgJD5LOIewnt5Zvqzc0nCDN02Gd0mraJRXyJdT7kjnZgtxKX yi8SbnRll/JHyd0+FNiuwgcEhN3kTrKUYXdY2I9pbAxYoEwroeoGgvUGDYXIu4isIshdac JiN071DtHNclUQ6gMuWq66t/hWyrWIFsBSVhogIwRBFokjaoUWpAkQRovgVQ2Hec+P+LDR zzMXMESJZwfwa7SsG02jvB9OWJcrgMqly+RI/ZmOGScLW6DVqoSpZIDbEfNOUeszRd03m8 CpEGnqOlTbbbx4sTimbj82VmfsgtX50/VnkQf1Eg36ucDDcGWr8uWv767vixCQ== 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 BC88C185F1; Tue, 8 Mar 2022 07:12:29 +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 2287CTXE027677; Tue, 8 Mar 2022 07:12:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2287CTUm027676; Tue, 8 Mar 2022 07:12:29 GMT (envelope-from git) Date: Tue, 8 Mar 2022 07:12:29 GMT Message-Id: <202203080712.2287CTUm027676@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: 1987ff8abca2 - stable/12 - cam: don't lock while handling an AC_UNIT_ATTENTION List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/12 X-Git-Reftype: branch X-Git-Commit: 1987ff8abca2c9bdff7f385ea2fd1c60cf5b3aeb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646723549; 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=mafuPLfLw7N7mAF/a70BYjXOJkcKpcWRoEb+EvpnbZs=; b=jrjB3fsiOLJTxIUhSN4qC9KtQvYS0Y6HwMpXwf8dHfXdPzlXCJiHC9rd9eS+iByzHb8cnL A1QhTTp0htMk1rydgwDb33M8J8m4j7YgD5NKXAL7fS3mvl3O942C9ZA6eDJr/TXX7ibNHK N3qsUGidFSc4mJKk9z7Oh5dTV3FoDtdEn2hQztzrqkvfLmsaLIYRVfcG4gIgIIAKQPu/o+ 5domzMaXw4dwMCg2GKgmYw2lsT7exxJXlte0yElPDuF7+a6gq/3eVBn+Aj8O4r0h/+nR+L tsSVMuaP+W1WtqI8Gko06X+4ws4l1sCpHKr+Z+apWm7nznND5qy0mDhNXAVtow== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646723549; a=rsa-sha256; cv=none; b=o2iVrVN7VWm+w7mk0nvw8BvbJq2iibEtQHjQ6Vgk1DH9acl/DLa2Yu7GqHTMPQbsN0uVy3 5S42PLnMfBED1JOhNc3qVB0nygrxHc0jHoXB53fFEXrY2KC+gG4i+CFIgTQEBvF1PnAU9Z 38COcdK0XPFY/D2an/KmGh73R2OD65GaYBDUFjhbbkU2aFqPiUn0/oae9y51DXWOluXYSF EdGwESqCI4vKUx479bV4wc5I7DuEEDBCK9/eBkMPfU8H9CmkRPQEhchwnPamhjkrvCUGZK ufBGQt0jxmzSu+6zGv0DvZYel/k55NuzKitquNStMcvf9guoWOZS8hqO6bc0lA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=1987ff8abca2c9bdff7f385ea2fd1c60cf5b3aeb commit 1987ff8abca2c9bdff7f385ea2fd1c60cf5b3aeb Author: Robert Wing AuthorDate: 2022-01-04 01:21:58 +0000 Commit: Robert Wing CommitDate: 2022-03-08 07:07:46 +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 Differential Revision: https://reviews.freebsd.org/D27735 (cherry picked from commit bb8441184bab60cd8a07c2b94bd6c4ae8b56ec25) --- 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 4f773b75498b..3177be9515cb 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2108,7 +2108,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; @@ -2118,9 +2118,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, @@ -2128,22 +2126,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;