Skip to contentSkip to conversation

scsi: ufs-mediatek: Prevent LPM operation on undeclared VCC

PATCH Applied Stanley Chu 3 participants 3 messages Jul 24, 2020 – Jul 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs-mediatek: Prevent LPM operation on undeclared VCC

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.

---
 drivers/scsi/ufs/ufs-mediatek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufs-mediatek.c +1 -1
index 31af8b3d2b53..66223fe200fc 100644
@@ -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)
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines

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.

#2 lore raw
In reply to Stanley Chu
Quoted 6 lines · Stanley Chu

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering