Commit be7594a4 authored by Can Guo's avatar Can Guo Committed by Martin K. Petersen

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/1583398391-14273-1-git-send-email-cang@codeaurora.org
Fixes: ba7af5ec ("scsi: ufs: export ufshcd_auto_hibern8_update for vendor usage")
Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 03264ddd
...@@ -3884,18 +3884,25 @@ EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit); ...@@ -3884,18 +3884,25 @@ EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit);
void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
{ {
unsigned long flags; unsigned long flags;
bool update = false;
if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT)) if (!ufshcd_is_auto_hibern8_supported(hba))
return; return;
spin_lock_irqsave(hba->host->host_lock, flags); spin_lock_irqsave(hba->host->host_lock, flags);
if (hba->ahit == ahit) if (hba->ahit != ahit) {
goto out_unlock; hba->ahit = ahit;
hba->ahit = ahit; update = true;
if (!pm_runtime_suspended(hba->dev)) }
ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
out_unlock:
spin_unlock_irqrestore(hba->host->host_lock, flags); spin_unlock_irqrestore(hba->host->host_lock, flags);
if (update && !pm_runtime_suspended(hba->dev)) {
pm_runtime_get_sync(hba->dev);
ufshcd_hold(hba, false);
ufshcd_auto_hibern8_enable(hba);
ufshcd_release(hba);
pm_runtime_put(hba->dev);
}
} }
EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update); EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment