Skip to content

Commit 08b12cd

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Switch to scsi_get_internal_cmd()
Instead of storing the tag of the reserved command in hba->reserved_slot, use scsi_get_internal_cmd() and scsi_put_internal_cmd() to allocate the tag for the reserved command dynamically. Add ufshcd_queue_reserved_command() for submitting reserved commands. Add support in ufshcd_abort() for device management commands. Use blk_execute_rq() for submitting reserved commands. Remove the code and data structures that became superfluous. This includes ufshcd_wait_for_dev_cmd(), hba->reserved_slot and ufs_dev_cmd.complete. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20251031204029.2883185-29-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a11c015 commit 08b12cd

4 files changed

Lines changed: 116 additions & 159 deletions

File tree

drivers/ufs/core/ufs-mcq.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,6 @@ int ufshcd_mcq_init(struct ufs_hba *hba)
479479
mutex_init(&hwq->sq_mutex);
480480
}
481481

482-
/* The very first HW queue serves device commands */
483-
hba->dev_cmd_queue = &hba->uhq[0];
484-
485482
host->host_tagset = 1;
486483
return 0;
487484
}
@@ -536,6 +533,7 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
536533
{
537534
struct scsi_cmnd *cmd = ufshcd_tag_to_cmd(hba, task_tag);
538535
struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd);
536+
struct request *rq = scsi_cmd_to_rq(cmd);
539537
struct ufs_hw_queue *hwq;
540538
void __iomem *reg, *opr_sqd_base;
541539
u32 nexus, id, val;
@@ -544,15 +542,12 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
544542
if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
545543
return -ETIMEDOUT;
546544

547-
if (task_tag != hba->reserved_slot) {
548-
if (!cmd)
549-
return -EINVAL;
550-
hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd));
551-
if (!hwq)
552-
return 0;
553-
} else {
554-
hwq = hba->dev_cmd_queue;
555-
}
545+
if (!cmd)
546+
return -EINVAL;
547+
548+
hwq = ufshcd_mcq_req_to_hwq(hba, rq);
549+
if (!hwq)
550+
return 0;
556551

557552
id = hwq->id;
558553

drivers/ufs/core/ufshcd-priv.h

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -369,30 +369,7 @@ static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, u8
369369
static inline struct scsi_cmnd *ufshcd_tag_to_cmd(struct ufs_hba *hba, u32 tag)
370370
{
371371
struct blk_mq_tags *tags = hba->host->tag_set.shared_tags;
372-
struct request *rq;
373-
374-
/*
375-
* Handle reserved tags differently because the UFS driver does not
376-
* call blk_mq_alloc_request() for allocating reserved requests.
377-
* Allocating reserved tags with blk_mq_alloc_request() would require
378-
* the following:
379-
* - Allocate an additional request queue from &hba->host->tag_set for
380-
* allocating reserved requests from.
381-
* - For that request queue, allocate a SCSI device.
382-
* - Calling blk_mq_alloc_request(hba->dev_mgmt_queue, REQ_OP_DRV_OUT,
383-
* BLK_MQ_REQ_RESERVED) for allocating a reserved request and
384-
* blk_mq_free_request() for freeing reserved requests.
385-
* - Set the .device pointer for these reserved requests.
386-
* - Submit reserved requests with blk_execute_rq().
387-
* - Modify ufshcd_queuecommand() such that it handles reserved requests
388-
* in another way than SCSI requests.
389-
* - Modify ufshcd_compl_one_cqe() such that it calls scsi_done() for
390-
* device management commands.
391-
* - Modify all callback functions called by blk_mq_tagset_busy_iter()
392-
* calls in the UFS driver and skip device management commands.
393-
*/
394-
rq = tag < UFSHCD_NUM_RESERVED ? tags->static_rqs[tag] :
395-
blk_mq_tag_to_rq(tags, tag);
372+
struct request *rq = blk_mq_tag_to_rq(tags, tag);
396373

397374
if (WARN_ON_ONCE(!rq))
398375
return NULL;

0 commit comments

Comments
 (0)