Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: tom.leiming@gmail.com
To: greg@kroah.com, dbrownell@users.sourceforge.net, felipe.balbi@nokia.com
Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
	Ming Lei <tom.leiming@gmail.com>, Anand Gadiyar <gadiyar@ti.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Subject: [PATCH 2/2] USB: musb-gadget: fix OUT transfer in double buffer case
Date: Fri, 27 Aug 2010 19:37:48 +0800	[thread overview]
Message-ID: <1282909068-2968-1-git-send-email-tom.leiming@gmail.com> (raw)

From: Ming Lei <tom.leiming@gmail.com>

This patch fixes two bugs of OUT transfer in double buffer case:

	-USE_MODE1 should be enabled except for ANOMALY_05000456 case, or
	else may cause infinite hang and data error bug in double buffer

	-DMA length should not go beyond the availabe space of request buffer

Without this patch, test #5 of usbtest can't be passed if we configure musb as
g_zero and use fifo mode 3 to enable double buffer mode.

With this patch, on my beagle B5, test#5(queued bulk out) may go beyond 14Mbyte/s
if musb is configured as g_zero and fifo mode 3 is taken, follows the test command:

	#./testusb -D DEV_NAME -c 1024 -t 5 -s 32768 -g 8   [1]

[1],
    -source of testusb : tools/usb/testusb.c under linux kernel;

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Cc: Anand Gadiyar <gadiyar@ti.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
 drivers/usb/musb/musb_dma.h    |    2 ++
 drivers/usb/musb/musb_gadget.c |    5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 916065b..dff91ce 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -89,6 +89,8 @@ struct musb_hw_ep;
 # if !ANOMALY_05000456
 #  define USE_MODE1
 # endif
+#else
+#  define USE_MODE1
 #endif
 
 /*
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index e0bd1c1..f1c44b9 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -662,10 +662,11 @@ static void rxstate(struct musb *musb, struct musb_request *req)
 				if (request->actual < request->length) {
 					int transfer_size = 0;
 #ifdef USE_MODE1
-					transfer_size = min(request->length,
+					transfer_size = min(request->length - request->actual,
 							channel->max_len);
 #else
-					transfer_size = len;
+					transfer_size = min(request->length - request->actual,
+							len);
 #endif
 					if (transfer_size <= musb_ep->packet_sz)
 						musb_ep->dma->desired_mode = 0;
-- 
1.6.2.5


             reply	other threads:[~2010-08-27 11:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-27 11:37 tom.leiming [this message]
2010-08-27 13:47 ` [PATCH 2/2] USB: musb-gadget: fix OUT transfer in double buffer case Gadiyar, Anand
     [not found]   ` <5A47E75E594F054BAF48C5E4FC4B92AB0328C1CB4B-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-08-27 14:23     ` Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282909068-2968-1-git-send-email-tom.leiming@gmail.com \
    --to=tom.leiming@gmail.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=felipe.balbi@nokia.com \
    --cc=gadiyar@ti.com \
    --cc=greg@kroah.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sshtylyov@ru.mvista.com \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox