Re: [PATCH v3 2/5] usb: dwc3: Add remote wakeup handling

From: Thinh Nguyen
Date: Tue Feb 07 2023 - 20:10:51 EST


On Tue, Feb 07, 2023, Elson Serrao wrote:
> On 2/6/2023 4:48 PM, Thinh Nguyen wrote:
> > > +static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async)
> > > {
> > > int retries;
> > > @@ -2296,9 +2309,14 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
> > > link_state = DWC3_DSTS_USBLNKST(reg);
> > > switch (link_state) {
> > > + case DWC3_LINK_STATE_U3: /* in HS, means SUSPEND */
> >
> > It's also possible to do remote wakeup in L1 for highspeed.
> >
>
> The rw_configured flag here is in context of triggering remote wakeup from
> bus suspend only.
>
> The remote wakeup setting for l1 in HighSpeed is controlled through LPM
> token and overrides/ignores the config desc bmAttributes wakeup bit.
>
> Section 4.1 of USB2_LinkPowerMangement_ECN[final] spec "The host system sets the Remote Wake Flag parameter in this request to
> enable or disable the addressed device
> for remote wake from L1. The value of this flag will temporarily (while in
> L1) override the current setting of the
> Remote Wake feature settable by the standard Set/ClearFeature() commands
> defined in Universal Serial Bus Specification, revision 2.0, Chapter 9."
>
> Please let me know if I am missing something.
>

It overrides the setting of the SetFeature request, not the device
configuration.

The rw_configured reflects the user configuration. Whether the host
tries to enable the remote wakeup through SetFeature request or LPM
token, the device should operate within the user configuration
limitation.

If the configuration indicates that it doesn't support remote wakeup, we
should prevent unexpected behavior from the device. For simplicity, we
can just return failure to wakeup for all states.

Thanks,
Thinh