aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVamshi Gajjela <[email protected]>2024-07-24 19:21:26 +0530
committerMartin K. Petersen <[email protected]>2024-08-01 21:59:00 -0400
commitab9fd06cb8f0db0854291833fc40c789e43a361f (patch)
tree1f264e3a47565e072672af9aec25e1c00770181a
parent7c632fc3ce64c05bae4addbdfa174f98d0431ca4 (diff)
scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: cad2e03d8607 ("ufs: add support to allow non standard behaviours (quirks)") Cc: [email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
-rw-r--r--drivers/ufs/core/ufshcd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 5e3c67e96956..0b3d0c8e0dda 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4100,11 +4100,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();
}
/**