On Wed, Jul 24, 2019 at 02:51:24PM +0100, Catalin Marinas wrote: > I think it may be better if we have both ZONE_DMA and ZONE_DMA32 on > arm64. ZONE_DMA would be based on the smallest dma-ranges as described > in the DT while DMA32 covers the first naturally aligned 4GB of RAM > (unchanged). When a smaller ZONE_DMA is not needed, it could be expanded > to cover what would normally be ZONE_DMA32 (or could we have ZONE_DMA as > 0-bytes? I don't think GFP_DMA can still allocate memory in this case). > > We'd probably have to define ARCH_ZONE_DMA_BITS for arm64 to something > smaller than 32-bit but sufficient to cover the known platforms like > RPi4 (the current 24 is too small, so maybe 30). AFAICT, > __dma_direct_optimal_gfp_mask() figures out whether GFP_DMA or GFP_DMA32 > should be passed.
ARCH_ZONE_DMA_BITS should probably become a variable. That way we can just initialize it to the default 24 bits in kernel/dma/direct.c and allow architectures to override it in their early boot code.