2021-04-07 18:50:58

by Dinghao Liu

[permalink] [raw]
Subject: [PATCH] usb: cdns3: Fix rumtime PM imbalance on error

When cdns3_gadget_start() fails, a pairing PM usage counter
decrement is needed to keep the counter balanced.

Signed-off-by: Dinghao Liu <[email protected]>
---
drivers/usb/cdns3/cdns3-gadget.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 582bfeceedb4..ad891a108aed 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -3255,8 +3255,11 @@ static int __cdns3_gadget_init(struct cdns *cdns)
pm_runtime_get_sync(cdns->dev);

ret = cdns3_gadget_start(cdns);
- if (ret)
+ if (ret) {
+ pm_runtime_mark_last_busy(cdns->dev);
+ pm_runtime_put_autosuspend(cdns->dev);
return ret;
+ }

/*
* Because interrupt line can be shared with other components in
--
2.17.1


2021-04-10 01:08:32

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH] usb: cdns3: Fix rumtime PM imbalance on error

On 21-04-07 13:22:26, Dinghao Liu wrote:
> When cdns3_gadget_start() fails, a pairing PM usage counter
> decrement is needed to keep the counter balanced.
>
> Signed-off-by: Dinghao Liu <[email protected]>
> ---
> drivers/usb/cdns3/cdns3-gadget.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index 582bfeceedb4..ad891a108aed 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -3255,8 +3255,11 @@ static int __cdns3_gadget_init(struct cdns *cdns)
> pm_runtime_get_sync(cdns->dev);
>
> ret = cdns3_gadget_start(cdns);
> - if (ret)
> + if (ret) {
> + pm_runtime_mark_last_busy(cdns->dev);
> + pm_runtime_put_autosuspend(cdns->dev);
> return ret;

It doesn't need to delay entering runtime suspend, I prefer using pm_runtime_put_sync directly.

--

Thanks,
Peter Chen

2021-04-12 05:39:10

by Dinghao Liu

[permalink] [raw]
Subject: Re: Re: [PATCH] usb: cdns3: Fix rumtime PM imbalance on error

> On 21-04-07 13:22:26, Dinghao Liu wrote:
> > When cdns3_gadget_start() fails, a pairing PM usage counter
> > decrement is needed to keep the counter balanced.
> >
> > Signed-off-by: Dinghao Liu <[email protected]>
> > ---
> > drivers/usb/cdns3/cdns3-gadget.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> > index 582bfeceedb4..ad891a108aed 100644
> > --- a/drivers/usb/cdns3/cdns3-gadget.c
> > +++ b/drivers/usb/cdns3/cdns3-gadget.c
> > @@ -3255,8 +3255,11 @@ static int __cdns3_gadget_init(struct cdns *cdns)
> > pm_runtime_get_sync(cdns->dev);
> >
> > ret = cdns3_gadget_start(cdns);
> > - if (ret)
> > + if (ret) {
> > + pm_runtime_mark_last_busy(cdns->dev);
> > + pm_runtime_put_autosuspend(cdns->dev);
> > return ret;
>
> It doesn't need to delay entering runtime suspend, I prefer using pm_runtime_put_sync directly.
>

Sounds reasonable, thanks! I will send a new patch soon.

Regards,
Dinghao