Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1419133 > unrolled thread
| Started by | Roger Quadros <rogerq@ti.com> |
|---|---|
| First post | 2016-06-10 11:00 +0200 |
| Last post | 2016-06-10 13:40 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] usb: dwc3: fix runtime PM in error path Roger Quadros <rogerq@ti.com> - 2016-06-10 11:00 +0200
Re: [PATCH] usb: dwc3: fix runtime PM in error path Felipe Balbi <balbi@kernel.org> - 2016-06-10 11:20 +0200
Re: [PATCH] usb: dwc3: fix runtime PM in error path Roger Quadros <rogerq@ti.com> - 2016-06-10 12:00 +0200
Re: [PATCH] usb: dwc3: fix runtime PM in error path Felipe Balbi <balbi@kernel.org> - 2016-06-10 12:10 +0200
[PATCH v2] usb: dwc3: fix runtime PM in error path Roger Quadros <rogerq@ti.com> - 2016-06-10 13:40 +0200
[PATCH v2] usb: dwc3: fix runtime PM in error path Roger Quadros <rogerq@ti.com> - 2016-06-10 13:40 +0200
| From | Roger Quadros <rogerq@ti.com> |
|---|---|
| Date | 2016-06-10 11:00 +0200 |
| Subject | [PATCH] usb: dwc3: fix runtime PM in error path |
| Message-ID | <rIqsh-2n3-7@gated-at.bofh.it> |
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(-)
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
--
2.7.4
[toc] | [next] | [standalone]
| From | Felipe Balbi <balbi@kernel.org> |
|---|---|
| Date | 2016-06-10 11:20 +0200 |
| Message-ID | <rIqLE-2IM-27@gated-at.bofh.it> |
| In reply to | #1419133 |
[Multipart message — attachments visible in raw view] — view raw
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 pm_runtime_get() failed at all. -- balbi
[toc] | [prev] | [next] | [standalone]
| From | Roger Quadros <rogerq@ti.com> |
|---|---|
| Date | 2016-06-10 12:00 +0200 |
| Message-ID | <rIrol-2W0-17@gated-at.bofh.it> |
| In reply to | #1419147 |
[Multipart message — attachments visible in raw view] — view raw
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
[toc] | [prev] | [next] | [standalone]
| From | Felipe Balbi <balbi@kernel.org> |
|---|---|
| Date | 2016-06-10 12:10 +0200 |
| Message-ID | <rIry1-3er-7@gated-at.bofh.it> |
| In reply to | #1419186 |
[Multipart message — attachments visible in raw view] — view raw
Roger Quadros <rogerq@ti.com> writes:
> [ Unknown signature status ]
> 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.
that's fine, but you're missing this hunk:
- pm_runtime_get_sync(dev);
+
+ ret = pm_runtime_get_sync(dev);
+ if (ret < 0)
+ goto err1;
+
pm_runtime_forbid(dev);
--
balbi
[toc] | [prev] | [next] | [standalone]
| From | Roger Quadros <rogerq@ti.com> |
|---|---|
| Date | 2016-06-10 13:40 +0200 |
| Subject | [PATCH v2] usb: dwc3: fix runtime PM in error path |
| Message-ID | <rIsX8-3Yr-27@gated-at.bofh.it> |
| In reply to | #1419133 |
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.
pm_runtime_get_sync() can fail as well so deal with that case too.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
v2:
- deal with pm_runtime_get_sync() failure
drivers/usb/dwc3/core.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 131e7eb..d51c9a9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -959,14 +959,17 @@ static int dwc3_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY);
pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
+ ret = pm_runtime_get_sync(dev);
+ if (ret < 0)
+ goto err1;
+
pm_runtime_forbid(dev);
ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
if (ret) {
dev_err(dwc->dev, "failed to allocate event buffers\n");
ret = -ENOMEM;
- goto err0;
+ goto err2;
}
if (IS_ENABLED(CONFIG_USB_DWC3_HOST) &&
@@ -983,12 +986,12 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
- goto err1;
+ goto err3;
ret = dwc3_core_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize core\n");
- goto err2;
+ goto err4;
}
/* Check the maximum_speed parameter */
@@ -1020,23 +1023,29 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_core_init_mode(dwc);
if (ret)
- goto err3;
+ goto err5;
dwc3_debugfs_init(dwc);
pm_runtime_put(dev);
return 0;
-err3:
+err5:
dwc3_event_buffers_cleanup(dwc);
-err2:
+err4:
dwc3_free_scratch_buffers(dwc);
-err1:
+err3:
dwc3_free_event_buffers(dwc);
dwc3_ulpi_exit(dwc);
+err2:
+ pm_runtime_allow(&pdev->dev);
+err1:
+ 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
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Roger Quadros <rogerq@ti.com> |
|---|---|
| Date | 2016-06-10 13:40 +0200 |
| Subject | [PATCH v2] usb: dwc3: fix runtime PM in error path |
| Message-ID | <rIsX8-3Yr-33@gated-at.bofh.it> |
| In reply to | #1419133 |
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.
pm_runtime_get_sync() can fail as well so deal with that case too.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
v2:
- deal with pm_runtime_get_sync() failure
drivers/usb/dwc3/core.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 131e7eb..d51c9a9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -959,14 +959,17 @@ static int dwc3_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY);
pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
+ ret = pm_runtime_get_sync(dev);
+ if (ret < 0)
+ goto err1;
+
pm_runtime_forbid(dev);
ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
if (ret) {
dev_err(dwc->dev, "failed to allocate event buffers\n");
ret = -ENOMEM;
- goto err0;
+ goto err2;
}
if (IS_ENABLED(CONFIG_USB_DWC3_HOST) &&
@@ -983,12 +986,12 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
- goto err1;
+ goto err3;
ret = dwc3_core_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize core\n");
- goto err2;
+ goto err4;
}
/* Check the maximum_speed parameter */
@@ -1020,23 +1023,29 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_core_init_mode(dwc);
if (ret)
- goto err3;
+ goto err5;
dwc3_debugfs_init(dwc);
pm_runtime_put(dev);
return 0;
-err3:
+err5:
dwc3_event_buffers_cleanup(dwc);
-err2:
+err4:
dwc3_free_scratch_buffers(dwc);
-err1:
+err3:
dwc3_free_event_buffers(dwc);
dwc3_ulpi_exit(dwc);
+err2:
+ pm_runtime_allow(&pdev->dev);
+err1:
+ 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
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web