usb: dwc2: Fix endless deferral probe
Subsystems (3)
PATCH 1/1 usb: dwc2: Fix endless deferral probe
The dwc2 USB driver tries to find a generic PHY first and then look for an old style USB PHY. In case of a valid generic PHY node without a PHY driver, the PHY layer will return -EPROBE_DEFER forever. So dwc2 will never tries for an USB PHY.
Fix this issue by finding a generic PHY and an old style USB PHY at once.
--- drivers/usb/dwc2/platform.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-)
drivers/usb/dwc2/platform.c +24 -18
@@ -225,10 +225,11 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) hsotg->phyif =GUSBCFG_PHYIF16 ;/* -* Attempt to find a generic PHY, then look for an old style -* USB PHY and then fall back to pdata +* Attempt to find a generic PHY or an old style USB PHY at once +* otherwise fall back to pdata */ hsotg->phy =devm_phy_get (hsotg->dev,"usb2-phy" ); + hsotg->uphy =devm_usb_get_phy (hsotg->dev,USB_PHY_TYPE_USB2 );if (IS_ERR (hsotg->phy)) { ret =PTR_ERR (hsotg->phy);switch (ret) {
@@ -237,29 +238,34 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) hsotg->phy =NULL ;break ;case -EPROBE_DEFER : -return ret; +if (IS_ERR (hsotg->uphy)) +return ret; + + hsotg->phy =NULL ; +break ;default :dev_err (hsotg->dev,"error getting phy %d\n" , ret);return ret; } } -if (!hsotg->phy) { - hsotg->uphy =devm_usb_get_phy (hsotg->dev,USB_PHY_TYPE_USB2 ); -if (IS_ERR (hsotg->uphy)) { - ret =PTR_ERR (hsotg->uphy); -switch (ret) { -case -ENODEV : -case -ENXIO : - hsotg->uphy =NULL ; -break ; -case -EPROBE_DEFER : -return ret; -default : -dev_err (hsotg->dev,"error getting usb phy %d\n" , - ret); +if (IS_ERR (hsotg->uphy)) { + ret =PTR_ERR (hsotg->uphy); +switch (ret) { +case -ENODEV : +case -ENXIO : + hsotg->uphy =NULL ; +break ; +case -EPROBE_DEFER : +if (!hsotg->phy)return ret; - } + + hsotg->uphy =NULL ; +break ; +default : +dev_err (hsotg->dev,"error getting usb phy %d\n" , + ret); +return ret; } }
Signature · 1 line
2.7.4
PATCH 1/1 usb: dwc2: Fix endless deferral probe
Quoted 7 lines · Stefan Wahren
The dwc2 USB driver tries to find a generic PHY first and then look for an old style USB PHY. In case of a valid generic PHY node without a PHY driver, the PHY layer will return -EPROBE_DEFER forever. So dwc2 will never tries for an USB PHY.
Fix this issue by finding a generic PHY and an old style USB PHY at once.
This would fix only one of the USB controllers (dwc2), but not the others that are affected. As I wrote in my suggested patch, dwc3 appears to be affected the same way, and all other host drivers that call usb_add_hcd() without first setting hcd->phy would suffer from this as well.
If we go down the route of addressing it here in the hcd drivers, we should at least change all three of those, and hope this doesn't regress in another way.
Arnd
PATCH 1/1 usb: dwc2: Fix endless deferral probe
Hi Arnd,
Am 09.01.2018 um 22:33 schrieb Arnd Bergmann:
Quoted 13 lines · Stefan Wahren
Quoted 7 lines
The dwc2 USB driver tries to find a generic PHY first and then look for an old style USB PHY. In case of a valid generic PHY node without a PHY driver, the PHY layer will return -EPROBE_DEFER forever. So dwc2 will never tries for an USB PHY.
Fix this issue by finding a generic PHY and an old style USB PHY at once.
This would fix only one of the USB controllers (dwc2), but not the others that are affected. As I wrote in my suggested patch, dwc3 appears to be affected the same way, and all other host drivers that call
usb_add_hcd()without first settinghcd->phywould suffer from this as well.
Quoted 5 lines
If we go down the route of addressing it here in the hcd drivers, we should at least change all three of those, and hope this doesn't regress in another way.
Arnd
i fully unterstand. But we leaving the path of "fixing a critical issue on BCM2835" and go to "fixing multiple USB host controller". I do this all in my spare time and don't have any of the other USB controller available. So before i proceed with any other patch i like so see some feedback from John, Greg or Felipe.
After finalizing this patch i think the chance is little that this would be applied to 4.15. So i seems to me that we still revert my DT clean up patch.
Stefan
PATCH 1/1 usb: dwc2: Fix endless deferral probe
Quoted 29 lines · Stefan Wahren
Hi Arnd,
Am 09.01.2018 um 22:33 schrieb Arnd Bergmann:
Quoted 17 lines
Quoted 8 lines · Stefan Wahren
The dwc2 USB driver tries to find a generic PHY first and then look for an old style USB PHY. In case of a valid generic PHY node without a PHY driver, the PHY layer will return -EPROBE_DEFER forever. So dwc2 will never tries for an USB PHY.
Fix this issue by finding a generic PHY and an old style USB PHY at once.
This would fix only one of the USB controllers (dwc2), but not the others that are affected. As I wrote in my suggested patch, dwc3 appears to be affected the same way, and all other host drivers that call
usb_add_hcd()without first settinghcd->phywould suffer from this as well.Quoted 6 lines
If we go down the route of addressing it here in the hcd drivers, we should
at least change all three of those, and hope this doesn't regress in another way.Arnd
Quoted 8 lines
i fully unterstand. But we leaving the path of "fixing a critical issue on BCM2835" and go to "fixing multiple USB host controller". I do this all in my spare time and don't have any of the other USB controller available. So before i proceed with any other patch i like so see some feedback from John, Greg or Felipe.
After finalizing this patch i think the chance is little that this would be applied to 4.15. So i seems to me that we still revert my DT clean up patch.
Could you confirm that this simpler patch fixes the problem for you? My feeling right now is that this would be the least invasive variant. This is obviously a critical regression for BCM2835, but I'm fairly sure it's just as critical for a lot of other SoCs that haven't done as much testing on linux-next.
Hans has already verified the earlier (more complex) version, but my analysis today has made it very likely that this one is fully sufficient to fix all affected platforms.
Reverting all nine patches that add #phy-cells would still be an option, but seems way more invasive at this point.
Arnd
drivers/phy/phy-core.c +0 -0
@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node
*np, int index)
if (ret)
return ERR_PTR(-ENODEV);+ /* This phy type handled by the usb-phy subsystem for now */
+ if (of_device_is_compatible(np, "usb-nop-xceiv"))
+ return ERR_PTR(-ENODEV);
+
mutex_lock(&phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) {PATCH 1/1 usb: dwc2: Fix endless deferral probe
Am 12.01.2018 um 00:32 schrieb Arnd Bergmann:
Quoted 32 lines · Stefan Wahren
Quoted 31 lines
Hi Arnd,
Am 09.01.2018 um 22:33 schrieb Arnd Bergmann:
Quoted 14 lines
Quoted 7 lines · Stefan Wahren
The dwc2 USB driver tries to find a generic PHY first and then look for an old style USB PHY. In case of a valid generic PHY node without a PHY driver, the PHY layer will return -EPROBE_DEFER forever. So dwc2 will never tries for an USB PHY.
Fix this issue by finding a generic PHY and an old style USB PHY at once.
This would fix only one of the USB controllers (dwc2), but not the others that are affected. As I wrote in my suggested patch, dwc3 appears to be affected the same way, and all other host drivers that call
usb_add_hcd()without first settinghcd->phywould suffer from this as well.Quoted 6 lines
If we go down the route of addressing it here in the hcd drivers, we should
at least change all three of those, and hope this doesn't regress in another way.Arnd
i fully unterstand. But we leaving the path of "fixing a critical issue on BCM2835" and go to "fixing multiple USB host controller". I do this all in my spare time and don't have any of the other USB controller available. So before i proceed with any other patch i like so see some feedback from John, Greg or Felipe.
Quoted 7 lines
Quoted 2 lines
After finalizing this patch i think the chance is little that this would be applied to 4.15. So i seems to me that we still revert my DT clean up patch.
Could you confirm that this simpler patch fixes the problem for you? My feeling right now is that this would be the least invasive variant. This is obviously a critical regression for BCM2835, but I'm fairly sure it's just as critical for a lot of other SoCs that haven't done as much testing on linux-next.
Even worse arm64 and mips could be affected, too.
Quoted 25 lines
Hans has already verified the earlier (more complex) version, but my analysis today has made it very likely that this one is fully sufficient to fix all affected platforms.
Reverting all nine patches that add #phy-cells would still be an option, but seems way more invasive at this point.
Arnd
drivers/phy/phy-core.c +4
-0@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)if (ret)return ERR_PTR (-ENODEV ); +/* This phy type handled by the usb-phy subsystem for now */ +if (of_device_is_compatible (np,"usb-nop-xceiv" )) +return ERR_PTR (-ENODEV ); +mutex_lock (&phy_provider_mutex); phy_provider =of_phy_provider_lookup (args.np);
Quoted 1 line
if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) {I tried this, but it doesn't work. "np" is the node of the USB controller, not of the phy?
PATCH 1/1 usb: dwc2: Fix endless deferral probe
Quoted 12 lines · Stefan Wahren
Am 12.01.2018 um 00:32 schrieb Arnd Bergmann:
Quoted 11 lines
On Wed, Jan 10, 2018 at 1:15 PM, Stefan Wahren <[email protected]>
drivers/phy/phy-core.c +0
-0@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)if (ret)return ERR_PTR (-ENODEV );
Quoted 12 lines
Quoted 8 lines
drivers/phy/phy-core.c +4
-0+/* This phy type handled by the usb-phy subsystem for now */ +if (of_device_is_compatible (np,"usb-nop-xceiv" )) +return ERR_PTR (-ENODEV ); +mutex_lock (&phy_provider_mutex); phy_provider =of_phy_provider_lookup (args.np);if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)){
I tried this, but it doesn't work. "np" is the node of the USB controller, not of the phy?
Correct, that was a really dumb mistake on my end, I'm glad I asked you to try it first.
I'll fix it up and send the right version with a proper changelog right away.
Thanks for bearing with me,
Arnd
PATCH 1/1 usb: dwc2: Fix endless deferral probe
Em Fri, 12 Jan 2018 10:18:59 +0100
Arnd Bergmann <[email protected]> escreveu:
Quoted 26 lines · Stefan Wahren
Quoted 12 lines
Am 12.01.2018 um 00:32 schrieb Arnd Bergmann:
Quoted 11 lines
On Wed, Jan 10, 2018 at 1:15 PM, Stefan Wahren <[email protected]>
drivers/phy/phy-core.c +0
-0@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)if (ret)return ERR_PTR (-ENODEV );Quoted 12 lines
Quoted 8 lines
drivers/phy/phy-core.c +4
-0+/* This phy type handled by the usb-phy subsystem for now */ +if (of_device_is_compatible (np,"usb-nop-xceiv" )) +return ERR_PTR (-ENODEV ); +mutex_lock (&phy_provider_mutex); phy_provider =of_phy_provider_lookup (args.np);if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)){
I tried this, but it doesn't work. "np" is the node of the USB controller, not of the phy?
Quoted 4 lines
Correct, that was a really dumb mistake on my end, I'm glad I asked you to try it first.
I'll fix it up and send the right version with a proper changelog right away.
I suspect you meant to do, instead:
drivers/phy/phy-core.c +4 -0
@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)if (ret)return ERR_PTR (-ENODEV ); +/* This phy type handled by the usb-phy subsystem for now */ +if (of_device_is_compatible (args.np,"usb-nop-xceiv" )) +return ERR_PTR (-ENODEV ); +mutex_lock (&phy_provider_mutex); phy_provider =of_phy_provider_lookup (args.np);if (IS_ERR (phy_provider) || !try_module_get (phy_provider->owner)) {
(e. g. args.np, instead of np).
The above works for me on RPi3:
$ uname -a Linux raspberrypi 4.15.0-rc7-mcc+ #28 SMP Fri Jan 12 12:35:19 EST 2018 armv7l GNU/Linux
$ lsusb Bus 001 Device 005: ID 045e:0750 Microsoft Corp. Wired Keyboard 600 Bus 001 Device 004: ID 0572:960c Conexant Systems (Rockwell), Inc. DVBSky S960C DVB-S2 tuner Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
So, if you change np -> args.np, feel free to add my:
Regards,
Mauro
PATCH 1/1 usb: dwc2: Fix endless deferral probe
Quoted 68 lines · Mauro Carvalho Chehab
Em Fri, 12 Jan 2018 10:18:59 +0100
Arnd Bergmann <[email protected]> escreveu:Quoted 26 lines · Stefan Wahren
Quoted 12 lines
Am 12.01.2018 um 00:32 schrieb Arnd Bergmann:
Quoted 11 lines
On Wed, Jan 10, 2018 at 1:15 PM, Stefan Wahren <[email protected]>
drivers/phy/phy-core.c +0
-0@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)if (ret)return ERR_PTR (-ENODEV );Quoted 12 lines
Quoted 8 lines
drivers/phy/phy-core.c +4
-0+/* This phy type handled by the usb-phy subsystem for now */ +if (of_device_is_compatible (np,"usb-nop-xceiv" )) +return ERR_PTR (-ENODEV ); +mutex_lock (&phy_provider_mutex); phy_provider =of_phy_provider_lookup (args.np);if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)){
I tried this, but it doesn't work. "np" is the node of the USB controller, not of the phy?
Quoted 4 lines
Correct, that was a really dumb mistake on my end, I'm glad I asked you to try it first.
I'll fix it up and send the right version with a proper changelog right away.
I suspect you meant to do, instead:
drivers/phy/phy-core.c +4
-0@@ -410,6 +410,10 @@ static struct phy *_of_phy_get(struct device_node *np, int index)if (ret)return ERR_PTR (-ENODEV ); +/* This phy type handled by the usb-phy subsystem for now */ +if (of_device_is_compatible (args.np,"usb-nop-xceiv" )) +return ERR_PTR (-ENODEV ); +mutex_lock (&phy_provider_mutex); phy_provider =of_phy_provider_lookup (args.np);if (IS_ERR (phy_provider) || !try_module_get (phy_provider->owner)) {(e. g. args.np, instead of np).
The above works for me on RPi3:
$ uname -a Linux raspberrypi 4.15.0-rc7-mcc+ #28 SMP Fri Jan 12 12:35:19 EST 2018 armv7l GNU/Linux$ lsusb Bus 001 Device 005: ID 045e:0750 Microsoft Corp. Wired Keyboard 600 Bus 001 Device 004: ID 0572:960c Conexant Systems (Rockwell), Inc. DVBSky S960C DVB-S2 tuner Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Quoted 3 lines
So, if you change np -> args.np, feel free to add my:
Thanks a lot for testing, args.np is what the version I sent today has after Stefan pointed out the mistake earlier.
Arnd