Re: [PATCH v19 5/6] usb: dwc3: core: only access GUSB3PIPECTL under lock

From: Greg Kroah-Hartman

Date: Thu Dec 03 2026 - 22:22:16 EST


On Sat, Nov 14, 2026 at 02:02:04AM +0100, Sebastian Reichel wrote:
> Update dwc3_enable_susphy() to take dwc->lock while updating
> GUSB3PIPECTL to protect the read-modify-write cycle from other users
> accessing the same register, which is soon introduced.
>
> Note: technically there is already dwc3_ss_phy_setup() as a second user,
> but it runs and finishes before any call to dwc3_enable_susphy() should
> happen.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
> ---
> drivers/usb/dwc3/core.c | 19 +++++++++++++++----
> drivers/usb/dwc3/glue.h | 2 +-
> 2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index daf5aec07fbf..0cb1b33a7c98 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -108,11 +108,13 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
> return 0;
> }
>
> -void dwc3_enable_susphy(struct dwc3 *dwc, bool enable)
> +static void __dwc3_enable_susphy(struct dwc3 *dwc, bool enable)
> {
> u32 reg;
> int i;
>
> + lockdep_assert_held(&dwc->lock);

Can't you also use __must_hold()?