All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org,
	Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Subject: [PATCH 5/6] musb: gadget: fix tx transfer path for mode0 operation
Date: Mon, 17 May 2010 16:38:07 +0530	[thread overview]
Message-ID: <1274094488-15925-5-git-send-email-ajay.gupta@ti.com> (raw)
In-Reply-To: <1274094488-15925-4-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>

Current gadget Tx path always programs DMA in mode-1 if request length
is more than packet size. As system DMA can work only in mode-0 so
updating the DMA mode and transfer length for it.

Also fixed an issue in device Tx completion path where 'is_dma' is
getting set unconditionally. This would fail the io if Tx transfer
is done in mode-0. Fixed it by updating it based on
'request->actual' length.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
---
 drivers/usb/musb/musb_gadget.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 6fca870..9ac45e4 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -317,6 +317,22 @@ static void txstate(struct musb *musb, struct musb_request *req)
 			else
 				musb_ep->dma->desired_mode = 1;
 
+			/*
+			 * Use system dma for unaligned buffers on RTL >= 1.8
+			 * for Inventra DMA. As system DMA can work only in
+			 * mode-0 so update the desired_mode and request_size.
+			 */
+			if (is_inventra_dma_enabled() &&
+				((request->dma + request->actual) & 0x3) &&
+				(musb->hwvers >= MUSB_HWVERS_1800)) {
+
+				request_size = min_t(size_t,
+					musb_ep->hw_ep->max_packet_sz_tx,
+					request->length - request->actual);
+
+				musb_ep->dma->desired_mode = 0;
+			}
+
 			use_dma = use_dma && c->channel_program(
 					musb_ep->dma, musb_ep->packet_sz,
 					musb_ep->dma->desired_mode,
@@ -463,7 +479,6 @@ void musb_g_tx(struct musb *musb, u8 epnum)
 		u8	is_dma = 0;
 
 		if (dma && (csr & MUSB_TXCSR_DMAENAB)) {
-			is_dma = 1;
 			csr |= MUSB_TXCSR_P_WZC_BITS;
 			csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_P_UNDERRUN |
 				 MUSB_TXCSR_TXPKTRDY);
@@ -471,6 +486,10 @@ void musb_g_tx(struct musb *musb, u8 epnum)
 			/* Ensure writebuffer is empty. */
 			csr = musb_readw(epio, MUSB_TXCSR);
 			request->actual += musb_ep->dma->actual_len;
+
+			if (request->actual == request->length)
+				is_dma = 1;
+
 			DBG(4, "TXCSR%d %04x, DMA off, len %zu, req %p\n",
 				epnum, csr, musb_ep->dma->actual_len, request);
 		}
-- 
1.6.2.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-05-17 11:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17 11:08 [PATCH 1/6] musb: save OTG base physical address Ajay Kumar Gupta
2010-05-17 11:08 ` [PATCH 2/6 v2] musb: use system DMA to fix Inventra DMA issue on RTL-1.4 Ajay Kumar Gupta
     [not found]   ` <1274094488-15925-2-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
2010-05-17 11:08     ` [PATCH 3/6] musb: add function to check if Inventra DMA used Ajay Kumar Gupta
2010-05-17 11:08       ` [PATCH 4/6] musb: use system DMA for unaligned buffers on RTL >= 1.8 Ajay Kumar Gupta
     [not found]         ` <1274094488-15925-4-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
2010-05-17 11:08           ` Ajay Kumar Gupta [this message]
     [not found]             ` <1274094488-15925-5-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
2010-05-17 11:08               ` [PATCH 6/6] musb: dma: use optimal transfer element for sdma Ajay Kumar Gupta
     [not found]                 ` <1274094488-15925-6-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
2010-05-18  9:47                   ` Sergei Shtylyov
2010-05-18 10:11                     ` Gupta, Ajay Kumar

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=1274094488-15925-5-git-send-email-ajay.gupta@ti.com \
    --to=ajay.gupta-l0cymroini0@public.gmane.org \
    --cc=felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.