[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251106012654.4094-1-sh043.lee@samsung.com>
Date: Thu, 6 Nov 2025 10:26:54 +0900
From: Seunghui Lee <sh043.lee@...sung.com>
To: linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org,
alim.akhtar@...sung.com, avri.altman@....com, bvanassche@....org,
martin.petersen@...cle.com, peter.wang@...iatek.com, beanhuo@...ron.com,
adrian.hunter@...el.com, storage.sec@...sung.com
Cc: Seunghui Lee <sh043.lee@...sung.com>
Subject: [PATCH] UFS: Make TM command timeout configurable from host side
Currently, UFS driver uses hardcoded TM_CMD_TIMEOUT (100ms) for all
Task Management commands, which may not be optimal for different UFS
devices and use cases.
This patch adds a configurable tm_cmd_timeout field to ufs_hba structure
and uses it instead of the hardcoded constant. The default value remains
TM_CMD_TIMEOUT to maintain backward compatibility.
[ 90.372004] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: ufshcd_abort: Device abort task at tag 9
[ 90.372025] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - issue time 80324520 us
[ 90.372037] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - complete time 0 us
[ 90.372049] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - Transfer Request Descriptor phys@...8120
[ 90.372085] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - Request UPIU phys@...400
[ 90.372121] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - Response UPIU phys@...600
[ 90.372180] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - PRDT - 2 entries phys@...800
[ 90.372193] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: ufshcd_abort: skipping abort
[ 90.514494] [0: scsi_eh_0: 209] ufshcd-qcom 1d84000.ufshc: __ufshcd_issue_tm_cmd: task management cmd 0x08 timed-out
Signed-off-by: Seunghui Lee <sh043.lee@...sung.com>
---
drivers/ufs/core/ufshcd.c | 3 ++-
include/ufs/ufshcd.h | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9ca27de4767a..6099504ffc35 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7252,7 +7252,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
/* wait until the task management command is completed */
err = wait_for_completion_io_timeout(&wait,
- msecs_to_jiffies(TM_CMD_TIMEOUT));
+ msecs_to_jiffies(hba->tm_cmd_timeout));
if (!err) {
ufshcd_add_tm_upiu_trace(hba, task_tag, UFS_TM_ERR);
dev_err(hba->dev, "%s: task management cmd 0x%.2x timed-out\n",
@@ -10565,6 +10565,7 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle)
hba->dev = dev;
hba->dev_ref_clk_freq = REF_CLK_FREQ_INVAL;
hba->nop_out_timeout = NOP_OUT_TIMEOUT;
+ hba->tm_cmd_timeout = TM_CMD_TIMEOUT;
ufshcd_set_sg_entry_size(hba, sizeof(struct ufshcd_sg_entry));
INIT_LIST_HEAD(&hba->clk_list_head);
spin_lock_init(&hba->outstanding_lock);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 9425cfd9d00e..aed792eb9e16 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -884,6 +884,7 @@ enum ufshcd_mcq_opr {
* @dev_cmd: ufs device management command information
* @last_dme_cmd_tstamp: time stamp of the last completed DME command
* @nop_out_timeout: NOP OUT timeout value
+ * @tm_cmd_timeout: TM CMD timeout value
* @dev_info: information about the UFS device
* @auto_bkops_enabled: to track whether bkops is enabled in device
* @vreg_info: UFS device voltage regulator information
@@ -1042,6 +1043,7 @@ struct ufs_hba {
struct ufs_dev_cmd dev_cmd;
ktime_t last_dme_cmd_tstamp;
int nop_out_timeout;
+ int tm_cmd_timeout;
/* Keeps information of the UFS device connected to this host */
struct ufs_dev_info dev_info;
--
2.43.0
Powered by blists - more mailing lists