Skip to content

Commit be7594a

Browse files
Can Guomartinkpetersen
authored andcommitted
scsi: ufs: Fix possible unclocked access to auto hibern8 timer register
Before access auto hibner8 timer register, make sure power and clock are properly configured to avoid unclocked register access. Link: https://lore.kernel.org/r/[email protected] Fixes: ba7af5e ("scsi: ufs: export ufshcd_auto_hibern8_update for vendor usage") Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Can Guo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 03264dd commit be7594a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/scsi/ufs/ufshcd.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,18 +3884,25 @@ EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit);
38843884
void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
38853885
{
38863886
unsigned long flags;
3887+
bool update = false;
38873888

3888-
if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
3889+
if (!ufshcd_is_auto_hibern8_supported(hba))
38893890
return;
38903891

38913892
spin_lock_irqsave(hba->host->host_lock, flags);
3892-
if (hba->ahit == ahit)
3893-
goto out_unlock;
3894-
hba->ahit = ahit;
3895-
if (!pm_runtime_suspended(hba->dev))
3896-
ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
3897-
out_unlock:
3893+
if (hba->ahit != ahit) {
3894+
hba->ahit = ahit;
3895+
update = true;
3896+
}
38983897
spin_unlock_irqrestore(hba->host->host_lock, flags);
3898+
3899+
if (update && !pm_runtime_suspended(hba->dev)) {
3900+
pm_runtime_get_sync(hba->dev);
3901+
ufshcd_hold(hba, false);
3902+
ufshcd_auto_hibern8_enable(hba);
3903+
ufshcd_release(hba);
3904+
pm_runtime_put(hba->dev);
3905+
}
38993906
}
39003907
EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update);
39013908

0 commit comments

Comments
 (0)