git: 8721f68642c3 - main - ufshci: fix the WLUN peripheral lookup timeout
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 30 Oct 2026 03:17:02 UTC
The branch main has been updated by jaeyoon:
URL: https://cgit.FreeBSD.org/src/commit/?id=8721f68642c392afa0413eafa3cefde66d65b6eb
commit 8721f68642c392afa0413eafa3cefde66d65b6eb
Author: Denis Lemire <denis@lemire.name>
AuthorDate: 2026-10-29 06:14:18 +0000
Commit: Jaeyoon Choi <jaeyoon@FreeBSD.org>
CommitDate: 2026-10-30 03:12:43 +0000
ufshci: fix the WLUN peripheral lookup timeout
The timeout in ufshci_sim_find_periph() is uint64_t, making the
comparison of timeout - ticks with zero always false. If the requested
peripheral does not become available, the lookup can wait indefinitely.
Use an sbintime_t deadline based on sbinuptime() and mstosbt(), and
compare the current uptime directly with the deadline. Preserve the
successful lookup path and existing timeout cleanup.
On an HP 15-fd0118ca with Intel N150 and Samsung UFS 3.1 storage, a
kernel built from stable/15 revision 84aa3cb3204d with this change
logged the missing-WLUN timeout, attached da0 and mounted root in two
boot trials.
Signed-off-by: Denis Lemire <denis@lemire.name>
Reviewed by: jaeyoon
Fixes: 31407551c3d4 ("ufshci: Add a check for WLUN during driver initialization")
MFC after: 3 days
Pull Request: https://github.com/freebsd/freebsd-src/pull/2520
---
sys/dev/ufshci/ufshci_sim.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sys/dev/ufshci/ufshci_sim.c b/sys/dev/ufshci/ufshci_sim.c
index d9ea84961879..dc5198ae6f35 100644
--- a/sys/dev/ufshci/ufshci_sim.c
+++ b/sys/dev/ufshci/ufshci_sim.c
@@ -452,7 +452,7 @@ ufshci_sim_find_periph(struct ufshci_controller *ctrlr, uint8_t wlun)
struct cam_path *path;
struct cam_periph *periph = NULL;
uint64_t scsi_lun;
- uint64_t timeout;
+ sbintime_t timeout;
/* The reset path can get here before the SIM is attached. */
if (ctrlr->ufshci_sim == NULL)
@@ -466,7 +466,7 @@ ufshci_sim_find_periph(struct ufshci_controller *ctrlr, uint8_t wlun)
}
/* Wait for the perip device to be found */
- timeout = ticks + MSEC_2_TICKS(ctrlr->device_init_timeout_in_ms);
+ timeout = sbinuptime() + mstosbt(ctrlr->device_init_timeout_in_ms);
while (1) {
xpt_path_lock(path);
@@ -478,7 +478,7 @@ ufshci_sim_find_periph(struct ufshci_controller *ctrlr, uint8_t wlun)
if (periph)
break;
- if (timeout - ticks < 0) {
+ if (sbinuptime() >= timeout) {
ufshci_printf(ctrlr,
"Failed to find the Well known LUN(0x%x)\n", wlun);
break;