Skip to contentSkip to conversation

scsi: ufs-mediatek: fix ufs power down specs violation

PATCH Applied [email protected] 4 participants 7 messages May 12, 2021 – May 15, 2021 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 scsi: ufs-mediatek: fix ufs power down specs violation

From: Peter Wang <[email protected]>

As per specs, e.g, JESD220E chapter 7.2, while powering off the ufs device, RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2. The power down sequence after fixing as below:

Power down:
1. Assert RST_N low
2. Turn-off VCC
3. Turn-off VCCQ/VCCQ2

---
 drivers/scsi/ufs/ufs-mediatek.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufs-mediatek.c +4 -0
index c55202b..47b4066 100644
@@ -922,6 +922,7 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
 	int err;
+	struct arm_smccc_res res;
 
 	if (ufshcd_is_link_hibern8(hba)) {
 		err = ufs_mtk_link_set_lpm(hba);
@@ -941,6 +942,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 			goto fail;
 	}
 
+	if (ufshcd_is_link_off(hba))
+		ufs_mtk_device_reset_ctrl(0, res);
+
 	return 0;
 fail:
 	/*
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 scsi: ufs-mediatek: fix ufs power down specs violation

From: Peter Wang <[email protected]>

As per specs, e.g, JESD220E chapter 7.2, while powering off the ufs device, RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2. The power down sequence after fixing as below:

Power down:
1. Assert RST_N low
2. Turn-off VCC
3. Turn-off VCCQ/VCCQ2

---
 drivers/scsi/ufs/ufs-mediatek.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufs-mediatek.c +4 -0
index c55202b..47b4066 100644
@@ -922,6 +922,7 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
 	int err;
+	struct arm_smccc_res res;
 
 	if (ufshcd_is_link_hibern8(hba)) {
 		err = ufs_mtk_link_set_lpm(hba);
@@ -941,6 +942,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 			goto fail;
 	}
 
+	if (ufshcd_is_link_off(hba))
+		ufs_mtk_device_reset_ctrl(0, res);
+
 	return 0;
 fail:
 	/*
Signature · 1 line
1.7.9.5
Reviewed-by on v4 1/1
#2 lore raw
In reply to [email protected]

Hi Peter,

Quoted 29 lines · On Wed, 2021-05-12 at 18:01 +0800, [email protected] wrote:

From: Peter Wang <[email protected]>

As per specs, e.g, JESD220E chapter 7.2, while powering off the ufs device, RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2. The power down sequence after fixing as below:

Power down:
1. Assert RST_N low
2. Turn-off VCC
3. Turn-off VCCQ/VCCQ2

---
 drivers/scsi/ufs/ufs-mediatek.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufs-mediatek.c +1 -0
index c55202b..47b4066 100644
@@ -922,6 +922,7 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
 	int err;
+	struct arm_smccc_res res;
 
 	if (ufshcd_is_link_hibern8(hba)) {
 		err = ufs_mtk_link_set_lpm(hba);

drivers/scsi/ufs/ufs-mediatek.c static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 947

Quoted 6 lines
drivers/scsi/ufs/ufs-mediatek.c +3 -0
@@ -941,6 +942,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 			goto fail;
 	}
 
+	if (ufshcd_is_link_off(hba))
+		ufs_mtk_device_reset_ctrl(0, res);
+

For the case "linkoff @ suspend", HW reset pin can be de-asserted via ufshcd_resume() -> ufshcd_reset_and_restore() -> ufshcd_vops_device_reset(), so this looks good to me.

#3 lore raw
In reply to [email protected]
Quoted 30 lines

From: Peter Wang <[email protected]>

As per specs, e.g, JESD220E chapter 7.2, while powering off the ufs device, RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2. The power down sequence after fixing as below:

Power down:
1. Assert RST_N low
2. Turn-off VCC
3. Turn-off VCCQ/VCCQ2

---
 drivers/scsi/ufs/ufs-mediatek.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufs-mediatek.c +1 -0
index c55202b..47b4066 100644
@@ -922,6 +922,7 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba
 *hba, bool lpm)
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
        int err;
+       struct arm_smccc_res res;
 
        if (ufshcd_is_link_hibern8(hba)) {
                err = ufs_mtk_link_set_lpm(hba);

drivers/scsi/ufs/ufs-mediatek.c static int ufs_mtk_suspend(struct ufs_hba *hba, · line 947

Quoted 6 lines
drivers/scsi/ufs/ufs-mediatek.c +2 -0
@@ -941,6 +942,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba,
 enum ufs_pm_op pm_op)
                        goto fail;
        }
 
+       if (ufshcd_is_link_off(hba))
+               ufs_mtk_device_reset_ctrl(0, res);

According to your commit log, you should call reset just before ufs_mtk_vreg_set_lpm, or turn phy off, whichever turn off vcc - Few lines above.

Thanks,
Avri

Quoted 6 lines
drivers/scsi/ufs/ufs-mediatek.c +1 -0
+
        return 0;
 fail:
        /*

--
1.7.9.5

author
#4 lore raw
Quoted 34 lines · Avri Altman
Quoted 34 lines

From: Peter Wang <[email protected]>

As per specs, e.g, JESD220E chapter 7.2, while powering off the ufs device, RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2. The power down sequence after fixing as below:

Power down:
1. Assert RST_N low
2. Turn-off VCC
3. Turn-off VCCQ/VCCQ2

---
 drivers/scsi/ufs/ufs-mediatek.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufs-mediatek.c +1 -0
index c55202b..47b4066 100644
@@ -922,6 +922,7 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba
 *hba, bool lpm)
 static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
        int err;
+       struct arm_smccc_res res;
 
        if (ufshcd_is_link_hibern8(hba)) {
                err = ufs_mtk_link_set_lpm(hba);
drivers/scsi/ufs/ufs-mediatek.c +0 -0
@@ -941,6 +942,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba,
 enum ufs_pm_op pm_op)
                        goto fail;
        }
 
Quoted 8 lines

drivers/scsi/ufs/ufs-mediatek.c static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 946

Quoted 2 lines
drivers/scsi/ufs/ufs-mediatek.c +2 -0
+       if (ufshcd_is_link_off(hba))
+               ufs_mtk_device_reset_ctrl(0, res);

According to your commit log, you should call reset just before ufs_mtk_vreg_set_lpm, or turn phy off, whichever turn off vcc - Few lines above.

Thanks,
Avri

ufs_mtk_vreg_set_lpm only set vccq2 power mode to lpm, dose't trun off vccq2.And turn phy off is also turn off vcc, dose't turn off vccq2. RST_N keep high is no problem when we trun off vcc and vccq2 keep on. But RST_N will got problem if we trun off vccq2.
(RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2) Here set RST_N to low is after shut down pm set link off, and before shutdown pm turn off vccq2.

Thanks
Peter

Quoted 8 lines
Quoted 7 lines
drivers/scsi/ufs/ufs-mediatek.c +1 -0
+
        return 0;
 fail:
        /*

--
1.7.9.5

#5 lore raw
Quoted 9 lines
Quoted 8 lines

drivers/scsi/ufs/ufs-mediatek.c static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 946

Quoted 2 lines
drivers/scsi/ufs/ufs-mediatek.c +2 -0
+       if (ufshcd_is_link_off(hba))
+               ufs_mtk_device_reset_ctrl(0, res);

According to your commit log, you should call reset just before ufs_mtk_vreg_set_lpm, or turn phy off, whichever turn off vcc - Few lines above.

Thanks,
Avri

Quoted 7 lines

ufs_mtk_vreg_set_lpm only set vccq2 power mode to lpm, dose't trun off vccq2.And turn phy off is also turn off vcc, dose't turn off vccq2. RST_N keep high is no problem when we trun off vcc and vccq2 keep on. But RST_N will got problem if we trun off vccq2.
(RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2) Here set RST_N to low is after shut down pm set link off, and before shutdown pm turn off vccq2.

OK. Thanks for clarifying this.

Thanks,
Avri

Quoted 12 lines

Thanks
Peter

Quoted 8 lines
Quoted 7 lines

+

        return 0;
 fail:
        /*

--
1.7.9.5

#6 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, 12 May 2021 18:01:45 +0800, [email protected] wrote:

As per specs, e.g, JESD220E chapter 7.2, while powering off the ufs device, RST_N signal should be between VSS(Ground) and VCCQ/VCCQ2. The power down sequence after fixing as below:

Power down:
1. Assert RST_N low
2. Turn-off VCC
3. Turn-off VCCQ/VCCQ2

Applied to 5.13/scsi-fixes, thanks!

[1/1] scsi: ufs-mediatek: fix ufs power down specs violation

      https://git.kernel.org/mkp/scsi/c/c625b80b9d00
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering