diff mbox series

usb: dwc3: gadget: fix delayed status missing for clear EP halt

Message ID 1606807357-12574-1-git-send-email-jun.li@nxp.com
State New
Headers show
Series usb: dwc3: gadget: fix delayed status missing for clear EP halt | expand

Commit Message

Jun Li Dec. 1, 2020, 7:22 a.m. UTC
With several improvements on handling of ClearFeature(halt), there
is one case of delayed status missing: if the xfernotready event
comes after end transfer and clear ep stall command completion,
we can not send the delayed status in dwc3_ep0_send_delayed_status()
as the ep0status is not ready, then in xfernotready event we still
can not send status because delayed_status is still set.

Cc: stable@vger.kernel.org
Fixes: d97c78a1908e ("usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command")
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/dwc3/ep0.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Jun Li Dec. 2, 2020, 2:29 a.m. UTC | #1
> -----Original Message-----

> From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

> Sent: Wednesday, December 2, 2020 1:00 AM

> To: Jun Li <jun.li@nxp.com>; balbi@kernel.org

> Cc: gregkh@linuxfoundation.org; Thinh Nguyen <Thinh.Nguyen@synopsys.com>;

> linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>

> Subject: Re: [PATCH] usb: dwc3: gadget: fix delayed status missing for clear

> EP halt

> 

> Hi,

> 

> Li Jun wrote:

> > With several improvements on handling of ClearFeature(halt), there is

> > one case of delayed status missing: if the xfernotready event comes

> > after end transfer and clear ep stall command completion, we can not

> > send the delayed status in dwc3_ep0_send_delayed_status() as the

> > ep0status is not ready, then in xfernotready event we still can not

> > send status because delayed_status is still set.

> >

> > Cc: stable@vger.kernel.org

> > Fixes: d97c78a1908e ("usb: dwc3: gadget: END_TRANSFER before

> > CLEAR_STALL command")

> > Signed-off-by: Li Jun <jun.li@nxp.com>

> > ---

> >  drivers/usb/dwc3/ep0.c | 8 +++++++-

> >  1 file changed, 7 insertions(+), 1 deletion(-)

> >

> > diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index

> > 7be3903..9580e9f 100644

> > --- a/drivers/usb/dwc3/ep0.c

> > +++ b/drivers/usb/dwc3/ep0.c

> > @@ -1058,10 +1058,16 @@ void dwc3_ep0_send_delayed_status(struct dwc3

> > *dwc)  {

> >  	unsigned int direction = !dwc->ep0_expect_in;

> >

> > +	/*

> > +	 * If we are ready to send delayed status

> > +	 * but wait status pharse, we can clear

> > +	 * delayed_status flag to let EP0 XferNotReady

> > +	 * handle it as a normal status sending.

> > +	 */

> > +	dwc->delayed_status = false;

> >  	if (dwc->ep0state != EP0_STATUS_PHASE)

> >  		return;

> >

> > -	dwc->delayed_status = false;

> >  	__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);  }

> >

> 

> This fix is already upstreamed:

> fa27e2f6c5e6 ("usb: dwc3: ep0: Fix delay status handling")

> 

> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.k

> ernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fc

> ommit%2F%3Fid%3Dfa27e2f6c5e674f3f1225f9ca7a7821faaf393bb&amp;data=04%7C

> 01%7Cjun.li%40nxp.com%7Cb4f70f5eedcc467e0ee708d8961a9f74%7C686ea1d3bc2b

> 4c6fa92cd99c5c301635%7C0%7C0%7C637424388404755873%7CUnknown%7CTWFpbGZsb

> 3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7

> C1000&amp;sdata=6lpOj%2FWUvLc%2FnEYaOoLjYq6JLEqdhmJSmcXpsT8%2Bu0Q%3D&am

> p;reserved=0


Ah, I missed that, so ignore my patch.

Thanks
Li Jun
> 

> Thanks,

> Thinh
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 7be3903..9580e9f 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -1058,10 +1058,16 @@  void dwc3_ep0_send_delayed_status(struct dwc3 *dwc)
 {
 	unsigned int direction = !dwc->ep0_expect_in;
 
+	/*
+	 * If we are ready to send delayed status
+	 * but wait status pharse, we can clear
+	 * delayed_status flag to let EP0 XferNotReady
+	 * handle it as a normal status sending.
+	 */
+	dwc->delayed_status = false;
 	if (dwc->ep0state != EP0_STATUS_PHASE)
 		return;
 
-	dwc->delayed_status = false;
 	__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
 }