scsi: ufs: mediatek: avoid sched_clock() misuse
Subsystems (2)
PATCH 1/1 scsi: ufs: mediatek: avoid sched_clock() misuse
From: Arnd Bergmann <[email protected]>
sched_clock() is not meant to be used in portable driver code, and assuming a particular clock frequency is not how this is meant to be used. It also causes a build failure because of a missing header inclusion:
drivers/scsi/ufs/ufs-mediatek.c:321:12: error: implicit declaration of function 'sched_clock' [-Werror,-Wimplicit-function-declaration]
timeout = sched_clock() + retry_ms * 1000000UL;
A better interface to use here ktime_get_mono_fast_ns(), which works mostly like ktime_get() but is safe to use inside of a suspend callback.
--- drivers/scsi/ufs/ufs-mediatek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufs-mediatek.c +3 -3
@@ -318,15 +318,15 @@ static void ufs_mtk_wait_idle_state(struct ufs_hba *hba,u32 val, sm;bool wait_idle; - timeout =sched_clock () + retry_ms *1000000UL ; - +/* cannot use plain ktime_get() in suspend */ + timeout =ktime_get_mono_fast_ns () + retry_ms *1000000UL ;/* wait a specific time after check base */ udelay (10 ); wait_idle = false; do { - time_checked = sched_clock(); + time_checked = ktime_get_mono_fast_ns(); ufs_mtk_dbg_sel(hba); val = ufshcd_readl(hba, REG_UFS_PROBE);
Signature · 1 line
2.29.2
Hi Arnd,
Quoted 28 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
sched_clock()is not meant to be used in portable driver code, and assuming a particular clock frequency is not how this is meant to be used. It also causes a build failure because of a missing header inclusion:
drivers/scsi/ufs/ufs-mediatek.c:321:12: error: implicit declaration of function 'sched_clock' [-Werror,-Wimplicit-function-declaration]timeout = sched_clock() + retry_ms * 1000000UL;A better interface to use here
ktime_get_mono_fast_ns(), which works mostly likektime_get()but is safe to use inside of a suspend callback.Fixes 9561f58442e4 ("scsi: ufs: mediatek: Support vops pre suspendto disable auto-hibern8")
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/scsi/ufs/ufs-mediatek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/scsi/ufs/ufs- renamed from drivers/scsi/ufs/ufs-mediatek.c +0
-0
mediatek.c
indexd1696db70ce8..a47241ed0a57100644
drivers/scsi/ufs/ufs-mediatek.c static void ufs_mtk_wait_idle_state(struct · line 323
Quoted 8 lines
drivers/scsi/ufs/ufs-mediatek.c +2
-2@@ -318,15 +318,15 @@ static void ufs_mtk_wait_idle_state(structufs_hba *hba, u32 val, sm;bool wait_idle; - timeout =sched_clock () + retry_ms *1000000UL ; - +/* cannot use plain ktime_get() in suspend */ + timeout =ktime_get_mono_fast_ns () + retry_ms *1000000UL ;
Thanks for this fix.
Quoted 11 lines
drivers/scsi/ufs/ufs-mediatek.c +1
-1/* wait a specific time after check base */ udelay (10 ); wait_idle = false; do { - time_checked = sched_clock(); + time_checked = ktime_get_mono_fast_ns(); ufs_mtk_dbg_sel(hba); val = ufshcd_readl(hba, REG_UFS_PROBE);
Quoted 28 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
sched_clock()is not meant to be used in portable driver code, and assuming a particular clock frequency is not how this is meant to be used. It also causes a build failure because of a missing header inclusion:
drivers/scsi/ufs/ufs-mediatek.c:321:12: error: implicit declaration of function 'sched_clock' [-Werror,-Wimplicit-function-declaration]timeout = sched_clock() + retry_ms * 1000000UL;A better interface to use here
ktime_get_mono_fast_ns(), which works mostly likektime_get()but is safe to use inside of a suspend callback.Fixes 9561f58442e4 ("scsi: ufs: mediatek: Support vops pre suspendto disable auto-hibern8")
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/scsi/ufs/ufs-mediatek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/scsi/ufs/ufs- renamed from drivers/scsi/ufs/ufs-mediatek.c +0
-0
mediatek.c
indexd1696db70ce8..a47241ed0a57100644
drivers/scsi/ufs/ufs-mediatek.c static void ufs_mtk_wait_idle_state(struct · line 323
Quoted 8 lines
drivers/scsi/ufs/ufs-mediatek.c +2
-2@@ -318,15 +318,15 @@ static void ufs_mtk_wait_idle_state(structufs_hba *hba, u32 val, sm;bool wait_idle; - timeout =sched_clock () + retry_ms *1000000UL ; - +/* cannot use plain ktime_get() in suspend */ + timeout =ktime_get_mono_fast_ns () + retry_ms *1000000UL ;
Thanks for this patch.
Quoted 11 lines
drivers/scsi/ufs/ufs-mediatek.c +1
-1/* wait a specific time after check base */ udelay (10 ); wait_idle = false; do { - time_checked = sched_clock(); + time_checked = ktime_get_mono_fast_ns(); ufs_mtk_dbg_sel(hba); val = ufshcd_readl(hba, REG_UFS_PROBE);
Martin K. Petersen
AppliedQuoted 8 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
sched_clock()is not meant to be used in portable driver code, and assuming a particular clock frequency is not how this is meant to be used. It also causes a build failure because of a missing header inclusion:[...]
Applied to 5.16/scsi-queue, thanks!
[1/1] scsi: ufs: mediatek: avoid sched_clock() misuse
https://git.kernel.org/mkp/scsi/c/bb4a8dcb4e94
Signature · 6 lines
Martin K. Petersen Oracle Linux Engineering _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek