linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Support for MIPSr6 CPU hotplug.
@ 2016-07-07  7:50 Matt Redfearn
  2016-07-07  7:50 ` Matt Redfearn
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips
  Cc: Matt Redfearn, Qais Yousef, linux-kernel, Thomas Gleixner,
	Markos Chandras, Paul Burton

This series adds support for hotplug of MIPSr6 Virtual Processors such
as found in the I6400.

Patch 1 allows VPs other than VP0 within a MIPSr6 core to start when a
core is booted.

Patch 2 adds support for removing CPUs, allowing CPU hotpug to be used
with MIPSr6 devices.

Patch 3 is a tidy up to move the CPU hotplug config option into the
Kernel type menu within menuconfig.

Based atop 4.7-rc6


Matt Redfearn (3):
  MIPS: smp-cps: Allow booting of CPU other than VP0 within a core
  MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors
  MIPS: Move CPU Hotplug config option into submenu

 arch/mips/Kconfig          | 20 ++++++++++----------
 arch/mips/kernel/smp-cps.c | 41 ++++++++++++++++++++++++++++++++---------
 2 files changed, 42 insertions(+), 19 deletions(-)

-- 
2.7.4

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

* [PATCH 0/3] Support for MIPSr6 CPU hotplug.
  2016-07-07  7:50 [PATCH 0/3] Support for MIPSr6 CPU hotplug Matt Redfearn
@ 2016-07-07  7:50 ` Matt Redfearn
  2016-07-07  7:50 ` [PATCH 1/3] MIPS: smp-cps: Allow booting of CPU other than VP0 within a core Matt Redfearn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips
  Cc: Matt Redfearn, Qais Yousef, linux-kernel, Thomas Gleixner,
	Markos Chandras, Paul Burton

This series adds support for hotplug of MIPSr6 Virtual Processors such
as found in the I6400.

Patch 1 allows VPs other than VP0 within a MIPSr6 core to start when a
core is booted.

Patch 2 adds support for removing CPUs, allowing CPU hotpug to be used
with MIPSr6 devices.

Patch 3 is a tidy up to move the CPU hotplug config option into the
Kernel type menu within menuconfig.

Based atop 4.7-rc6


Matt Redfearn (3):
  MIPS: smp-cps: Allow booting of CPU other than VP0 within a core
  MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors
  MIPS: Move CPU Hotplug config option into submenu

 arch/mips/Kconfig          | 20 ++++++++++----------
 arch/mips/kernel/smp-cps.c | 41 ++++++++++++++++++++++++++++++++---------
 2 files changed, 42 insertions(+), 19 deletions(-)

-- 
2.7.4

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

* [PATCH 1/3] MIPS: smp-cps: Allow booting of CPU other than VP0 within a core
  2016-07-07  7:50 [PATCH 0/3] Support for MIPSr6 CPU hotplug Matt Redfearn
  2016-07-07  7:50 ` Matt Redfearn
@ 2016-07-07  7:50 ` Matt Redfearn
  2016-07-07  7:50   ` Matt Redfearn
  2016-07-07  7:50 ` [PATCH 2/3] MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors Matt Redfearn
  2016-07-07  7:50 ` [PATCH 3/3] MIPS: Move CPU Hotplug config option into submenu Matt Redfearn
  3 siblings, 1 reply; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips
  Cc: Matt Redfearn, Qais Yousef, linux-kernel, Thomas Gleixner,
	Markos Chandras, Paul Burton

The boot_core function was hardcoded to always start VP0 when starting
a core via the CPC. When hotplugging a CPU this may not be the desired
behaviour.

Make boot_core receive the VP ID to start running on the core, such that
alternate VPs can be started via CPU hotplug.
Also ensure that all other VPs within the core are stopped before
bringing the core out of reset so that only the desired VP starts.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/smp-cps.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 4ed36f288d64..006e99de170d 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -206,7 +206,7 @@ err_out:
 	}
 }
 
-static void boot_core(unsigned core)
+static void boot_core(unsigned int core, unsigned int vpe_id)
 {
 	u32 access, stat, seq_state;
 	unsigned timeout;
@@ -233,8 +233,9 @@ static void boot_core(unsigned core)
 		mips_cpc_lock_other(core);
 
 		if (mips_cm_revision() >= CM_REV_CM3) {
-			/* Run VP0 following the reset */
-			write_cpc_co_vp_run(0x1);
+			/* Run only the requested VP following the reset */
+			write_cpc_co_vp_stop(0xf);
+			write_cpc_co_vp_run(1 << vpe_id);
 
 			/*
 			 * Ensure that the VP_RUN register is written before the
@@ -306,7 +307,7 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
 
 	if (!test_bit(core, core_power)) {
 		/* Boot a VPE on a powered down core */
-		boot_core(core);
+		boot_core(core, vpe_id);
 		goto out;
 	}
 
-- 
2.7.4

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

* [PATCH 1/3] MIPS: smp-cps: Allow booting of CPU other than VP0 within a core
  2016-07-07  7:50 ` [PATCH 1/3] MIPS: smp-cps: Allow booting of CPU other than VP0 within a core Matt Redfearn
@ 2016-07-07  7:50   ` Matt Redfearn
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips
  Cc: Matt Redfearn, Qais Yousef, linux-kernel, Thomas Gleixner,
	Markos Chandras, Paul Burton

The boot_core function was hardcoded to always start VP0 when starting
a core via the CPC. When hotplugging a CPU this may not be the desired
behaviour.

Make boot_core receive the VP ID to start running on the core, such that
alternate VPs can be started via CPU hotplug.
Also ensure that all other VPs within the core are stopped before
bringing the core out of reset so that only the desired VP starts.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/smp-cps.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 4ed36f288d64..006e99de170d 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -206,7 +206,7 @@ err_out:
 	}
 }
 
