Skip to contentSkip to conversation

usb/host: Let usb phy shutdown later

PATCH Superseded Surong Pang 3 participants 10 messages Apr 12, 2022 – Apr 29, 2022 1 message not in the archive

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

PATCH 1/1 usb/host: Let usb phy shutdown later

From: Surong Pang <[email protected]>

Let usb phy shutdown later in xhci_plat_remove function. Some phy driver doesn't divide 3.0/2.0 very clear. If calls usb_phy_shutdown earlier than usb_remove_hcd(hcd), It will case 10s cmd timeout issue.

Call usb phy shutdown later has better compatibility.

---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +1 -1
index 649ffd861b44..dc73a81cbe9b 100644
@@ -390,7 +390,6 @@ static int xhci_plat_remove(struct platform_device *dev)
 
 	usb_remove_hcd(shared_hcd);
 	xhci->shared_hcd = NULL;
-	usb_phy_shutdown(hcd->usb_phy);
 
 	usb_remove_hcd(hcd);
 	usb_put_hcd(shared_hcd);
@@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 	clk_disable_unprepare(clk);
 	clk_disable_unprepare(reg_clk);
 	usb_put_hcd(hcd);
+	usb_phy_shutdown(hcd->usb_phy);
 
 	pm_runtime_disable(&dev->dev);
 	pm_runtime_put_noidle(&dev->dev);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 27 lines · Surong Pang

From: Surong Pang <[email protected]>

Let usb phy shutdown later in xhci_plat_remove function. Some phy driver doesn't divide 3.0/2.0 very clear. If calls usb_phy_shutdown earlier than usb_remove_hcd(hcd), It will case 10s cmd timeout issue.

Call usb phy shutdown later has better compatibility.

---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +0 -1
index 649ffd861b44..dc73a81cbe9b 100644
@@ -390,7 +390,6 @@ static int xhci_plat_remove(struct platform_device *dev)
 
 	usb_remove_hcd(shared_hcd);
 	xhci->shared_hcd = NULL;
-	usb_phy_shutdown(hcd->usb_phy);
 
 	usb_remove_hcd(hcd);
 	usb_put_hcd(shared_hcd);

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 4 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 	clk_disable_unprepare(clk);
 	clk_disable_unprepare(reg_clk);
 	usb_put_hcd(hcd);
+	usb_phy_shutdown(hcd->usb_phy);

hcd might be freed already here.
maybe call usb_phy_shutdown(hcd->usb_phy) before usb_put_hcd(hcd)

-Mathias

#2 lore raw

shared_hcd might be freed already here, but hcd should not be freed here, because "usb_put_hcd(hcd)" is called later.

Quoted 40 lines · Mathias Nyman <[email protected]> 于2022年4月19日周二 22:43写道:
Quoted 27 lines · Surong Pang

From: Surong Pang <[email protected]>

Let usb phy shutdown later in xhci_plat_remove function. Some phy driver doesn't divide 3.0/2.0 very clear. If calls usb_phy_shutdown earlier than usb_remove_hcd(hcd), It will case 10s cmd timeout issue.

Call usb phy shutdown later has better compatibility.

---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +0 -1
index 649ffd861b44..dc73a81cbe9b 100644
@@ -390,7 +390,6 @@ static int xhci_plat_remove(struct platform_device *dev)
 
      usb_remove_hcd(shared_hcd);
      xhci->shared_hcd = NULL;
-     usb_phy_shutdown(hcd->usb_phy);
 
      usb_remove_hcd(hcd);
      usb_put_hcd(shared_hcd);

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 4 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
      clk_disable_unprepare(clk);
      clk_disable_unprepare(reg_clk);
      usb_put_hcd(hcd);
+     usb_phy_shutdown(hcd->usb_phy);

hcd might be freed already here.
maybe call usb_phy_shutdown(hcd->usb_phy) before usb_put_hcd(hcd)

-Mathias

#3 lore raw
Quoted 2 lines · surong pang

shared_hcd might be freed already here, but hcd should not be freed here, because "usb_put_hcd(hcd)" is called later.

To me it still looks like this patch calls usb_phy_shutdown(hcd->usb_phy) _after_ usb_put_hcd(hcd):

Quoted 5 lines
Quoted 5 lines

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 5 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
      clk_disable_unprepare(clk);
      clk_disable_unprepare(reg_clk);
      usb_put_hcd(hcd);
+     usb_phy_shutdown(hcd->usb_phy);

shared hcd was freed even earlier, before disabling the clocks.

Thanks
Mathias

#4 lore raw
Quoted 5 lines
Quoted 5 lines

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 5 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
      clk_disable_unprepare(clk);
      clk_disable_unprepare(reg_clk);
+    usb_phy_shutdown(hcd->usb_phy);
      usb_put_hcd(hcd);

Is it ok to put usb_phy_shutdown before usb_put_hcd(hcd)? hcd is released at usb_put_hcd.

UNISOC DWC3 phy is not divided USB 2.0/3.0 phy clearly. Yes, it's UNISOC's issue.
It UNISOC's dtsi: phys = <&ssphy>, <&ssphy>;
If to shutdown phy too earlier, it will cost 10s timeout to do xhci_reset. usb_remmove_hcd --> usb_stop_hcd --> xhci_stop --> xhci_reset --> xhci_handshake(&xhci->op_regs->command, CMD_RESET, 0, 10 * 1000 *1000)

I want to know this change is acceptable or not?

hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); Why in xhci_plat_remove, just to shutdown "usb-phy"[0], not to shutdown "usb-phy"[1] ?

Quoted 19 lines · Mathias Nyman <[email protected]> 于2022年4月22日周五 15:51写道:
Quoted 2 lines · surong pang

shared_hcd might be freed already here, but hcd should not be freed here, because "usb_put_hcd(hcd)" is called later.

To me it still looks like this patch calls usb_phy_shutdown(hcd->usb_phy) _after_ usb_put_hcd(hcd):

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
 > @@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 >       clk_disable_unprepare(clk);
 >       clk_disable_unprepare(reg_clk);
Quoted 2 lines
      usb_put_hcd(hcd);

+ usb_phy_shutdown(hcd->usb_phy);

shared hcd was freed even earlier, before disabling the clocks.

Thanks
Mathias

#5 lore raw
Quoted 8 lines · surong pang
Quoted 5 lines
Quoted 5 lines

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 5 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
      clk_disable_unprepare(clk);
      clk_disable_unprepare(reg_clk);
+    usb_phy_shutdown(hcd->usb_phy);
      usb_put_hcd(hcd);

Is it ok to put usb_phy_shutdown before usb_put_hcd(hcd)? hcd is released at usb_put_hcd.

yes, above looks good.

Quoted 8 lines

UNISOC DWC3 phy is not divided USB 2.0/3.0 phy clearly. Yes, it's UNISOC's issue.
It UNISOC's dtsi: phys = <&ssphy>, <&ssphy>;
If to shutdown phy too earlier, it will cost 10s timeout to do xhci_reset. usb_remmove_hcd --> usb_stop_hcd --> xhci_stop --> xhci_reset --> xhci_handshake(&xhci->op_regs->command, CMD_RESET, 0, 10 * 1000 *1000)

Quoted 5 lines

I want to know this change is acceptable or not?

hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); Why in xhci_plat_remove, just to shutdown "usb-phy"[0], not to shutdown "usb-phy"[1] ?

xhci-plat.c only takes one phy at index 0, so we only shutdowns that one.

Looks like usb core hcd code has better phy handling when adding and removing hcds. It supports multiple phys.
If possible use that instead.

See drivers/usb/core/hcd.c usb_add_hcd()

Thanks
-Mathias

#6 lore raw

PATCH v2 1/1 usb/host: Let usb phy shutdown later

From: Surong Pang <[email protected]>

Let usb phy shutdown later in xhci_plat_remove function. Some phy driver doesn't divide 3.0/2.0 very clear. If calls usb_phy_shutdown earlier than usb_remove_hcd(hcd), It will case 10s cmd timeout issue.

Call usb phy shutdown later has better compatibility.

---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +1 -1
index 649ffd861b44..fe492ed99cb7 100644
@@ -390,13 +390,13 @@ static int xhci_plat_remove(struct platform_device *dev)
 
 	usb_remove_hcd(shared_hcd);
 	xhci->shared_hcd = NULL;
