Skip to contentSkip to conversation

arm/arm64: few fixes

PATCH Applied Andrew Jones 1 participant 7 messages Dec 14, 2016 – Dec 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover arm/arm64: few fixes

Fix1, patches 1: SKIP if pci-testdev isn't available rather than FAIL
Fix2, patches 4,5: 64-bit MPIDRs will have 2 32-bit regs in DT Fix3, patches 2,3: While doing Fix2 I noticed a need for different/strict
setup order

Andrew Jones (5):
arm/pci-test: skip on pci/pci-testdev probe failure lib/arm/setup: fix and comment init order lib/powerpc/setup: comment init dependencies
devicetree: cpu nodes may have 64-bit regs arm/arm64: support 64-bit MPIDRs

 lib/arm/asm/processor.h   |  2 +-
 lib/arm/asm/setup.h       |  2 +-
 lib/arm64/asm/processor.h |  2 +-
 lib/devicetree.h          |  2 +-
 lib/arm/setup.c           | 13 +++++++++----
 lib/devicetree.c          |  9 +++++++--
 lib/powerpc/setup.c       |  6 +++++-
 lib/powerpc/smp.c         |  2 +-
 arm/pci-test.c            | 13 +++++++++----
 powerpc/tm.c              |  2 +-
 10 files changed, 36 insertions(+), 17 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/5 arm/pci-test: skip on pci/pci-testdev probe failure

Some configurations don't have pci or pci-testdev. This patch avoids saying FAIL in those cases. Instead we get SKIP.

Cc Alexander Gordeev <[email protected]>
---
 arm/pci-test.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
arm/pci-test.c +9 -4
index 10a367de5357..cf128ac1b032 100644
@@ -14,14 +14,19 @@ int main(void)
 {
 	int ret;
 
-	if (!pci_probe())
-		report_abort("PCI bus probing failed\n");
+	if (!pci_probe()) {
+		printf("PCI bus probing failed, skipping tests...\n");
+		return report_summary();
+	}
 
 	pci_print();
 
 	ret = pci_testdev();
-	report("PCI test device passed %d/%d tests",
-		ret >= NR_TESTS, ret > 0 ? ret : 0, NR_TESTS);
+	if (ret == -1)
+		report_skip("No PCI test device");
+	else
+		report("PCI test device passed %d/%d tests",
+			ret >= NR_TESTS, ret > 0 ? ret : 0, NR_TESTS);
 
 	return report_summary();
 }
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/5 lib/arm/setup: fix and comment init order

In reply to Andrew Jones

While reading code I noticed we need to call thread_info_init before mem_init to be correct. In practice it hasn't mattered because cpu0 is calling mem_init, and it's cpu index is 0, which is what a fresh first boot would have it be anyway. With reset tests (coming soon) combined with mmu tests (hopefully coming someday) it could be problematic though, so let's fix it. Additionally comment the order to make sure we maintain it. The io_init dependency on mem_init is because io_init calls init functions that make use of heap allocation.

---
 lib/arm/setup.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/arm/setup.c +7 -2
index e52a25abd722..1751c3997c53 100644
@@ -126,12 +126,17 @@ void setup(const void *fdt)
 	ret = dt_init(&stacktop);
 	assert(ret == 0);
 
-	mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size));
-	io_init();
 	cpu_init();
 
+	/* cpu_init must be called before thread_info_init */
 	thread_info_init(current_thread_info(), 0);
 
+	/* thread_info_init must be called before mem_init */
+	mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size));
+
+	/* mem_init must be called before io_init */
+	io_init();
+
 	ret = dt_get_bootargs(&bootargs);
 	assert(ret == 0);
 	setup_args_progname(bootargs);
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/5 lib/powerpc/setup: comment init dependencies

In reply to Andrew Jones

cpu_init must be called before mem_init because cpu_init determines the cache-line sizes. Currently io_init has no dependency on mem_init, but io_init should be allowed to use heap allocation, and someday it may, so we proactively comment it.

Cc Laurent Vivier <[email protected]>
Cc Thomas Huth <[email protected]>
---
 lib/powerpc/setup.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/powerpc/setup.c +4 -0
index 9153f7bebc6a..0e776235e22d 100644
@@ -168,7 +168,11 @@ void setup(const void *fdt)
 	assert(ret == 0);
 
 	cpu_init();
+
+	/* cpu_init must be called before mem_init */
 	mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size));
+
+	/* mem_init must be called before io_init */
 	io_init();
 
 	ret = dt_get_bootargs(&bootargs);
Signature · 1 line
2.9.3
#4 lore raw

PATCH 4/5 devicetree: cpu nodes may have 64-bit regs

In reply to Andrew Jones
---
 lib/devicetree.h    | 2 +-
 lib/arm/setup.c     | 2 +-
 lib/devicetree.c    | 9 +++++++--
 lib/powerpc/setup.c | 2 +-
 lib/powerpc/smp.c   | 2 +-
 powerpc/tm.c        | 2 +-
 6 files changed, 12 insertions(+), 7 deletions(-)
lib/devicetree.h +1 -1
index 315ba948e7cc..0083587633d4 100644
@@ -234,7 +234,7 @@ extern int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs);
  *  - zero on success
  *  - a negative FDT_ERR_* value on failure
  */
-extern int dt_for_each_cpu_node(void (*func)(int fdtnode, u32 regval,
+extern int dt_for_each_cpu_node(void (*func)(int fdtnode, u64 regval,
 				void *info), void *info);
 
 #endif /* _DEVICETREE_H_ */
lib/arm/setup.c +1 -1
index 1751c3997c53..ac3fadb07828 100644
@@ -40,7 +40,7 @@ int mpidr_to_cpu(uint64_t mpidr)
 	return -1;
 }
 
-static void cpu_set(int fdtnode __unused, u32 regval, void *info __unused)
+static void cpu_set(int fdtnode __unused, u64 regval, void *info __unused)
 {
 	int cpu = nr_cpus++;
 
lib/devicetree.c +7 -2
index 26232a3e61ab..671c64a2ca51 100644
@@ -202,13 +202,14 @@ int dt_get_memory_params(struct dt_pbus_reg *regs, int nr_regs)
 	return node != -FDT_ERR_NOTFOUND ? node : nr;
 }
 
-int dt_for_each_cpu_node(void (*func)(int fdtnode, u32 regval, void *info),
+int dt_for_each_cpu_node(void (*func)(int fdtnode, u64 regval, void *info),
 			 void *info)
 {
 	const struct fdt_property *prop;
 	int cpus, cpu, ret, len;
 	struct dt_reg raw_reg;
 	u32 nac, nsc;
+	u64 regval;
 
 	cpus = fdt_path_offset(fdt, "/cpus");
 	if (cpus < 0)
@@ -233,7 +234,11 @@ int dt_for_each_cpu_node(void (*func)(int fdtnode, u32 regval, void *info),
 		if (ret < 0)
 			return ret;
 
-		func(cpu, raw_reg.address_cells[0], info);
+		regval = raw_reg.address_cells[0];
+		if (nac == 2)
+			regval = (regval << 32) | raw_reg.address_cells[1];
+
+		func(cpu, regval, info);
 	}
 
 	return 0;
lib/powerpc/setup.c +1 -1
index 0e776235e22d..d56de36410c7 100644
@@ -40,7 +40,7 @@ struct cpu_set_params {
 
 static char exception_stack[NR_CPUS][EXCEPTION_STACK_SIZE];
 
-static void cpu_set(int fdtnode, u32 regval, void *info)
+static void cpu_set(int fdtnode, u64 regval, void *info)
 {
 	static bool read_common_info = false;
 	struct cpu_set_params *params = info;
lib/powerpc/smp.c +1 -1
index 946ad26b12ae..e18894bb17e8 100644
@@ -75,7 +75,7 @@ struct start_threads start_cpu(int cpu_node, secondary_entry_fn entry,
 	return (struct start_threads) { nr_threads, nr_started };
 }
 
-static void start_each_secondary(int fdtnode, u32 regval __unused, void *info)
+static void start_each_secondary(int fdtnode, u64 regval __unused, void *info)
 {
 	struct secondary_entry_data *datap = info;
 	struct start_threads ret = start_cpu(fdtnode, datap->entry, datap->r3);
powerpc/tm.c +1 -1
index b611061209e8..ff7b2f957a37 100644
@@ -14,7 +14,7 @@
 #include <devicetree.h>
 
 /* Check "ibm,pa-features" property of a CPU node for the TM flag */
-static void cpu_has_tm(int fdtnode, u32 regval __unused, void *ptr)
+static void cpu_has_tm(int fdtnode, u64 regval __unused, void *ptr)
 {
 	const struct fdt_property *prop;
 	int plen;
Signature · 1 line
2.9.3
#5 lore raw

PATCH 5/5 arm/arm64: support 64-bit MPIDRs

In reply to Andrew Jones
---
 lib/arm/asm/processor.h   | 2 +-
 lib/arm/asm/setup.h       | 2 +-
 lib/arm64/asm/processor.h | 2 +-
 lib/arm/setup.c           | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
lib/arm/asm/processor.h +1 -1
index 6dc1472468dd..a8c4628da818 100644
@@ -46,7 +46,7 @@ static inline void local_irq_disable(void)
 }
 
 #define MPIDR __ACCESS_CP15(c0, 0, c0, 5)
-static inline unsigned int get_mpidr(void)
+static inline uint64_t get_mpidr(void)
 {
 	return read_sysreg(MPIDR);
 }
lib/arm/asm/setup.h +1 -1
index 1de99dd184d1..b0d51f5f0721 100644
@@ -11,7 +11,7 @@
 #include <asm/pgtable-hwdef.h>
 
 #define NR_CPUS			255
-extern u32 cpus[NR_CPUS];	/* per-cpu IDs (MPIDRs) */
+extern u64 cpus[NR_CPUS];	/* per-cpu IDs (MPIDRs) */
 extern int nr_cpus;
 
 #define NR_MEM_REGIONS		8
lib/arm64/asm/processor.h +1 -1
index f42f15c79d43..1d9223f728a5 100644
@@ -78,7 +78,7 @@ static inline void local_irq_disable(void)
 	asm volatile("msr daifset, #2" : : : "memory");
 }
 
-static inline unsigned int get_mpidr(void)
+static inline uint64_t get_mpidr(void)
 {
 	return read_sysreg(mpidr_el1);
 }
lib/arm/setup.c +1 -1
index ac3fadb07828..68eae91286d6 100644
@@ -24,7 +24,7 @@ extern unsigned long stacktop;
 extern void io_init(void);
 extern void setup_args_progname(const char *args);
 
-u32 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (~0U) };
+u64 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (u64)~0 };
 int nr_cpus;
 
 struct mem_region mem_regions[NR_MEM_REGIONS];
Signature · 1 line
2.9.3
author Applied
#6 lore raw
In reply to Andrew Jones
Quoted 12 lines · Andrew Jones

Fix1, patches 1: SKIP if pci-testdev isn't available rather than FAIL
Fix2, patches 4,5: 64-bit MPIDRs will have 2 32-bit regs in DT Fix3, patches 2,3: While doing Fix2 I noticed a need for different/strict
setup order

Andrew Jones (5):
arm/pci-test: skip on pci/pci-testdev probe failure lib/arm/setup: fix and comment init order lib/powerpc/setup: comment init dependencies
devicetree: cpu nodes may have 64-bit regs arm/arm64: support 64-bit MPIDRs

Quoted 15 lines
 lib/arm/asm/processor.h   |  2 +-
 lib/arm/asm/setup.h       |  2 +-
 lib/arm64/asm/processor.h |  2 +-
 lib/devicetree.h          |  2 +-
 lib/arm/setup.c           | 13 +++++++++----
 lib/devicetree.c          |  9 +++++++--
 lib/powerpc/setup.c       |  6 +++++-
 lib/powerpc/smp.c         |  2 +-
 arm/pci-test.c            | 13 +++++++++----
 powerpc/tm.c              |  2 +-
 10 files changed, 36 insertions(+), 17 deletions(-)
Signature · 1 line
2.9.3

Applied to arm/next

Thanks,
drew