lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220616053725.5681-6-stanley.chu@mediatek.com>
Date:   Thu, 16 Jun 2022 13:37:19 +0800
From:   Stanley Chu <stanley.chu@...iatek.com>
To:     <linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <martin.petersen@...cle.com>, <avri.altman@....com>,
        <alim.akhtar@...sung.com>, <jejb@...ux.ibm.com>,
        <bvanassche@....org>
CC:     <peter.wang@...iatek.com>, <chun-hung.wu@...iatek.com>,
        <alice.chao@...iatek.com>, <powen.kao@...iatek.com>,
        <mason.zhang@...iatek.com>, <qilin.tan@...iatek.com>,
        <lin.gui@...iatek.com>, <eddie.huang@...iatek.com>,
        <tun-yu.yu@...iatek.com>, <cc.chou@...iatek.com>,
        <chaotian.jing@...iatek.com>, <jiajie.hao@...iatek.com>,
        <stanley.chu@...iatek.com>
Subject: [PATCH v5 05/11] scsi: ufs-mediatek: Prevent device regulators setting as LPM incorrectly

From: Po-Wen Kao <powen.kao@...iatek.com>

Device regulatrs are allowed to enter low-power mode
if neither device is not in active mode, nor VCC does not
keep on.

Simply fix this by adding conditions before LPM decision.

Reviewed-by: Stanley Chu <stanley.chu@...iatek.com>
Signed-off-by: Po-Wen Kao <powen.kao@...iatek.com>
Signed-off-by: Stanley Chu <stanley.chu@...iatek.com>
---
 drivers/ufs/host/ufs-mediatek.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 817d957512a3..03762ecaaaf8 100755
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1034,10 +1034,18 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 	if (!hba->vreg_info.vccq2 || !hba->vreg_info.vcc)
 		return;
 
-	if (lpm && !hba->vreg_info.vcc->enabled)
+	/* Bypass LPM when device is still active */
+	if (lpm && ufshcd_is_ufs_dev_active(hba))
+		return;
+
+	/* Bypass LPM if VCC is enabled */
+	if (lpm && hba->vreg_info.vcc->enabled)
+		return;
+
+	if (lpm)
 		regulator_set_mode(hba->vreg_info.vccq2->reg,
 				   REGULATOR_MODE_IDLE);
-	else if (!lpm)
+	else
 		regulator_set_mode(hba->vreg_info.vccq2->reg,
 				   REGULATOR_MODE_NORMAL);
 }
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