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
Cc: [email protected]
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(-)
--
2.19.0
The ELF appended dtb can be accessed now via 'fw_passed_dtb'.
Signed-off-by: Yasha Cherikovsky <[email protected]>
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]>
Cc: [email protected]
Cc: [email protected]
---
arch/mips/bmips/setup.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c
index 3b6f687f177c..b71b6eaaf7ed 100644
--- a/arch/mips/bmips/setup.c
+++ b/arch/mips/bmips/setup.c
@@ -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;
--
2.19.0
It makes the code more readable, especially in the nested ifdefs.
Signed-off-by: Yasha Cherikovsky <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: James Hogan <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/mips/kernel/head.S | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index d1bb506adc10..fef2f61c5394 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -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
--
2.19.0
Since 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.
Fixes: 15f37e158892 ("MIPS: store the appended dtb address in a variable")
Signed-off-by: Yasha Cherikovsky <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: James Hogan <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/mips/kernel/head.S | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index fef2f61c5394..351d40fe0859 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -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
--
2.19.0
The 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.
Signed-off-by: Yasha Cherikovsky <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: James Hogan <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/mips/cavium-octeon/setup.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index a8034d0dcade..3c26054ce72b 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -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.");
--
2.19.0
On 9/25/2018 11:08 AM, Yasha Cherikovsky wrote:
> The ELF appended dtb can be accessed now via 'fw_passed_dtb'.
>
> Signed-off-by: Yasha Cherikovsky <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
> 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]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> arch/mips/bmips/setup.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c
> index 3b6f687f177c..b71b6eaaf7ed 100644
> --- a/arch/mips/bmips/setup.c
> +++ b/arch/mips/bmips/setup.c
> @@ -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;
>
--
Florian
Hi Yasha,
On Tue, Sep 25, 2018 at 09:08:21PM +0300, Yasha Cherikovsky wrote:
> 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.
Thanks - applied to mips-next for 4.20.
Paul
Hi Paul,
On Wed, 2018-09-26 at 20:36 +0000, Paul Burton wrote:
> Hi Yasha,
>
> On Tue, Sep 25, 2018 at 09:08:21PM +0300, Yasha Cherikovsky wrote:
> > 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.
>
> Thanks - applied to mips-next for 4.20.
>
> Paul
Thanks!
Yasha