Skip to content

Commit ab9fd06

Browse files
Vamshi Gajjelamartinkpetersen
authored andcommitted
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 <vamshigajjela@google.com> Link: https://lore.kernel.org/r/20240724135126.1786126-1-vamshigajjela@google.com Fixes: cad2e03 ("ufs: add support to allow non standard behaviours (quirks)") Cc: stable@vger.kernel.org Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 7c632fc commit ab9fd06

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,11 +4100,16 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
41004100
min_sleep_time_us =
41014101
MIN_DELAY_BEFORE_DME_CMDS_US - delta;
41024102
else
4103-
return; /* no more delay required */
4103+
min_sleep_time_us = 0; /* no more delay required */
41044104
}
41054105

4106-
/* allow sleep for extra 50us if needed */
4107-
usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
4106+
if (min_sleep_time_us > 0) {
4107+
/* allow sleep for extra 50us if needed */
4108+
usleep_range(min_sleep_time_us, min_sleep_time_us + 50);
4109+
}
4110+
4111+
/* update the last_dme_cmd_tstamp */
4112+
hba->last_dme_cmd_tstamp = ktime_get();
41084113
}
41094114

41104115
/**

0 commit comments

Comments
 (0)