linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] scsi: ufs: Fix possible unclocked access to auto hibern8 timer register
@ 2020-03-05  8:53 Can Guo
  2020-03-05  9:09 ` Stanley Chu
  2020-03-10 23:00 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Can Guo @ 2020-03-05  8:53 UTC (permalink / raw)
  To: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team,
	saravanak, salyzyn, cang
  Cc: Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Stanley Chu, Bean Huo, Bart Van Assche,
	Venkat Gopalakrishnan, Tomas Winkler, open list

Before access auto hibner8 timer register, make sure power and clock are
properly configured to avoid unclocked register access.

Fixes: ba7af5ec5126 ("scsi: ufs: export ufshcd_auto_hibern8_update for vendor usage")
Signed-off-by: Can Guo <cang@codeaurora.org>
---
 drivers/scsi/ufs/ufshcd.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e987fa3a..5698f11 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3914,18 +3914,25 @@ int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
 {
 	unsigned long flags;
+	bool update = false;
 
-	if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
+	if (!ufshcd_is_auto_hibern8_supported(hba))
 		return;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	if (hba->ahit == ahit)
-		goto out_unlock;
-	hba->ahit = ahit;
-	if (!pm_runtime_suspended(hba->dev))
-		ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
-out_unlock:
+	if (hba->ahit != ahit) {
+		hba->ahit = ahit;
+		update = true;
+	}
 	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);
 
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] scsi: ufs: Fix possible unclocked access to auto hibern8 timer register
  2020-03-05  8:53 [PATCH v1 1/1] scsi: ufs: Fix possible unclocked access to auto hibern8 timer register Can Guo
@ 2020-03-05  9:09 ` Stanley Chu
  2020-03-10 23:00 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Stanley Chu @ 2020-03-05  9:09 UTC (permalink / raw)
  To: Can Guo
  Cc: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team,
	saravanak, salyzyn, Alim Akhtar, Avri Altman,
	James E.J. Bottomley, Martin K. Petersen, Bean Huo,
	Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list

Hi Can,

On Thu, 2020-03-05 at 00:53 -0800, Can Guo wrote:
> Before access auto hibner8 timer register, make sure power and clock are
> properly configured to avoid unclocked register access.
> 
> Fixes: ba7af5ec5126 ("scsi: ufs: export ufshcd_auto_hibern8_update for vendor usage")
> Signed-off-by: Can Guo <cang@codeaurora.org>

Thanks for fixing this!

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] scsi: ufs: Fix possible unclocked access to auto hibern8 timer register
  2020-03-05  8:53 [PATCH v1 1/1] scsi: ufs: Fix possible unclocked access to auto hibern8 timer register Can Guo
  2020-03-05  9:09 ` Stanley Chu
@ 2020-03-10 23:00 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-03-10 23:00 UTC (permalink / raw)
  To: Can Guo
  Cc: asutoshd, nguyenb, hongwus, rnayak, linux-scsi, kernel-team,
	saravanak, salyzyn, Alim Akhtar, Avri Altman,
	James E.J. Bottomley, Martin K. Petersen, Stanley Chu, Bean Huo,
	Bart Van Assche, Venkat Gopalakrishnan, Tomas Winkler, open list


Can,

> Before access auto hibner8 timer register, make sure power and clock
> are properly configured to avoid unclocked register access.

Applied to 5.6/scsi-fixes, thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-10 23:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05  8:53 [PATCH v1 1/1] scsi: ufs: Fix possible unclocked access to auto hibern8 timer register Can Guo
2020-03-05  9:09 ` Stanley Chu
2020-03-10 23:00 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).