-static void boot_core(unsigned core)
+static void boot_core(unsigned int core, unsigned int vpe_id)
 {
 	u32 access, stat, seq_state;
 	unsigned timeout;
@@ -233,8 +233,9 @@ static void boot_core(unsigned core)
 		mips_cpc_lock_other(core);
 
 		if (mips_cm_revision() >= CM_REV_CM3) {
-			/* Run VP0 following the reset */
-			write_cpc_co_vp_run(0x1);
+			/* Run only the requested VP following the reset */
+			write_cpc_co_vp_stop(0xf);
+			write_cpc_co_vp_run(1 << vpe_id);
 
 			/*
 			 * Ensure that the VP_RUN register is written before the
@@ -306,7 +307,7 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
 
 	if (!test_bit(core, core_power)) {
 		/* Boot a VPE on a powered down core */
-		boot_core(core);
+		boot_core(core, vpe_id);
 		goto out;
 	}
 
-- 
2.7.4

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

* [PATCH 2/3] MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors
  2016-07-07  7:50 [PATCH 0/3] Support for MIPSr6 CPU hotplug Matt Redfearn
  2016-07-07  7:50 ` Matt Redfearn
  2016-07-07  7:50 ` [PATCH 1/3] MIPS: smp-cps: Allow booting of CPU other than VP0 within a core Matt Redfearn
@ 2016-07-07  7:50 ` Matt Redfearn
  2016-07-07  7:50   ` Matt Redfearn
  2016-07-07  7:50 ` [PATCH 3/3] MIPS: Move CPU Hotplug config option into submenu Matt Redfearn
  3 siblings, 1 reply; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips
  Cc: Matt Redfearn, Qais Yousef, linux-kernel, Markos Chandras, Paul Burton

Introduce support for hotplug of Virtual Processors in MIPSr6 systems.
The method is simpler than the VPE parallel from the now-deprecated MT
ASE, it can now simply write the VP_STOP register with the mask of VPs
to halt, and use the VP_RUNNING register to determine when the VP has
halted.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/smp-cps.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 006e99de170d..234e7e781a94 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -412,14 +412,16 @@ static enum {
 
 void play_dead(void)
 {
-	unsigned cpu, core;
+	unsigned int cpu, core, vpe_id;
 
 	local_irq_disable();
 	idle_task_exit();
 	cpu = smp_processor_id();
 	cpu_death = CPU_DEATH_POWER;
 
-	if (cpu_has_mipsmt) {
+	pr_debug("CPU%d going offline\n", cpu);
+
+	if (cpu_has_mipsmt || cpu_has_vp) {
 		core = cpu_data[cpu].core;
 
 		/* Look for another online VPE within the core */
@@ -440,10 +442,21 @@ void play_dead(void)
 	complete(&cpu_death_chosen);
 
 	if (cpu_death == CPU_DEATH_HALT) {
-		/* Halt this TC */
-		write_c0_tchalt(TCHALT_H);
-		instruction_hazard();
+		vpe_id = cpu_vpe_id(&cpu_data[cpu]);
+
+		pr_debug("Halting core %d VP%d\n", core, vpe_id);
+		if (cpu_has_mipsmt) {
+			/* Halt this TC */
+			write_c0_tchalt(TCHALT_H);
+			instruction_hazard();
+		} else if (cpu_has_vp) {
+			write_cpc_cl_vp_stop(1 << vpe_id);
+
+			/* Ensure that the VP_STOP register is written */
+			wmb();
+		}
 	} else {
+		pr_debug("Gating power to core %d\n", core);
 		/* Power down the core */
 		cps_pm_enter_state(CPS_PM_POWER_GATED);
 	}
@@ -470,6 +483,7 @@ static void wait_for_sibling_halt(void *ptr_cpu)
 static void cps_cpu_die(unsigned int cpu)
 {
 	unsigned core = cpu_data[cpu].core;
+	unsigned int vpe_id = cpu_vpe_id(&cpu_data[cpu]);
 	unsigned stat;
 	int err;
 
@@ -498,10 +512,12 @@ static void cps_cpu_die(unsigned int cpu)
 		 * in which case the CPC will refuse to power down the core.
 		 */
 		do {
+			mips_cm_lock_other(core, vpe_id);
 			mips_cpc_lock_other(core);
 			stat = read_cpc_co_stat_conf();
 			stat &= CPC_Cx_STAT_CONF_SEQSTATE_MSK;
 			mips_cpc_unlock_other();
+			mips_cm_unlock_other();
 		} while (stat != CPC_Cx_STAT_CONF_SEQSTATE_D0 &&
 			 stat != CPC_Cx_STAT_CONF_SEQSTATE_D2 &&
 			 stat != CPC_Cx_STAT_CONF_SEQSTATE_U2);
@@ -518,6 +534,12 @@ static void cps_cpu_die(unsigned int cpu)
 					       (void *)(unsigned long)cpu, 1);
 		if (err)
 			panic("Failed to call remote sibling CPU\n");
+	} else if (cpu_has_vp) {
+		do {
+			mips_cm_lock_other(core, vpe_id);
+			stat = read_cpc_co_vp_running();
+			mips_cm_unlock_other();
+		} while (stat & (1 << vpe_id));
 	}
 }
 
-- 
2.7.4

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

* [PATCH 2/3] MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors
  2016-07-07  7:50 ` [PATCH 2/3] MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors Matt Redfearn
@ 2016-07-07  7:50   ` Matt Redfearn
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips
  Cc: Matt Redfearn, Qais Yousef, linux-kernel, Markos Chandras, Paul Burton

Introduce support for hotplug of Virtual Processors in MIPSr6 systems.
The method is simpler than the VPE parallel from the now-deprecated MT
ASE, it can now simply write the VP_STOP register with the mask of VPs
to halt, and use the VP_RUNNING register to determine when the VP has
halted.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/smp-cps.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 006e99de170d..234e7e781a94 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -412,14 +412,16 @@ static enum {
 
 void play_dead(void)
 {
-	unsigned cpu, core;
+	unsigned int cpu, core, vpe_id;
 
 	local_irq_disable();
 	idle_task_exit();
 	cpu = smp_processor_id();
 	cpu_death = CPU_DEATH_POWER;
 
-	if (cpu_has_mipsmt) {
+	pr_debug("CPU%d going offline\n", cpu);
+
+	if (cpu_has_mipsmt || cpu_has_vp) {
 		core = cpu_data[cpu].core;
 
 		/* Look for another online VPE within the core */
@@ -440,10 +442,21 @@ void play_dead(void)
 	complete(&cpu_death_chosen);
 
 	if (cpu_death == CPU_DEATH_HALT) {
-		/* Halt this TC */
-		write_c0_tchalt(TCHALT_H);
-		instruction_hazard();
+		vpe_id = cpu_vpe_id(&cpu_data[cpu]);
+
+		pr_debug("Halting core %d VP%d\n", core, vpe_id);
+		if (cpu_has_mipsmt) {
+			/* Halt this TC */
+			write_c0_tchalt(TCHALT_H);
+			instruction_hazard();
+		} else if (cpu_has_vp) {
+			write_cpc_cl_vp_stop(1 << vpe_id);
+
+			/* Ensure that the VP_STOP register is written */
+			wmb();
+		}
 	} else {
+		pr_debug("Gating power to core %d\n", core);
 		/* Power down the core */
 		cps_pm_enter_state(CPS_PM_POWER_GATED);
 	}
@@ -470,6 +483,7 @@ static void wait_for_sibling_halt(void *ptr_cpu)
 static void cps_cpu_die(unsigned int cpu)
 {
 	unsigned core = cpu_data[cpu].core;
+	unsigned int vpe_id = cpu_vpe_id(&cpu_data[cpu]);
 	unsigned stat;
 	int err;
 
@@ -498,10 +512,12 @@ static void cps_cpu_die(unsigned int cpu)
 		 * in which case the CPC will refuse to power down the core.
 		 */
 		do {
+			mips_cm_lock_other(core, vpe_id);
 			mips_cpc_lock_other(core);
 			stat = read_cpc_co_stat_conf();
 			stat &= CPC_Cx_STAT_CONF_SEQSTATE_MSK;
 			mips_cpc_unlock_other();
+			mips_cm_unlock_other();
 		} while (stat != CPC_Cx_STAT_CONF_SEQSTATE_D0 &&
 			 stat != CPC_Cx_STAT_CONF_SEQSTATE_D2 &&
 			 stat != CPC_Cx_STAT_CONF_SEQSTATE_U2);
@@ -518,6 +534,12 @@ static void cps_cpu_die(unsigned int cpu)
 					       (void *)(unsigned long)cpu, 1);
 		if (err)
 			panic("Failed to call remote sibling CPU\n");
+	} else if (cpu_has_vp) {
+		do {
+			mips_cm_lock_other(core, vpe_id);
+			stat = read_cpc_co_vp_running();
+			mips_cm_unlock_other();
+		} while (stat & (1 << vpe_id));
 	}
 }
 
-- 
2.7.4

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

* [PATCH 3/3] MIPS: Move CPU Hotplug config option into submenu
  2016-07-07  7:50 [PATCH 0/3] Support for MIPSr6 CPU hotplug Matt Redfearn
                   ` (2 preceding siblings ...)
  2016-07-07  7:50 ` [PATCH 2/3] MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors Matt Redfearn
@ 2016-07-07  7:50 ` Matt Redfearn
  2016-07-07  7:50   ` Matt Redfearn
  3 siblings, 1 reply; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips; +Cc: Matt Redfearn, linux-kernel

The KConfig option HOTPLUG_CPU should appear in the "Kernel Type"
submenu. Relocate it to where SMP support is configured.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 arch/mips/Kconfig | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ac91939b9b75..fd06bccf2011 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1111,16 +1111,6 @@ config NEED_DMA_MAP_STATE
 config SYS_HAS_EARLY_PRINTK
 	bool
 
-config HOTPLUG_CPU
-	bool "Support for hot-pluggable CPUs"
-	depends on SMP && SYS_SUPPORTS_HOTPLUG_CPU
-	help
-	  Say Y here to allow turning CPUs off and on. CPUs can be
-	  controlled through /sys/devices/system/cpu.
-	  (Note: power management support will enable this option
-	    automatically on SMP systems. )
-	  Say N if you want to disable CPU hotplug.
-
 config SYS_SUPPORTS_HOTPLUG_CPU
 	bool
 
@@ -2634,6 +2624,16 @@ config SMP
 
 	  If you don't know what to do here, say N.
 
+config HOTPLUG_CPU
+	bool "Support for hot-pluggable CPUs"
+	depends on SMP && SYS_SUPPORTS_HOTPLUG_CPU
+	help
+	  Say Y here to allow turning CPUs off and on. CPUs can be
+	  controlled through /sys/devices/system/cpu.
+	  (Note: power management support will enable this option
+	    automatically on SMP systems. )
+	  Say N if you want to disable CPU hotplug.
+
 config SMP_UP
 	bool
 
-- 
2.7.4

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

* [PATCH 3/3] MIPS: Move CPU Hotplug config option into submenu
  2016-07-07  7:50 ` [PATCH 3/3] MIPS: Move CPU Hotplug config option into submenu Matt Redfearn
@ 2016-07-07  7:50   ` Matt Redfearn
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Redfearn @ 2016-07-07  7:50 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips; +Cc: Matt Redfearn, linux-kernel

The KConfig option HOTPLUG_CPU should appear in the "Kernel Type"
submenu. Relocate it to where SMP support is configured.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 arch/mips/Kconfig | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ac91939b9b75..fd06bccf2011 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1111,16 +1111,6 @@ config NEED_DMA_MAP_STATE
 config SYS_HAS_EARLY_PRINTK
 	bool
 
-config HOTPLUG_CPU
-	bool "Support for hot-pluggable CPUs"
-	depends on SMP && SYS_SUPPORTS_HOTPLUG_CPU
-	help
-	  Say Y here to allow turning CPUs off and on. CPUs can be
-	  controlled through /sys/devices/system/cpu.
-	  (Note: power management support will enable this option
-	    automatically on SMP systems. )
-	  Say N if you want to disable CPU hotplug.
-
 config SYS_SUPPORTS_HOTPLUG_CPU
 	bool
 
@@ -2634,6 +2624,16 @@ config SMP
 
 	  If you don't know what to do here, say N.
 
+config HOTPLUG_CPU
+	bool "Support for hot-pluggable CPUs"
+	depends on SMP && SYS_SUPPORTS_HOTPLUG_CPU
+	help
+	  Say Y here to allow turning CPUs off and on. CPUs can be
+	  controlled through /sys/devices/system/cpu.
+	  (Note: power management support will enable this option
+	    automatically on SMP systems. )
+	  Say N if you want to disable CPU hotplug.
+
 config SMP_UP
 	bool
 
-- 
2.7.4

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

end of thread, other threads:[~2016-07-07  7:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-07  7:50 [PATCH 0/3] Support for MIPSr6 CPU hotplug Matt Redfearn
2016-07-07  7:50 ` Matt Redfearn
2016-07-07  7:50 ` [PATCH 1/3] MIPS: smp-cps: Allow booting of CPU other than VP0 within a core Matt Redfearn
2016-07-07  7:50   ` Matt Redfearn
2016-07-07  7:50 ` [PATCH 2/3] MIPS: smp-cps: Add support for CPU hotplug of MIPSr6 processors Matt Redfearn
2016-07-07  7:50   ` Matt Redfearn
2016-07-07  7:50 ` [PATCH 3/3] MIPS: Move CPU Hotplug config option into submenu Matt Redfearn
2016-07-07  7:50   ` Matt Redfearn

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).