All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: musb: allow unaligned memory data transfers
@ 2010-01-12 15:42 Vikram Pandita
       [not found] ` <1263310937-7249-1-git-send-email-vikram.pandita-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Vikram Pandita @ 2010-01-12 15:42 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-omap, Vikram Pandita, Anand Gadiyar, Maulik Mankad,
	Nilkesh Patra, Felipe Balbi

On MUSB:IP rev RTL1.8 and above(OMAP3630, OMAP4),
DMA addresses have to be word aligned.

g-ether gadget passes unaligned buffers to the controller
For such buffers, dma fails and a fall back mechanism of interrupt
mode is used

Validated on Zoom3 with g-ether diver

Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Cc: Maulik Mankad <x0082077@ti.com>
Cc: Nilkesh Patra <nilkesh.patra@ti.com>
Cc: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/usb/musb/musb_gadget.c |    9 ++++++++-
 drivers/usb/musb/musbhsdma.c   |   11 +++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index cbcf14a..7ad3571 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -681,8 +681,15 @@ static void rxstate(struct musb *musb, struct musb_request *req)
 							transfer_size);
 				}
 
-				if (use_dma)
+				if (use_dma) {
 					return;
+				} else {
+					/* Need to clear DMAENAB for the
+					 * backup PIO mode transfer to work
+					 */
+					csr &= ~MUSB_RXCSR_DMAENAB;
+					musb_writew(epio, MUSB_RXCSR, csr);
+				}
 			}
 #endif	/* Mentor's DMA */
 
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index a237550..f118ae2 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -166,6 +166,8 @@ static int dma_channel_program(struct dma_channel *channel,
 				dma_addr_t dma_addr, u32 len)
 {
 	struct musb_dma_channel *musb_channel = channel->private_data;
+	struct musb_dma_controller *controller = musb_channel->controller;
+	struct musb *musb = controller->private_data;
 
 	DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
 		musb_channel->epnum,
@@ -175,6 +177,15 @@ static int dma_channel_program(struct dma_channel *channel,
 	BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
 		channel->status == MUSB_DMA_STATUS_BUSY);
 
+	/* On MUSB:RTL1.8 and above, DMA has to be word aligned */
+	if ((dma_addr % 4) &&
+		(musb->hwvers >= MUSB_HWVERS_1800)) {
+		/* Fail DMA for unaligned buffers:
+		 * Use PIO for such buffers
+		 */
+		return false;
+	}
+
 	channel->actual_len = 0;
 	musb_channel->start_addr = dma_addr;
 	musb_channel->len = len;
-- 
1.6.6.rc0.66.ge160d


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: musb: allow unaligned memory data transfers
       [not found] ` <1263310937-7249-1-git-send-email-vikram.pandita-l0cyMroinI0@public.gmane.org>
@ 2010-01-14 11:23   ` Felipe Balbi
  2010-01-14 13:36     ` Gadiyar, Anand
  0 siblings, 1 reply; 5+ messages in thread
From: Felipe Balbi @ 2010-01-14 11:23 UTC (permalink / raw)
  To: ext Vikram Pandita
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Anand Gadiyar,
	Maulik Mankad, Nilkesh Patra, Balbi Felipe (Nokia-D/Helsinki)

Hi,

