linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: stefan.wahren@i2se.com (Stefan Wahren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] usb: dwc2: Fix endless deferral probe
Date: Tue,  9 Jan 2018 20:28:54 +0100	[thread overview]
Message-ID: <1515526134-2148-1-git-send-email-stefan.wahren@i2se.com> (raw)

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

             reply	other threads:[~2018-01-09 19:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 19:28 Stefan Wahren [this message]
2018-01-09 21:33 ` [PATCH] usb: dwc2: Fix endless deferral probe 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515526134-2148-1-git-send-email-stefan.wahren@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).