[PATCH] arm64: mm: fix DMA zone when dma-ranges is missing

Catalin Marinas catalin.marinas at arm.com
Tue Aug 27 03:11:42 PDT 2024


On Tue, Aug 27, 2024 at 11:44:09AM +0300, Baruch Siach wrote:
> Some platforms, like Rockchip RK3568 based Odroid M1, do not provide DMA
> limits information in device-tree dma-ranges property. Still some device
> drivers set DMA limit that relies on DMA zone at low 4GB memory area.
> Until commit ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by
> zone_dma_limit"), zone_sizes_init() restricted DMA zone to low 32-bit
> when there is RAM there.
> 
> Restore DMA zone 32-bit limit for platforms that have RAM in this area.
> 
> Fixes: ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit")
> Reported-by: Marek Szyprowski <m.szyprowski at samsung.com>
> Tested-by: Marek Szyprowski <m.szyprowski at samsung.com>
> Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> ---
> This should go via the dma-mapping tree that contains the fixed commit.
> ---
>  arch/arm64/mm/init.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index bfb10969cbf0..7fcd0aaa9bb6 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -116,6 +116,9 @@ static void __init arch_reserve_crashkernel(void)
>  
>  static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit)
>  {
> +	if (memblock_start_of_DRAM() < U32_MAX)
> +		zone_limit = min(zone_limit, U32_MAX);
> +
>  	return min(zone_limit, memblock_end_of_DRAM() - 1) + 1;
>  }

Thanks both Baruch and Marek for digging into this and finding a
solution.

Reviewed-by: Catalin Marinas <catalin.marinas at arm.com>



More information about the linux-arm-kernel mailing list