[PATCH 1/3] powerpc/prom: Drop support for old FDT versions

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3004d

4 messages, 2 authors, 2018-05-16 · open the first message on its own page

[PATCH 1/3] powerpc/prom: Drop support for old FDT versions

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-05-09 13:42:38

In commit e6a6928c3ea1 ("of/fdt: Convert FDT functions to use
libfdt") (Apr 2014), the generic flat device tree code dropped support
for flat device tree's older than version 0x10 (16).

We still have code in our CPU scanning to cope with flat device tree
versions earlier than 2, which can now never trigger, so drop it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 9dbed488aba1..05e7fb47a7a4 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -332,25 +332,10 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	 * NOTE: This must match the parsing done in smp_setup_cpu_maps.
 	 */
 	for (i = 0; i < nthreads; i++) {
-		/*
-		 * version 2 of the kexec param format adds the phys cpuid of
-		 * booted proc.
-		 */
-		if (fdt_version(initial_boot_params) >= 2) {
-			if (be32_to_cpu(intserv[i]) ==
-			    fdt_boot_cpuid_phys(initial_boot_params)) {
-				found = boot_cpu_count;
-				found_thread = i;
-			}
-		} else {
-			/*
-			 * Check if it's the boot-cpu, set it's hw index now,
-			 * unfortunately this format did not support booting
-			 * off secondary threads.
-			 */
-			if (of_get_flat_dt_prop(node,
-					"linux,boot-cpu", NULL) != NULL)
-				found = boot_cpu_count;
+		if (be32_to_cpu(intserv[i]) ==
+			fdt_boot_cpuid_phys(initial_boot_params)) {
+			found = boot_cpu_count;
+			found_thread = i;
 		}
 #ifdef CONFIG_SMP
 		/* logical cpu id is always 0 on UP kernels */
-- 
2.14.1

[PATCH 2/3] powerpc/prom: Save the boot CPU hardware id in a local

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-05-09 13:42:40

In early_init_dt_scan_cpus() we find the boot CPU, and get it's
hardware CPU number. Currently we do that by using the thread number
and doing be32_to_cpu(instserv[i]) three times.

The endian flips are not very efficient, but the main concern is just
that it's ugly to do the same flip in three places. Instead just put
the endian flipped value in a local and use it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 05e7fb47a7a4..9edb0d0af986 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -313,8 +313,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	const __be32 *intserv;
 	int i, nthreads;
 	int len;
-	int found = -1;
-	int found_thread = 0;
+	int found = -1, found_hwid = -1;
 
 	/* We are scanning "cpu" nodes only */
 	if (type == NULL || strcmp(type, "cpu") != 0)
@@ -332,11 +331,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	 * NOTE: This must match the parsing done in smp_setup_cpu_maps.
 	 */
 	for (i = 0; i < nthreads; i++) {
-		if (be32_to_cpu(intserv[i]) ==
-			fdt_boot_cpuid_phys(initial_boot_params)) {
+		found_hwid = be32_to_cpu(intserv[i]);
+		if (found_hwid == fdt_boot_cpuid_phys(initial_boot_params))
 			found = boot_cpu_count;
-			found_thread = i;
-		}
 #ifdef CONFIG_SMP
 		/* logical cpu id is always 0 on UP kernels */
 		boot_cpu_count++;
@@ -347,8 +344,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	if (found < 0)
 		return 0;
 
-	DBG("boot cpu: logical %d physical %d\n", found,
-	    be32_to_cpu(intserv[found_thread]));
+	DBG("boot cpu: logical %d physical %d\n", found, found_hwid);
 	boot_cpuid = found;
 
 	/*
@@ -389,7 +385,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 		cur_cpu_spec->cpu_features |= CPU_FTR_SMT;
 	allocate_paca(boot_cpuid);
 #endif
-	set_hard_smp_processor_id(found, be32_to_cpu(intserv[found_thread]));
+	set_hard_smp_processor_id(found, found_hwid);
 
 	return 0;
 }
-- 
2.14.1

[PATCH 3/3] powerpc/prom: Clean up local variables in early_init_dt_scan_cpus()

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2018-05-09 13:42:40

This is cosmetic, but the current arrangement is hell ugly, so clean
it up.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 9edb0d0af986..0e47fb85f47d 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -308,12 +308,11 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 					  const char *uname, int depth,
 					  void *data)
 {
-	const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
-	const __be32 *prop;
-	const __be32 *intserv;
-	int i, nthreads;
-	int len;
-	int found = -1, found_hwid = -1;
+	int i, len, nthreads, found_hwid, found;
+	const __be32 *prop, *intserv;
+	const char *type;
+
+	type = of_get_flat_dt_prop(node, "device_type", NULL);
 
 	/* We are scanning "cpu" nodes only */
 	if (type == NULL || strcmp(type, "cpu") != 0)
@@ -330,6 +329,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 	 * Now see if any of these threads match our boot cpu.
 	 * NOTE: This must match the parsing done in smp_setup_cpu_maps.
 	 */
+	found = found_hwid = -1;
 	for (i = 0; i < nthreads; i++) {
 		found_hwid = be32_to_cpu(intserv[i]);
 		if (found_hwid == fdt_boot_cpuid_phys(initial_boot_params))
-- 
2.14.1

Re: [1/3] powerpc/prom: Drop support for old FDT versions

From: Michael Ellerman <hidden>
Date: 2018-05-16 13:38:48

On Wed, 2018-05-09 at 13:42:27 UTC, Michael Ellerman wrote:
In commit e6a6928c3ea1 ("of/fdt: Convert FDT functions to use
libfdt") (Apr 2014), the generic flat device tree code dropped support
for flat device tree's older than version 0x10 (16).

We still have code in our CPU scanning to cope with flat device tree
versions earlier than 2, which can now never trigger, so drop it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Applied to powerpc next.

https://git.kernel.org/powerpc/c/89c190627257a38d5e4d7cb3e5382f

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help