MIPS: Simplify ELF appended dtb handling
Subsystems (2)
cover MIPS: Simplify ELF appended dtb handling
Hi,
This patch series simplifies and cleans up the handling of CONFIG_MIPS_ELF_APPENDED_DTB in the MIPS tree.
Specifically, it makes sure that the dtb appears in 'fw_passed_dtb' also under CONFIG_MIPS_ELF_APPENDED_DTB=y.
This allows to remove special platform code that handled the ELF appended dtb case, and replace it with the generic appended dtb case (fw_passed_dtb).
There's also a bonus: platforms that already handle 'fw_passed_dtb', gain now automatic support for detecting a DT blob under CONFIG_MIPS_ELF_APPENDED_DTB=y.
Patches:
- Patch 1 adds only comments (to make the file more readable for patch 2).
- Patch 2 fixes 'fw_passed_dtb' under CONFIG_MIPS_ELF_APPENDED_DTB=y.
- Patch 3 simplifies CONFIG_MIPS_ELF_APPENDED_DTB handling on the BMIPS platform.
- Patch 4 simplifies CONFIG_MIPS_ELF_APPENDED_DTB handling on the Octeon platform.
Patches 3 and 4 depend on patch 2.
The patches are on top of v4.18.
The patches are also available at:
https://github.com/yashac3/linux-rtl8186/commits/elf_appended_dtb_changes_on_4_18
Please review.
Thanks,
Yasha
Yasha Cherikovsky (4):
MIPS/head: Add comments after #endif and #else
MIPS/head: Store ELF appended dtb in a global variable too
MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
MIPS: Octeon: Remove special handling of
CONFIG_MIPS_ELF_APPENDED_DTB=y
arch/mips/bmips/setup.c | 9 +-------- arch/mips/cavium-octeon/setup.c | 10 +++------- arch/mips/kernel/head.S | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 23 deletions(-)
Signature · 1 line
2.19.0
PATCH 1/4 MIPS/head: Add comments after #endif and #else
It makes the code more readable, especially in the nested ifdefs.
--- arch/mips/kernel/head.S | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/mips/kernel/head.S +7 -7
@@ -77,7 +77,7 @@ EXPORT(_stext) */ FEXPORT(__kernel_entry) j kernel_entry -#endif +#endif /* CONFIG_BOOT_RAW */ __REF
@@ -99,19 +99,19 @@ NESTED(kernel_entry, 16, sp) # kernel entry point #ifdef CONFIG_CPU_BIG_ENDIAN li t1, 0xd00dfeed -#else +#else /* !CONFIG_CPU_BIG_ENDIAN */ li t1, 0xedfe0dd0 -#endif +#endif /* !CONFIG_CPU_BIG_ENDIAN */ lw t0, (t2) beq t0, t1, dtb_found -#endif +#endif /* CONFIG_MIPS_RAW_APPENDED_DTB */ li t1, -2 move t2, a1 beq a0, t1, dtb_found li t2, 0 dtb_found: -#endif +#endif /* CONFIG_USE_OF */ PTR_LA t0, __bss_start # clear .bss LONG_S zero, (t0) PTR_LA t1, __bss_stop - LONGSIZE
@@ -156,9 +156,9 @@ dtb_found: * newly sync'd icache. */ jr.hb v0 -#else +#else /* !CONFIG_RELOCATABLE */ j start_kernel -#endif +#endif /* !CONFIG_RELOCATABLE */ END(kernel_entry) #ifdef CONFIG_SMP
Signature · 1 line
2.19.0
PATCH 2/4 MIPS/head: Store ELF appended dtb in a global variable too
In reply to Yasha CherikovskySince commit 15f37e158892 ("MIPS: store the appended
dtb address in a variable"),
in kernels with MIPS_RAW_APPENDED_DTB=y, the early boot code detects the dtb and stores it in the 'fw_passed_dtb' variable.
However, the dtb is not stored in 'fw_passed_dtb' in kernels with MIPS_ELF_APPENDED_DTB=y.
Under MIPS_ELF_APPENDED_DTB=y, the dtb is also located in the __appended_dtb section, so we just need to update the #ifdef.
This will allow to access the dtb in a more uniform way.
--- arch/mips/kernel/head.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/mips/kernel/head.S +4 -2
@@ -94,7 +94,9 @@ NESTED(kernel_entry, 16, sp) # kernel entry point 0: #ifdef CONFIG_USE_OF -#ifdef CONFIG_MIPS_RAW_APPENDED_DTB +#if defined(CONFIG_MIPS_RAW_APPENDED_DTB) || \ + defined(CONFIG_MIPS_ELF_APPENDED_DTB) + PTR_LA t2, __appended_dtb #ifdef CONFIG_CPU_BIG_ENDIAN
@@ -104,7 +106,7 @@ NESTED(kernel_entry, 16, sp) # kernel entry point #endif /* !CONFIG_CPU_BIG_ENDIAN */ lw t0, (t2) beq t0, t1, dtb_found -#endif /* CONFIG_MIPS_RAW_APPENDED_DTB */ +#endif /* CONFIG_MIPS_RAW_APPENDED_DTB || CONFIG_MIPS_ELF_APPENDED_DTB */ li t1, -2 move t2, a1 beq a0, t1, dtb_found
Signature · 1 line
2.19.0
PATCH 3/4 MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
In reply to Yasha CherikovskyThe ELF appended dtb can be accessed now via 'fw_passed_dtb'.
--- arch/mips/bmips/setup.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
arch/mips/bmips/setup.c +1 -8
@@ -153,8 +153,6 @@ void __init plat_time_init(void) mips_hpt_frequency = freq; } -extern const char __appended_dtb; -void __init plat_mem_setup (void ) {void *dtb;
@@ -164,15 +162,10 @@ void __init plat_mem_setup(void) ioport_resource.start =0 ; ioport_resource.end = ~0 ; -#ifdef CONFIG_MIPS_ELF_APPENDED_DTB -if (!fdt_check_header (&__appended_dtb)) - dtb = (void *)&__appended_dtb; - else -#endif /* intended to somewhat resemble ARM; see Documentation/arm/Booting */ if (fw_arg0 ==0 && fw_arg1 ==0xffffffff ) dtb =phys_to_virt (fw_arg2); -else if (fw_passed_dtb)/* UHI interface */ +else if (fw_passed_dtb)/* UHI interface or appended dtb */ dtb = (void *)fw_passed_dtb;else if (__dtb_start != __dtb_end) dtb = (void *)__dtb_start;
Signature · 1 line
2.19.0
Re: [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
Quoted 3 lines · Yasha Cherikovsky
The ELF appended dtb can be accessed now via '
fw_passed_dtb'.Signed-off-by Yasha Cherikovsky <[email protected]>
Quoted 42 lines
Cc Kevin Cernekee <[email protected]>Cc Florian Fainelli <[email protected]>Cc Ralf Baechle <[email protected]>Cc Paul Burton <[email protected]>Cc James Hogan <[email protected]>--- arch/mips/bmips/setup.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)arch/mips/bmips/setup.c +1
-8@@ -153,8 +153,6 @@ void __init plat_time_init(void) mips_hpt_frequency = freq; } -extern const char __appended_dtb; -void __init plat_mem_setup (void ) {void *dtb;@@ -164,15 +162,10 @@ void __init plat_mem_setup(void) ioport_resource.start =0 ; ioport_resource.end = ~0 ; -#ifdef CONFIG_MIPS_ELF_APPENDED_DTB -if (!fdt_check_header (&__appended_dtb)) - dtb = (void *)&__appended_dtb; - else -#endif /* intended to somewhat resemble ARM; see Documentation/arm/Booting */ if (fw_arg0 ==0 && fw_arg1 ==0xffffffff ) dtb =phys_to_virt (fw_arg2); -else if (fw_passed_dtb)/* UHI interface */ +else if (fw_passed_dtb)/* UHI interface or appended dtb */ dtb = (void *)fw_passed_dtb;else if (__dtb_start != __dtb_end) dtb = (void *)__dtb_start;
Signature · 1 line
Florian
PATCH 4/4 MIPS: Octeon: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
In reply to Yasha CherikovskyThe ELF appended dtb can be accessed now via 'fw_passed_dtb'.
Since raw appended dtb is accessed via that variable too, this now effectively allows to boot with CONFIG_MIPS_RAW_APPENDED_DTB=y on Octeon.
--- arch/mips/cavium-octeon/setup.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/mips/cavium-octeon/setup.c +3 -7
@@ -1156,7 +1156,6 @@ void __init prom_free_prom_memory(void)void __init octeon_fill_mac_addresses (void );int octeon_prune_device_tree (void ); -extern const char __appended_dtb;extern const char __dtb_octeon_3xxx_begin;extern const char __dtb_octeon_68xx_begin;void __init device_tree_init (void )
@@ -1165,15 +1164,12 @@ void __init device_tree_init(void)bool do_prune;bool fill_mac; -#ifdef CONFIG_MIPS_ELF_APPENDED_DTB -if (!fdt_check_header (&__appended_dtb)) { - fdt = &__appended_dtb; +if (fw_passed_dtb) { + fdt = (void *)fw_passed_dtb; do_prune = false; fill_mac = true;pr_info ("Using appended Device Tree.\n" ); - } else -#endif -if (octeon_bootinfo->minor_version >=3 && octeon_bootinfo->fdt_addr) { + }else if (octeon_bootinfo->minor_version >=3 && octeon_bootinfo->fdt_addr) { fdt =phys_to_virt (octeon_bootinfo->fdt_addr);if (fdt_check_header (fdt))panic ("Corrupt Device Tree passed to kernel." );
Signature · 1 line
2.19.0
Hi Yasha,
Quoted 8 lines · Yasha Cherikovsky
Hi,
This patch series simplifies and cleans up the handling of
CONFIG_MIPS_ELF_APPENDED_DTBin the MIPS tree.Specifically, it makes sure that the dtb appears in '
fw_passed_dtb' also underCONFIG_MIPS_ELF_APPENDED_DTB=y.
Quoted 7 lines
This allows to remove special platform code that handled the ELF appended dtb case, and replace it with the generic appended dtb case (
fw_passed_dtb).There's also a bonus: platforms that already handle '
fw_passed_dtb', gain now automatic support for detecting a DT blob underCONFIG_MIPS_ELF_APPENDED_DTB=y.
Thanks - applied to mips-next for 4.20.
Paul
Hi Paul,
Quoted 15 lines · Paul Burton
Hi Yasha,
Quoted 12 lines · Yasha Cherikovsky
Hi,
This patch series simplifies and cleans up the handling of
CONFIG_MIPS_ELF_APPENDED_DTBin the MIPS tree.Specifically, it makes sure that the dtb appears in '
fw_passed_dtb' also underCONFIG_MIPS_ELF_APPENDED_DTB=y.This allows to remove special platform code that handled the ELF appended dtb case, and replace it with the generic appended dtb case (
fw_passed_dtb).
Quoted 7 lines
Quoted 3 lines
There's also a bonus: platforms that already handle '
fw_passed_dtb', gain now automatic support for detecting a DT blob underCONFIG_MIPS_ELF_APPENDED_DTB=y.Thanks - applied to mips-next for 4.20.
Paul
Thanks!
Yasha