Skip to contentSkip to conversation

ufs: core: correct ufshcd_shutdown flow

PATCH Superseded [email protected] 3 participants 4 messages Jul 26, 2022 – Jul 27, 2022

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ufs: core: correct ufshcd_shutdown flow

From: Peter Wang <[email protected]>

In normal case: ufshcd_wl_shutdown -> ufshcd_shtdown ufshcd_shtdown should turn off clock/power after ufshcd_wl_shutdown which set device power off and link off.

Also remove pm_runtime_get_sync.
The reason why here can remove pm_runtime_get_sync is because,
(1) ufshcd_wl_shutdown -> pm_runtime_get_sync, will resume hba->dev too.
(2) device resume(turn on clk/power) is not required, even if device is in RPM_SUSPENDED.

---
 drivers/ufs/core/ufshcd.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/ufs/core/ufshcd.c +1 -5
index c7b337480e3e..d13c76983555 100644
@@ -9462,12 +9462,8 @@ EXPORT_SYMBOL(ufshcd_runtime_resume);
 int ufshcd_shutdown(struct ufs_hba *hba)
 {
 	if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
-		goto out;
-
-	pm_runtime_get_sync(hba->dev);
+		ufshcd_suspend(hba);
 
-	ufshcd_suspend(hba);
-out:
 	hba->is_powered = false;
 	/* allow force shutdown even in case of errors */
 	return 0;
Signature · 1 line
2.18.0
maintainer
#1 lore raw
Quoted 37 lines · On Tue, Jul 26, 2022 at 07:36:53PM +0800, [email protected] wrote:

From: Peter Wang <[email protected]>

In normal case: ufshcd_wl_shutdown -> ufshcd_shtdown ufshcd_shtdown should turn off clock/power after ufshcd_wl_shutdown which set device power off and link off.

Also remove pm_runtime_get_sync.
The reason why here can remove pm_runtime_get_sync is because,
(1) ufshcd_wl_shutdown -> pm_runtime_get_sync, will resume hba->dev too.
(2) device resume(turn on clk/power) is not required, even if device is in RPM_SUSPENDED.

---
 drivers/ufs/core/ufshcd.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/ufs/core/ufshcd.c +1 -5
index c7b337480e3e..d13c76983555 100644
@@ -9462,12 +9462,8 @@ EXPORT_SYMBOL(ufshcd_runtime_resume);
 int ufshcd_shutdown(struct ufs_hba *hba)
 {
 	if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
-		goto out;
-
-	pm_runtime_get_sync(hba->dev);
+		ufshcd_suspend(hba);
 
-	ufshcd_suspend(hba);
-out:
 	hba->is_powered = false;
 	/* allow force shutdown even in case of errors */
 	return 0;
Signature · 1 line
2.18.0

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

#2 lore raw
In reply to [email protected]
Quoted 3 lines · On 7/26/22 04:36, [email protected] wrote:

In normal case: ufshcd_wl_shutdown -> ufshcd_shtdown ufshcd_shtdown should turn off clock/power after ufshcd_wl_shutdown which set device power off and link off.

The above sentence is confusing: it mentions "normal case" which suggests there is also an abnormal case. Isn't the order in which ufshcd_wl_shutdown() and ufshcd_shutdown() are called always the same?

Otherwise this patch looks good to me.

Thanks,

Bart.

author
#3 lore raw
Quoted 5 lines · Bart Van Assche
Quoted 3 lines · On 7/26/22 04:36, [email protected] wrote:

In normal case: ufshcd_wl_shutdown -> ufshcd_shtdown ufshcd_shtdown should turn off clock/power after ufshcd_wl_shutdown which set device power off and link off.

Quoted 7 lines

The above sentence is confusing: it mentions "normal case" which suggests there is also an abnormal case. Isn't the order in which ufshcd_wl_shutdown() and ufshcd_shutdown() are called always the same?

Otherwise this patch looks good to me.

Thanks,

Bart.

Hi Bart,

Yes, You are right,

I' ll make patch description more clear.

Thanks

Peter