[RFC] [PATCH] usb: gadget: fix dtd dma confusion

Neil Zhang zhangwm at marvell.com
Wed May 9 11:50:17 EST 2012


Hi Christoph,

> -----Original Message-----
> From: Christoph Fritz [mailto:chf.fritz at googlemail.com]
> Sent: 2012年5月9日 8:02
> To: Fabio Estevam; Neil Zhang; Li Yang; Felipe Balbi; Greg Kroah-
> Hartman; linux-usb at vger.kernel.org; linuxppc-dev at lists.ozlabs.org; Hans
> J. Koch; Daniel Mack
> Cc: Thomas Dahlmann; Nicolas Ferre; Eric Miao; Russell King; Haojian
> Zhuang; Ben Dooks; Kukjin Kim; Sascha Hauer; Oliver Neukum; Chen Peter-
> B29397; Ido Shayevitz; Estevam Fabio-R49496
> Subject: [RFC] [PATCH] usb: gadget: fix dtd dma confusion
> 
> On Wed, Apr 11, 2012 at 10:15:49AM -0300, Fabio Estevam wrote:
> > On Wed, Apr 11, 2012 at 4:39 AM, Christoph Fritz
> > <chf.fritz at googlemail.com> wrote:
> >
> > > Can you approve this behaviour of g_ether/usbnet when using iperf?
> >
> > I am not very familiar with iperf, so I will let others comment.
> 
> Hi to All,
> 
> after a while of testing and searching I can come up with a patch
> that fixes g_ether <-> iperf for fsl_udc on ARM i.MX35.
> 
> The sad part is that this kind of fix is already implemented for
> marvell mv_udc driver since last year but still _not_ in the ~15
> other *udc.c drivers.
> 
> See here:
> daec765da767e4a6a30e1298862b28f2cae9a73f
> usb: gadget: mv_udc: fix dtd dma confusion
> 
> So hereby I'm CC-ing all *udc.c maintainers to point out that this
> issue maybe affects you too.
> 
> And maybe someone can explain if this:
> +				if (curr_td->next_td_ptr ==
> EP_QUEUE_HEAD_NEXT_TERMINATE) {
> is necessary and why (please see below).
> 
 
The outer loop is to check whether the controller still point to the current dtd.
If so, we should wait it to move onto the next dtd.
But there is an exception, if the current dtd is the last dtd on this ep queue, 
then the controller can never move on.
Fortunately, we can check register epstatus (offset: 0x1b8) to see whether the buffer is free again.

> Thanks,
>  -- Christoph
> 
> ---
> Subject: [PATCH] usb: gadget: fsl_udc: fix dtd dma confusion
> 
> The controller will hang when doing testings with g_ether and iperf
> (tool for measuring maximum TCP and UDP bandwidth).  This patch adds a
> delay to wait for controller to release dtd dma before freeing it.
> 
> Signed-off-by: Christoph Fritz <chf.fritz at googlemail.com>
> ---
>  drivers/usb/gadget/fsl_udc_core.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/fsl_udc_core.c
> b/drivers/usb/gadget/fsl_udc_core.c
> index 55abfb6..fc86108 100644
> --- a/drivers/usb/gadget/fsl_udc_core.c
> +++ b/drivers/usb/gadget/fsl_udc_core.c
> @@ -1638,6 +1638,15 @@ static int process_ep_req(struct fsl_udc *udc,
> int pipe,
>  			status = REQ_UNCOMPLETE;
>  			return status;
>  		} else if (remaining_length) {
> +			/* wait controller release dtd dma */
> +			while ((curr_qh->curr_dtd_ptr == curr_td->td_dma)) {
> +				if (curr_td->next_td_ptr ==
> +						EP_QUEUE_HEAD_NEXT_TERMINATE) {
> +					udelay(100);
> +					break;
> +				}
> +				udelay(1);
> +			}
>  			if (direction) {
>  				VDBG("Transmit dTD remaining length not zero");
>  				status = -EPROTO;
> --
> 1.7.2.5
> 

Best Regards,
Neil Zhang


More information about the Linuxppc-dev mailing list