scsi: ufs: core: mcq: Find hardware queue to queue request
authorAsutosh Das <quic_asutoshd@quicinc.com>
Fri, 13 Jan 2023 20:48:48 +0000 (12:48 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 14 Jan 2023 02:03:37 +0000 (21:03 -0500)
Add support to find the hardware queue on which the request would be
queued.  Since the very first queue is to serve device commands, an offset
of 1 is added to the index of the hardware queue.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufs-mcq.c
drivers/ufs/core/ufshcd-priv.h
drivers/ufs/core/ufshcd.c

index 68158259b223c15eb8ed03751266759c1efdc963..be84bcef20449e25601dbeee25a1e5d89e00b408 100644 (file)
@@ -92,6 +92,25 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds)
        ufshcd_writel(hba, val, REG_UFS_MCQ_CFG);
 }
 
+/**
+ * ufshcd_mcq_req_to_hwq - find the hardware queue on which the
+ * request would be issued.
+ * @hba - per adapter instance
+ * @req - pointer to the request to be issued
+ *
+ * Returns the hardware queue instance on which the request would
+ * be queued.
+ */
+struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
+                                        struct request *req)
+{
+       u32 utag = blk_mq_unique_tag(req);
+       u32 hwq = blk_mq_unique_tag_to_hwq(utag);
+
+       /* uhq[0] is used to serve device commands */
+       return &hba->uhq[hwq + UFSHCD_MCQ_IO_QUEUE_OFFSET];
+}
+
 /**
  * ufshcd_mcq_decide_queue_depth - decide the queue depth
  * @hba - per adapter instance
index 013111fca0f75b251a7832d23e3645bf704d2cf4..470f726b58cc7f5e6746966d2700dc88138548ac 100644 (file)
@@ -67,7 +67,10 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba);
 void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba);
 void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds);
 void ufshcd_mcq_select_mcq_mode(struct ufs_hba *hba);
+struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
+                                          struct request *req);
 
+#define UFSHCD_MCQ_IO_QUEUE_OFFSET     1
 #define SD_ASCII_STD true
 #define SD_RAW false
 int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
index 655903b1d8f7af1f6ed6e8adeaba67769e5d7a7b..15188f57d6160a03410f67157a05529384752d19 100644 (file)
@@ -2935,6 +2935,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
                goto out;
        }
 
+       if (is_mcq_enabled(hba))
+               hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd));
+
        ufshcd_send_command(hba, tag, hwq);
 
 out: