提交 e67dd080 编写于 作者: C Catalin Marinas 提交者: Zheng Zengkai

arm64: Remove arm64_dma32_phys_limit and its uses

mainline inclusion
from mainline-5.11-rc4
commit d78050ee
category: bugfix
bugzilla: 50423
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d78050ee35440d7879ed94011c52994b8932e96e

-------------------------------------------------

With the introduction of a dynamic ZONE_DMA range based on DT or IORT
information, there's no need for CMA allocations from the wider
ZONE_DMA32 since on most platforms ZONE_DMA will cover the 32-bit
addressable range. Remove the arm64_dma32_phys_limit and set
arm64_dma_phys_limit to cover the smallest DMA range required on the
platform. CMA allocation and crashkernel reservation now go in the
dynamically sized ZONE_DMA, allowing correct functionality on RPi4.
Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
Cc: Chen Zhou <chenzhou10@huawei.com>
Reviewed-by: NNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> # On RPi4B
Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>

 Conflicts:
	arch/arm64/mm/init.c
Reviewed-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 1708d903
...@@ -28,11 +28,7 @@ ...@@ -28,11 +28,7 @@
/* 2M alignment for crash kernel regions */ /* 2M alignment for crash kernel regions */
#define CRASH_ALIGN SZ_2M #define CRASH_ALIGN SZ_2M
#ifdef CONFIG_ZONE_DMA
#define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit #define CRASH_ADDR_LOW_MAX arm64_dma_phys_limit
#else
#define CRASH_ADDR_LOW_MAX arm64_dma32_phys_limit
#endif
#define CRASH_ADDR_HIGH_MAX MEMBLOCK_ALLOC_ACCESSIBLE #define CRASH_ADDR_HIGH_MAX MEMBLOCK_ALLOC_ACCESSIBLE
......
...@@ -102,8 +102,7 @@ ...@@ -102,8 +102,7 @@
#endif /* CONFIG_ARM64_FORCE_52BIT */ #endif /* CONFIG_ARM64_FORCE_52BIT */
extern phys_addr_t arm64_dma_phys_limit; extern phys_addr_t arm64_dma_phys_limit;
extern phys_addr_t arm64_dma32_phys_limit; #define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)
#define ARCH_LOW_ADDRESS_LIMIT ((arm64_dma_phys_limit ? : arm64_dma32_phys_limit) - 1)
struct debug_info { struct debug_info {
#ifdef CONFIG_HAVE_HW_BREAKPOINT #ifdef CONFIG_HAVE_HW_BREAKPOINT
......
...@@ -54,13 +54,13 @@ s64 memstart_addr __ro_after_init = -1; ...@@ -54,13 +54,13 @@ s64 memstart_addr __ro_after_init = -1;
EXPORT_SYMBOL(memstart_addr); EXPORT_SYMBOL(memstart_addr);
/* /*
* We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of * If the corresponding config options are enabled, we create both ZONE_DMA
* memory as some devices, namely the Raspberry Pi 4, have peripherals with * and ZONE_DMA32. By default ZONE_DMA covers the 32-bit addressable memory
* this limited view of the memory. ZONE_DMA32 will cover the rest of the 32 * unless restricted on specific platforms (e.g. 30-bit on Raspberry Pi 4).
* bit addressable memory area. * In such case, ZONE_DMA32 covers the rest of the 32-bit addressable memory,
* otherwise it is empty.
*/ */
phys_addr_t arm64_dma_phys_limit __ro_after_init; phys_addr_t arm64_dma_phys_limit __ro_after_init;
phys_addr_t arm64_dma32_phys_limit __ro_after_init;
#ifndef CONFIG_KEXEC_CORE #ifndef CONFIG_KEXEC_CORE
static void __init reserve_crashkernel(void) static void __init reserve_crashkernel(void)
...@@ -144,6 +144,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) ...@@ -144,6 +144,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; unsigned long max_zone_pfns[MAX_NR_ZONES] = {0};
unsigned int __maybe_unused acpi_zone_dma_bits; unsigned int __maybe_unused acpi_zone_dma_bits;
unsigned int __maybe_unused dt_zone_dma_bits; unsigned int __maybe_unused dt_zone_dma_bits;
phys_addr_t __maybe_unused dma32_phys_limit = max_zone_phys(32);
#ifdef CONFIG_ZONE_DMA #ifdef CONFIG_ZONE_DMA
acpi_zone_dma_bits = fls64(acpi_iort_dma_get_max_cpu_address()); acpi_zone_dma_bits = fls64(acpi_iort_dma_get_max_cpu_address());
...@@ -153,8 +154,12 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) ...@@ -153,8 +154,12 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit);
#endif #endif
#ifdef CONFIG_ZONE_DMA32 #ifdef CONFIG_ZONE_DMA32
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(arm64_dma32_phys_limit); max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
if (!arm64_dma_phys_limit)
arm64_dma_phys_limit = dma32_phys_limit;
#endif #endif
if (!arm64_dma_phys_limit)
arm64_dma_phys_limit = PHYS_MASK + 1;
max_zone_pfns[ZONE_NORMAL] = max; max_zone_pfns[ZONE_NORMAL] = max;
free_area_init(max_zone_pfns); free_area_init(max_zone_pfns);
...@@ -362,16 +367,9 @@ void __init arm64_memblock_init(void) ...@@ -362,16 +367,9 @@ void __init arm64_memblock_init(void)
early_init_fdt_scan_reserved_mem(); early_init_fdt_scan_reserved_mem();
if (IS_ENABLED(CONFIG_ZONE_DMA32))
arm64_dma32_phys_limit = max_zone_phys(32);
else
arm64_dma32_phys_limit = PHYS_MASK + 1;
reserve_elfcorehdr(); reserve_elfcorehdr();
high_memory = __va(memblock_end_of_DRAM() - 1) + 1; high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
dma_contiguous_reserve(arm64_dma32_phys_limit);
} }
void __init bootmem_init(void) void __init bootmem_init(void)
...@@ -406,6 +404,11 @@ void __init bootmem_init(void) ...@@ -406,6 +404,11 @@ void __init bootmem_init(void)
sparse_init(); sparse_init();
zone_sizes_init(min, max); zone_sizes_init(min, max);
/*
* Reserve the CMA area after arm64_dma_phys_limit was initialised.
*/
dma_contiguous_reserve(arm64_dma_phys_limit);
/* /*
* request_standard_resources() depends on crashkernel's memory being * request_standard_resources() depends on crashkernel's memory being
* reserved, so do it here. * reserved, so do it here.
...@@ -488,7 +491,7 @@ static void __init free_unused_memmap(void) ...@@ -488,7 +491,7 @@ static void __init free_unused_memmap(void)
void __init mem_init(void) void __init mem_init(void)
{ {
if (swiotlb_force == SWIOTLB_FORCE || if (swiotlb_force == SWIOTLB_FORCE ||
max_pfn > PFN_DOWN(arm64_dma_phys_limit ? : arm64_dma32_phys_limit)) max_pfn > PFN_DOWN(arm64_dma_phys_limit))
swiotlb_init(1); swiotlb_init(1);
else else
swiotlb_force = SWIOTLB_NO_FORCE; swiotlb_force = SWIOTLB_NO_FORCE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册