From: Seunghui Lee <sh043.lee@samsung.com>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org,
martin.petersen@oracle.com, peter.wang@mediatek.com,
beanhuo@micron.com, adrian.hunter@intel.com,
storage.sec@samsung.com
Cc: Seunghui Lee <sh043.lee@samsung.com>
Subject: [PATCH] UFS: Make TM command timeout configurable from host side
Date: Thu, 6 Nov 2025 10:26:54 +0900 [thread overview]
Message-ID: <20251106012654.4094-1-sh043.lee@samsung.com> (raw)
In-Reply-To: <CGME20251106012702epcas1p28fdeed020ea44f18dcc751c283fbbcc2@epcas1p2.samsung.com>
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@0x28120
[ 90.372085] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - Request UPIU phys@0xb400
[ 90.372121] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - Response UPIU phys@0xb600
[ 90.372180] [1: kworker/u16:1: 10] ufshcd-qcom 1d84000.ufshc: UPIU[9] - PRDT - 2 entries phys@0xb800
[ 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@samsung.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
next parent reply other threads:[~2025-11-06 1:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20251106012702epcas1p28fdeed020ea44f18dcc751c283fbbcc2@epcas1p2.samsung.com>
2025-11-06 1:26 ` Seunghui Lee [this message]
2025-11-11 2:46 ` Peter Wang (王信友)
2025-11-11 8:44 ` Seunghui Lee
2025-11-11 9:03 ` Peter Wang (王信友)
2025-11-11 16:37 ` Bart Van Assche
2025-11-12 2:58 ` Peter Wang (王信友)
2025-11-12 8:49 ` Seunghui Lee
2025-11-12 9:42 ` Peter Wang (王信友)
2025-11-12 16:51 ` Bart Van Assche
2025-11-13 10:08 ` Peter Wang (王信友)
2025-11-17 7:11 ` Seunghui Lee
2025-11-17 8:40 ` Peter Wang (王信友)
2025-11-17 9:48 ` Seunghui Lee
2025-11-18 5:48 ` Peter Wang (王信友)
2025-11-17 16:43 ` Bart Van Assche
2025-11-18 5:55 ` Peter Wang (王信友)
2025-11-18 17:31 ` Bart Van Assche
2025-11-19 9:20 ` Peter Wang (王信友)
2025-11-17 16:40 ` Bart Van Assche
2025-11-18 5:52 ` Peter Wang (王信友)
2025-11-11 16:38 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251106012654.4094-1-sh043.lee@samsung.com \
--to=sh043.lee@samsung.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=storage.sec@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®