diff mbox series

[v1] scsi: ufs-mediatek: Prevent LPM operation on undeclared VCC

Message ID 20200724141627.20094-1-stanley.chu@mediatek.com (mailing list archive)
State Mainlined
Commit 0255b1e3d84962f8f8d19f9e2768a8a4f0de7487
Headers show
Series [v1] scsi: ufs-mediatek: Prevent LPM operation on undeclared VCC | expand

Commit Message

Stanley Chu July 24, 2020, 2:16 p.m. UTC
In some platforms, VCC regulator may not be declared in device tree
to keep itself "always-on". In this case, hba->vreg_info.vcc is NULL
and shall not be operated during any flow.

Prevent possible NULL hba->vreg_info.vcc access in LPM mode by checking
if it is valid first.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs-mediatek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Avri Altman July 27, 2020, 10:56 a.m. UTC | #1
> 
> In some platforms, VCC regulator may not be declared in device tree
> to keep itself "always-on". In this case, hba->vreg_info.vcc is NULL
> and shall not be operated during any flow.
> 
> Prevent possible NULL hba->vreg_info.vcc access in LPM mode by checking
> if it is valid first.
> 
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Martin K. Petersen July 29, 2020, 4:10 a.m. UTC | #2
On Fri, 24 Jul 2020 22:16:27 +0800, Stanley Chu wrote:

> In some platforms, VCC regulator may not be declared in device tree
> to keep itself "always-on". In this case, hba->vreg_info.vcc is NULL
> and shall not be operated during any flow.
> 
> Prevent possible NULL hba->vreg_info.vcc access in LPM mode by checking
> if it is valid first.

Applied to 5.9/scsi-queue, thanks!

[1/1] scsi: ufs-mediatek: Prevent LPM operation on undeclared VCC
      https://git.kernel.org/mkp/scsi/c/0255b1e3d849
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 31af8b3d2b53..66223fe200fc 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -574,7 +574,7 @@  static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
 
 static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 {
-	if (!hba->vreg_info.vccq2)
+	if (!hba->vreg_info.vccq2 || !hba->vreg_info.vcc)
 		return;
 
 	if (lpm & !hba->vreg_info.vcc->enabled)