Skip to contentSkip to conversation

x86: apl: Add support for different number of cores

PATCH New Wolfgang Wallner 2 participants 6 messages Feb 25, 2020 – Feb 28, 2020 x86

lore
Share & tools
lore
#0 lore raw

cover x86: apl: Add support for different number of cores

Currently the Apollo Lake implementation of cpu_ops.get_count returns a hardcoded value of 4.

The function cpu_x86_get_count() provides a more generic implementation that reads the number of cores from device tree. But this function is currently static.

This series:
- makes cpu_x86_get_count() non-static
- drops the Apollo Lake specific get_count implementation and uses cpu_x86_get_count() instead

With the changes in this series also Apollo Lake variants with a different number of cores boot correctly.

Wolfgang Wallner (2):
x86: cpu_x86: Make cpu_x86_get_count() non-static
x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

 arch/x86/cpu/apollolake/cpu.c  |  7 +------
 arch/x86/cpu/cpu_x86.c         |  2 +-
 arch/x86/include/asm/cpu_x86.h | 12 ++++++++++++
 3 files changed, 14 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 x86: cpu_x86: Make cpu_x86_get_count() non-static

The function cpu_x86_get_count() is also useful for other modules. Make it non-static and add a prototype + description.

---

 arch/x86/cpu/cpu_x86.c         |  2 +-
 arch/x86/include/asm/cpu_x86.h | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/cpu/cpu_x86.c +1 -1
index 1aaf851bb4..3f2ba0881e 100644
@@ -52,7 +52,7 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size)
 	return 0;
 }
 
-static int cpu_x86_get_count(struct udevice *dev)
+int cpu_x86_get_count(struct udevice *dev)
 {
 	int node, cpu;
 	int num = 0;
arch/x86/include/asm/cpu_x86.h +12 -0
index 19223f2c3b..ae8f4dcd5d 100644
@@ -30,6 +30,18 @@ int cpu_x86_bind(struct udevice *dev);
  */
 int cpu_x86_get_desc(struct udevice *dev, char *buf, int size);
 
+/**
+ * cpu_x86_get_count() - Get the number of cores for an x86 CPU
+ *
+ * This function is suitable to use as the get_count() method for
+ * the CPU uclass.
+ *
+ * @dev:	Device to check (UCLASS_CPU)
+ * @return:	Number of cores if successful,
+ *		-ENOENT if not "/cpus" entry is found in the device tree
+ */
+int cpu_x86_get_count(struct udevice *dev);
+
 /**
  * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU
  *
Signature · 1 line
2.25.1
#2 lore raw

PATCH 1/2 x86: cpu_x86: Make cpu_x86_get_count() non-static

Quoted 11 lines · Wolfgang Wallner

The function cpu_x86_get_count() is also useful for other modules. Make it non-static and add a prototype + description.

---

 arch/x86/cpu/cpu_x86.c         |  2 +-
 arch/x86/include/asm/cpu_x86.h | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
#3 lore raw

PATCH 2/2 x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

In reply to Wolfgang Wallner

Use cpu_x86_get_count() to read the number of cores.

cpu_x86_get_count() reads the number of CPUs from the device tree. Using this function we can support multiple Apollo Lake variants, e.g.: E3940 (4 cores) and E3930 (2 cores).

This was tested on the E3940 and E3930 Apollo Lake variants.

---

 arch/x86/cpu/apollolake/cpu.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
arch/x86/cpu/apollolake/cpu.c +1 -6
index 3d05c82a5c..aa7a3dbd63 100644
@@ -14,15 +14,10 @@ static int apl_get_info(struct udevice *dev, struct cpu_info *info)
 	return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
 }
 
-static int apl_get_count(struct udevice *dev)
-{
-	return 4;
-}
-
 static const struct cpu_ops cpu_x86_apl_ops = {
 	.get_desc	= cpu_x86_get_desc,
 	.get_info	= apl_get_info,
-	.get_count	= apl_get_count,
+	.get_count	= cpu_x86_get_count,
 	.get_vendor	= cpu_x86_get_vendor,
 };
 
Signature · 1 line
2.25.1
#4 lore raw

PATCH 2/2 x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

Quoted 7 lines · Wolfgang Wallner

Use cpu_x86_get_count() to read the number of cores.

cpu_x86_get_count() reads the number of CPUs from the device tree. Using this function we can support multiple Apollo Lake variants, e.g.: E3940 (4 cores) and E3930 (2 cores).

Quoted 9 lines

This was tested on the E3940 and E3930 Apollo Lake variants.

---

 arch/x86/cpu/apollolake/cpu.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
#5 lore raw

cover x86: apl: Add support for different number of cores

In reply to Wolfgang Wallner
Quoted 14 lines · Wolfgang Wallner

Currently the Apollo Lake implementation of cpu_ops.get_count returns a hardcoded value of 4.

The function cpu_x86_get_count() provides a more generic implementation that reads the number of cores from device tree. But this function is currently static.

This series:
- makes cpu_x86_get_count() non-static
- drops the Apollo Lake specific get_count implementation and uses cpu_x86_get_count() instead

Quoted 7 lines

With the changes in this series also Apollo Lake variants with a different number of cores boot correctly.

Wolfgang Wallner (2):
x86: cpu_x86: Make cpu_x86_get_count() non-static
x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

series applied to u-boot-x86, thanks!