diff mbox

usb: dwc3: fix runtime PM in error path

Message ID 1465548878-30085-1-git-send-email-rogerq@ti.com
State New
Headers show

Commit Message

Roger Quadros June 10, 2016, 8:54 a.m. UTC
If there is a failure after pm_runtime_enable/get_sync()
we need to call pm_runtime_disable/put_sync().

Otherwise it will lead to an unbalanced pm_runtime_enable() on the
subsequent probe if the earlier probe bailed out due to -EPROBE_DEFER.

Signed-off-by: Roger Quadros <rogerq@ti.com>

---
 drivers/usb/dwc3/core.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

-- 
2.7.4

Comments

Roger Quadros June 10, 2016, 9:52 a.m. UTC | #1
On 10/06/16 12:16, Felipe Balbi wrote:
> 

> Hi,

> 

> Roger Quadros <rogerq@ti.com> writes:

>> If there is a failure after pm_runtime_enable/get_sync()

>> we need to call pm_runtime_disable/put_sync().

>>

>> Otherwise it will lead to an unbalanced pm_runtime_enable() on the

>> subsequent probe if the earlier probe bailed out due to -EPROBE_DEFER.

>>

>> Signed-off-by: Roger Quadros <rogerq@ti.com>

> 

> where is this supposed to be applied? You're not checking if


On your testing/next

> pm_runtime_get() failed at all.

> 


I'm not adding pm_runtime_get in my patch.
Just fixing up the failure path in core.c.

cheers,
-roger
diff mbox

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 5bf38f8..222d2c9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1419,7 +1419,7 @@  static int dwc3_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(dwc->dev, "failed to allocate event buffers\n");
 		ret = -ENOMEM;
-		goto err0;
+		goto err1;
 	}
 
 	if (IS_ENABLED(CONFIG_USB_DWC3_HOST) &&
@@ -1436,12 +1436,12 @@  static int dwc3_probe(struct platform_device *pdev)
 
 	ret = dwc3_alloc_scratch_buffers(dwc);
 	if (ret)
-		goto err1;
+		goto err2;
 
 	ret = dwc3_core_init(dwc);
 	if (ret) {
 		dev_err(dev, "failed to initialize core\n");
-		goto err2;
+		goto err3;
 	}
 
 	/* Check the maximum_speed parameter */
@@ -1473,23 +1473,28 @@  static int dwc3_probe(struct platform_device *pdev)
 
 	ret = dwc3_core_init_mode(dwc);
 	if (ret)
-		goto err3;
+		goto err4;
 
 	dwc3_debugfs_init(dwc);
 	pm_runtime_put(dev);
 
 	return 0;
 
-err3:
+err4:
 	dwc3_event_buffers_cleanup(dwc);
 
-err2:
+err3:
 	dwc3_free_scratch_buffers(dwc);
 
-err1:
+err2:
 	dwc3_free_event_buffers(dwc);
 	dwc3_ulpi_exit(dwc);
 
+err1:
+	pm_runtime_allow(&pdev->dev);
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+
 err0:
 	/*
 	 * restore res->start back to its original value so that, in case the