Skip to content

Commit 9a2c950

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Remove the ufshcd_lrb task_tag member
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> Link: https://patch.msgid.link/20251031204029.2883185-26-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 176b930 commit 9a2c950

2 files changed

Lines changed: 30 additions & 33 deletions

File tree

drivers/ufs/core/ufshcd.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ static void ufshcd_print_tr(struct ufs_hba *hba, struct scsi_cmnd *cmd,
599599
bool pr_prdt)
600600
{
601601
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
602-
const int tag = lrbp->task_tag;
602+
const int tag = scsi_cmd_to_rq(cmd)->tag;
603603
int prdt_length;
604604

605605
if (hba->monitor.enabled) {
@@ -2369,6 +2369,7 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
23692369
struct ufs_hw_queue *hwq)
23702370
{
23712371
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
2372+
const int tag = scsi_cmd_to_rq(cmd)->tag;
23722373
unsigned long flags;
23732374

23742375
if (hba->monitor.enabled) {
@@ -2397,11 +2398,10 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
23972398
} else {
23982399
spin_lock_irqsave(&hba->outstanding_lock, flags);
23992400
if (hba->vops && hba->vops->setup_xfer_req)
2400-
hba->vops->setup_xfer_req(hba, lrbp->task_tag,
2401+
hba->vops->setup_xfer_req(hba, tag,
24012402
ufshcd_is_scsi_cmd(cmd));
2402-
__set_bit(lrbp->task_tag, &hba->outstanding_reqs);
2403-
ufshcd_writel(hba, 1 << lrbp->task_tag,
2404-
REG_UTP_TRANSFER_REQ_DOOR_BELL);
2403+
__set_bit(tag, &hba->outstanding_reqs);
2404+
ufshcd_writel(hba, 1 << tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);
24052405
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
24062406
}
24072407
}
@@ -2798,18 +2798,19 @@ static void ufshcd_prepare_utp_scsi_cmd_upiu(struct scsi_cmnd *cmd,
27982798
u8 upiu_flags)
27992799
{
28002800
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
2801+
const int tag = scsi_cmd_to_rq(cmd)->tag;
28012802
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
28022803
unsigned short cdb_len;
28032804

28042805
ucd_req_ptr->header = (struct utp_upiu_header){
28052806
.transaction_code = UPIU_TRANSACTION_COMMAND,
28062807
.flags = upiu_flags,
28072808
.lun = lrbp->lun,
2808-
.task_tag = lrbp->task_tag,
2809+
.task_tag = tag,
28092810
.command_set_type = UPIU_COMMAND_SET_TYPE_SCSI,
28102811
};
28112812

2812-
WARN_ON_ONCE(ucd_req_ptr->header.task_tag != lrbp->task_tag);
2813+
WARN_ON_ONCE(ucd_req_ptr->header.task_tag != tag);
28132814

28142815
ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length);
28152816

@@ -2830,6 +2831,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
28302831
{
28312832
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
28322833
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
2834+
const int tag = scsi_cmd_to_rq(cmd)->tag;
28332835
struct ufs_query *query = &hba->dev_cmd.query;
28342836
u16 len = be16_to_cpu(query->request.upiu_req.length);
28352837

@@ -2838,7 +2840,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
28382840
.transaction_code = UPIU_TRANSACTION_QUERY_REQ,
28392841
.flags = upiu_flags,
28402842
.lun = lrbp->lun,
2841-
.task_tag = lrbp->task_tag,
2843+
.task_tag = tag,
28422844
.query_function = query->request.query_func,
28432845
/* Data segment length only need for WRITE_DESC */
28442846
.data_segment_length =
@@ -2861,12 +2863,13 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct scsi_cmnd *cmd)
28612863
{
28622864
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
28632865
struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
2866+
const int tag = scsi_cmd_to_rq(cmd)->tag;
28642867

28652868
memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req));
28662869

28672870
ucd_req_ptr->header = (struct utp_upiu_header){
28682871
.transaction_code = UPIU_TRANSACTION_NOP_OUT,
2869-
.task_tag = lrbp->task_tag,
2872+
.task_tag = tag,
28702873
};
28712874
}
28722875

@@ -2951,7 +2954,6 @@ static void __ufshcd_setup_cmd(struct ufs_hba *hba, struct scsi_cmnd *cmd,
29512954

29522955
memset(lrbp->ucd_req_ptr, 0, sizeof(*lrbp->ucd_req_ptr));
29532956

2954-
lrbp->task_tag = tag;
29552957
lrbp->lun = lun;
29562958
ufshcd_prepare_lrbp_crypto(ufshcd_is_scsi_cmd(cmd) ?
29572959
scsi_cmd_to_rq(cmd) : NULL, lrbp);
@@ -3249,6 +3251,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
32493251
static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
32503252
struct ufshcd_lrb *lrbp, int max_timeout)
32513253
{
3254+
struct scsi_cmnd *cmd = (struct scsi_cmnd *)lrbp - 1;
3255+
const int tag = scsi_cmd_to_rq(cmd)->tag;
32523256
unsigned long time_left = msecs_to_jiffies(max_timeout);
32533257
unsigned long flags;
32543258
bool pending;
@@ -3265,18 +3269,18 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
32653269
} else {
32663270
err = -ETIMEDOUT;
32673271
dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n",
3268-
__func__, lrbp->task_tag);
3272+
__func__, tag);
32693273

32703274
/* MCQ mode */
32713275
if (hba->mcq_enabled) {
32723276
/* successfully cleared the command, retry if needed */
3273-
if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0)
3277+
if (ufshcd_clear_cmd(hba, tag) == 0)
32743278
err = -EAGAIN;
32753279
return err;
32763280
}
32773281

32783282
/* SDB mode */
3279-
if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) {
3283+
if (ufshcd_clear_cmd(hba, tag) == 0) {
32803284
/* successfully cleared the command, retry if needed */
32813285
err = -EAGAIN;
32823286
/*
@@ -3285,11 +3289,9 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
32853289
* variable.
32863290
*/
32873291
spin_lock_irqsave(&hba->outstanding_lock, flags);
3288-
pending = test_bit(lrbp->task_tag,
3289-
&hba->outstanding_reqs);
3292+
pending = test_bit(tag, &hba->outstanding_reqs);
32903293
if (pending)
3291-
__clear_bit(lrbp->task_tag,
3292-
&hba->outstanding_reqs);
3294+
__clear_bit(tag, &hba->outstanding_reqs);
32933295
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
32943296

32953297
if (!pending) {
@@ -3302,11 +3304,10 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
33023304
}
33033305
} else {
33043306
dev_err(hba->dev, "%s: failed to clear tag %d\n",
3305-
__func__, lrbp->task_tag);
3307+
__func__, tag);
33063308

33073309
spin_lock_irqsave(&hba->outstanding_lock, flags);
3308-
pending = test_bit(lrbp->task_tag,
3309-
&hba->outstanding_reqs);
3310+
pending = test_bit(tag, &hba->outstanding_reqs);
33103311
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
33113312

33123313
if (!pending) {
@@ -5468,6 +5469,7 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,
54685469
struct cq_entry *cqe)
54695470
{
54705471
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
5472+
const int tag = scsi_cmd_to_rq(cmd)->tag;
54715473
int result = 0;
54725474
int scsi_status;
54735475
enum utp_ocs ocs;
@@ -5539,10 +5541,8 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,
55395541
case OCS_ABORTED:
55405542
case OCS_INVALID_COMMAND_STATUS:
55415543
result |= DID_REQUEUE << 16;
5542-
dev_warn(hba->dev,
5543-
"OCS %s from controller for tag %d\n",
5544-
(ocs == OCS_ABORTED ? "aborted" : "invalid"),
5545-
lrbp->task_tag);
5544+
dev_warn(hba->dev, "OCS %s from controller for tag %d\n",
5545+
ocs == OCS_ABORTED ? "aborted" : "invalid", tag);
55465546
break;
55475547
case OCS_INVALID_CMD_TABLE_ATTR:
55485548
case OCS_INVALID_PRDT_ATTR:
@@ -5555,9 +5555,8 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,
55555555
case OCS_GENERAL_CRYPTO_ERROR:
55565556
default:
55575557
result |= DID_ERROR << 16;
5558-
dev_err(hba->dev,
5559-
"OCS error from controller = %x for tag %d\n",
5560-
ocs, lrbp->task_tag);
5558+
dev_err(hba->dev, "OCS error from controller = %x for tag %d\n",
5559+
ocs, tag);
55615560
ufshcd_print_evt_hist(hba);
55625561
ufshcd_print_host_state(hba);
55635562
break;
@@ -7692,8 +7691,8 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag)
76927691
u8 resp = 0xF;
76937692

76947693
for (poll_cnt = 100; poll_cnt; poll_cnt--) {
7695-
err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag,
7696-
UFS_QUERY_TASK, &resp);
7694+
err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_QUERY_TASK,
7695+
&resp);
76977696
if (!err && resp == UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED) {
76987697
/* cmd pending in the device */
76997698
dev_err(hba->dev, "%s: cmd pending in the device. tag = %d\n",
@@ -7726,8 +7725,7 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag)
77267725
if (!poll_cnt)
77277726
return -EBUSY;
77287727

7729-
err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag,
7730-
UFS_ABORT_TASK, &resp);
7728+
err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_ABORT_TASK, &resp);
77317729
if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
77327730
if (!err) {
77337731
err = resp; /* service response error */
@@ -7837,7 +7835,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
78377835
goto release;
78387836
}
78397837

7840-
err = ufshcd_try_to_abort_task(hba, lrbp->task_tag);
7838+
err = ufshcd_try_to_abort_task(hba, tag);
78417839
if (err) {
78427840
dev_err(hba->dev, "%s: failed with err %d\n", __func__, err);
78437841
ufshcd_set_req_abort_skip(hba, hba->outstanding_reqs);

include/ufs/ufshcd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ struct ufshcd_lrb {
188188
int scsi_status;
189189

190190
int command_type;
191-
int task_tag;
192191
u8 lun; /* UPIU LUN id field is only 8-bit wide */
193192
bool intr_cmd;
194193
bool req_abort_skip;

0 commit comments

Comments
 (0)