On Tue, Jan 12, 2010 at 04:42:17PM +0100, ext Vikram Pandita wrote:
>diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
>index a237550..f118ae2 100644
>--- a/drivers/usb/musb/musbhsdma.c
>+++ b/drivers/usb/musb/musbhsdma.c
>@@ -166,6 +166,8 @@ static int dma_channel_program(struct dma_channel *channel,
> 				dma_addr_t dma_addr, u32 len)
> {
> 	struct musb_dma_channel *musb_channel = channel->private_data;
>+	struct musb_dma_controller *controller = musb_channel->controller;
>+	struct musb *musb = controller->private_data;
>
> 	DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
> 		musb_channel->epnum,
>@@ -175,6 +177,15 @@ static int dma_channel_program(struct dma_channel *channel,
> 	BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
> 		channel->status == MUSB_DMA_STATUS_BUSY);
>
>+	/* On MUSB:RTL1.8 and above, DMA has to be word aligned */
>+	if ((dma_addr % 4) &&
>+		(musb->hwvers >= MUSB_HWVERS_1800)) {

is it only inventra dma that suffers from this ? If not, we could move 
this check before even calling the dma routine.

-- 
balbi
--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] USB: musb: allow unaligned memory data transfers
  2010-01-14 11:23   ` Felipe Balbi
@ 2010-01-14 13:36     ` Gadiyar, Anand
       [not found]       ` <5A47E75E594F054BAF48C5E4FC4B92AB031E2EB521-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Gadiyar, Anand @ 2010-01-14 13:36 UTC (permalink / raw)
  To: felipe.balbi@nokia.com, Pandita, Vikram
  Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
	Mankad, Maulik Ojas, Patra, Nilkesh

> From: Felipe Balbi wrote:
> >+	/* On MUSB:RTL1.8 and above, DMA has to be word aligned */
> >+	if ((dma_addr % 4) &&
> >+		(musb->hwvers >= MUSB_HWVERS_1800)) {
> 
> is it only inventra dma that suffers from this ? If not, we could move 
> this check before even calling the dma routine.

Yes, it's only the integrated Inventra DMA that behaves like this.

Anyway, I don't think newer versions of the IP are being used by
anyone without the Inventra DMA. The older versions though are
sometimes used with external DMA controllers.

- Anand

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: musb: allow unaligned memory data transfers
       [not found]       ` <5A47E75E594F054BAF48C5E4FC4B92AB031E2EB521-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
@ 2010-01-14 13:49         ` Sergei Shtylyov
       [not found]           ` <4B4F20DE.6040001-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2010-01-14 13:49 UTC (permalink / raw)
  To: Gadiyar, Anand
  Cc: felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org,
	Pandita, Vikram,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mankad, Maulik Ojas, Patra, Nilkesh

Hello.

Gadiyar, Anand wrote:

>> From: Felipe Balbi wrote:
>>     
>>> +	/* On MUSB:RTL1.8 and above, DMA has to be word aligned */
>>> +	if ((dma_addr % 4) &&
>>> +		(musb->hwvers >= MUSB_HWVERS_1800)) {
>>>       
>> is it only inventra dma that suffers from this ? If not, we could move 
>> this check before even calling the dma routine.
>>     
>
> Yes, it's only the integrated Inventra DMA that behaves like this.
>
> Anyway, I don't think newer versions of the IP are being used by
> anyone without the Inventra DMA. The older versions though are
> sometimes used with external DMA controllers.

   DA8xx/OMAP-L1x  has MUSB version 1.800 and external, CPPI 4.1 DMA 
controller.

WBR, Sergei

--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] USB: musb: allow unaligned memory data transfers
       [not found]           ` <4B4F20DE.6040001-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
@ 2010-01-14 13:53             ` Gadiyar, Anand
  0 siblings, 0 replies; 5+ messages in thread
From: Gadiyar, Anand @ 2010-01-14 13:53 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org,
	Pandita, Vikram,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mankad, Maulik Ojas, Patra, Nilkesh

Sergei Shtylyov wrote:
> Gadiyar, Anand wrote:
> 
> >> From: Felipe Balbi wrote:
> >>     
> >>> +	/* On MUSB:RTL1.8 and above, DMA has to be word aligned */
> >>> +	if ((dma_addr % 4) &&
> >>> +		(musb->hwvers >= MUSB_HWVERS_1800)) {
> >>>       
> >> is it only inventra dma that suffers from this ? If not, we could move 
> >> this check before even calling the dma routine.
> >>     
> >
> > Yes, it's only the integrated Inventra DMA that behaves like this.
> >
> > Anyway, I don't think newer versions of the IP are being used by
> > anyone without the Inventra DMA. The older versions though are
> > sometimes used with external DMA controllers.
> 
>    DA8xx/OMAP-L1x  has MUSB version 1.800 and external, CPPI 4.1 DMA 
> controller.
> 

Ah, okay. Thanks for the info - I did not know this.

- Anand
--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-01-14 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-12 15:42 [PATCH] USB: musb: allow unaligned memory data transfers Vikram Pandita
     [not found] ` <1263310937-7249-1-git-send-email-vikram.pandita-l0cyMroinI0@public.gmane.org>
2010-01-14 11:23   ` Felipe Balbi
2010-01-14 13:36     ` Gadiyar, Anand
     [not found]       ` <5A47E75E594F054BAF48C5E4FC4B92AB031E2EB521-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-01-14 13:49         ` Sergei Shtylyov
     [not found]           ` <4B4F20DE.6040001-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-01-14 13:53             ` Gadiyar, Anand

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.