linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: Fix endless deferral probe
@ 2018-01-09 19:28 Stefan Wahren
  2018-01-09 21:33 ` Arnd Bergmann
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Wahren @ 2018-01-09 19:28 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Fixes: 6c2dad69163f ("usb: dwc2: Return errors from PHY")
Link: https://marc.info/?l=linux-usb&m=151518314314753&w=2
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/usb/dwc2/platform.c | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 3e26550..5279567 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -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;
 		}
 	}
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-01-12 19:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09 19:28 [PATCH] usb: dwc2: Fix endless deferral probe Stefan Wahren
2018-01-09 21:33 ` Arnd Bergmann
2018-01-10 12:15   ` Stefan Wahren
2018-01-11 23:32     ` Arnd Bergmann
2018-01-12  8:06       ` Stefan Wahren
2018-01-12  9:18         ` Arnd Bergmann
2018-01-12 17:51           ` Mauro Carvalho Chehab
2018-01-12 19:45             ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).