[patch] 2.3.40pre6: Take 3: avoid bounce buffers
Tim Waugh
twaugh en redhat.com
Vie Ene 21 07:22:25 CST 2000
Hi Linus,
Here's my third attempt to get this right. ;-) It tries to avoid a DMA
bounce buffer when possible.
Tim.
*/
Index: linux/drivers/parport/parport_pc.c
diff -u linux/drivers/parport/parport_pc.c:1.1.1.12 linux/drivers/parport/parport_pc.c:1.20
--- linux/drivers/parport/parport_pc.c:1.1.1.12 Tue Jan 18 11:16:06 2000
+++ linux/drivers/parport/parport_pc.c Thu Jan 20 18:03:59 2000
@@ -549,9 +549,23 @@
{
int ret = 0;
unsigned long dmaflag;
- size_t left = length;
+ 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 */
+ /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */
+ if (buf+length <= MAX_DMA_ADDRESS) {
+ /* If it would cross a 64k boundary, cap it at the end. */
+ if ((buf ^ (buf+length-1)) & ~0xffff)
+ maxlen = (0x10000 - buf) & 0xffff;
+
+ dma_addr = virt_to_bus(buf);
+ } else {
+ dma_addr = virt_to_bus(priv->dma_buf);
+ maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */
+ }
+
port = port->physport;
/* We don't want to be interrupted every character. */
@@ -566,16 +580,17 @@
size_t count = left;
- if (count > PAGE_SIZE)
- count = PAGE_SIZE;
+ if (count > maxlen)
+ count = maxlen;
- memcpy(priv->dma_buf, buf, count);
+ if (maxlen == PAGE_SIZE) /* bounce buffer ! */
+ memcpy(priv->dma_buf, buf, count);
dmaflag = claim_dma_lock();
disable_dma(port->dma);
clear_dma_ff(port->dma);
set_dma_mode(port->dma, DMA_MODE_WRITE);
- set_dma_addr(port->dma, virt_to_bus((volatile char *) priv->dma_buf));
+ set_dma_addr(port->dma, dma_addr);
set_dma_count(port->dma, count);
/* Set DMA mode */
-
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