Skip to contentSkip to conversation

usb: dwc3: fixes for v4.6-rc

PATCH New Roger Quadros 1 participant 4 messages Apr 11, 2016 – Apr 12, 2016

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

cover usb: dwc3: fixes for v4.6-rc

Hi,

These are some dwc3 fixes that were done by Felipe. I've just rebased and posted them.

cheers,
-roger

Felipe Balbi (2):
usb: dwc3: omap: fix up error path on probe()
usb: dwc3: core: fix PHY handling during suspend

 drivers/usb/dwc3/core.c      | 23 ++++++++++++++++++++++-
 drivers/usb/dwc3/dwc3-omap.c | 12 ++++--------
 2 files changed, 26 insertions(+), 9 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/2 usb: dwc3: omap: fix up error path on probe()

From: Felipe Balbi <[email protected]>

Even if pm_runtime_get*() fails, we *MUST* call pm_runtime_put_sync() before disabling PM.

While at it, remove superfluous dwc3_omap_disable_irqs() in error path.

---
 drivers/usb/dwc3/dwc3-omap.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/dwc3/dwc3-omap.c +4 -8
index 22e9606..55da2c7 100644
@@ -496,7 +496,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
 		dev_err(dev, "get_sync failed with err %d\n", ret);
-		goto err0;
+		goto err1;
 	}
 
 	dwc3_omap_map_offset(omap);
@@ -516,28 +516,24 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 
 	ret = dwc3_omap_extcon_register(omap);
 	if (ret < 0)
-		goto err2;
+		goto err1;
 
 	ret = of_platform_populate(node, NULL, NULL, dev);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to create dwc3 core\n");
-		goto err3;
+		goto err2;
 	}
 
 	dwc3_omap_enable_irqs(omap);
 
 	return 0;
 
-err3:
+err2:
 	extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb);
 	extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb);
-err2:
-	dwc3_omap_disable_irqs(omap);
 
 err1:
 	pm_runtime_put_sync(dev);
-
-err0:
 	pm_runtime_disable(dev);
 
 	return ret;
Signature · 1 line
2.5.0
#2 lore raw

PATCH 2/2 usb: dwc3: core: fix PHY handling during suspend

In reply to Roger Quadros

From: Felipe Balbi <[email protected]>

we need to power off the PHY during suspend and
power it back on during resume.

[[email protected]: fix call to usb_phy_set_suspend() in dwc3_suspend()]
---
 drivers/usb/dwc3/core.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +22 -1
index 17fd8144..44ff68e 100644
@@ -1162,6 +1162,11 @@ static int dwc3_suspend(struct device *dev)
 	phy_exit(dwc->usb2_generic_phy);
 	phy_exit(dwc->usb3_generic_phy);
 
+	usb_phy_set_suspend(dwc->usb2_phy, 1);
+	usb_phy_set_suspend(dwc->usb3_phy, 1);
+	WARN_ON(phy_power_off(dwc->usb2_generic_phy) < 0);
+	WARN_ON(phy_power_off(dwc->usb3_generic_phy) < 0);
+
 	pinctrl_pm_select_sleep_state(dev);
 
 	return 0;
@@ -1175,11 +1180,21 @@ static int dwc3_resume(struct device *dev)
 
 	pinctrl_pm_select_default_state(dev);
 
+	usb_phy_set_suspend(dwc->usb2_phy, 0);
+	usb_phy_set_suspend(dwc->usb3_phy, 0);
+	ret = phy_power_on(dwc->usb2_generic_phy);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_power_on(dwc->usb3_generic_phy);
+	if (ret < 0)
+		goto err_usb2phy_power;
+
 	usb_phy_init(dwc->usb3_phy);
 	usb_phy_init(dwc->usb2_phy);
 	ret = phy_init(dwc->usb2_generic_phy);
 	if (ret < 0)
-		return ret;
+		goto err_usb3phy_power;
 
 	ret = phy_init(dwc->usb3_generic_phy);
 	if (ret < 0)
@@ -1212,6 +1227,12 @@ static int dwc3_resume(struct device *dev)
 err_usb2phy_init:
 	phy_exit(dwc->usb2_generic_phy);
 
+err_usb3phy_power:
+	phy_power_off(dwc->usb3_generic_phy);
+
+err_usb2phy_power:
+	phy_power_off(dwc->usb2_generic_phy);
+
 	return ret;
 }
 
Signature · 1 line
2.5.0
#3 lore raw

PATCH 3/3 usb: dwc3: gadget: Fix suspend/resume during device mode

In reply to Roger Quadros

Gadget controller might not be always active during system suspend/resume as gadget driver might not have yet been loaded or might have been unloaded prior to system suspend.

Check if we're active and only then perform
necessary actions during suspend/resume.

---
 drivers/usb/dwc3/gadget.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/dwc3/gadget.c +6 -0
index 3ac170f..efbb801 100644
@@ -2931,6 +2931,9 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
 
 int dwc3_gadget_suspend(struct dwc3 *dwc)
 {
+	if (!dwc->gadget_driver)
+		return 0;
+
 	if (dwc->pullups_connected) {
 		dwc3_gadget_disable_irq(dwc);
 		dwc3_gadget_run_stop(dwc, true, true);
@@ -2949,6 +2952,9 @@ int dwc3_gadget_resume(struct dwc3 *dwc)
 	struct dwc3_ep		*dep;
 	int			ret;
 
+	if (!dwc->gadget_driver)
+		return 0;
+
 	/* Start with SuperSpeed Default */
 	dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
 
Signature · 1 line
2.5.0