[patch] 2.3.39: Don't use bounce buffer when not needed (parport)

Tim Waugh twaugh en redhat.com
Vie Ene 21 01:38:16 CST 2000


On Tue, 18 Jan 2000, Alan Cox wrote:

> > +	size_t maxlen = 0x10000;            /* max 64k per DMA transfer */
> >  
> > +	/* above 16 MB we use a bounce buffer as ISA-DMA is not possible */
> > +	if (buf+length <= MAX_DMA_ADDRESS)
> > +		dma_addr = virt_to_bus(buf);
> > +	else {
> > +		dma_addr = virt_to_bus(priv->dma_buf);
> > +		maxlen   = PAGE_SIZE;          /* sizeof(priv->dma_buf) */
> > +	}
> 
> You are missing a test here. You also have to check if the start and
> end of the block are in the same 64K range (the PC DMA controller
> doesnt increment the top byte on a wrap)

Does it look any better with this applied on top?

Tim.
*/

Index: drivers/parport/parport_pc.c
===================================================================
RCS file: /usr/local/src/cvsroot/linux/drivers/parport/parport_pc.c,v
retrieving revision 1.19
diff -d -u -r1.19 parport_pc.c
--- drivers/parport/parport_pc.c	2000/01/18 13:23:03	1.19
+++ drivers/parport/parport_pc.c	2000/01/20 15:55:56
@@ -552,12 +552,16 @@
 	size_t left = length;
 	const struct parport_pc_private *priv = port->physport->private_data;
 	unsigned long dma_addr;
-	size_t maxlen = 0x10000;            /* max 64k per DMA transfer */
+	size_t maxlen = 1<<16; /* max 64k per DMA transfer */
 
 	/* above 16 MB we use a bounce buffer as ISA-DMA is not possible */
-	if (buf+length <= MAX_DMA_ADDRESS)
+	if (buf+length <= MAX_DMA_ADDRESS) {
+                /* If it would cross a 64k boundary, cap it at the end. */
+                if ((buf & ~((1<<16) - 1)) != ((buf+length) & ~((1<<16) - 1)))
+                        maxlen = ((1<<16) - 1) & ~buf;
+
 		dma_addr = virt_to_bus(buf);
-	else {
+        } else {
 		dma_addr = virt_to_bus(priv->dma_buf);
 		maxlen   = PAGE_SIZE;          /* sizeof(priv->dma_buf) */
 	}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda