Re: [RFC] usb: musb: allow dma engine to check compatibility with usb request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

On Tue, Dec 21, 2010 at 03:49:31PM +0100, Mian Yousaf Kaukab wrote:
When DMA mode is enabled, gadget MUSB driver calls dma_map_single() or
dma_sync_single_for_device() on given buffer when usb request is queued.
Later at ->channel_program() it is possible that DMA engine can not handle
this request.
For example ->channel_program in tusb6010_omap.c:

static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
		u8 rndis_mode, dma_addr_t dma_addr, u32 len)
{
...
       if (unlikely(dma_addr & 0x1) || (len < 32) || (len > packet_sz))
               return false;
...
       if (dma_addr & 0x2)
               return false;
...
}

In this case, usb request will be handled in PIO mode which renders dma mapping
operations as unnecessary.

This patch adds a mechanism to allow DMA engine to decide early if it is
possible to do DMA or not.

One more case to handle is when short packet arrives for rx transfers and dma-
engine can not handle it due to alignment or size threshold. In this case
buffers must be unmapped before calling musb_read_fifo(). This is more important
for platforms with outer-cache due to the following patch:

	commit 2ffe2da3e71652d4f4cae19539b5c78c2a239136
	Author: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>
	Date:   Sat Oct 31 16:52:16 2009 +0000

		ARM: dma-mapping: fix for speculative prefetching

Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@xxxxxxxxxxxxxx>
Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>

NAK.

---
This patch is based on git://gitorious.org/usb/usb.git musb-hw

drivers/usb/musb/musb_dma.h    |    2 +
drivers/usb/musb/musb_gadget.c |   81 ++++++++++++++++++++++++++-------------
drivers/usb/musb/musb_gadget.h |    8 +++-
3 files changed, 63 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 916065b..870e5b4 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -169,6 +169,8 @@ struct dma_controller {
							dma_addr_t dma_addr,
							u32 length);
	int			(*channel_abort)(struct dma_channel *);
+	int			(*is_req_compatible)(struct dma_controller *,
+					struct musb_ep *, struct usb_request *);

you really don't need this. It's enough to do all checks in
rxstate()/txstate() before mapping the request and if you have to
fallback to pio (due to e.g. short packet) just go ahead and unmap the
buffer. No weird checks needed :-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index edff014..362b3f7 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -92,6 +92,28 @@

/* ----------------------------------------------------------------------- */

+static void musb_gadget_unmap_dma(struct musb *musb, struct musb_request *req)

you're unmapping the request, so would musb_gadget_unmap_request() be a
better name ?

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux