Skip to contentSkip to conversation

ARM: oxnas: Add SMP support for OX820

PATCH Superseded Neil Armstrong 3 participants 6 messages Oct 17, 2016 – Oct 31, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ARM: oxnas: Add SMP support for OX820

In order to support the SMP feature of the Oxford Semiconductor OX820 SoC,
add the necessary code to handle the wake-up, hotplug and cpu entry.

Neil Armstrong (2):
ARM: oxnas: Add OX820 SMP support
ARM: oxnas: Add OX820 config and makefile entry

 arch/arm/Makefile             |   1 +
 arch/arm/mach-oxnas/Kconfig   |  30 +++++---
 arch/arm/mach-oxnas/Makefile  |   2 +
 arch/arm/mach-oxnas/headsmp.S |  28 ++++++++
 arch/arm/mach-oxnas/hotplug.c | 111 +++++++++++++++++++++++++++++
 arch/arm/mach-oxnas/platsmp.c | 161 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 324 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-oxnas/Makefile
 create mode 100644 arch/arm/mach-oxnas/headsmp.S
 create mode 100644 arch/arm/mach-oxnas/hotplug.c
 create mode 100644 arch/arm/mach-oxnas/platsmp.c
Signature · 1 line
2.7.0
#1 lore raw

PATCH 1/2 ARM: oxnas: Add OX820 SMP support

The Oxford Semiconductor OX820 is a ARM11MPcore based SoC sharing some features with the OX810 earlier SoC.
This patch adds the core to wake up the second core.

---
 arch/arm/mach-oxnas/Makefile  |   2 +
 arch/arm/mach-oxnas/headsmp.S |  28 ++++++++
 arch/arm/mach-oxnas/hotplug.c | 111 +++++++++++++++++++++++++++++
 arch/arm/mach-oxnas/platsmp.c | 161 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 302 insertions(+)
 create mode 100644 arch/arm/mach-oxnas/Makefile
 create mode 100644 arch/arm/mach-oxnas/headsmp.S
 create mode 100644 arch/arm/mach-oxnas/hotplug.c
 create mode 100644 arch/arm/mach-oxnas/platsmp.c
arch/arm/mach-oxnas/Makefile new file +2 -0
new file mode 100644
index 0000000..b625906
@@ -0,0 +1,2 @@
+obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
+obj-$(CONFIG_HOTPLUG_CPU) 	+= hotplug.o
arch/arm/mach-oxnas/headsmp.S new file +28 -0
new file mode 100644
index 0000000..2a94dcb
@@ -0,0 +1,28 @@
+/*
+ * linux/arch/arm/mach-oxnas/headsmp.S
+ *
+ * Copyright (C) 2013 Ma Haijun <[email protected]>
+ * Copyright (c) 2003 ARM Limited
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/linkage.h>
+#include <linux/init.h>
+
+	__INIT
+
+/*
+ * OX820 specific entry point for secondary CPUs.
+ */
+ENTRY(ox820_secondary_startup)
+	mov r4, #0
+	/* invalidate both caches and branch target cache */
+	mcr p15, 0, r4, c7, c7, 0
+	/*
+	 * we've been released from the holding pen: secondary_stack
+	 * should now contain the SVC stack for this core
+	 */
+	b	secondary_startup
arch/arm/mach-oxnas/hotplug.c new file +111 -0

111 lines not on this page · raw message

arch/arm/mach-oxnas/platsmp.c new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
2.7.0
#5 lore raw

PATCH 2/2 ARM: oxnas: Add OX820 config and makefile entry

In reply to Neil Armstrong

Refactor the oxnas Kconfig entries among the OX810SE and OX820 configs, and add the files to support the OX820 SMP feature.

---
 arch/arm/Makefile           |  1 +
 arch/arm/mach-oxnas/Kconfig | 30 +++++++++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)
arch/arm/Makefile +1 -0
index 6be9ee1..68312a9 100644
@@ -191,6 +191,7 @@ machine-$(CONFIG_ARCH_MXS)		+= mxs
 machine-$(CONFIG_ARCH_NETX)		+= netx
 machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
 machine-$(CONFIG_ARCH_NSPIRE)		+= nspire
+machine-$(CONFIG_ARCH_OXNAS)		+= oxnas
 machine-$(CONFIG_ARCH_OMAP1)		+= omap1
 machine-$(CONFIG_ARCH_OMAP2PLUS)	+= omap2
 machine-$(CONFIG_ARCH_ORION5X)		+= orion5x
arch/arm/mach-oxnas/Kconfig +21 -9
index 29100be..8fa4557 100644
@@ -1,9 +1,16 @@
 menuconfig ARCH_OXNAS
 	bool "Oxford Semiconductor OXNAS Family SoCs"
 	select ARCH_HAS_RESET_CONTROLLER
+	select COMMON_CLK_OXNAS
 	select GPIOLIB
+	select MFD_SYSCON
+	select OXNAS_RPS_TIMER
+	select PINCTRL_OXNAS
+	select RESET_CONTROLLER
+	select RESET_OXNAS
+	select VERSATILE_FPGA_IRQ
 	select PINCTRL
-	depends on ARCH_MULTI_V5
+	depends on ARCH_MULTI_V5 || ARCH_MULTI_V6
 	help
 	  Support for OxNas SoC family developed by Oxford Semiconductor.
 
@@ -11,16 +18,21 @@ if ARCH_OXNAS
 
 config MACH_OX810SE
 	bool "Support OX810SE Based Products"
-	select ARCH_HAS_RESET_CONTROLLER
-	select COMMON_CLK_OXNAS
+	depends on ARCH_MULTI_V5
 	select CPU_ARM926T
-	select MFD_SYSCON
-	select OXNAS_RPS_TIMER
-	select PINCTRL_OXNAS
-	select RESET_CONTROLLER
-	select RESET_OXNAS
-	select VERSATILE_FPGA_IRQ
 	help
 	  Include Support for the Oxford Semiconductor OX810SE SoC Based Products.
 
+config MACH_OX820
+	bool "Support OX820 Based Products"
+	depends on ARCH_MULTI_V6
+	select ARM_GIC
+	select DMA_CACHE_RWFO if SMP
+	select CPU_V6K
+	select HAVE_SMP
+	select HAVE_ARM_SCU if SMP
+	select HAVE_ARM_TWD if SMP
+	help
+	  Include Support for the Oxford Semiconductor OX820 SoC Based Products.
+
 endif
Signature · 1 line
2.7.0
#2 lore raw

Re: [PATCH 1/2] ARM: oxnas: Add OX820 SMP support

In reply to Neil Armstrong
Quoted 21 lines · CEST Neil Armstrong
arch/arm/mach-oxnas/platsmp.c new file +20 -0
+
+       /*
+        * This is really belt and braces; we hold unintended secondary
+        * CPUs in the holding pen until we're ready for them.  However,
+        * since we haven't sent them a soft interrupt, they shouldn't
+        * be there.
+        */
+       write_pen_release(cpu);
+
+       /*
+        * Enable GIC cpu interface in CPU Interface Control Register
+        */
+       writel(GIC_CPU_CTRL_ENABLE,
+               gic_cpu_ctrl + GIC_NCPU_OFFSET(cpu) + GIC_CPU_CTRL);
+
+       /*
+        * Send the secondary CPU a soft interrupt, thereby causing
+        * the boot monitor to read the system wide flags register,
+        * and branch to the address found there.
+        */

arch/arm/mach-oxnas/platsmp.c line 101

Quoted 10 lines
arch/arm/mach-oxnas/platsmp.c new file +10 -0
+
+       arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+       timeout = jiffies + (1 * HZ);
+       while (time_before(jiffies, timeout)) {
+               smp_rmb();
+               if (read_pen_release() == -1)
+                       break;
+
+               udelay(10);
+       }

This seems to have been copied from plat-versatile, but is really not needed here since you apparently have proper hardware support for starting up the CPUs.

Any reason you can't just write to the cpu_ctrl register once and keep going without that whole holding_pen loop and spinlock?

Arnd

#3 lore raw

Re: [PATCH 1/2] ARM: oxnas: Add OX820 SMP support

Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · CEST Neil Armstrong
arch/arm/mach-oxnas/platsmp.c new file +27 -0
+
+       /*
+        * This is really belt and braces; we hold unintended secondary
+        * CPUs in the holding pen until we're ready for them.  However,
+        * since we haven't sent them a soft interrupt, they shouldn't
+        * be there.
+        */
+       write_pen_release(cpu);
+
+       /*
+        * Enable GIC cpu interface in CPU Interface Control Register
+        */
+       writel(GIC_CPU_CTRL_ENABLE,
+               gic_cpu_ctrl + GIC_NCPU_OFFSET(cpu) + GIC_CPU_CTRL);
+
+       /*
+        * Send the secondary CPU a soft interrupt, thereby causing
+        * the boot monitor to read the system wide flags register,
+        * and branch to the address found there.
+        */
+
+       arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+       timeout = jiffies + (1 * HZ);
+       while (time_before(jiffies, timeout)) {
+               smp_rmb();
+               if (read_pen_release() == -1)
+                       break;
Quoted 8 lines

arch/arm/mach-oxnas/platsmp.c line 101

Quoted 4 lines
arch/arm/mach-oxnas/platsmp.c new file +3 -0
+
+               udelay(10);
+       }

This seems to have been copied from plat-versatile, but is really not needed here since you apparently have proper hardware support for starting up the CPUs.

Yes it seems.

Quoted 4 lines

Any reason you can't just write to the cpu_ctrl register once and keep going without that whole holding_pen loop and spinlock?

I suppose but I did not find any good examples except the plat-versatile code. I will try some simpler code.

Quoted 3 lines

Arnd

Neil

#4 lore raw

Re: [PATCH 1/2] ARM: oxnas: Add OX820 SMP support

Quoted 5 lines · Neil Armstrong
Quoted 4 lines · Arnd Bergmann

On Monday, October 17, 2016 10:43:02 AM CEST Neil Armstrong wrote:
This seems to have been copied from plat-versatile, but is really not needed here since you apparently have proper hardware support for starting up the CPUs.

Quoted 8 lines

Yes it seems.

Quoted 4 lines

Any reason you can't just write to the cpu_ctrl register once and keep going without that whole holding_pen loop and spinlock?

I suppose but I did not find any good examples except the plat-versatile code. I will try some simpler code.

There's plenty of examples - most ARM SMP platforms in the kernel now do not blindly copy the versatile code. You only have to go looking for arch/arm/*/platsmp.c files to find them.

I'm not sure what you'd call a "good example" - maybe the imx code? arch/arm/mach-imx/platsmp.c can't be simpler:

static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle)

{
        imx_set_cpu_jump(cpu, v7_secondary_startup);
        imx_enable_cpu(cpu, true);
        return 0;
}

I guess the difficult thing is to understand what each of those called functions does... though the function names give a very accurate clue there.

and because plat-versatile is almost entirely software-based, it's easy to understand and follow, _despite_ being completely broken for things like PM and kexec (which, the platform does not support.)

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.