Re: wrong usage of MAX_DMA_ADDRESS in bootmem.h

From: Russell King - ARM Linux
Date: Wed Oct 01 2008 - 10:07:10 EST


On Wed, Oct 01, 2008 at 07:07:42AM -0500, Christoph Lameter wrote:
> Russell King - ARM Linux wrote:
>
> > Not correct. MAX_DMA_ADDRESS is a virtual address. ISA_DMA_THRESHOLD
> > is the last byte of _physical_ memory which ISA DMA can transfer:
>
> > include/asm-x86/scatterlist.h:#define ISA_DMA_THRESHOLD (0x00ffffff)
> >
> > So what you've just suggested is completely insane.
>
> Someone screwed around with the basics here. MAX_DMA_ADDRESS is no longer
> related to MAX_DMA_PFN for the x86_32 case. What is the point of relating
> MAX_DMA_ADDRESS to PAGE_OFFSET? Looks like we are creating more confusion
> about the strange DMA zone.

Because it is a virtual address. It has to be. You're using __pa() on it,
and __pa() ONLY takes a virtual address.

> The best would be to rename these variables to make the semantics clearer
>
> ZONE_DMA related variables:
>
> MAX_DMA_PFN -> MAX_ZONE_DMA_PFN
> MAX_DMA_ADDRESS -> MAX_ZONE_DMA_ADDRESS
>
> MAX_DMA32_PFN -> MAX_ZONE_DMA32_PFN
> MAX_DMA32_ADDRESS -> MAX_ZONE_DMA32_ADDRESS
>
> Then the general DMAability
>
> MAX_DMA_ADDRESS -> DMA_LIMIT

That's no clearer. Are they physical addresses? Or are they virtual
addresses? Can't guess that from the names.

> > Incorrect. MAX_DMA_ADDRESS is the highest possible virtual DMA address:
>
> MAX_DMA_ADDRESS is the highest possible address for the DMA zone. Not the
> highest possible address that any DMA controller can use.

Semantically disagree.

If you only have a controller which can address 1MB of memory (yes, they do
exist) then MAX_DMA_ADDRESS must be PAGE_OFFSET + 1MB, otherwise you have
precisely NO way to obtain memory from the kernel for this DMA controller
- and that means you want the DMA zone to be sized to 1MB. So _indirectly_
it's true that MAX_DMA_ADDRESS is the highest possible address for the DMA
zone.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/