linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] MIPS: Simplify ELF appended dtb handling
@ 2018-09-25 18:08 Yasha Cherikovsky
  2018-09-25 18:08 ` [PATCH 1/4] MIPS/head: Add comments after #endif and #else Yasha Cherikovsky
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Yasha Cherikovsky @ 2018-09-25 18:08 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips
  Cc: Yasha Cherikovsky, linux-kernel

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: linux-kernel@vger.kernel.org


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] MIPS/head: Add comments after #endif and #else
  2018-09-25 18:08 [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Yasha Cherikovsky
@ 2018-09-25 18:08 ` Yasha Cherikovsky
  2018-09-25 18:08 ` [PATCH 2/4] MIPS/head: Store ELF appended dtb in a global variable too Yasha Cherikovsky
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Yasha Cherikovsky @ 2018-09-25 18:08 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips
  Cc: Yasha Cherikovsky, linux-kernel

It makes the code more readable, especially in the nested ifdefs.

Signed-off-by: Yasha Cherikovsky <yasha.che3@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] MIPS/head: Store ELF appended dtb in a global variable too
  2018-09-25 18:08 [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Yasha Cherikovsky
  2018-09-25 18:08 ` [PATCH 1/4] MIPS/head: Add comments after #endif and #else Yasha Cherikovsky
@ 2018-09-25 18:08 ` Yasha Cherikovsky
  2018-09-25 18:08 ` [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y Yasha Cherikovsky
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Yasha Cherikovsky @ 2018-09-25 18:08 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips
  Cc: Yasha Cherikovsky, linux-kernel

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 <yasha.che3@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
  2018-09-25 18:08 [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Yasha Cherikovsky
  2018-09-25 18:08 ` [PATCH 1/4] MIPS/head: Add comments after #endif and #else Yasha Cherikovsky
  2018-09-25 18:08 ` [PATCH 2/4] MIPS/head: Store ELF appended dtb in a global variable too Yasha Cherikovsky
@ 2018-09-25 18:08 ` Yasha Cherikovsky
  2018-09-26  2:52   ` Florian Fainelli
  2018-09-25 18:08 ` [PATCH 4/4] MIPS: Octeon: " Yasha Cherikovsky
  2018-09-26 20:36 ` [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Paul Burton
  4 siblings, 1 reply; 8+ messages in thread
From: Yasha Cherikovsky @ 2018-09-25 18:08 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips
  Cc: Yasha Cherikovsky, Kevin Cernekee, Florian Fainelli, linux-kernel

The ELF appended dtb can be accessed now via 'fw_passed_dtb'.

Signed-off-by: Yasha Cherikovsky <yasha.che3@gmail.com>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] MIPS: Octeon: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
  2018-09-25 18:08 [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Yasha Cherikovsky
                   ` (2 preceding siblings ...)
  2018-09-25 18:08 ` [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y Yasha Cherikovsky
@ 2018-09-25 18:08 ` Yasha Cherikovsky
  2018-09-26 20:36 ` [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Paul Burton
  4 siblings, 0 replies; 8+ messages in thread
From: Yasha Cherikovsky @ 2018-09-25 18:08 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips
  Cc: Yasha Cherikovsky, linux-kernel

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 <yasha.che3@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y
  2018-09-25 18:08 ` [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y Yasha Cherikovsky
@ 2018-09-26  2:52   ` Florian Fainelli
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2018-09-26  2:52 UTC (permalink / raw)
  To: Yasha Cherikovsky, Ralf Baechle, Paul Burton, James Hogan, linux-mips
  Cc: Kevin Cernekee, linux-kernel, Jonas Gorski



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 <yasha.che3@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> Cc: Kevin Cernekee <cernekee@gmail.com>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paul.burton@mips.com>
> Cc: James Hogan <jhogan@kernel.org>
> Cc: linux-mips@linux-mips.org
> Cc: linux-kernel@vger.kernel.org
> ---
>   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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] MIPS: Simplify ELF appended dtb handling
  2018-09-25 18:08 [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Yasha Cherikovsky
                   ` (3 preceding siblings ...)
  2018-09-25 18:08 ` [PATCH 4/4] MIPS: Octeon: " Yasha Cherikovsky
@ 2018-09-26 20:36 ` Paul Burton
  2018-09-26 20:52   ` Yasha Cherikovsky
  4 siblings, 1 reply; 8+ messages in thread
From: Paul Burton @ 2018-09-26 20:36 UTC (permalink / raw)
  To: Yasha Cherikovsky; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] MIPS: Simplify ELF appended dtb handling
  2018-09-26 20:36 ` [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Paul Burton
@ 2018-09-26 20:52   ` Yasha Cherikovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Yasha Cherikovsky @ 2018-09-26 20:52 UTC (permalink / raw)
  To: Paul Burton; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-26 20:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 18:08 [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Yasha Cherikovsky
2018-09-25 18:08 ` [PATCH 1/4] MIPS/head: Add comments after #endif and #else Yasha Cherikovsky
2018-09-25 18:08 ` [PATCH 2/4] MIPS/head: Store ELF appended dtb in a global variable too Yasha Cherikovsky
2018-09-25 18:08 ` [PATCH 3/4] MIPS: BMIPS: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y Yasha Cherikovsky
2018-09-26  2:52   ` Florian Fainelli
2018-09-25 18:08 ` [PATCH 4/4] MIPS: Octeon: " Yasha Cherikovsky
2018-09-26 20:36 ` [PATCH 0/4] MIPS: Simplify ELF appended dtb handling Paul Burton
2018-09-26 20:52   ` Yasha Cherikovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).