From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Tomas Marek <tomas.marek@elrest.cz>, <hminas@synopsys.com>,
<gregkh@linuxfoundation.org>
Cc: <Arthur.Petrosyan@synopsys.com>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <oleg.karfich@wago.com>
Subject: Re: [PATCH] usb: dwc2: drd: fix clock gating on USB role switch
Date: Tue, 3 Sep 2024 16:20:26 +0300 [thread overview]
Message-ID: <a2ea1fa0-645d-2a16-f396-797e5b96fd45@omp.ru> (raw)
In-Reply-To: <20240903094156.6516-1-tomas.marek@elrest.cz>
On 9/3/24 12:41 PM, Tomas Marek wrote:
> The dwc2_handle_usb_suspend_intr() function disables gadget clocks in USB
> peripheral mode when no other power-down mode is available (introduced by
> commit 0112b7ce68ea ("usb: dwc2: Update dwc2_handle_usb_suspend_intr function.")).
> However, the dwc2_drd_role_sw_set() USB role update handler attempts to
> read DWC2 registers if the USB role has changed while the USB is in suspend
> mode (when the clocks are gated). This causes the system to hang.
>
> Release gadget clocks before handling the USB role update.
>
> Fixes: 0112b7ce68ea ("usb: dwc2: Update dwc2_handle_usb_suspend_intr function.")
>
> Signed-off-by: Tomas Marek <tomas.marek@elrest.cz>
> ---
> drivers/usb/dwc2/drd.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c
> index a8605b02115b..ccb33cd1f04b 100644
> --- a/drivers/usb/dwc2/drd.c
> +++ b/drivers/usb/dwc2/drd.c
> @@ -127,6 +127,18 @@ static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)
> role = USB_ROLE_DEVICE;
> }
>
> +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
> + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
> + if (dwc2_is_device_mode(hsotg)) {
Why not avoid #ifdef by doing e.g.:
if ((IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) &&
dwc2_is_device_mode(hsotg)) {
> + if (hsotg->lx_state == DWC2_L2) {
> + if (hsotg->params.power_down ==
> + DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended &&
> + !hsotg->params.no_clock_gating)
Well, these *if*s are mergeable too... :-)
> + dwc2_gadget_exit_clock_gating(hsotg, 0);
> + }
> + }
> +#endif
> +
[...]
MBR, Sergey
next prev parent reply other threads:[~2024-09-03 13:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 9:41 [PATCH] usb: dwc2: drd: fix clock gating on USB role switch Tomas Marek
2024-09-03 10:00 ` Greg KH
2024-09-03 13:20 ` Sergey Shtylyov [this message]
2024-09-04 5:30 ` Tomas Marek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2ea1fa0-645d-2a16-f396-797e5b96fd45@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=Arthur.Petrosyan@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=hminas@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oleg.karfich@wago.com \
--cc=tomas.marek@elrest.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox