Re: [PATCH] usb: dwc3: gadget: Inform system of suspended state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 17, 2024, Thinh Nguyen wrote:
> On Thu, Jun 13, 2024, Mike Looijmans wrote:
> > > 
> > > Wait, I thought the host initiated the usb suspend. Did you trigger usb
> > > suspend by putting the host in suspend? Or does the suspend event only
> > > come when you perform a disconnect?
> > 
> > All I do is unplug the cable. The host (PC running Ubuntu 22) doesn't eject
> > or suspend or anything like that.
> > 
> 
> This is a very typical connect/disconnect flow. I'm surprised that it's
> not caught on your platform before. What's the compatible string for
> your platform?
> 
> > 
> > > 
> > > Can you confirm if the suspend event was there before you disconnect the
> > > device?
> > 
> > Disconnecting the cable is what leads to the "suspend" event.
> > 
> 
> Can you try this:
> 
> It's a simple workaround, but may not catch the issue while operating in
> Fullspeed.
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 89fc690fdf34..894ca1044281 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -4339,6 +4339,18 @@ static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,
>  {
>  	enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK;
>  
> +	if (next == DWC3_LINK_STATE_U3) {
> +		u8 speed;
> +		u32 reg;
> +
> +		reg = dwc3_readl(dwc->regs, DWC3_DSTS);
> +		speed = reg & DWC3_DSTS_CONNECTSPD;
> +		if (dwc->speed != speed) {

Minor tweak to this condition to this instead:
		if (dwc->gadget->speed != USB_SPEED_UNKNOWN &&
		    dwc->speed != speed) {

> +			dwc3_gadget_disconnect_interrupt(dwc);
> +			return;
> +		}
> +	}
> +
>  	if (!dwc->suspended && next == DWC3_LINK_STATE_U3) {
>  		dwc->suspended = true;
>  		dwc3_suspend_gadget(dwc);
> 
> 
> Otherwise, there's no other SW workaround that I can think of.
> 

Thanks,
Thinh




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux