Base patches for ARM devicetree groundwork
Subsystems (3)
cover Base patches for ARM devicetree groundwork
Hi all,
As requested, these are the non-DT-specific patches from my DT series, rebased onto the current branch. The first patch may be useful on its own, the other two are only really needed for the DT work.
Cheers,
Jeremy
---
Jeremy Kerr (3):
arm: use generic infrastructure for early params
arm: change command_line to cmd_line, and export it
arm: export arm_add_memory
PATCH 1/3 arm: use generic infrastructure for early params
The ARM setup code includes its own parser for early params, there's also one in the generic init code.
This patch removes __early_init (and related code) from arch/arm/kernel/setup.c, and changes users to the generic early_init macro instead.
The generic macro takes a char * argument, rather than char **, so we need to update the parser functions a little.
--- arch/arm/include/asm/setup.h | 12 ----- arch/arm/kernel/setup.c | 62 +++++++----------------------- arch/arm/kernel/vmlinux.lds.S | 4 - arch/arm/mach-footbridge/common.c | 7 +-- arch/arm/mm/init.c | 12 +++-- arch/arm/mm/mmu.c | 41 ++++++++++--------- 6 files changed, 48 insertions(+), 90 deletions(-)
arch/arm/include/asm/setup.h +0 -12
@@ -223,18 +223,6 @@ extern struct meminfo meminfo;#define bank_phys_end (bank) ((bank)->start + (bank)->size)#define bank_phys_size (bank) (bank)->size -/* -* Early command line parameters. -*/ -struct early_params { -const char *arg; -void (*fn)(char **p); -}; - -#define __early_param (name,fn) \ -static struct early_params __early_##fn __used \ -__attribute__((__section__(".early_param.init"))) = { name, fn } -#endif /* __KERNEL__ */ #endif
arch/arm/kernel/setup.c +16 -46
87 lines not on this page · raw message
arch/arm/kernel/vmlinux.lds.S +0 -4
@@ -43,10 +43,6 @@ SECTIONS INIT_SETUP(16) - __early_begin = .; - *(.early_param.init) - __early_end = .; - INIT_CALLS CON_INITCALL SECURITY_INITCALL
arch/arm/mach-footbridge/common.c +4 -3
@@ -32,12 +32,13 @@ unsigned int mem_fclk_21285 = 50000000;EXPORT_SYMBOL (mem_fclk_21285); -static void __init early_fclk (char **arg) +static int __init early_fclk (char *arg) { - mem_fclk_21285 =simple_strtoul (*arg, arg,0 ); + mem_fclk_21285 =simple_strtoul (arg,NULL ,0 ); +return 0 ; } -__early_param ("mem_fclk_21285=" , early_fclk); +early_param ("mem_fclk_21285" , early_fclk);static int __init parse_tag_memclk (const struct tag *tag) {
arch/arm/mm/init.c +7 -5
@@ -32,19 +32,21 @@static unsigned long phys_initrd_start__initdata =0 ;static unsigned long phys_initrd_size__initdata =0 ; -static void __init early_initrd (char **p) +static int __init early_initrd (char *p) {unsigned long start, size; +char *endp; - start =memparse (*p, p); -if (**p ==',' ) { - size =memparse ((*p) +1 , p); + start =memparse (p, &endp); +if (*endp ==',' ) { + size =memparse (endp +1 ,NULL ); phys_initrd_start = start; phys_initrd_size = size; } +return 0 ; } -__early_param ("initrd=" , early_initrd); +early_param ("initrd" , early_initrd);static int __init parse_tag_initrd (const struct tag *tag) {
arch/arm/mm/mmu.c +21 -20
92 lines not on this page · raw message
PATCH 1/3 arm: use generic infrastructure for early params
Quoted 11 lines · Jeremy Kerr
The ARM setup code includes its own parser for early params, there's also one in the generic init code.
This patch removes
__early_init(and related code) fromarch/arm/kernel/setup.c, and changes users to the genericearly_initmacro instead.The generic macro takes a char * argument, rather than char **, so we need to update the parser functions a little.
Signed-off-by Jeremy Kerr <[email protected]>
Any chance of having this in the patch system please?
Thanks.
PATCH 2/3 arm: change command_line to cmd_line, and export it
In reply to Jeremy Kerrdrivers/of/fdt expects a cmd_line symbol, while arm uses command_line. Change to the former and make accessible from setup.h, so that we can share with the fdt code.
This means a change in section from .init.data to .data
--- arch/arm/include/asm/setup.h | 6 ++++-- arch/arm/kernel/setup.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-)
arch/arm/include/asm/setup.h +4 -2
@@ -16,8 +16,6 @@#include <linux/types.h> -#define COMMAND_LINE_SIZE 1024 -/* The list ends with an ATAG_NONE node. */ #define ATAG_NONE 0x00000000
@@ -223,6 +221,10 @@ extern struct meminfo meminfo;#define bank_phys_end (bank) ((bank)->start + (bank)->size)#define bank_phys_size (bank) (bank)->size +#define COMMAND_LINE_SIZE 1024 + +extern char cmd_line[COMMAND_LINE_SIZE ]; +#endif /* __KERNEL__ */ #endif
arch/arm/kernel/setup.c +4 -4
@@ -117,7 +117,7 @@ EXPORT_SYMBOL(elf_platform);static const char *cpu_name;static const char *machine_name; -static char __initdata command_line[COMMAND_LINE_SIZE ]; +char cmd_line[COMMAND_LINE_SIZE ];static char default_command_line[COMMAND_LINE_SIZE ]__initdata =CONFIG_CMDLINE ;static union {char c[4 ];unsigned long l; } endian_test__initdata = { {'l' ,'?' ,'?' ,'b' } };
@@ -706,9 +706,9 @@ void __init setup_arch(char **cmdline_p)/* parse_early_param needs a boot_command_line */ strlcpy (boot_command_line, from,COMMAND_LINE_SIZE ); -/* populate command_line too for later use, preserving boot_command_line */ -strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE ); - *cmdline_p = command_line; +/* populate cmd_line too for later use, preserving boot_command_line */ +strlcpy (cmd_line, boot_command_line,COMMAND_LINE_SIZE ); + *cmdline_p = cmd_line;parse_early_param ();
PATCH 2/3 arm: change command_line to cmd_line, and export it
Quoted 3 lines · Jeremy Kerr
drivers/of/fdtexpects acmd_linesymbol, while arm usescommand_line. Change to the former and make accessible fromsetup.h, so that we can share with the fdt code.
Until the dt code gets merged, I'd prefer to keep the 'command_line' or 'cmd_line' static. Also, please leave 'COMMAND_LINE_SIZE' visible to stuff outside kernel-space (it could be used by boot loaders, which borrow this file.)
In other words, can I have a patch in the patch system which just does the renaming?
PATCH 3/3 arm: export arm_add_memory
In reply to Jeremy KerrWe'd like to add memory from the device tree, so make arm_add_memory non-static and add a prototype in setup.h
--- arch/arm/include/asm/setup.h | 2 ++ arch/arm/kernel/setup.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/include/asm/setup.h +2 -0
@@ -225,6 +225,8 @@ extern struct meminfo meminfo;extern char cmd_line[COMMAND_LINE_SIZE ]; +extern int arm_add_memory (unsigned long start,unsigned long size); +#endif /* __KERNEL__ */ #endif
arch/arm/kernel/setup.c +1 -1
@@ -383,7 +383,7 @@ static struct machine_desc * __init setup_machine(unsigned int nr)return list; } -static int __init arm_add_memory (unsigned long start,unsigned long size) +int __init arm_add_memory (unsigned long start,unsigned long size) {struct membank *bank = &meminfo.bank[meminfo.nr_banks];
PATCH 3/3 arm: export arm_add_memory
Quoted 4 lines · Jeremy Kerr
We'd like to add memory from the device tree, so make
arm_add_memorynon-static and add a prototype insetup.hSigned-off-by Jeremy Kerr <[email protected]>
I've been thinking about this a bit, and rather than indirecting the DT stuff through an inline function, I think we should rename the function instead to something that's compatible with DT. Yes, that means changing the arguments, but in the longer term, we're likely to need to pass more than 32-bits of memory start/size to the kernel.
PATCH 3/3 arm: export arm_add_memory
Russell,
Quoted 5 lines
I've been thinking about this a bit, and rather than indirecting the DT stuff through an inline function, I think we should rename the function instead to something that's compatible with DT. Yes, that means changing the arguments, but in the longer term, we're likely to need to pass more than 32-bits of memory start/size to the kernel.
Any thoughts on using the generic LMB infrastructure to manage this instead?
The DT code is written for arches that have LMB support, so the main reason for this patch is to provide a hook into non-LMB arches.
Cheers,
Jeremy
PATCH 3/3 arm: export arm_add_memory
Quoted 8 lines · Jeremy Kerr
Russell,
Quoted 5 lines
I've been thinking about this a bit, and rather than indirecting the DT stuff through an inline function, I think we should rename the function instead to something that's compatible with DT. Yes, that means changing the arguments, but in the longer term, we're likely to need to pass more than 32-bits of memory start/size to the kernel.
Quoted 4 lines
Any thoughts on using the generic LMB infrastructure to manage this instead?
The DT code is written for arches that have LMB support, so the main reason for this patch is to provide a hook into non-LMB arches.
Maybe when we go to 64-bit memory; until that time it looks like it doesn't meet our needs and would be additional bloat.
It certainly would need some modification - the auto-coalescing which it currently does would be a problem - we explicitly split our memory information if it overlaps a lowmem/highmem boundary, and where it splits sparsemem/discontig zones. We also sort our memory information into ascending address, which LMB also doesn't do.
We certainly don't need the lmb allocation stuff, and I don't understand why LMB is trying to implement this functionality. Bootmem was supposed to get around the problem of early kernel allocations (before the main page allocator and therefore kmalloc) were up and running - and it does this fairly well. The only down-side to it is you need to find some way of placing its bitmap for registering the allocated/free areas. That's fairly easy to do (and we've done it on ARM with no problems.)
So why do we need an early-early allocator? (Should we expect to see in a few years an early-early-early allocator and an early-early-early-early allocator as well? :P)