git: a33860b0a2b9 - main - ufshci: do not reset the device in the XPT_RESET_DEV handler

From: Jaeyoon Choi <jaeyoon_at_FreeBSD.org>
Date: Mon, 10 Aug 2026 02:31:34 UTC
The branch main has been updated by jaeyoon:

URL: https://cgit.FreeBSD.org/src/commit/?id=a33860b0a2b98caf32c2ff62707f254ca92773f4

commit a33860b0a2b98caf32c2ff62707f254ca92773f4
Author:     Jaeyoon Choi <jaeyoon@FreeBSD.org>
AuthorDate: 2026-08-10 01:53:27 +0000
Commit:     Jaeyoon Choi <jaeyoon@FreeBSD.org>
CommitDate: 2026-08-10 02:28:54 +0000

    ufshci: do not reset the device in the XPT_RESET_DEV handler
    
    CAM calls the SIM action callback with the SIM lock and the CAM
    device lock held. The XPT_RESET_DEV handler called
    ufshci_dev_reset(), which sleeps on device commands. Sleeping there
    panics when another thread contends for the lock: "panic: sleeping
    thread holds CAM device lock".
    
    Report success without touching the device, as nvme_sim(4) does.
    A real device reset needs the controller reset path. That rework is
    planned together with in-flight request recovery.
    
    Sponsored by:           Samsung Electronics
    Reviewed by:            imp (mentor)
    Differential Revision:  https://reviews.freebsd.org/D58671
---
 sys/dev/ufshci/ufshci_sim.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sys/dev/ufshci/ufshci_sim.c b/sys/dev/ufshci/ufshci_sim.c
index e40079b23354..f969d9c8311b 100644
--- a/sys/dev/ufshci/ufshci_sim.c
+++ b/sys/dev/ufshci/ufshci_sim.c
@@ -288,13 +288,14 @@ ufshci_cam_action(struct cam_sim *sim, union ccb *ccb)
 		break;
 	}
 	case XPT_RESET_BUS:
-		ccb->ccb_h.status = CAM_REQ_CMP;
-		break;
 	case XPT_RESET_DEV:
-		if (ufshci_dev_reset(ctrlr))
-			ccb->ccb_h.status = CAM_REQ_CMP_ERR;
-		else
-			ccb->ccb_h.status = CAM_REQ_CMP;
+		/*
+		 * This callback cannot sleep: CAM calls it with the SIM
+		 * lock and the CAM device lock held. It cannot reset the
+		 * device here. Report success so CAM keeps going, like
+		 * nvme_sim(4) does.
+		 */
+		ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
 	case XPT_ABORT:
 		ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;