Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936065Ab3DPQ56 (ORCPT ); Tue, 16 Apr 2013 12:57:58 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:36049 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935693Ab3DPQ55 convert rfc822-to-8bit (ORCPT ); Tue, 16 Apr 2013 12:57:57 -0400 From: "B, Ravi" To: "Bilovol, Ruslan" , "Balbi, Felipe" , "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] usb: musb: gadget: fix enumeration on heavy-loaded systems Thread-Topic: [PATCH] usb: musb: gadget: fix enumeration on heavy-loaded systems Thread-Index: AQHOOrj9vvmkWKgZJUSEVp2nIwd7q5jZD1Sw Date: Tue, 16 Apr 2013 16:57:52 +0000 Message-ID: <6C6B28D4DC342643927BEAFCE8707BF63EAAC0E5@DBDE01.ent.ti.com> References: <1366126904-31605-1-git-send-email-ruslan.bilovol@ti.com> In-Reply-To: <1366126904-31605-1-git-send-email-ruslan.bilovol@ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.24.170.142] Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3486 Lines: 97 > -----Original Message----- > From: linux-usb-owner@vger.kernel.org [mailto:linux-usb- > owner@vger.kernel.org] On Behalf Of Bilovol, Ruslan > Sent: Tuesday, April 16, 2013 9:12 PM > To: Balbi, Felipe; gregkh@linuxfoundation.org; linux-usb@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: [PATCH] usb: musb: gadget: fix enumeration on heavy-loaded > systems > > From musb point of view, the Address Assignment sequence during > device enumeration is next: > - first ep0 interrupt: > * read the address from USB_REQ_SET_ADDRESS request > * set up CSR0L.DataEnd bit (that is ACK > signalization for the host) > - second ep0 interrupt: > * indicates that the request completed successfully > * set up musb device address > Now musb device should answer to this address > > From the host perspective, if peripheral device acquires > SET_ADDRESS request, it now may be accessed only using that address. > However, on heavy loaded systems, time between first and > second musb ep0 interrupts may be too long and musb controller > misses requests between. What is meant by heavily loaded system? Is the device is heavily loaded during enumeration stage? Why second ep0 interrupt is too long? whether interrupt occurrence to interrupt service is taking too long? As result, device enumeration may be > unsuccessful. This can be checked on USB3.0 Host and > using USB3.0 test suite (from usb.org) running ch9 tests > for USB2.0 devices. You mean the usb2.0 musb controller (in device mode) connected to USB3.0 host? > Usually 'Addressed state/TD9.1: Device Descriptor Test' will fail > > The fix consists in checking CSR0L.DataEnd state and assigning > the device address in the first ep0 interrupt handling, so > delay is as minimal as possible > > Signed-off-by: Ruslan Bilovol > --- > drivers/usb/musb/musb_gadget_ep0.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/drivers/usb/musb/musb_gadget_ep0.c > b/drivers/usb/musb/musb_gadget_ep0.c > index c9c1ac4..59bc5a5 100644 > --- a/drivers/usb/musb/musb_gadget_ep0.c > +++ b/drivers/usb/musb/musb_gadget_ep0.c > @@ -885,6 +885,37 @@ stall: > finish: > musb_writew(regs, MUSB_CSR0, > musb->ackpend); > + > + /* > + * If we are at end of SET_ADDRESS sequence, > + * update the address immediately if possible, > + * otherwise we may miss packets between > + * sending ACK from musb side and musb's next > + * interrupt handler firing (in which we update > + * the address). At least this fixes next > + * USB2.0 ch9 test of USB30CV utility: > + * "Addressed state - Device Descriptor test" > + */ > + if (musb->set_address && (musb->ackpend & > + MUSB_CSR0_P_DATAEND) && > + (musb->ep0_state == > + MUSB_EP0_STAGE_STATUSIN)) { > + u16 ack_delay = 500; > + > + while ((musb_readw(regs, MUSB_CSR0) & > + MUSB_CSR0_P_DATAEND) && > + --ack_delay) { > + cpu_relax(); > + udelay(1); > + } > + > + if (ack_delay) { > + musb->set_address = false; > + musb_writeb(mbase, MUSB_FADDR, > + musb->address); > + } > + } > + > musb->ackpend = 0; > } > } -- Ravi B -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/