Re: [PATCH v19 5/6] usb: dwc3: core: only access GUSB3PIPECTL under lock
From: Thinh Nguyen
Date: Fri Dec 04 2026 - 17:47:01 EST
On Fri, Dec 04, 2026, Thinh Nguyen wrote:
> On Fri, Dec 04, 2026, Sebastian Reichel wrote:
> > Hello Greg,
> >
> > On Thu, Dec 03, 2026 at 05:48:53PM +0100, Greg Kroah-Hartman wrote:
> > > 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()?
> >
> > That sure works and looks quite sensible to me. As this is the only
> > feedback for the v19, would it be okay to send that as follow-up?
>
> I don't think __must_hold() is needed here. dwc3 doesn't use it
> anywhere, and dwc3_set_prtcap() only needs the lock when ignore_susphy
> is false, so lockdep_assert_held() fits better.
On second thought, a lock that dwc3_set_prtcap() needs only for some
ignore_susphy values is a bad interface, and the GCTL read-modify-write
needs the lock anyway.
As a follow-up, please make it unconditional. Add
__must_hold(&dwc->lock) to dwc3_set_prtcap() and __dwc3_enable_susphy(),
and take the lock in the callers that pass ignore_susphy == true.
Document that dwc3_set_prtcap() must be called with the lock held.
>
> Acked-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
>
The ack on this patch stands.
Thanks,
Thinh