All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Gadiyar <gadiyar@ti.com>
To: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@suse.de>
Cc: Anand Gadiyar <gadiyar@ti.com>, Felipe Balbi <balbi@ti.com>,
	Ming Lei <tom.leiming@gmail.com>,
	Ajay Kumar Gupta <ajay.gupta@ti.com>,
	Mike Frysinger <vapier@gentoo.org>
Subject: [PATCH RFC] usb: musb: fail unaligned DMA transfers on v1.8 and above
Date: Sun, 31 Oct 2010 10:55:59 +0530	[thread overview]
Message-ID: <1288502759-18618-1-git-send-email-gadiyar@ti.com> (raw)

The Inventra DMA engine in version 1.8 and later of the MUSB
controller cannot handle DMA addresses that are not aligned
to a 4 byte boundary. It ends up ignoring the last two bits
programmed in the DMA_ADDR register. This is a deliberate
design change in the controller and is documented in the
programming guide.

Earlier versions of the controller could handle these
accesses just fine.

Fail dma_channel_program if we see an unaligned address when
using the newer controllers, so that the caller can carry out
the transfer using PIO mode.
(Current callers already have this backup path in place).

Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Cc: Ajay Kumar Gupta <ajay.gupta@ti.com>
Cc: Mike Frysinger <vapier@gentoo.org>
---
Patch based on linux-next as of 20101029.

I believe Blackfin is also affected by this, but I'm not sure how
they're working around this. Mike?

 drivers/usb/musb/musbhsdma.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

Index: mainline/drivers/usb/musb/musbhsdma.c
===================================================================
--- mainline.orig/drivers/usb/musb/musbhsdma.c
+++ mainline/drivers/usb/musb/musbhsdma.c
@@ -158,6 +158,8 @@ static int dma_channel_program(struct dm
 				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,
@@ -167,6 +169,18 @@ static int dma_channel_program(struct dm
 	BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
 		channel->status == MUSB_DMA_STATUS_BUSY);
 
+	/*
+	 * The DMA engine in RTL1.8 and above cannot handle
+	 * DMA addresses that are not aligned to a 4 byte boundary.
+	 * It ends up masking the last two bits of the address
+	 * programmed in DMA_ADDR.
+	 *
+	 * Fail such DMA transfers, so that the backup PIO mode
+	 * can carry out the transfer
+	 */
+	if ((musb->hwvers >= MUSB_HWVERS_1800) && (dma_addr %4))
+		return false;
+
 	channel->actual_len = 0;
 	musb_channel->start_addr = dma_addr;
 	musb_channel->len = len;

             reply	other threads:[~2010-10-31  5:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-31  5:25 Anand Gadiyar [this message]
     [not found] ` <1288502759-18618-1-git-send-email-gadiyar-l0cyMroinI0@public.gmane.org>
2010-10-31  9:59   ` [PATCH RFC] usb: musb: fail unaligned DMA transfers on v1.8 and above Ming Lei
2010-11-08  6:21     ` Anand Gadiyar
2010-11-01 12:43   ` Sergei Shtylyov
2010-11-05 12:26 ` Felipe Balbi

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=1288502759-18618-1-git-send-email-gadiyar@ti.com \
    --to=gadiyar@ti.com \
    --cc=ajay.gupta@ti.com \
    --cc=balbi@ti.com \
    --cc=gregkh@suse.de \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tom.leiming@gmail.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 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.