All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fabrice Gasnier" <fabrice.gasnier@foss.st.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v6 09/11] usb: dwc2: restore peripheral mode on low-level enable
Date: Wed, 25 Nov 2026 17:08:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-233807@kernel.org> (raw)
In-Reply-To: <20261125-dwc2-low-power-fixes-stm32-v6-9-d5df33b93eaf@foss.st.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: dwc2: missing GOTGCTL override restore in
  dwc2_drd_resume() for ROLE_NONE
--

commit d994a6181c5bc6aa556fe623825b039f6d0ac91e
Author: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

usb: dwc2: restore peripheral mode on low-level enable

This commit restores the forced mode or role switch session overrides in
__dwc2_lowlevel_hw_enable() when dr_mode is USB_DR_MODE_PERIPHERAL, and
skips doing so in dwc2_resume() for peripheral mode.

> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 24ede0b6ab815..38954dee6ad0d 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -129,6 +129,18 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
>  	if (ret)
>  		goto err_dis_clk;
>  
> +	if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) {
> +		/*
> +		 * Gadget code manages low-level hardware on its own. Restore
> +		 * the mode and role switch session after register loss while
> +		 * it was disabled.
> +		 */
> +		if (hsotg->role_sw)
> +			dwc2_drd_resume(hsotg);
> +		else
> +			dwc2_force_dr_mode(hsotg);
> +	}
> +
>  	return 0;
>  
>  err_dis_clk:

[Severity: Medium]
Does dwc2_drd_resume() leave the GOTGCTL override enable bits cleared when
the role is USB_ROLE_NONE?

At probe, dwc2_ovr_init() enables GOTGCTL_BVALOEN, GOTGCTL_AVALOEN,
GOTGCTL_VBVALOEN and GOTGCTL_DBNCE_FLTR_BYPASS with the session valid
values cleared even when there is no default role.  If registers are lost
during suspend while ll_hw_enabled is false (so gr_backup is neither saved
nor restored) and a gadget driver binds while the role switch state is
USB_ROLE_NONE and role_sw_default_mode is USB_DR_MODE_UNKNOWN,
dwc2_drd_resume() skips writing GOTGCTL:

drivers/usb/dwc2/drd.c:dwc2_drd_resume() {
	...
		/* restore last role that may have been lost */
		if (role == USB_ROLE_HOST)
			dwc2_ovr_avalid(hsotg, true);
		else if (role == USB_ROLE_DEVICE)
			dwc2_ovr_bvalid(hsotg, true);

		dwc2_force_mode(hsotg, role == USB_ROLE_HOST);
	...
}

Without those override enable bits, dwc2_force_mode() runs without
GOTGCTL_DBNCE_FLTR_BYPASS and dwc2_hsotg_core_connect() reads the raw PHY
GOTGCTL_BSESVLD signal instead of the role switch override.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-dwc2-low-power-fixes-stm32-v6-0-d5df33b93eaf@foss.st.com?part=9

  reply	other threads:[~2026-11-25 17:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 16:32 [PATCH v6 00/11] usb: dwc2: fix low power issues found on stm32mp1 Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 01/11] usb: dwc2: fix recovery after PM domain off Fabrice Gasnier
2026-11-25 16:58   ` sashiko-bot
2026-11-25 16:32 ` [PATCH v6 02/11] usb: dwc2: keep TOUTCAL canary valid after PHY init Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 03/11] usb: dwc2: drop stale state after register restore on resume Fabrice Gasnier
2026-11-25 17:09   ` sashiko-bot
2026-11-25 16:32 ` [PATCH v6 04/11] usb: dwc2: clean up old role on mode change during suspend Fabrice Gasnier
2026-11-25 16:57   ` sashiko-bot
2026-11-25 16:32 ` [PATCH v6 05/11] usb: dwc2: fix a possible interrupt storm in hcd resume Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 06/11] usb: dwc2: fix a possible interrupt storm on stm32mp1 Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 07/11] usb: dwc2: hcd: fix possible successive vbus supply enables Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 08/11] usb: dwc2: hcd: don't disable external vbus in system suspend Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 09/11] usb: dwc2: restore peripheral mode on low-level enable Fabrice Gasnier
2026-11-25 17:08   ` sashiko-bot [this message]
2026-11-25 16:32 ` [PATCH v6 10/11] usb: dwc2: platform: fix stm32mp15 detection logic power management Fabrice Gasnier
2026-11-25 16:32 ` [PATCH v6 11/11] usb: dwc2: drop redundant ll_hw_enabled checks in suspend/resume Fabrice Gasnier
2026-11-25 17:09 ` [PATCH v6 00/11] usb: dwc2: fix low power issues found on stm32mp1 sashiko-bot

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=sashiko-outbox-233807@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.