From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Peter Wang <peter.wang@mediatek.com>,
Avri Altman <avri.altman@sandisk.com>,
Bean Huo <beanhuo@micron.com>,
Manivannan Sadhasivam <mani@kernel.org>,
Can Guo <quic_cang@quicinc.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Nitin Rawat <quic_nitirawa@quicinc.com>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH v5 25/28] ufs: core: Remove the ufshcd_lrb task_tag member
Date: Wed, 24 Sep 2025 13:30:44 -0700 [thread overview]
Message-ID: <20250924203142.4073403-26-bvanassche@acm.org> (raw)
In-Reply-To: <20250924203142.4073403-1-bvanassche@acm.org>
Remove the ufshcd_lrb task_tag member and use scsi_cmd_to_rq(cmd)->tag
instead. Use rq->tag instead of lrbp->task_tag. This patch reduces the
size of struct ufshcd_lrb.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 62 +++++++++++++++++++--------------------
include/ufs/ufshcd.h | 1 -
2 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 02e3e4c4bf3e..7193505c030d 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -604,7 +604,7 @@ static void ufshcd_print_tr(struct ufs_hba *hba, struct scsi_cmnd *cmd,
bool pr_prdt)
{
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
- const int tag = lrbp->task_tag;
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
int prdt_length;
if (hba->monitor.enabled) {
@@ -2368,6 +2368,7 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
struct ufs_hw_queue *hwq)
{
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
unsigned long flags;
if (hba->monitor.enabled) {
@@ -2396,11 +2397,10 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
} else {
spin_lock_irqsave(&hba->outstanding_lock, flags);
if (hba->vops && hba->vops->setup_xfer_req)
- hba->vops->setup_xfer_req(hba, lrbp->task_tag,
+ hba->vops->setup_xfer_req(hba, tag,
ufshcd_is_scsi_cmd(cmd));
- __set_bit(lrbp->task_tag, &hba->outstanding_reqs);
- ufshcd_writel(hba, 1 << lrbp->task_tag,
- REG_UTP_TRANSFER_REQ_DOOR_BELL);
+ __set_bit(tag, &hba->outstanding_reqs);
+ ufshcd_writel(hba, 1 << tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
}
}
@@ -2797,6 +2797,7 @@ static void ufshcd_prepare_utp_scsi_cmd_upiu(struct scsi_cmnd *cmd,
u8 upiu_flags)
{
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
unsigned short cdb_len;
@@ -2804,11 +2805,11 @@ static void ufshcd_prepare_utp_scsi_cmd_upiu(struct scsi_cmnd *cmd,
.transaction_code = UPIU_TRANSACTION_COMMAND,
.flags = upiu_flags,
.lun = lrbp->lun,
- .task_tag = lrbp->task_tag,
+ .task_tag = tag,
.command_set_type = UPIU_COMMAND_SET_TYPE_SCSI,
};
- WARN_ON_ONCE(ucd_req_ptr->header.task_tag != lrbp->task_tag);
+ WARN_ON_ONCE(ucd_req_ptr->header.task_tag != tag);
ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length);
@@ -2829,6 +2830,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
{
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
struct ufs_query *query = &hba->dev_cmd.query;
u16 len = be16_to_cpu(query->request.upiu_req.length);
@@ -2837,7 +2839,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
.transaction_code = UPIU_TRANSACTION_QUERY_REQ,
.flags = upiu_flags,
.lun = lrbp->lun,
- .task_tag = lrbp->task_tag,
+ .task_tag = tag,
.query_function = query->request.query_func,
/* Data segment length only need for WRITE_DESC */
.data_segment_length =
@@ -2860,12 +2862,13 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct scsi_cmnd *cmd)
{
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req));
ucd_req_ptr->header = (struct utp_upiu_header){
.transaction_code = UPIU_TRANSACTION_NOP_OUT,
- .task_tag = lrbp->task_tag,
+ .task_tag = tag,
};
}
@@ -2950,7 +2953,6 @@ static void __ufshcd_setup_cmd(struct ufs_hba *hba, struct scsi_cmnd *cmd,
memset(lrbp->ucd_req_ptr, 0, sizeof(*lrbp->ucd_req_ptr));
- lrbp->task_tag = tag;
lrbp->lun = lun;
ufshcd_prepare_lrbp_crypto(cmd ? scsi_cmd_to_rq(cmd) : NULL, lrbp);
}
@@ -3246,6 +3248,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
struct ufshcd_lrb *lrbp, int max_timeout)
{
+ struct scsi_cmnd *cmd = (struct scsi_cmnd *)lrbp - 1;
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
unsigned long time_left = msecs_to_jiffies(max_timeout);
unsigned long flags;
bool pending;
@@ -3262,18 +3266,18 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
} else {
err = -ETIMEDOUT;
dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n",
- __func__, lrbp->task_tag);
+ __func__, tag);
/* MCQ mode */
if (hba->mcq_enabled) {
/* successfully cleared the command, retry if needed */
- if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0)
+ if (ufshcd_clear_cmd(hba, tag) == 0)
err = -EAGAIN;
return err;
}
/* SDB mode */
- if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) {
+ if (ufshcd_clear_cmd(hba, tag) == 0) {
/* successfully cleared the command, retry if needed */
err = -EAGAIN;
/*
@@ -3282,11 +3286,9 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
* variable.
*/
spin_lock_irqsave(&hba->outstanding_lock, flags);
- pending = test_bit(lrbp->task_tag,
- &hba->outstanding_reqs);
+ pending = test_bit(tag, &hba->outstanding_reqs);
if (pending)
- __clear_bit(lrbp->task_tag,
- &hba->outstanding_reqs);
+ __clear_bit(tag, &hba->outstanding_reqs);
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
if (!pending) {
@@ -3299,11 +3301,10 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
}
} else {
dev_err(hba->dev, "%s: failed to clear tag %d\n",
- __func__, lrbp->task_tag);
+ __func__, tag);
spin_lock_irqsave(&hba->outstanding_lock, flags);
- pending = test_bit(lrbp->task_tag,
- &hba->outstanding_reqs);
+ pending = test_bit(tag, &hba->outstanding_reqs);
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
if (!pending) {
@@ -5459,6 +5460,7 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,
struct cq_entry *cqe)
{
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
+ const int tag = scsi_cmd_to_rq(cmd)->tag;
int result = 0;
int scsi_status;
enum utp_ocs ocs;
@@ -5530,10 +5532,8 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,
case OCS_ABORTED:
case OCS_INVALID_COMMAND_STATUS:
result |= DID_REQUEUE << 16;
- dev_warn(hba->dev,
- "OCS %s from controller for tag %d\n",
- (ocs == OCS_ABORTED ? "aborted" : "invalid"),
- lrbp->task_tag);
+ dev_warn(hba->dev, "OCS %s from controller for tag %d\n",
+ ocs == OCS_ABORTED ? "aborted" : "invalid", tag);
break;
case OCS_INVALID_CMD_TABLE_ATTR:
case OCS_INVALID_PRDT_ATTR:
@@ -5546,9 +5546,8 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,
case OCS_GENERAL_CRYPTO_ERROR:
default:
result |= DID_ERROR << 16;
- dev_err(hba->dev,
- "OCS error from controller = %x for tag %d\n",
- ocs, lrbp->task_tag);
+ dev_err(hba->dev, "OCS error from controller = %x for tag %d\n",
+ ocs, tag);
ufshcd_print_evt_hist(hba);
ufshcd_print_host_state(hba);
break;
@@ -7663,8 +7662,8 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag)
u8 resp = 0xF;
for (poll_cnt = 100; poll_cnt; poll_cnt--) {
- err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag,
- UFS_QUERY_TASK, &resp);
+ err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_QUERY_TASK,
+ &resp);
if (!err && resp == UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED) {
/* cmd pending in the device */
dev_err(hba->dev, "%s: cmd pending in the device. tag = %d\n",
@@ -7697,8 +7696,7 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag)
if (!poll_cnt)
return -EBUSY;
- err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag,
- UFS_ABORT_TASK, &resp);
+ err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_ABORT_TASK, &resp);
if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
if (!err) {
err = resp; /* service response error */
@@ -7808,7 +7806,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
goto release;
}
- err = ufshcd_try_to_abort_task(hba, lrbp->task_tag);
+ err = ufshcd_try_to_abort_task(hba, tag);
if (err) {
dev_err(hba->dev, "%s: failed with err %d\n", __func__, err);
ufshcd_set_req_abort_skip(hba, hba->outstanding_reqs);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 89dcac34c957..9eb69241e40f 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -188,7 +188,6 @@ struct ufshcd_lrb {
int scsi_status;
int command_type;
- int task_tag;
u8 lun; /* UPIU LUN id field is only 8-bit wide */
bool intr_cmd;
bool req_abort_skip;
next prev parent reply other threads:[~2025-09-24 20:35 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 20:30 [PATCH v5 00/28] Optimize the hot path in the UFS driver Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 01/28] scsi: core: Support allocating reserved commands Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 02/28] scsi: core: Move two statements Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 03/28] scsi: core: Make the budget map optional Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 04/28] scsi: core: Support allocating a pseudo SCSI device Bart Van Assche
2025-09-26 7:14 ` John Garry
2025-09-26 20:01 ` Bart Van Assche
2025-09-26 22:21 ` Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 05/28] scsi: core: Introduce .queue_reserved_command() Bart Van Assche
2025-09-26 7:24 ` John Garry
2025-09-26 20:05 ` Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 06/28] scsi: core: Add scsi_{get,put}_internal_cmd() helpers Bart Van Assche
2025-09-25 16:38 ` John Garry
2025-09-24 20:30 ` [PATCH v5 07/28] scsi_debug: Abort SCSI commands via .queue_reserved_command() Bart Van Assche
2025-09-26 7:32 ` John Garry
2025-09-26 20:44 ` Bart Van Assche
2025-09-30 7:03 ` John Garry
2025-10-01 18:26 ` Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 08/28] ufs: core: Move an assignment in ufshcd_mcq_process_cqe() Bart Van Assche
2025-09-26 6:12 ` Avri Altman
2025-09-24 20:30 ` [PATCH v5 09/28] ufs: core: Change the type of one ufshcd_add_cmd_upiu_trace() argument Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 10/28] ufs: core: Only call ufshcd_add_command_trace() for SCSI commands Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 11/28] ufs: core: Change the type of one ufshcd_add_command_trace() argument Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 12/28] ufs: core: Change the type of one ufshcd_send_command() argument Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 13/28] ufs: core: Only call ufshcd_should_inform_monitor() for SCSI commands Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 14/28] ufs: core: Change the monitor function argument types Bart Van Assche
2025-09-26 6:24 ` Avri Altman
2025-09-24 20:30 ` [PATCH v5 15/28] ufs: core: Rework ufshcd_mcq_compl_pending_transfer() Bart Van Assche
2025-09-26 6:44 ` Avri Altman
2025-09-24 20:30 ` [PATCH v5 16/28] ufs: core: Rework ufshcd_eh_device_reset_handler() Bart Van Assche
2025-09-26 7:17 ` Avri Altman
2025-09-24 20:30 ` [PATCH v5 17/28] ufs: core: Rework the SCSI host queue depth calculation code Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 18/28] ufs: core: Allocate the SCSI host earlier Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 19/28] ufs: core: Call ufshcd_init_lrb() later Bart Van Assche
2025-09-27 9:39 ` Avri Altman
2025-09-24 20:30 ` [PATCH v5 20/28] ufs: core: Use hba->reserved_slot Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 21/28] ufs: core: Make the reserved slot a reserved request Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 22/28] ufs: core: Do not clear driver-private command data Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 23/28] ufs: core: Optimize the hot path Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 24/28] ufs: core: Pass a SCSI pointer instead of an LRB pointer Bart Van Assche
2025-09-24 20:30 ` Bart Van Assche [this message]
2025-09-24 20:30 ` [PATCH v5 26/28] ufs: core: Make blk_mq_tagset_busy_iter() skip reserved requests Bart Van Assche
2025-09-24 20:30 ` [PATCH v5 27/28] ufs: core: Move code out of ufshcd_wait_for_dev_cmd() Bart Van Assche
2025-09-27 9:11 ` Avri Altman
2025-09-24 20:30 ` [PATCH v5 28/28] ufs: core: Switch to scsi_get_internal_cmd() Bart Van Assche
2025-09-26 10:08 ` [PATCH v5 00/28] Optimize the hot path in the UFS driver John Garry
2025-09-26 17:32 ` 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=20250924203142.4073403-26-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=avri.altman@sandisk.com \
--cc=beanhuo@micron.com \
--cc=ebiggers@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=neil.armstrong@linaro.org \
--cc=peter.wang@mediatek.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nitirawa@quicinc.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