Messages in this thread Patch in this message | | | Date | Mon, 24 Jan 2000 14:37:00 +0000 (GMT) | From | Tim Waugh <> | Subject | [patch] 2.3.41pre2: avoid bounce buffers (again!) |
| |
Here's a patch for 2.3.41pre2 for avoiding bounce buffers when possible for parport. Please test it out.
Thanks, 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.21 --- linux/drivers/parport/parport_pc.c:1.1.1.12 Tue Jan 18 11:16:06 2000 +++ linux/drivers/parport/parport_pc.c Fri Jan 21 09:52:42 2000 @@ -549,8 +549,24 @@ { 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 */ + unsigned long start = (unsigned long) buf; + unsigned long end = (unsigned long) buf + length - 1; + + /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */ + if (end <= MAX_DMA_ADDRESS) { + /* If it would cross a 64k boundary, cap it at the end. */ + if ((start ^ end) & ~0xffff) + maxlen = (0x10000 - start) & 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; @@ -566,16 +582,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@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |