Messages in this thread | | | Subject | MAX_DMA_ADDRESS, virt_to_bus (and 3c505.c bug) | Date | Fri, 06 Nov 1998 03:37:49 +0100 | From | Jan Kasprzak <> |
| |
Hi all,
I am writing a driver for an ISA card which uses ISA DMA. I have a few questions on MAX_DMA_ADDRESS (see <asm-i386/dma.h>) and virt_to_bus().
The driver tries to do the transfer directly from the skb, if the skb->data is DMA-able memory (<16M on ISA) and falls back to the pre-allocated bounce buffer otherwise:
if (virt_to_bus(skb->data) < MAX_DMA_ADDRESS) { memcpy(device->bouncebuf, skb->data, skb->len); device->txbuf = device->bouncebuf; } else device->txbuf = skb->data;
This does not work, because the MAX_DMA_ADDRESS is #defined to be PAGE_OFFSET+0x01000000, so it refers to the _virtual_ address instead of the bus one. The correct condition should be
if (skb->data < MAX_DMA_ADDRESS) ...
Now I have grep'd the Linux sources for the MAX_DMA_ADDRESS. I have found that 3c505.c uses MAX_DMA_ADDRESS once comparing it with some pointer, but on the other place it compares the MAX_DMA_ADDRESS and virt_to_bus(the same pointer). I think 3c505.c is broken at this place and needs to be fixed. Am I right there?
And another question related to the virt_to_bus on x86: This function is defined as (x) & ~PAGE_OFFSET. It works for the current value of the PAGE_OFFSET, but IMHO it does not work when I change the PAGE_OFFSET to 0x70000000, as suggested in <asm-i386/page.h> for >1GB RAM machines. Shouldn't the virt_to_bus be defined as (x)-PAGE_OFFSET ? The physical memory is mapped 1:1 from the PAGE_OFFSET virtual address, IIRC.
Thanks for any replies
-Yenya
-- \ Jan "Yenya" Kasprzak <kas at fi.muni.cz> http://www.fi.muni.cz/~kas/ \\ PGP: finger kas at aisa.fi.muni.cz 0D99A7FB206605D7 8B35FCDE05B18A5E // \\\ Czech Linux Homepage: http://www.linux.cz/ /// /// I think I'd rather be forced to learn perl than 68020 MMU. -Alan Cox \\\
- 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/
| |