From nobody Tue Nov 03 04:33:47 2026 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 4jJbLN1pDyz6xs71 for ; Tue, 03 Nov 2026 04:33:48 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jJbLM5zkpz4fp6 for ; Tue, 03 Nov 2026 04:33:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793680427; 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=x5U7atlgdQTlGGIEX1etAXGsu+jm77qmyROY0MsGDf8=; b=Cl25X9pprTPsWniOyhJHnR2Gn8bhGD8L8KW1PUJgN6pIVWamUIB5cBgMebmOIOFi96WKYE fxAOg80L0I6uaKm07lamg7VTPeh0EweHU3Hpzon3N3tAvefoM95kV8WXO7LHHhEMtcWx+G KeB246oduDBeOikp3yO4t15VsaiCG4Wzqb4zLs3/H5dOIbRi7V/7w//3jKCP+VFNyGh7cT R0qtLDP54/34i2z+GBX4sqE2+VDl4dKdon6EFcnjwD1Xb16C8WxCwVQXe5KsEVKTVsDqCk QPBbwS93fKWUy+ZcDAZD5PUdwJTdMU8L++W5vCdLYBk0Eo9ThJRM20HwzAVFhQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793680427; b=AneBqW+X7PcbGXke5RZKMlCJssgy4zhagvp29OMzyTAYz8bkCGoLhm0iwex/+qj/vJ/HHk 0lUF2EJ4mwM50PIWLZeI42JiMZQRV4i8yAkpWmS0/QyP6U2bMBSQ7lh4LGxkkTHVht3Eex bj47NWij43JcA5/3jNisF9Yzol/hTALn/YW6tIwfFRs6zAqe6HvFNZ+gLsiStxCpkfoig6 aogbn/4oviktT/K/Jx1+A4ReX4mqBKopXI6dujDyEiUVzkUk9ABeGbGz3wdU7NUd8nYjgm +Oa4147TjW2MgsdUun0DnWniI8zoSyWHDf3GFzTs8Oidoz57tpTLHj0jQX0SSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793680427; 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=x5U7atlgdQTlGGIEX1etAXGsu+jm77qmyROY0MsGDf8=; b=Zp8ZYS3sEiPJxq8D8MY2wnBXoZZBeCnTHz4UV+VNrR+MmqioD7+Oe9DyQ3inmQrfktLm5v SNh8s3pzLnQVi0r5HPmCqqRPgvq2NXVRLPFtB+BAqhFc/aaY9xhIkp+pyPvehQ9tTKh1xs 8ljv8bLqm3MSNyCCpN620pezsOTGtgyBdGmwpAZtD27aJaFsyFsQqrKXDrBWmQ3Uj7IOd4 WjMnabgAIS6rD4qit8CXDpEN4MOQpgu/CEAt9vbG1ssGco6nvjiL+Gr960T4nJ8zZwo2gj TVhvtcp2I/kIifLnNo+lWkLQeaYWU8a52NkUFs8W6fBGBvrHLsPbj+z1yyfL2w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jJbLM5S7Dz1GLn for ; Tue, 03 Nov 2026 04:33:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2021d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 03 Nov 2026 04:33:47 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jaeyoon Choi Subject: git: 5a53e2a6ba95 - main - ufshci: requeue requests that a reset aborted List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jaeyoon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a53e2a6ba951ed90c05986efdd2bf995f7163e5 Auto-Submitted: auto-generated Date: Tue, 03 Nov 2026 04:33:47 +0000 Message-Id: <6ae9642b.2021d.541c8a1@gitrepo.freebsd.org> The branch main has been updated by jaeyoon: URL: https://cgit.FreeBSD.org/src/commit/?id=5a53e2a6ba951ed90c05986efdd2bf995f7163e5 commit 5a53e2a6ba951ed90c05986efdd2bf995f7163e5 Author: Jaeyoon Choi AuthorDate: 2026-11-03 04:22:20 +0000 Commit: Jaeyoon Choi CommitDate: 2026-11-03 04:29:44 +0000 ufshci: requeue requests that a reset aborted A request taken back by a reset was reported to CAM as an error, which used up a retry. A few resets in a row failed the I/O even though the device never saw it. Pass the overall command status to the completion callback and requeue aborted requests. The polled completion carries it too, so the passthrough ioctl reports it instead of a placeholder zero. The abort path now reports an invalid status instead of aborted, so a command that never finishes still uses up its retries. Reviewed by: imp Sponsored by: Samsung Electronics Differential Revision: https://reviews.freebsd.org/D61117 --- sys/dev/ufshci/ufshci.c | 1 + sys/dev/ufshci/ufshci.h | 2 ++ sys/dev/ufshci/ufshci_ioctl.c | 3 +-- sys/dev/ufshci/ufshci_ioctl.h | 2 +- sys/dev/ufshci/ufshci_req_queue.c | 10 +++++++++- sys/dev/ufshci/ufshci_sim.c | 10 +++++++++- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/sys/dev/ufshci/ufshci.c b/sys/dev/ufshci/ufshci.c index 84a9629e74b0..44a5762d51c1 100644 --- a/sys/dev/ufshci/ufshci.c +++ b/sys/dev/ufshci/ufshci.c @@ -59,6 +59,7 @@ ufshci_completion_poll_cb(void *arg, const struct ufshci_completion *cpl, * or failed. */ memcpy(&status->cpl.response_upiu, &cpl->response_upiu, cpl->size); + status->cpl.ocs = cpl->ocs; status->error = error; atomic_store_rel_int(&status->done, 1); } diff --git a/sys/dev/ufshci/ufshci.h b/sys/dev/ufshci/ufshci.h index 3a225d92cb60..902e19cf6083 100644 --- a/sys/dev/ufshci/ufshci.h +++ b/sys/dev/ufshci/ufshci.h @@ -653,6 +653,8 @@ union ufshci_reponse_upiu { struct ufshci_completion { union ufshci_reponse_upiu response_upiu; size_t size; + /* Overall command status of the completed request. */ + uint8_t ocs; }; typedef void (*ufshci_cb_fn_t)(void *, const struct ufshci_completion *, bool); diff --git a/sys/dev/ufshci/ufshci_ioctl.c b/sys/dev/ufshci/ufshci_ioctl.c index ead404baea8e..4ea2dbc38ed2 100644 --- a/sys/dev/ufshci/ufshci_ioctl.c +++ b/sys/dev/ufshci/ufshci_ioctl.c @@ -176,8 +176,7 @@ ufshci_passthrough_cmd(struct ufshci_controller *ctrlr, memcpy(&pt->resp_upiu, &status.cpl.response_upiu, min(sizeof(pt->resp_upiu), sizeof(status.cpl.response_upiu))); pt->xfer_len = pt->len; - /* The completion does not carry the overall command status yet. */ - pt->ocs = 0; + pt->ocs = status.cpl.ocs; /* * A refused command still answered, so let the caller read the diff --git a/sys/dev/ufshci/ufshci_ioctl.h b/sys/dev/ufshci/ufshci_ioctl.h index c545c073fc0a..ae095062c391 100644 --- a/sys/dev/ufshci/ufshci_ioctl.h +++ b/sys/dev/ufshci/ufshci_ioctl.h @@ -39,7 +39,7 @@ struct ufshci_pt_command { uint32_t flags; /* [in] UFSHCI_PT_FLAG_* */ uint32_t timeout_ms; /* [in] reserved, must be 0 */ uint32_t xfer_len; /* [out] bytes the request carried */ - uint8_t ocs; /* [out] reserved, always 0 for now */ + uint8_t ocs; /* [out] overall command status */ uint8_t reserved[7]; }; diff --git a/sys/dev/ufshci/ufshci_req_queue.c b/sys/dev/ufshci/ufshci_req_queue.c index d9cb3ba510bc..1c7ae5f54f48 100644 --- a/sys/dev/ufshci/ufshci_req_queue.c +++ b/sys/dev/ufshci/ufshci_req_queue.c @@ -240,6 +240,11 @@ ufshci_req_queue_complete_aborted_hwq(struct ufshci_hw_queue *hwq) tr->slot_state = UFSHCI_SLOT_STATE_COMPLETING; mtx_unlock(&hwq->qlock); + /* + * TODO: The request that timed out and caused the reset is + * requeued here as well, without using a retry, so a command + * the device never answers repeats timeout and reset forever. + */ ufshci_req_queue_manual_complete_tracker(tr, UFSHCI_DESC_ABORTED, UFSHCI_RESPONSE_CODE_GENERAL_FAILURE); @@ -323,6 +328,8 @@ ufshci_req_queue_complete_tracker(struct ufshci_tracker *tr) ocs = hwq->utrd[tr->slot_num].overall_command_status; } + cpl.ocs = ocs; + error = ufshci_req_queue_response_is_error(req_queue, ocs, &cpl.response_upiu); @@ -562,8 +569,9 @@ ufshci_abort_complete(void *arg, const struct ufshci_completion *status, */ ufshci_printf(tr->hwq->ctrlr, "abort task request failed, aborting task manually\n"); + /* Not ABORTED: the SIM requeues those without a retry. */ ufshci_req_queue_manual_complete_tracker(tr, - UFSHCI_DESC_ABORTED, UFSHCI_RESPONSE_CODE_GENERAL_FAILURE); + UFSHCI_DESC_INVALID, UFSHCI_RESPONSE_CODE_GENERAL_FAILURE); output_param1 = be32toh( status->response_upiu.task_mgmt_response_upiu.output_param1); diff --git a/sys/dev/ufshci/ufshci_sim.c b/sys/dev/ufshci/ufshci_sim.c index a6e160a99083..848fa753428e 100644 --- a/sys/dev/ufshci/ufshci_sim.c +++ b/sys/dev/ufshci/ufshci_sim.c @@ -46,7 +46,15 @@ ufshci_sim_scsiio_done(void *ccb_arg, const struct ufshci_completion *cpl, min(sense_data_len, sense_data_max_size)); ccb->ccb_h.status &= ~CAM_SIM_QUEUED; - if (error) { + if (cpl->ocs == UFSHCI_DESC_ABORTED) { + /* + * A reset took the request back, so requeue it without a + * retry. A failed controller rejects the resubmit, so + * this cannot loop. + */ + ccb->ccb_h.status = CAM_REQUEUE_REQ; + xpt_done(ccb); + } else if (error) { printf("ufshci: SCSI command completion error, Status(0x%x)" " Key(0x%x), ASC(0x%x), ASCQ(0x%x)\n", cpl->response_upiu.cmd_response_upiu.header