--- zzzz-none-000/linux-4.1.52/arch/arm/mm/init.c 2018-05-28 02:26:45.000000000 +0000 +++ bcm63-7530ax-731/linux-4.1.52/arch/arm/mm/init.c 2022-03-02 11:37:12.000000000 +0000 @@ -38,6 +38,8 @@ #include "mm.h" +#include + #ifdef CONFIG_CPU_CP15_MMU unsigned long __init __clear_cr(unsigned long mask) { @@ -121,6 +123,30 @@ } #endif +#if defined(CONFIG_BCM_KF_ARM_BCM963XX) && defined(CONFIG_BCM_ZONE_ACP) +static void __init arm_adjust_acp_zone(unsigned long *size, unsigned long *hole) +{ + unsigned long total_size = size[ZONE_NORMAL]; +#ifndef CONFIG_ZONE_DMA + total_size += size[0]; +#endif + + if (total_size <= (CONFIG_BCM_ACP_MEM_SIZE << (20 - PAGE_SHIFT))) + return; + +#ifdef CONFIG_ZONE_DMA + size[ZONE_NORMAL] -= CONFIG_BCM_ACP_MEM_SIZE << (20 - PAGE_SHIFT); +#else + size[ZONE_NORMAL] = size[0] - (CONFIG_BCM_ACP_MEM_SIZE << (20 - PAGE_SHIFT)); +#endif + size[ZONE_ACP] = CONFIG_BCM_ACP_MEM_SIZE << (20 - PAGE_SHIFT); +#ifndef CONFIG_ZONE_DMA + hole[ZONE_NORMAL] = hole[0]; +#endif + hole[ZONE_ACP] = 0; +} +#endif + void __init setup_dma_zone(const struct machine_desc *mdesc) { #ifdef CONFIG_ZONE_DMA @@ -185,6 +211,10 @@ arm_dma_zone_size >> PAGE_SHIFT); #endif +#if defined(CONFIG_BCM_KF_ARM_BCM963XX) && defined(CONFIG_BCM_ZONE_ACP) + arm_adjust_acp_zone(zone_size, zhole_size); +#endif + free_area_init_node(0, zone_size, min, zhole_size); } @@ -268,6 +298,8 @@ if (mdesc->reserve) mdesc->reserve(); + avm_mtd_remove_and_reserve_mem_area(); + early_init_fdt_scan_reserved_mem(); /* reserve memory for DMA contiguous allocations */ @@ -715,8 +747,12 @@ #endif } +void avm_mtd_cleanup(void) __weak; +void avm_mtd_cleanup(void) {} + void free_initmem(void) { + avm_mtd_cleanup(); fix_kernmem_perms(); free_tcmmem();