ARM64: Setup DMA32 zone size by bootargs
Subsystems (3)
PATCH 1/1 ARM64: Setup DMA32 zone size by bootargs
this patch allowing the arm64 DMA zone be configurable.
---
Hi
For some devices, the main memory split into 2 part due to the memory architecture, the efficient and less inefficient part.
One of the use case is fine-tune the dma32 size to contain all the efficient part of memory block on this kind of architecture,
but in general, the DMA32 zone size is hardcode to 4G.
.../admin-guide/kernel-parameters.txt | 3 ++ arch/arm64/include/asm/memory.h | 2 ++ arch/arm64/mm/init.c | 33 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -956,6 +956,9 @@ The filter can be disabled or changed to another driver later using sysfs. + dma32_zone=nn [KMG] [KNL,BOOT] + Forces the DMA32 zone size of <nn> in mb, arm64 only. + driver_async_probe= [KNL] List of driver names to be probed asynchronously. Format: <driver_name1>,<driver_name2>...
arch/arm64/include/asm/memory.h +2 -0
@@ -174,6 +174,8 @@ extern u64 kimage_vaddr;/* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +extern phys_addr_t arm_dma_zone_size; +static inline unsigned long kaslr_offset (void ) {return kimage_vaddr -KIMAGE_VADDR ;
arch/arm64/mm/init.c +30 -3
@@ -60,6 +60,9 @@ EXPORT_SYMBOL(physvirt_offset);struct page *vmemmap__ro_after_init ;EXPORT_SYMBOL (vmemmap); +phys_addr_t arm_dma_zone_size__ro_after_init ; +EXPORT_SYMBOL (arm_dma_zone_size); +/* * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of * memory as some devices, namely the Raspberry Pi 4, have peripherals with
@@ -242,6 +245,25 @@ static int __init early_mem(char *p) }early_param ("mem" , early_mem); +/* +* Setup the dma32 zone size +*/ +static int __init setup_dma32_zone (char *p) +{ +if (!p) +return -EINVAL ; + +if (kstrtoull (p,0 , &arm_dma_zone_size)) +return -EINVAL ; + + arm_dma_zone_size *=SZ_1M ; +pr_notice ("Setup dma32 zone size to %llu Mb\n" , arm_dma_zone_size); + +return 0 ; +} + +early_param ("dma32_zone" , setup_dma32_zone); +static int __init early_init_dt_scan_usablemem (unsigned long node,const char *uname,int depth,void *data) {
@@ -392,10 +414,15 @@ void __init arm64_memblock_init(void) arm64_dma_phys_limit =max_zone_phys (ARM64_ZONE_DMA_BITS ); } -if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - arm64_dma32_phys_limit =max_zone_phys (32 ); -else +if (IS_ENABLED (CONFIG_ZONE_DMA32 )) { +if (arm_dma_zone_size) + arm64_dma32_phys_limit = arm_dma_zone_size + +memblock_start_of_DRAM (); +else + arm64_dma32_phys_limit =max_zone_phys (32 ); + }else { arm64_dma32_phys_limit =PHYS_MASK +1 ; + }reserve_crashkernel ();
Signature · 1 line
2.18.0
Quoted 5 lines · Phil Chang
this patch allowing the arm64 DMA zone be configurable.
Signed-off-by Alix Wu <[email protected]>Signed-off-by YJ Chiang <[email protected]>Signed-off-by Phil Chang <[email protected]>
Quoted 8 lines
---
HiFor some devices, the main memory split into 2 part due to the memory architecture, the efficient and less inefficient part.
One of the use case is fine-tune the dma32 size to contain all the efficient part of memory block on this kind of architecture,
but in general, the DMA32 zone size is hardcode to 4G.
The sole point of ZONE_DMA32 is to contain all the 32-bit addressable memory which is not covered by ZONE_DMA. As such the only possible thing that could be configured is the size of ZONE_DMA (if present), and this patch makes no sense.
If you want to describe NUMA characteristics, use NUMA properties. Giving users freedom to break fundamental assumptions of the DMA layer by arbitrarily changing the meaning of "32-bit" is not an appropriate solution.
Robin.
Quoted 92 lines
.../admin-guide/kernel-parameters.txt | 3 ++ arch/arm64/include/asm/memory.h | 2 ++ arch/arm64/mm/init.c | 33 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +3
-0@@ -956,6 +956,9 @@ The filter can be disabled or changed to another driver later using sysfs. + dma32_zone=nn [KMG] [KNL,BOOT] + Forces the DMA32 zone size of <nn> in mb, arm64 only. + driver_async_probe= [KNL] List of driver names to be probed asynchronously. Format: <driver_name1>,<driver_name2>...arch/arm64/include/asm/memory.h +2
-0@@ -174,6 +174,8 @@ extern u64 kimage_vaddr;/* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +extern phys_addr_t arm_dma_zone_size; +static inline unsigned long kaslr_offset (void ) {return kimage_vaddr -KIMAGE_VADDR ;arch/arm64/mm/init.c +30
-3@@ -60,6 +60,9 @@ EXPORT_SYMBOL(physvirt_offset);struct page *vmemmap__ro_after_init ;EXPORT_SYMBOL (vmemmap); +phys_addr_t arm_dma_zone_size__ro_after_init ; +EXPORT_SYMBOL (arm_dma_zone_size); +/* * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of * memory as some devices, namely the Raspberry Pi 4, have peripherals with @@ -242,6 +245,25 @@ static int __init early_mem(char *p) }early_param ("mem" , early_mem); +/* +* Setup the dma32 zone size +*/ +static int __init setup_dma32_zone (char *p) +{ +if (!p) +return -EINVAL ; + +if (kstrtoull (p,0 , &arm_dma_zone_size)) +return -EINVAL ; + + arm_dma_zone_size *=SZ_1M ; +pr_notice ("Setup dma32 zone size to %llu Mb\n" , arm_dma_zone_size); + +return 0 ; +} + +early_param ("dma32_zone" , setup_dma32_zone); +static int __init early_init_dt_scan_usablemem (unsigned long node,const char *uname,int depth,void *data) {@@ -392,10 +414,15 @@ void __init arm64_memblock_init(void) arm64_dma_phys_limit =max_zone_phys (ARM64_ZONE_DMA_BITS ); } -if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - arm64_dma32_phys_limit =max_zone_phys (32 ); -else +if (IS_ENABLED (CONFIG_ZONE_DMA32 )) { +if (arm_dma_zone_size) + arm64_dma32_phys_limit = arm_dma_zone_size + +memblock_start_of_DRAM (); +else + arm64_dma32_phys_limit =max_zone_phys (32 ); + }else { arm64_dma32_phys_limit =PHYS_MASK +1 ; + }reserve_crashkernel ();
Quoted 19 lines
Quoted 5 lines
this patch allowing the arm64 DMA zone be configurable.
Signed-off-by Alix Wu <[email protected]>Signed-off-by YJ Chiang <[email protected]>Signed-off-by Phil Chang <[email protected]>Quoted 8 lines
---
HiFor some devices, the main memory split into 2 part due to the memory architecture, the efficient and less inefficient part.
One of the use case is fine-tune the dma32 size to contain all the efficient part of memory block on this kind of architecture,
but in general, the DMA32 zone size is hardcode to 4G.The sole point of
ZONE_DMA32is to contain all the 32-bit addressable memory which is not covered byZONE_DMA. As such the only possible thing that could be configured is the size ofZONE_DMA(if present), and this patch makes no sense.
Quoted 6 lines
If you want to describe NUMA characteristics, use NUMA properties. Giving users freedom to break fundamental assumptions of the DMA layer by arbitrarily changing the meaning of "32-bit" is not an appropriate solution.
Robin.
Hi Robin
Thannks for your reply, how about add a condiction to limit the customize dma32 zone size under 4G ?
Quoted 92 lines
Quoted 92 lines
.../admin-guide/kernel-parameters.txt | 3 ++ arch/arm64/include/asm/memory.h | 2 ++ arch/arm64/mm/init.c | 33 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +3
-0@@ -956,6 +956,9 @@ The filter can be disabled or changed to another driver later using sysfs. + dma32_zone=nn [KMG] [KNL,BOOT] + Forces the DMA32 zone size of <nn> in mb, arm64 only. + driver_async_probe= [KNL] List of driver names to be probed asynchronously. Format: <driver_name1>,<driver_name2>...arch/arm64/include/asm/memory.h +2
-0@@ -174,6 +174,8 @@ extern u64 kimage_vaddr;/* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +extern phys_addr_t arm_dma_zone_size; +static inline unsigned long kaslr_offset (void ) {return kimage_vaddr -KIMAGE_VADDR ;arch/arm64/mm/init.c +30
-3@@ -60,6 +60,9 @@ EXPORT_SYMBOL(physvirt_offset);struct page *vmemmap__ro_after_init ;EXPORT_SYMBOL (vmemmap); +phys_addr_t arm_dma_zone_size__ro_after_init ; +EXPORT_SYMBOL (arm_dma_zone_size); +/* * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of * memory as some devices, namely the Raspberry Pi 4, have peripherals with @@ -242,6 +245,25 @@ static int __init early_mem(char *p) }early_param ("mem" , early_mem); +/* +* Setup the dma32 zone size +*/ +static int __init setup_dma32_zone (char *p) +{ +if (!p) +return -EINVAL ; + +if (kstrtoull (p,0 , &arm_dma_zone_size)) +return -EINVAL ; + + arm_dma_zone_size *=SZ_1M ; +pr_notice ("Setup dma32 zone size to %llu Mb\n" , arm_dma_zone_size); + +return 0 ; +} + +early_param ("dma32_zone" , setup_dma32_zone); +static int __init early_init_dt_scan_usablemem (unsigned long node,const char *uname,int depth,void *data) {@@ -392,10 +414,15 @@ void __init arm64_memblock_init(void) arm64_dma_phys_limit =max_zone_phys (ARM64_ZONE_DMA_BITS ); } -if (IS_ENABLED (CONFIG_ZONE_DMA32 )) - arm64_dma32_phys_limit =max_zone_phys (32 ); -else +if (IS_ENABLED (CONFIG_ZONE_DMA32 )) { +if (arm_dma_zone_size) + arm64_dma32_phys_limit = arm_dma_zone_size + +memblock_start_of_DRAM (); +else + arm64_dma32_phys_limit =max_zone_phys (32 ); + }else { arm64_dma32_phys_limit =PHYS_MASK +1 ; + }reserve_crashkernel ();
Randy Dunlap
reviewerDocumentation/admin-guide/kernel-parameters.txt line 960
Quoted 10 lines · Phil Chang
Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -956,6 +956,9 @@ The filter can be disabled or changed to another driver later using sysfs. + dma32_zone=nn [KMG] [KNL,BOOT] + Forces the DMA32 zone size of <nn> in mb, arm64 only.
Preferred:
Documentation/admin-guide/kernel-parameters.txt line 964
Quoted 7 lines
Documentation/admin-guide/kernel-parameters.txt +3
-0+ dma32_zone=nn [KMG] [KNL,BOOT,ARM64] + Forces the DMA32 zone size of <nn> in MB. + driver_async_probe= [KNL] List of driver names to be probed asynchronously. Format: <driver_name1>,<driver_name2>...
thanks.
Signature · 1 line
~Randy
Randy Dunlap
reviewerQuoted 9 lines · Randy Dunlap
Quoted 8 lines · Phil Chang
Documentation/admin-guide/kernel-parameters.txt +0
-0@@ -956,6 +956,9 @@ The filter can be disabled or changed to another driver later using sysfs.
Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt line 960
Quoted 2 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0+ dma32_zone=nn [KMG] [KNL,BOOT] + Forces the DMA32 zone size of <nn> in mb, arm64 only.Preferred:
Documentation/admin-guide/kernel-parameters.txt line 961
Quoted 1 line
Documentation/admin-guide/kernel-parameters.txt +1
-0+ dma32_zone=nn [KMG] [KNL,BOOT,ARM64]
Oh, I doubt that the "[KMG]" should be there at all.
Quoted 9 lines
Documentation/admin-guide/kernel-parameters.txt line 964
Quoted 6 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0+ Forces the DMA32 zone size of <nn> in MB. + driver_async_probe= [KNL] List of driver names to be probed asynchronously. Format: <driver_name1>,<driver_name2>...thanks.
Signature · 1 line
~Randy