* [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume
@ 2024-09-06 0:58 Roy Luo
2024-09-07 0:58 ` Thinh Nguyen
0 siblings, 1 reply; 5+ messages in thread
From: Roy Luo @ 2024-09-06 0:58 UTC (permalink / raw)
To: royluo, Thinh.Nguyen, gregkh, badhri, frank.wang, linux-usb,
linux-kernel
Cc: stable
When dwc3_resume_common() returns an error, runtime pm is left in
disabled state in dwc3_resume(). The next dwc3_suspend_common()
should be skipped as the device is already in suspended state but
it's not because power.disable_depth is non-zero.
Ensures runtime PM is always re-enabled even after failed resume
attempts.
Fixes: 68c26fe58182 ("usb: dwc3: set pm runtime active before resume common")
Cc: stable@vger.kernel.org
Signed-off-by: Roy Luo <royluo@google.com>
---
drivers/usb/dwc3/core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index ccc3895dbd7f..1928b074b2df 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -2537,7 +2537,7 @@ static int dwc3_suspend(struct device *dev)
static int dwc3_resume(struct device *dev)
{
struct dwc3 *dwc = dev_get_drvdata(dev);
- int ret;
+ int ret = 0;
pinctrl_pm_select_default_state(dev);
@@ -2547,12 +2547,11 @@ static int dwc3_resume(struct device *dev)
ret = dwc3_resume_common(dwc, PMSG_RESUME);
if (ret) {
pm_runtime_set_suspended(dev);
- return ret;
}
pm_runtime_enable(dev);
- return 0;
+ return ret;
}
static void dwc3_complete(struct device *dev)
base-commit: ad618736883b8970f66af799e34007475fe33a68
--
2.46.0.469.g59c65b2a67-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume
2024-09-06 0:58 [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume Roy Luo
@ 2024-09-07 0:58 ` Thinh Nguyen
2024-09-13 18:02 ` Roy Luo
0 siblings, 1 reply; 5+ messages in thread
From: Thinh Nguyen @ 2024-09-07 0:58 UTC (permalink / raw)
To: Roy Luo
Cc: Thinh Nguyen, gregkh@linuxfoundation.org, badhri@google.com,
frank.wang@rock-chips.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
On Fri, Sep 06, 2024, Roy Luo wrote:
> When dwc3_resume_common() returns an error, runtime pm is left in
> disabled state in dwc3_resume(). The next dwc3_suspend_common()
What issue did you see when dwc3_suspend_common is not skipped?
BR,
Thinh
> should be skipped as the device is already in suspended state but
> it's not because power.disable_depth is non-zero.
> Ensures runtime PM is always re-enabled even after failed resume
> attempts.
>
> Fixes: 68c26fe58182 ("usb: dwc3: set pm runtime active before resume common")
> Cc: stable@vger.kernel.org
> Signed-off-by: Roy Luo <royluo@google.com>
> ---
> drivers/usb/dwc3/core.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index ccc3895dbd7f..1928b074b2df 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -2537,7 +2537,7 @@ static int dwc3_suspend(struct device *dev)
> static int dwc3_resume(struct device *dev)
> {
> struct dwc3 *dwc = dev_get_drvdata(dev);
> - int ret;
> + int ret = 0;
>
> pinctrl_pm_select_default_state(dev);
>
> @@ -2547,12 +2547,11 @@ static int dwc3_resume(struct device *dev)
> ret = dwc3_resume_common(dwc, PMSG_RESUME);
> if (ret) {
> pm_runtime_set_suspended(dev);
> - return ret;
> }
>
> pm_runtime_enable(dev);
>
> - return 0;
> + return ret;
> }
>
> static void dwc3_complete(struct device *dev)
>
> base-commit: ad618736883b8970f66af799e34007475fe33a68
> --
> 2.46.0.469.g59c65b2a67-goog
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume
2024-09-07 0:58 ` Thinh Nguyen
@ 2024-09-13 18:02 ` Roy Luo
2024-09-13 18:12 ` Thinh Nguyen
0 siblings, 1 reply; 5+ messages in thread
From: Roy Luo @ 2024-09-13 18:02 UTC (permalink / raw)
To: Thinh Nguyen
Cc: gregkh@linuxfoundation.org, badhri@google.com,
frank.wang@rock-chips.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
On Fri, Sep 6, 2024 at 5:58 PM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
>
> On Fri, Sep 06, 2024, Roy Luo wrote:
> > When dwc3_resume_common() returns an error, runtime pm is left in
> > disabled state in dwc3_resume(). The next dwc3_suspend_common()
>
> What issue did you see when dwc3_suspend_common is not skipped?
Apologies for the delayed response.
To answer your question, if dwc3_suspend_common() isn't skipped, it
can lead to issues because dwc->dev is already in a suspended state.
This could mean its parent devices (like the power domain or glue
driver) are also suspended and may have released resources that dwc
requires.
Consequently, calling dwc3_suspend_common() in this situation could
result in attempts to access unclocked or unpowered registers.
Regards,
Roy Luo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume
2024-09-13 18:02 ` Roy Luo
@ 2024-09-13 18:12 ` Thinh Nguyen
2024-09-13 23:24 ` Roy Luo
0 siblings, 1 reply; 5+ messages in thread
From: Thinh Nguyen @ 2024-09-13 18:12 UTC (permalink / raw)
To: Roy Luo
Cc: Thinh Nguyen, gregkh@linuxfoundation.org, badhri@google.com,
frank.wang@rock-chips.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
On Fri, Sep 13, 2024, Roy Luo wrote:
> On Fri, Sep 6, 2024 at 5:58 PM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
> >
> > On Fri, Sep 06, 2024, Roy Luo wrote:
> > > When dwc3_resume_common() returns an error, runtime pm is left in
> > > disabled state in dwc3_resume(). The next dwc3_suspend_common()
> >
> > What issue did you see when dwc3_suspend_common is not skipped?
>
> Apologies for the delayed response.
>
> To answer your question, if dwc3_suspend_common() isn't skipped, it
> can lead to issues because dwc->dev is already in a suspended state.
> This could mean its parent devices (like the power domain or glue
> driver) are also suspended and may have released resources that dwc
> requires.
> Consequently, calling dwc3_suspend_common() in this situation could
> result in attempts to access unclocked or unpowered registers.
>
Can you include this info in the commit message?
And while at it, can you also update minor style change to remove the
brackets for single line if statement to this:
ret = dwc3_resume_common(dwc, PMSG_RESUME);
if (ret)
pm_runtime_set_suspended(dev);
Thanks,
Thinh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume
2024-09-13 18:12 ` Thinh Nguyen
@ 2024-09-13 23:24 ` Roy Luo
0 siblings, 0 replies; 5+ messages in thread
From: Roy Luo @ 2024-09-13 23:24 UTC (permalink / raw)
To: Thinh Nguyen
Cc: gregkh@linuxfoundation.org, badhri@google.com,
frank.wang@rock-chips.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
On Fri, Sep 13, 2024 at 11:12 AM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
>
> Can you include this info in the commit message?
>
> And while at it, can you also update minor style change to remove the
> brackets for single line if statement to this:
>
> ret = dwc3_resume_common(dwc, PMSG_RESUME);
> if (ret)
> pm_runtime_set_suspended(dev);
>
Sure, sent out v2 for review.
Regards,
Roy Luo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-13 23:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 0:58 [PATCH v1] usb: dwc3: re-enable runtime PM after failed resume Roy Luo
2024-09-07 0:58 ` Thinh Nguyen
2024-09-13 18:02 ` Roy Luo
2024-09-13 18:12 ` Thinh Nguyen
2024-09-13 23:24 ` Roy Luo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox