On Tue, Aug 08, 2023 at 06:29:58PM +0800, Xu Yang wrote: > Some NXP processor using chipidea IP has a bug when frame babble is > detected. > > As per 4.15.1.1.1 Serial Bus Babble: > A babble condition also exists if IN transaction is in progress at > High-speed SOF2 point. This is called frame balle. The host controller s/balle/babble/ > must disable the port to which the frame babble is detected. > > The USB controller has disabled the port (PE cleared) and has asserted > USBERRINT when frame babble is detected, but PEC is not asserted. > Therefore, the SW didn't aware that port has been disabled. Then the s/didn't/isn't/ > SW keeps sending packets to this port, but all of the transfers will > fail. > > This workaround will firstly assert PCD by SW when USBERRINT is detected > and then judge whether port change has really occurred or not by polling > roothub status. Because the PEC doesn't get asserted in our case, this > patch will also assert it by SW when specific conditions are satisfied. > > Signed-off-by: Xu Yang <xu.yang_2@xxxxxxx> > --- > drivers/usb/host/ehci-hcd.c | 5 +++++ > drivers/usb/host/ehci-hub.c | 10 +++++++++- > drivers/usb/host/ehci.h | 10 ++++++++++ > 3 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c > index a1930db0da1c..d6b276c354db 100644 > --- a/drivers/usb/host/ehci-hcd.c > +++ b/drivers/usb/host/ehci-hcd.c > @@ -762,6 +762,11 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) > bh = 1; > } > > + /* Force to check port status */ > + if (ehci->has_ci_pec_bug && (status & STS_ERR) > + && !(status & STS_PCD)) > + status |= STS_PCD; Suggestion for minor improvement: First, you don't really need the (status & STS_PCD) test, because if the bit is already set then turning it again on won't matter. Second, after that test has been removed you can merge this code with the INCR(ehci->stats.error) line above, removing the (status & STS_ERR) test. The rest of the patch looks okay. Alan Stern