Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Bart Van Assche and committed by
Martin K. Petersen
9a2c9500 176b9300

+30 -33
+30 -32
drivers/ufs/core/ufshcd.c
··· 599 599 bool pr_prdt) 600 600 { 601 601 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; 603 603 int prdt_length; 604 604 605 605 if (hba->monitor.enabled) { ··· 2369 2369 struct ufs_hw_queue *hwq) 2370 2370 { 2371 2371 struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); 2372 + const int tag = scsi_cmd_to_rq(cmd)->tag; 2372 2373 unsigned long flags; 2373 2374 2374 2375 if (hba->monitor.enabled) { ··· 2398 2397 } else { 2399 2398 spin_lock_irqsave(&hba->outstanding_lock, flags); 2400 2399 if (hba->vops && hba->vops->setup_xfer_req) 2401 - hba->vops->setup_xfer_req(hba, lrbp->task_tag, 2400 + hba->vops->setup_xfer_req(hba, tag, 2402 2401 ufshcd_is_scsi_cmd(cmd)); 2403 - __set_bit(lrbp->task_tag, &hba->outstanding_reqs); 2404 - ufshcd_writel(hba, 1 << lrbp->task_tag, 2405 - REG_UTP_TRANSFER_REQ_DOOR_BELL); 2402 + __set_bit(tag, &hba->outstanding_reqs); 2403 + ufshcd_writel(hba, 1 << tag, REG_UTP_TRANSFER_REQ_DOOR_BELL); 2406 2404 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 2407 2405 } 2408 2406 } ··· 2798 2798 u8 upiu_flags) 2799 2799 { 2800 2800 struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); 2801 + const int tag = scsi_cmd_to_rq(cmd)->tag; 2801 2802 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; 2802 2803 unsigned short cdb_len; 2803 2804 ··· 2806 2805 .transaction_code = UPIU_TRANSACTION_COMMAND, 2807 2806 .flags = upiu_flags, 2808 2807 .lun = lrbp->lun, 2809 - .task_tag = lrbp->task_tag, 2808 + .task_tag = tag, 2810 2809 .command_set_type = UPIU_COMMAND_SET_TYPE_SCSI, 2811 2810 }; 2812 2811 2813 - WARN_ON_ONCE(ucd_req_ptr->header.task_tag != lrbp->task_tag); 2812 + WARN_ON_ONCE(ucd_req_ptr->header.task_tag != tag); 2814 2813 2815 2814 ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length); 2816 2815 ··· 2831 2830 { 2832 2831 struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); 2833 2832 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; 2833 + const int tag = scsi_cmd_to_rq(cmd)->tag; 2834 2834 struct ufs_query *query = &hba->dev_cmd.query; 2835 2835 u16 len = be16_to_cpu(query->request.upiu_req.length); 2836 2836 ··· 2840 2838 .transaction_code = UPIU_TRANSACTION_QUERY_REQ, 2841 2839 .flags = upiu_flags, 2842 2840 .lun = lrbp->lun, 2843 - .task_tag = lrbp->task_tag, 2841 + .task_tag = tag, 2844 2842 .query_function = query->request.query_func, 2845 2843 /* Data segment length only need for WRITE_DESC */ 2846 2844 .data_segment_length = ··· 2863 2861 { 2864 2862 struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); 2865 2863 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; 2864 + const int tag = scsi_cmd_to_rq(cmd)->tag; 2866 2865 2867 2866 memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req)); 2868 2867 2869 2868 ucd_req_ptr->header = (struct utp_upiu_header){ 2870 2869 .transaction_code = UPIU_TRANSACTION_NOP_OUT, 2871 - .task_tag = lrbp->task_tag, 2870 + .task_tag = tag, 2872 2871 }; 2873 2872 } 2874 2873 ··· 2954 2951 2955 2952 memset(lrbp->ucd_req_ptr, 0, sizeof(*lrbp->ucd_req_ptr)); 2956 2953 2957 - lrbp->task_tag = tag; 2958 2954 lrbp->lun = lun; 2959 2955 ufshcd_prepare_lrbp_crypto(ufshcd_is_scsi_cmd(cmd) ? 2960 2956 scsi_cmd_to_rq(cmd) : NULL, lrbp); ··· 3251 3249 static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, 3252 3250 struct ufshcd_lrb *lrbp, int max_timeout) 3253 3251 { 3252 + struct scsi_cmnd *cmd = (struct scsi_cmnd *)lrbp - 1; 3253 + const int tag = scsi_cmd_to_rq(cmd)->tag; 3254 3254 unsigned long time_left = msecs_to_jiffies(max_timeout); 3255 3255 unsigned long flags; 3256 3256 bool pending; ··· 3269 3265 } else { 3270 3266 err = -ETIMEDOUT; 3271 3267 dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n", 3272 - __func__, lrbp->task_tag); 3268 + __func__, tag); 3273 3269 3274 3270 /* MCQ mode */ 3275 3271 if (hba->mcq_enabled) { 3276 3272 /* successfully cleared the command, retry if needed */ 3277 - if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) 3273 + if (ufshcd_clear_cmd(hba, tag) == 0) 3278 3274 err = -EAGAIN; 3279 3275 return err; 3280 3276 } 3281 3277 3282 3278 /* SDB mode */ 3283 - if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) { 3279 + if (ufshcd_clear_cmd(hba, tag) == 0) { 3284 3280 /* successfully cleared the command, retry if needed */ 3285 3281 err = -EAGAIN; 3286 3282 /* ··· 3289 3285 * variable. 3290 3286 */ 3291 3287 spin_lock_irqsave(&hba->outstanding_lock, flags); 3292 - pending = test_bit(lrbp->task_tag, 3293 - &hba->outstanding_reqs); 3288 + pending = test_bit(tag, &hba->outstanding_reqs); 3294 3289 if (pending) 3295 - __clear_bit(lrbp->task_tag, 3296 - &hba->outstanding_reqs); 3290 + __clear_bit(tag, &hba->outstanding_reqs); 3297 3291 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 3298 3292 3299 3293 if (!pending) { ··· 3304 3302 } 3305 3303 } else { 3306 3304 dev_err(hba->dev, "%s: failed to clear tag %d\n", 3307 - __func__, lrbp->task_tag); 3305 + __func__, tag); 3308 3306 3309 3307 spin_lock_irqsave(&hba->outstanding_lock, flags); 3310 - pending = test_bit(lrbp->task_tag, 3311 - &hba->outstanding_reqs); 3308 + pending = test_bit(tag, &hba->outstanding_reqs); 3312 3309 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 3313 3310 3314 3311 if (!pending) { ··· 5469 5468 struct cq_entry *cqe) 5470 5469 { 5471 5470 struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); 5471 + const int tag = scsi_cmd_to_rq(cmd)->tag; 5472 5472 int result = 0; 5473 5473 int scsi_status; 5474 5474 enum utp_ocs ocs; ··· 5541 5539 case OCS_ABORTED: 5542 5540 case OCS_INVALID_COMMAND_STATUS: 5543 5541 result |= DID_REQUEUE << 16; 5544 - dev_warn(hba->dev, 5545 - "OCS %s from controller for tag %d\n", 5546 - (ocs == OCS_ABORTED ? "aborted" : "invalid"), 5547 - lrbp->task_tag); 5542 + dev_warn(hba->dev, "OCS %s from controller for tag %d\n", 5543 + ocs == OCS_ABORTED ? "aborted" : "invalid", tag); 5548 5544 break; 5549 5545 case OCS_INVALID_CMD_TABLE_ATTR: 5550 5546 case OCS_INVALID_PRDT_ATTR: ··· 5555 5555 case OCS_GENERAL_CRYPTO_ERROR: 5556 5556 default: 5557 5557 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); 5561 5560 ufshcd_print_evt_hist(hba); 5562 5561 ufshcd_print_host_state(hba); 5563 5562 break; ··· 7691 7692 u8 resp = 0xF; 7692 7693 7693 7694 for (poll_cnt = 100; poll_cnt; poll_cnt--) { 7694 - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, 7695 - UFS_QUERY_TASK, &resp); 7695 + err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_QUERY_TASK, 7696 + &resp); 7696 7697 if (!err && resp == UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED) { 7697 7698 /* cmd pending in the device */ 7698 7699 dev_err(hba->dev, "%s: cmd pending in the device. tag = %d\n", ··· 7725 7726 if (!poll_cnt) 7726 7727 return -EBUSY; 7727 7728 7728 - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, 7729 - UFS_ABORT_TASK, &resp); 7729 + err = ufshcd_issue_tm_cmd(hba, lrbp->lun, tag, UFS_ABORT_TASK, &resp); 7730 7730 if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { 7731 7731 if (!err) { 7732 7732 err = resp; /* service response error */ ··· 7835 7837 goto release; 7836 7838 } 7837 7839 7838 - err = ufshcd_try_to_abort_task(hba, lrbp->task_tag); 7840 + err = ufshcd_try_to_abort_task(hba, tag); 7839 7841 if (err) { 7840 7842 dev_err(hba->dev, "%s: failed with err %d\n", __func__, err); 7841 7843 ufshcd_set_req_abort_skip(hba, hba->outstanding_reqs);
-1
include/ufs/ufshcd.h
··· 188 188 int scsi_status; 189 189 190 190 int command_type; 191 - int task_tag; 192 191 u8 lun; /* UPIU LUN id field is only 8-bit wide */ 193 192 bool intr_cmd; 194 193 bool req_abort_skip;