* [PATCH v2 1/4] scsi: ufs: Remove request tag range checks
2023-09-21 19:22 [PATCH v2 0/4] UFS core patches Bart Van Assche
@ 2023-09-21 19:22 ` Bart Van Assche
2023-09-22 6:31 ` John Garry
2023-09-21 19:22 ` [PATCH v2 2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver Bart Van Assche
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2023-09-21 19:22 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, daejun7.park, John Garry,
James E.J. Bottomley, Stanley Chu, Can Guo, Manivannan Sadhasivam,
Asutosh Das, Bean Huo, Bao D. Nguyen, Arthur Simchaev
The block layer core guarantees that tag numbers are in the expected
range. Hence remove the statements that check this. This patch suppresses
Coverity warnings about left shifts with a negative right hand operand.
The following commit originally introduced request tag range checks:
14497328b6a6 ("scsi: ufs: verify command tag validity").
Cc: daejun7.park@samsung.com
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index dc1285351336..f48a65fa3bf7 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2822,8 +2822,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
int err = 0;
struct ufs_hw_queue *hwq = NULL;
- WARN_ONCE(tag < 0 || tag >= hba->nutrs, "Invalid tag %d\n", tag);
-
switch (hba->ufshcd_state) {
case UFSHCD_STATE_OPERATIONAL:
break;
@@ -6923,8 +6921,6 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
spin_lock_irqsave(host->host_lock, flags);
task_tag = req->tag;
- WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n",
- task_tag);
hba->tmf_rqs[req->tag] = req;
treq->upiu_req.req_header.task_tag = task_tag;
@@ -7498,8 +7494,6 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
bool outstanding;
u32 reg;
- WARN_ONCE(tag < 0, "Invalid tag %d\n", tag);
-
ufshcd_hold(hba);
if (!is_mcq_enabled(hba)) {
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 1/4] scsi: ufs: Remove request tag range checks
2023-09-21 19:22 ` [PATCH v2 1/4] scsi: ufs: Remove request tag range checks Bart Van Assche
@ 2023-09-22 6:31 ` John Garry
0 siblings, 0 replies; 11+ messages in thread
From: John Garry @ 2023-09-22 6:31 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen
Cc: linux-scsi, daejun7.park, James E.J. Bottomley, Stanley Chu,
Can Guo, Manivannan Sadhasivam, Asutosh Das, Bean Huo,
Bao D. Nguyen, Arthur Simchaev
On 21/09/2023 20:22, Bart Van Assche wrote:
> The block layer core guarantees that tag numbers are in the expected
> range. Hence remove the statements that check this. This patch suppresses
> Coverity warnings about left shifts with a negative right hand operand.
> The following commit originally introduced request tag range checks:
> 14497328b6a6 ("scsi: ufs: verify command tag validity").
>
> Cc:daejun7.park@samsung.com
> Cc: John Garry<john.g.garry@oracle.com>
> Signed-off-by: Bart Van Assche<bvanassche@acm.org>
Feel free to add:
Reviewed-by: John Garry <john.g.garry@oracle.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver
2023-09-21 19:22 [PATCH v2 0/4] UFS core patches Bart Van Assche
2023-09-21 19:22 ` [PATCH v2 1/4] scsi: ufs: Remove request tag range checks Bart Van Assche
@ 2023-09-21 19:22 ` Bart Van Assche
2023-09-22 11:18 ` Alim Akhtar
2023-09-21 19:22 ` [PATCH v2 3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu() Bart Van Assche
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2023-09-21 19:22 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, Alim Akhtar, James E.J. Bottomley,
Krzysztof Kozlowski, Stanley Chu, Can Guo, Manivannan Sadhasivam,
Asutosh Das, Bean Huo, Bao D. Nguyen, Arthur Simchaev, Po-Wen Kao,
Eric Biggers, Keoseong Park
The DMA alignment for the Exynos controller follows directly from the
PRDT segment size configured in ufs-exynos.c. Hence, move the DMA
alignment code into the Exynos driver source code.
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 6 ++++--
drivers/ufs/host/ufs-exynos.c | 9 +++++++--
include/ufs/ufshcd.h | 7 ++-----
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index f48a65fa3bf7..379229d51f04 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5095,8 +5095,7 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)
struct request_queue *q = sdev->request_queue;
blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
- if (hba->quirks & UFSHCD_QUIRK_4KB_DMA_ALIGNMENT)
- blk_queue_update_dma_alignment(q, SZ_4K - 1);
+
/*
* Block runtime-pm until all consumers are added.
* Refer ufshcd_setup_links().
@@ -5112,6 +5111,9 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)
*/
sdev->silence_suspend = 1;
+ if (hba->vops && hba->vops->config_scsi_dev)
+ hba->vops->config_scsi_dev(sdev);
+
ufshcd_crypto_register(hba, q);
return 0;
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 3396e0388512..e5d145a2676e 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -1511,6 +1511,11 @@ static int fsd_ufs_pre_link(struct exynos_ufs *ufs)
return 0;
}
+static void exynos_ufs_config_scsi_dev(struct scsi_device *sdev)
+{
+ blk_queue_update_dma_alignment(sdev->request_queue, SZ_4K - 1);
+}
+
static int fsd_ufs_post_link(struct exynos_ufs *ufs)
{
int i;
@@ -1579,6 +1584,7 @@ static const struct ufs_hba_variant_ops ufs_hba_exynos_ops = {
.hibern8_notify = exynos_ufs_hibern8_notify,
.suspend = exynos_ufs_suspend,
.resume = exynos_ufs_resume,
+ .config_scsi_dev = exynos_ufs_config_scsi_dev,
};
static struct ufs_hba_variant_ops ufs_hba_exynosauto_vh_ops = {
@@ -1680,8 +1686,7 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {
UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR |
UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |
- UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING |
- UFSHCD_QUIRK_4KB_DMA_ALIGNMENT,
+ UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING,
.opts = EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL |
EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX |
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 7d07b256e906..e0d6590d163d 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -28,6 +28,7 @@
#define UFSHCD "ufshcd"
+struct scsi_device;
struct ufs_hba;
enum dev_cmd_type {
@@ -371,6 +372,7 @@ struct ufs_hba_variant_ops {
int (*get_outstanding_cqs)(struct ufs_hba *hba,
unsigned long *ocqs);
int (*config_esi)(struct ufs_hba *hba);
+ void (*config_scsi_dev)(struct scsi_device *sdev);
};
/* clock gating state */
@@ -596,11 +598,6 @@ enum ufshcd_quirks {
*/
UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING = 1 << 13,
- /*
- * Align DMA SG entries on a 4 KiB boundary.
- */
- UFSHCD_QUIRK_4KB_DMA_ALIGNMENT = 1 << 14,
-
/*
* This quirk needs to be enabled if the host controller does not
* support UIC command
^ permalink raw reply related [flat|nested] 11+ messages in thread* RE: [PATCH v2 2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver
2023-09-21 19:22 ` [PATCH v2 2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver Bart Van Assche
@ 2023-09-22 11:18 ` Alim Akhtar
0 siblings, 0 replies; 11+ messages in thread
From: Alim Akhtar @ 2023-09-22 11:18 UTC (permalink / raw)
To: 'Bart Van Assche', 'Martin K . Petersen'
Cc: linux-scsi, 'James E.J. Bottomley',
'Krzysztof Kozlowski', 'Stanley Chu',
'Can Guo', 'Manivannan Sadhasivam',
'Asutosh Das', 'Bean Huo',
'Bao D. Nguyen', 'Arthur Simchaev',
'Po-Wen Kao', 'Eric Biggers',
'Keoseong Park'
Hi Bart
> -----Original Message-----
> From: Bart Van Assche <bvanassche@acm.org>
> Sent: Friday, September 22, 2023 12:53 AM
> To: Martin K . Petersen <martin.petersen@oracle.com>
> Cc: linux-scsi@vger.kernel.org; Bart Van Assche <bvanassche@acm.org>;
> Alim Akhtar <alim.akhtar@samsung.com>; James E.J. Bottomley
> <jejb@linux.ibm.com>; Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org>; Stanley Chu
> <stanley.chu@mediatek.com>; Can Guo <quic_cang@quicinc.com>;
> Manivannan Sadhasivam <mani@kernel.org>; Asutosh Das
> <quic_asutoshd@quicinc.com>; Bean Huo <beanhuo@micron.com>; Bao D.
> Nguyen <quic_nguyenb@quicinc.com>; Arthur Simchaev
> <Arthur.Simchaev@wdc.com>; Po-Wen Kao <powen.kao@mediatek.com>;
> Eric Biggers <ebiggers@google.com>; Keoseong Park
> <keosung.park@samsung.com>
> Subject: [PATCH v2 2/4] scsi: ufs: Move the 4K alignment code into the
> Exynos driver
>
> The DMA alignment for the Exynos controller follows directly from the PRDT
> segment size configured in ufs-exynos.c. Hence, move the DMA alignment
> code into the Exynos driver source code.
>
> Cc: Alim Akhtar <alim.akhtar@samsung.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested on exynos7 platform, able to use ufs with this change, so
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
> drivers/ufs/core/ufshcd.c | 6 ++++--
> drivers/ufs/host/ufs-exynos.c | 9 +++++++--
> include/ufs/ufshcd.h | 7 ++-----
> 3 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> f48a65fa3bf7..379229d51f04 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -5095,8 +5095,7 @@ static int ufshcd_slave_configure(struct scsi_device
> *sdev)
> struct request_queue *q = sdev->request_queue;
>
> blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD -
> 1);
> - if (hba->quirks & UFSHCD_QUIRK_4KB_DMA_ALIGNMENT)
> - blk_queue_update_dma_alignment(q, SZ_4K - 1);
> +
> /*
> * Block runtime-pm until all consumers are added.
> * Refer ufshcd_setup_links().
> @@ -5112,6 +5111,9 @@ static int ufshcd_slave_configure(struct scsi_device
> *sdev)
> */
> sdev->silence_suspend = 1;
>
> + if (hba->vops && hba->vops->config_scsi_dev)
> + hba->vops->config_scsi_dev(sdev);
> +
> ufshcd_crypto_register(hba, q);
>
> return 0;
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index 3396e0388512..e5d145a2676e 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -1511,6 +1511,11 @@ static int fsd_ufs_pre_link(struct exynos_ufs *ufs)
> return 0;
> }
>
> +static void exynos_ufs_config_scsi_dev(struct scsi_device *sdev) {
> + blk_queue_update_dma_alignment(sdev->request_queue, SZ_4K -
> 1); }
> +
> static int fsd_ufs_post_link(struct exynos_ufs *ufs) {
> int i;
> @@ -1579,6 +1584,7 @@ static const struct ufs_hba_variant_ops
> ufs_hba_exynos_ops = {
> .hibern8_notify =
> exynos_ufs_hibern8_notify,
> .suspend = exynos_ufs_suspend,
> .resume = exynos_ufs_resume,
> + .config_scsi_dev = exynos_ufs_config_scsi_dev,
> };
>
> static struct ufs_hba_variant_ops ufs_hba_exynosauto_vh_ops = { @@ -
> 1680,8 +1686,7 @@ static const struct exynos_ufs_drv_data
> exynos_ufs_drvs = {
> UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR |
>
> UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
>
> UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |
> -
> UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING |
> - UFSHCD_QUIRK_4KB_DMA_ALIGNMENT,
> +
> UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING,
> .opts = EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL |
>
> EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
> EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX |
> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index
> 7d07b256e906..e0d6590d163d 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -28,6 +28,7 @@
>
> #define UFSHCD "ufshcd"
>
> +struct scsi_device;
> struct ufs_hba;
>
> enum dev_cmd_type {
> @@ -371,6 +372,7 @@ struct ufs_hba_variant_ops {
> int (*get_outstanding_cqs)(struct ufs_hba *hba,
> unsigned long *ocqs);
> int (*config_esi)(struct ufs_hba *hba);
> + void (*config_scsi_dev)(struct scsi_device *sdev);
> };
>
> /* clock gating state */
> @@ -596,11 +598,6 @@ enum ufshcd_quirks {
> */
> UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING = 1 << 13,
>
> - /*
> - * Align DMA SG entries on a 4 KiB boundary.
> - */
> - UFSHCD_QUIRK_4KB_DMA_ALIGNMENT = 1 <<
> 14,
> -
> /*
> * This quirk needs to be enabled if the host controller does not
> * support UIC command
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu()
2023-09-21 19:22 [PATCH v2 0/4] UFS core patches Bart Van Assche
2023-09-21 19:22 ` [PATCH v2 1/4] scsi: ufs: Remove request tag range checks Bart Van Assche
2023-09-21 19:22 ` [PATCH v2 2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver Bart Van Assche
@ 2023-09-21 19:22 ` Bart Van Assche
2023-09-22 5:16 ` Avri Altman
2023-09-21 19:22 ` [PATCH v2 4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests Bart Van Assche
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2023-09-21 19:22 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, Stanley Chu,
Can Guo, Manivannan Sadhasivam, Asutosh Das, Bean Huo,
Bao D. Nguyen, Arthur Simchaev
ufshcd_comp_scsi_upiu() has one caller and that caller ensures that
lrbp->cmd != NULL. Hence leave out the lrbp->cmd check from
ufshcd_comp_scsi_upiu().
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 379229d51f04..8561383076e8 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2714,27 +2714,19 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
* for SCSI Purposes
* @hba: per adapter instance
* @lrbp: pointer to local reference block
- *
- * Return: 0 upon success; < 0 upon failure.
*/
-static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
{
u8 upiu_flags;
- int ret = 0;
if (hba->ufs_version <= ufshci_version(1, 1))
lrbp->command_type = UTP_CMD_TYPE_SCSI;
else
lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
- if (likely(lrbp->cmd)) {
- ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, lrbp->cmd->sc_data_direction, 0);
- ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
- } else {
- ret = -EINVAL;
- }
-
- return ret;
+ ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+ lrbp->cmd->sc_data_direction, 0);
+ ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
}
/**
^ permalink raw reply related [flat|nested] 11+ messages in thread* RE: [PATCH v2 3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu()
2023-09-21 19:22 ` [PATCH v2 3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu() Bart Van Assche
@ 2023-09-22 5:16 ` Avri Altman
0 siblings, 0 replies; 11+ messages in thread
From: Avri Altman @ 2023-09-22 5:16 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen
Cc: linux-scsi@vger.kernel.org, James E.J. Bottomley, Stanley Chu,
Can Guo, Manivannan Sadhasivam, Asutosh Das, Bean Huo,
Bao D. Nguyen, Arthur Simchaev
> ufshcd_comp_scsi_upiu() has one caller and that caller ensures that
> lrbp->cmd != NULL. Hence leave out the lrbp->cmd check from
> ufshcd_comp_scsi_upiu().
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
> ---
> drivers/ufs/core/ufshcd.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> 379229d51f04..8561383076e8 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2714,27 +2714,19 @@ static int ufshcd_compose_devman_upiu(struct
> ufs_hba *hba,
> * for SCSI Purposes
> * @hba: per adapter instance
> * @lrbp: pointer to local reference block
> - *
> - * Return: 0 upon success; < 0 upon failure.
> */
> -static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb
> *lrbp)
> +static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct
> +ufshcd_lrb *lrbp)
> {
> u8 upiu_flags;
> - int ret = 0;
>
> if (hba->ufs_version <= ufshci_version(1, 1))
> lrbp->command_type = UTP_CMD_TYPE_SCSI;
> else
> lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
>
> - if (likely(lrbp->cmd)) {
> - ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, lrbp->cmd-
> >sc_data_direction, 0);
> - ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
> - } else {
> - ret = -EINVAL;
> - }
> -
> - return ret;
> + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> + lrbp->cmd->sc_data_direction, 0);
> + ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
> }
>
> /**
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests
2023-09-21 19:22 [PATCH v2 0/4] UFS core patches Bart Van Assche
` (2 preceding siblings ...)
2023-09-21 19:22 ` [PATCH v2 3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu() Bart Van Assche
@ 2023-09-21 19:22 ` Bart Van Assche
2023-09-22 5:15 ` Avri Altman
2023-09-27 15:14 ` [PATCH v2 0/4] UFS core patches Martin K. Petersen
2023-10-10 2:09 ` Martin K. Petersen
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2023-09-21 19:22 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, Stanley Chu,
Can Guo, Manivannan Sadhasivam, Asutosh Das, Bean Huo,
Bao D. Nguyen, Arthur Simchaev, Avri Altman
Make the UFS device execute realtime (RT) requests before other requests.
This will be used in Android to reduce the I/O latency of the foreground
app.
Note: UFS devices do not support CDL so using CDL is not a viable
alternative.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 4 ++++
include/ufs/ufs.h | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 8561383076e8..c614619f06bd 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2717,6 +2717,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
*/
static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
{
+ struct request *rq = scsi_cmd_to_rq(lrbp->cmd);
+ unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
u8 upiu_flags;
if (hba->ufs_version <= ufshci_version(1, 1))
@@ -2726,6 +2728,8 @@ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
lrbp->cmd->sc_data_direction, 0);
+ if (ioprio_class == IOPRIO_CLASS_RT)
+ upiu_flags |= UPIU_CMD_FLAGS_CP;
ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
}
diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h
index 0cced88f4531..e77ab1786856 100644
--- a/include/ufs/ufs.h
+++ b/include/ufs/ufs.h
@@ -98,9 +98,10 @@ enum upiu_response_transaction {
UPIU_TRANSACTION_REJECT_UPIU = 0x3F,
};
-/* UPIU Read/Write flags */
+/* UPIU Read/Write flags. See also table "UPIU Flags" in the UFS standard. */
enum {
UPIU_CMD_FLAGS_NONE = 0x00,
+ UPIU_CMD_FLAGS_CP = 0x04,
UPIU_CMD_FLAGS_WRITE = 0x20,
UPIU_CMD_FLAGS_READ = 0x40,
};
^ permalink raw reply related [flat|nested] 11+ messages in thread* RE: [PATCH v2 4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests
2023-09-21 19:22 ` [PATCH v2 4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests Bart Van Assche
@ 2023-09-22 5:15 ` Avri Altman
0 siblings, 0 replies; 11+ messages in thread
From: Avri Altman @ 2023-09-22 5:15 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen
Cc: linux-scsi@vger.kernel.org, James E.J. Bottomley, Stanley Chu,
Can Guo, Manivannan Sadhasivam, Asutosh Das, Bean Huo,
Bao D. Nguyen, Arthur Simchaev
>
> Make the UFS device execute realtime (RT) requests before other requests.
> This will be used in Android to reduce the I/O latency of the foreground app.
>
> Note: UFS devices do not support CDL so using CDL is not a viable
> alternative.
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
> ---
> drivers/ufs/core/ufshcd.c | 4 ++++
> include/ufs/ufs.h | 3 ++-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> 8561383076e8..c614619f06bd 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2717,6 +2717,8 @@ static int ufshcd_compose_devman_upiu(struct
> ufs_hba *hba,
> */
> static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb
> *lrbp) {
> + struct request *rq = scsi_cmd_to_rq(lrbp->cmd);
> + unsigned int ioprio_class =
> + IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
> u8 upiu_flags;
>
> if (hba->ufs_version <= ufshci_version(1, 1)) @@ -2726,6 +2728,8 @@
> static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb
> *lrbp)
>
> ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> lrbp->cmd->sc_data_direction, 0);
> + if (ioprio_class == IOPRIO_CLASS_RT)
> + upiu_flags |= UPIU_CMD_FLAGS_CP;
> ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags); }
>
> diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h index
> 0cced88f4531..e77ab1786856 100644
> --- a/include/ufs/ufs.h
> +++ b/include/ufs/ufs.h
> @@ -98,9 +98,10 @@ enum upiu_response_transaction {
> UPIU_TRANSACTION_REJECT_UPIU = 0x3F,
> };
>
> -/* UPIU Read/Write flags */
> +/* UPIU Read/Write flags. See also table "UPIU Flags" in the UFS
> +standard. */
> enum {
> UPIU_CMD_FLAGS_NONE = 0x00,
> + UPIU_CMD_FLAGS_CP = 0x04,
> UPIU_CMD_FLAGS_WRITE = 0x20,
> UPIU_CMD_FLAGS_READ = 0x40,
> };
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/4] UFS core patches
2023-09-21 19:22 [PATCH v2 0/4] UFS core patches Bart Van Assche
` (3 preceding siblings ...)
2023-09-21 19:22 ` [PATCH v2 4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests Bart Van Assche
@ 2023-09-27 15:14 ` Martin K. Petersen
2023-10-10 2:09 ` Martin K. Petersen
5 siblings, 0 replies; 11+ messages in thread
From: Martin K. Petersen @ 2023-09-27 15:14 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Martin K . Petersen, linux-scsi
Bart,
> Please consider these UFS core patches for the next merge window.
Applied to 6.7/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v2 0/4] UFS core patches
2023-09-21 19:22 [PATCH v2 0/4] UFS core patches Bart Van Assche
` (4 preceding siblings ...)
2023-09-27 15:14 ` [PATCH v2 0/4] UFS core patches Martin K. Petersen
@ 2023-10-10 2:09 ` Martin K. Petersen
5 siblings, 0 replies; 11+ messages in thread
From: Martin K. Petersen @ 2023-10-10 2:09 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Martin K . Petersen, linux-scsi
On Thu, 21 Sep 2023 12:22:45 -0700, Bart Van Assche wrote:
> Please consider these UFS core patches for the next merge window.
>
> Thanks,
>
> Bart.
>
> Changes compared to v1:
> - In patch 1/4, instead of preserving the WARN_ONCE() statements, remove these.
> - Added a reference to CDL in the description of patch 4/4.
>
> [...]
Applied to 6.7/scsi-queue, thanks!
[1/4] scsi: ufs: Remove request tag range checks
https://git.kernel.org/mkp/scsi/c/cdaaff61d3bf
[2/4] scsi: ufs: Move the 4K alignment code into the Exynos driver
https://git.kernel.org/mkp/scsi/c/858231bdb223
[3/4] scsi: ufs: Simplify ufshcd_comp_scsi_upiu()
https://git.kernel.org/mkp/scsi/c/c788cf8a21cd
[4/4] scsi: ufs: Set the Command Priority (CP) flag for RT requests
https://git.kernel.org/mkp/scsi/c/00d2fa28da0a
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 11+ messages in thread