* Alan Stern <[EMAIL PROTECTED]> [070328 12:10]:
> On Wed, 28 Mar 2007, Tony Lindgren wrote:
> 
> > Hi,
> > 
> > Here's a little patch to make sure tranfer_buffer is always if DMA
> > is temporarily unavailable. I ran into this with tusb6010 that
> > currently can only do limited DMA. This fixes a problem of connecting
> > storage devices and doing mixed DMA/PIO access.
> 
> Your patch isn't correct, or at least, it is very misleading.  It calls 
> page_address() in a situation where it cannot be certain that the page 
> frame lies in accessible kernel memory.  On some systems the value it 
> calculates will be garbage.
> 
> At a minimum you need to add a comment explaining that if the page isn't
> accessible, the transfer_buffer value won't ever be used.

Yeah it's a bit ugly. I don't think there's currently an easy way
to optimize out mapping of transfer_buffer on such systems.

Here's a version with better comments.

Tony
From: Tony Lindgren <[EMAIL PROTECTED]>
Subject: USB: Always map transfer_buffer

In case a DMA channel for an endpoint is temporarily
unavailable, the host controller driver may still be
able to transfer the data using PIO. Without this patch
the transfer_buffer is not mapped, and host controller
does not know what to use for PIO.

Signed-off-by: Tony Lindgren <[EMAIL PROTECTED]>

Index: linux-omap-2.6/drivers/usb/core/message.c
===================================================================
--- linux-omap-2.6.orig/drivers/usb/core/message.c	2007-03-28 10:59:21.000000000 -0400
+++ linux-omap-2.6/drivers/usb/core/message.c	2007-03-28 14:35:00.000000000 -0400
@@ -412,16 +412,19 @@ int usb_sg_init (
 		io->urbs [i]->status = -EINPROGRESS;
 		io->urbs [i]->actual_length = 0;
 
+		/*
+		 * Some systems need both transfer_buffer and transfer_dma
+		 * to revert to PIO if DMA is temporarily unavailable.
+		 * Note that transfer_buffer may not be accessible on some
+		 * systems. In that case there is no need to use it either.
+		 */
+		io->urbs [i]->transfer_buffer =
+			page_address (sg [i].page) + sg [i].offset;
 		if (dma) {
-			/* hc may use _only_ transfer_dma */
 			io->urbs [i]->transfer_dma = sg_dma_address (sg + i);
 			len = sg_dma_len (sg + i);
-		} else {
-			/* hc may use _only_ transfer_buffer */
-			io->urbs [i]->transfer_buffer =
-				page_address (sg [i].page) + sg [i].offset;
+		} else
 			len = sg [i].length;
-		}
 
 		if (length) {
 			len = min_t (unsigned, len, length);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to