-	usb_phy_shutdown(hcd->usb_phy);
 
 	usb_remove_hcd(hcd);
 	usb_put_hcd(shared_hcd);
 
 	clk_disable_unprepare(clk);
 	clk_disable_unprepare(reg_clk);
+	usb_phy_shutdown(hcd->usb_phy);
 	usb_put_hcd(hcd);
 
 	pm_runtime_disable(&dev->dev);
Signature · 1 line
2.17.1
maintainer
#7 lore raw
Quoted 10 lines · Surong Pang

From: Surong Pang <[email protected]>

Let usb phy shutdown later in xhci_plat_remove function. Some phy driver doesn't divide 3.0/2.0 very clear. If calls usb_phy_shutdown earlier than usb_remove_hcd(hcd), It will case 10s cmd timeout issue.

Call usb phy shutdown later has better compatibility.

The subject should say "xhci-plat", right?

Quoted 11 lines
---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +0 -0
index 649ffd861b44..fe492ed99cb7 100644
@@ -390,13 +390,13 @@ static int xhci_plat_remove(struct platform_device *dev)
 
 	usb_remove_hcd(shared_hcd);

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 10 lines
drivers/usb/host/xhci-plat.c +1 -1
 	xhci->shared_hcd = NULL;
-	usb_phy_shutdown(hcd->usb_phy);
 
 	usb_remove_hcd(hcd);
 	usb_put_hcd(shared_hcd);
 
 	clk_disable_unprepare(clk);
 	clk_disable_unprepare(reg_clk);
+	usb_phy_shutdown(hcd->usb_phy);
 	usb_put_hcd(hcd);

Does this fix a specific commit id?

thanks,

greg k-h

A message that is not in the archive (sent off-list or not yet received): CAEDbmAQmYQdMNY8sANnSuauBcsemrV1MFR3bB83JJ7cHNdWGmA@mail.gmail.com

maintainer
#9 lore raw

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 2 lines · surong pang

Dear Greg,
No, It's just a patch to call usb_phy_shutdown later.

I do not understand this response, sorry, as I have no context here.

Also, please fix your email client to not send html email, the mailing lists reject mail written that way.

thanks,

greg k-h

#10 lore raw

Re: [PATCH V2] xhci-plat: Let usb phy shutdown later

In reply to a message not in the archive

Dear Greg,
Sorry for html email response.
Yes, The subject should say "xhci-plat". And it didn't fix a specific commit id.

Quoted 48 lines · surong pang <[email protected]> 于2022年4月28日周四 14:26写道:

Dear Greg,
No, It's just a patch to call usb_phy_shutdown later.

Quoted 42 lines · Greg KH <[email protected]> 于2022年4月26日周二 19:53写道:
Quoted 10 lines · Surong Pang

From: Surong Pang <[email protected]>

Let usb phy shutdown later in xhci_plat_remove function. Some phy driver doesn't divide 3.0/2.0 very clear. If calls usb_phy_shutdown earlier than usb_remove_hcd(hcd), It will case 10s cmd timeout issue.

Call usb phy shutdown later has better compatibility.

The subject should say "xhci-plat", right?

Quoted 11 lines
---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-plat.c +0 -0
index 649ffd861b44..fe492ed99cb7 100644
@@ -390,13 +390,13 @@ static int xhci_plat_remove(struct platform_device *dev)
 
      usb_remove_hcd(shared_hcd);

drivers/usb/host/xhci-plat.c static int xhci_plat_remove(struct platform_device *dev) · line 400

Quoted 10 lines
drivers/usb/host/xhci-plat.c +1 -1
      xhci->shared_hcd = NULL;
-     usb_phy_shutdown(hcd->usb_phy);
 
      usb_remove_hcd(hcd);
      usb_put_hcd(shared_hcd);
 
      clk_disable_unprepare(clk);
      clk_disable_unprepare(reg_clk);
+     usb_phy_shutdown(hcd->usb_phy);
      usb_put_hcd(hcd);

Does this fix a specific commit id?

thanks,

greg k-h