About IO server settings for DMA in L4Linux

Adam Lackorzynski adam at os.inf.tu-dresden.de
Tue Dec 13 00:23:48 CET 2016

On Mon Dec 12, 2016 at 11:39:52 +0000, Jesse-SC Chou (周書正) wrote:
> However, I've got a very strange virtual memory to physical mapping without the flag "Io.Hw_device_DF_dma_supported".
> On my platform, the memory physical memory is at "0x20000000 ~ 0x27FFFFFF".
> When without the flag "Io.Hw_device_DF_dma_supported", the dma_alloc_coherent() give me a physical address "0x05a2d000". This is not a reasonable physical memory address.
> When adding the flag "Io.Hw_device_DF_dma_supported" to DEVICE1, the dma_alloc_coherent() give me a physical address "0x2502d000". This is a reasonable physical memory address.
> I traced into dma_alloc_coherent(), finally it will call to l4x_virt_to_phys(). I printed out the content of v2p_for_each(i) data structure:
> ----------------------------------------
> Without "Io.Hw_device_DF_dma_supported" in DEVICE1: (the physical address is not correct)
> i->virt=0x02000000 i->phys=0x02000000 i->size=48f000
> i->virt=0x02600000 i->phys=0x02600000 i->size=4000000
> i->virt=0x06604000 i->phys=0x060c0000 i->size=40000
> i->virt=0x06732000 i->phys=0x05a2d000 i->size=1000
> ----------------------------------------
> With "Io.Hw_device_DF_dma_supported" in DEVICE1: (the physical address is reasonable)
> i->virt=0x02000000 i->phys=0x2017c000 i->size=48f000
> i->virt=0x02600000 i->phys=0x21c00000 i->size=4000000
> i->virt=0x06604000 i->phys=0x256c0000 i->size=40000
> i->virt=0x06732000 i->phys=0x2502d000 i->size=1000
> ----------------------------------------
> The result seems the v2p mapping is wrong when without "Io.Hw_device_DF_dma_supported".

Ok, thanks for debugging this. Mixup of versions on my side, you need
the flag.
> I have the following questions:
> 1. The above result seems not reasonable. Do you have any idea?
> 2. I also noticed that in arm_dma_alloc(), l4x_dmapool_mem_alloc() is wrapped by "CONFIG_L4_DMAPOOL". Is "CONFIG_L4_DMAPOOL" mandatory?

CONFIG_L4_DMAPOOL is for some different use case, do not enable it.

> 3. If "CONFIG_L4_DMA_POOL" is optional, arm_dma_alloc() will call "__dma_alloc(dev, size, handle, gfp, prot, false, attrs, __builtin_return_address(0))".
> the 6th argument is "false". Does it mean the dma_alloc_coherent() in L4Linux always return a non-coherent DMA region? That is, we have to handle the cache issue by myself.

There's arm_coherent_dma_alloc() too. I think both variants are there
and are used as required. L4Linux has the cache-handling functionality
and Linux code will use it as required. I'm not aware of any issues in
this area.

Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/

More information about the l4-hackers mailing list