2022-11-23 04:47:47

by Asutosh Das

[permalink] [raw]
Subject: [PATCH v5 12/16] ufs: core: mcq: Find hardware queue to queue request

Adds 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 <[email protected]>
Signed-off-by: Can Guo <[email protected]>
Signed-off-by: Asutosh Das <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
---
drivers/ufs/core/ufs-mcq.c | 20 ++++++++++++++++++++
drivers/ufs/core/ufshcd-priv.h | 3 +++
drivers/ufs/core/ufshcd.c | 3 +++
3 files changed, 26 insertions(+)

diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 7179f86..10a0d0d7 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -94,6 +94,26 @@ static const struct ufshcd_res_info ufs_res_info[RES_MAX] = {
};

/**
+ * 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
*
diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
index 5616047..14df7ce 100644
--- a/drivers/ufs/core/ufshcd-priv.h
+++ b/drivers/ufs/core/ufshcd-priv.h
@@ -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,
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 93a9e38..52c0386 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2921,6 +2921,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:
--
2.7.4


2022-11-28 16:33:55

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH v5 12/16] ufs: core: mcq: Find hardware queue to queue request

On Tue, Nov 22, 2022 at 08:10:25PM -0800, Asutosh Das wrote:
> Adds 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 <[email protected]>
> Signed-off-by: Can Guo <[email protected]>
> Signed-off-by: Asutosh Das <[email protected]>

One small nitpick below...

Reviewed-by: Manivannan Sadhasivam <[email protected]>

> Reviewed-by: Bart Van Assche <[email protected]>
> ---
> drivers/ufs/core/ufs-mcq.c | 20 ++++++++++++++++++++
> drivers/ufs/core/ufshcd-priv.h | 3 +++
> drivers/ufs/core/ufshcd.c | 3 +++
> 3 files changed, 26 insertions(+)
>
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 7179f86..10a0d0d7 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -94,6 +94,26 @@ static const struct ufshcd_res_info ufs_res_info[RES_MAX] = {
> };
>
> /**
> + * 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];
> +}
> +

Remove extra newline.

Thanks,
Mani

> +
> +/**
> * ufshcd_mcq_decide_queue_depth - decide the queue depth
> * @hba - per adapter instance
> *
> diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
> index 5616047..14df7ce 100644
> --- a/drivers/ufs/core/ufshcd-priv.h
> +++ b/drivers/ufs/core/ufshcd-priv.h
> @@ -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,
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 93a9e38..52c0386 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2921,6 +2921,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:
> --
> 2.7.4
>

--
மணிவண்ணன் சதாசிவம்