* [PATCH] scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
@ 2024-07-24 13:51 Vamshi Gajjela
2024-07-29 18:26 ` Bart Van Assche
0 siblings, 1 reply; 2+ messages in thread
From: Vamshi Gajjela @ 2024-07-24 13:51 UTC (permalink / raw)
To: Alim Akhtar, Avri Altman, Bart Van Assche
Cc: Yaniv Gardi, linux-scsi, linux-kernel, stable, Vamshi Gajjela
The ufshcd_add_delay_before_dme_cmd() always introduces a delay of
MIN_DELAY_BEFORE_DME_CMDS_US between DME commands even when it's not
required. The delay is added when the UFS host controller supplies the
quirk UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS.
Fix the logic to update hba->last_dme_cmd_tstamp to ensure subsequent
DME commands have the correct delay in the range of 0 to
MIN_DELAY_BEFORE_DME_CMDS_US.
Update the timestamp at the end of the function to ensure it captures
the latest time after any necessary delay has been applied.
Signed-off-by: Vamshi Gajjela <vamshigajjela@google.com>
Fixes: cad2e03d8607 ("ufs: add support to allow non standard behaviours (quirks)")
Cc: stable@vger.kernel.org
---
drivers/ufs/core/ufshcd.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index dc757ba47522..406bda1585f6 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4090,11 +4090,16 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
min_sleep_time_us =
MIN_DELAY_BEFORE_DME_CMDS_US - delta;
else
- return; /* no more delay required */
+ min_sleep_time_us = 0; /* no more delay required */
}
- /* allow sleep for extra 50us if needed */
- usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
+ if (min_sleep_time_us > 0) {
+ /* allow sleep for extra 50us if needed */
+ usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
+ }
+
+ /* update the last_dme_cmd_tstamp */
+ hba->last_dme_cmd_tstamp = ktime_get();
}
/**
--
2.45.2.1089.g2a221341d9-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
2024-07-24 13:51 [PATCH] scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic Vamshi Gajjela
@ 2024-07-29 18:26 ` Bart Van Assche
0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2024-07-29 18:26 UTC (permalink / raw)
To: Vamshi Gajjela, Alim Akhtar, Avri Altman
Cc: Yaniv Gardi, linux-scsi, linux-kernel, stable
On 7/24/24 6:51 AM, Vamshi Gajjela wrote:
> The ufshcd_add_delay_before_dme_cmd() always introduces a delay of
> MIN_DELAY_BEFORE_DME_CMDS_US between DME commands even when it's not
> required. The delay is added when the UFS host controller supplies the
> quirk UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS.
>
> Fix the logic to update hba->last_dme_cmd_tstamp to ensure subsequent
> DME commands have the correct delay in the range of 0 to
> MIN_DELAY_BEFORE_DME_CMDS_US.
>
> Update the timestamp at the end of the function to ensure it captures
> the latest time after any necessary delay has been applied.
>
> Signed-off-by: Vamshi Gajjela <vamshigajjela@google.com>
> Fixes: cad2e03d8607 ("ufs: add support to allow non standard behaviours (quirks)")
> Cc: stable@vger.kernel.org
> ---
> drivers/ufs/core/ufshcd.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index dc757ba47522..406bda1585f6 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -4090,11 +4090,16 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
> min_sleep_time_us =
> MIN_DELAY_BEFORE_DME_CMDS_US - delta;
> else
> - return; /* no more delay required */
> + min_sleep_time_us = 0; /* no more delay required */
> }
>
> - /* allow sleep for extra 50us if needed */
> - usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
> + if (min_sleep_time_us > 0) {
> + /* allow sleep for extra 50us if needed */
> + usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
> + }
> +
> + /* update the last_dme_cmd_tstamp */
> + hba->last_dme_cmd_tstamp = ktime_get();
> }
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-29 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 13:51 [PATCH] scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic Vamshi Gajjela
2024-07-29 18:26 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®