allocating memory at boot
sk.syed2
sk.syed2 at gmail.com
Thu Feb 17 16:32:37 EST 2011
> I'm currently trying to port a (currently for unreleased hardware and
> under nda) driver from x86 to arm and in doing so I've run into a
> problem with allocating memory using pci_alloc_consistent. Looking into
> it I can't allocate more than 1MB whereas I need to allocate at least
> 2MB of contiguous memory.
I guess pci_alloc_consistent calls dma_alloc_coherent, so why does
it fail to allocate 2MB of memory?
What is the error do you see?
Looking further into it, the conventional
> method to get around this at the moment seems to be to statically link
> the driver into the kernel and use alloc_bootmem or alloc_bootmem_low
> (mentioned in ldd3 and all over google).
>
> The problem I've run into however is that I get a warning at boot which is:
>
> WARNING: at mm/bootmem.c:672 alloc_arch_preferred_bootmem+0x34/0x64()
You need to call alloc_bootmem at an early stage before slab is initialized.
>
> Looking at that code in bootmem.c this is a warning which I think is
> there to tell me that SLAB is available and warn against trying to
> allocate at boot. However it reportedly allocates the memory but when
> the driver tries to use this memory later, then the system hangs.
Is the driver using the memory for DMA? Are you using the memory
returned by alloc_bootmem directly?
Remember DMA works on physical addresses not virtual. You might have
to use dma_map_single/dma_unmap_single.
Also does the h/w has any limitations of the physical memory range it
can access? Like only first 64MB of RAM?
regards
-syed
More information about the Kernelnewbies
mailing list