public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading)
@ 2016-02-03  3:15 Paul Burton
  2016-02-03  3:15 ` [PATCH 01/15] MIPS: Detect MIPSr6 Virtual Processor support Paul Burton
                   ` (14 more replies)
  0 siblings, 15 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Maciej W. Rozycki, Joshua Kinard, Leonid Yegoshin,
	Jason Cooper, Ezequiel Garcia, Rusty Russell, Steven J. Hill,
	Andrew Bresticker, Maciej W. Rozycki, Thomas Gleixner,
	Bjorn Helgaas, Markos Chandras, Petri Gynther, Alex Smith,
	Niklas Cassel, Matt Redfearn, linux-kernel, James Hogan,
	Marc Zyngier

This series introduces support for the multi-core & multi-threading
capabilities of the I6400. That is, it introduces support for MIPSr6
Virtual Processors & enables CPS SMP for MIPSr6.

Based atop v4.5-rc2.

Markos Chandras (3):
  MIPS: traps: Make sure secondary cores have a sane ebase register
  MIPS: pm-cps: Avoid offset overflow on MIPSr6
  MIPS: CPC: Add start, stop and running CM3 CPC registers

Paul Burton (12):
  MIPS: Detect MIPSr6 Virtual Processor support
  MIPS: CM: Add CM GCR_BEV_BASE accessors
  MIPS: CM: Fix mips_cm_max_vp_width for UP kernels
  irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR
  irqchip: mips-gic: Provide VP ID accessor
  MIPS: smp-cps: Ensure our VP ident calculation is correct
  MIPS: smp-cps: Pull cache init into a function
  MIPS: smp-cps: Pull boot config retrieval out of mips_cps_boot_vpes
  MIPS: smp-cps: Skip core setup if coherent
  MIPS: smp-cps: Support MIPSr6 Virtual Processors
  MIPS: smp-cps: Add nothreads kernel parameter
  MIPS: smp-cps: Stop printing EJTAG exceptions to UART

 arch/mips/Kconfig                    |   2 +-
 arch/mips/include/asm/cpu-features.h |   4 +
 arch/mips/include/asm/cpu-info.h     |   4 +-
 arch/mips/include/asm/cpu.h          |   1 +
 arch/mips/include/asm/mips-cm.h      |   6 +-
 arch/mips/include/asm/mips-cpc.h     |   3 +
 arch/mips/include/asm/mipsregs.h     |   1 +
 arch/mips/include/asm/smp-cps.h      |   2 +-
 arch/mips/kernel/cps-vec.S           | 296 ++++++++++++++++++++++-------------
 arch/mips/kernel/cpu-probe.c         |   2 +
 arch/mips/kernel/pm-cps.c            |  15 +-
 arch/mips/kernel/smp-cps.c           |  64 +++++++-
 arch/mips/kernel/traps.c             |   7 +
 drivers/irqchip/irq-mips-gic.c       |  22 ++-
 include/linux/irqchip/mips-gic.h     |  17 ++
 15 files changed, 320 insertions(+), 126 deletions(-)

-- 
2.7.0

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

* [PATCH 01/15] MIPS: Detect MIPSr6 Virtual Processor support
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 02/15] MIPS: traps: Make sure secondary cores have a sane ebase register Paul Burton
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Maciej W. Rozycki, Joshua Kinard, Steven J. Hill,
	Leonid Yegoshin, linux-kernel, James Hogan, Markos Chandras

MIPSr6 introduces support for "Virtual Processors", which are
conceptually similar to VPEs from the now-deprecated MT ASE. Detect
whether the system supports VPs using the VP bit in Config5, adding
cpu_has_vp for use by later patches.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/include/asm/cpu-features.h | 4 ++++
 arch/mips/include/asm/cpu.h          | 1 +
 arch/mips/include/asm/mipsregs.h     | 1 +
 arch/mips/kernel/cpu-probe.c         | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index eeec8c8..57cdc5b 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -311,6 +311,10 @@
 #define cpu_has_mipsmt		(cpu_data[0].ases & MIPS_ASE_MIPSMT)
 #endif
 
+#ifndef cpu_has_vp
+#define cpu_has_vp		(cpu_data[0].options & MIPS_CPU_VP)
+#endif
+
 #ifndef cpu_has_userlocal
 #define cpu_has_userlocal	(cpu_data[0].options & MIPS_CPU_ULRI)
 #endif
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index a97ca97..82a26ed 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -388,6 +388,7 @@ enum cpu_type_enum {
 #define MIPS_CPU_FTLB		0x20000000000ull /* CPU has Fixed-page-size TLB */
 #define MIPS_CPU_NAN_LEGACY	0x40000000000ull /* Legacy NaN implemented */
 #define MIPS_CPU_NAN_2008	0x80000000000ull /* 2008 NaN implemented */
+#define MIPS_CPU_VP		0x100000000000ull /* MIPSr6 Virtual Processors (multi-threading) */
 
 /*
  * CPU ASE encodings
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 3ad19ad..ca251f6 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -623,6 +623,7 @@
 #define MIPS_CONF5_MRP		(_ULCAST_(1) << 3)
 #define MIPS_CONF5_LLB		(_ULCAST_(1) << 4)
 #define MIPS_CONF5_MVH		(_ULCAST_(1) << 5)
+#define MIPS_CONF5_VP		(_ULCAST_(1) << 7)
 #define MIPS_CONF5_FRE		(_ULCAST_(1) << 8)
 #define MIPS_CONF5_UFE		(_ULCAST_(1) << 9)
 #define MIPS_CONF5_MSAEN	(_ULCAST_(1) << 27)
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index b725b71..e38442d 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -796,6 +796,8 @@ static inline unsigned int decode_config5(struct cpuinfo_mips *c)
 	if (config5 & MIPS_CONF5_MVH)
 		c->options |= MIPS_CPU_XPA;
 #endif
+	if (cpu_has_mips_r6 && (config5 & MIPS_CONF5_VP))
+		c->options |= MIPS_CPU_VP;
 
 	return config5 & MIPS_CONF_M;
 }
-- 
2.7.0

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

* [PATCH 02/15] MIPS: traps: Make sure secondary cores have a sane ebase register
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
  2016-02-03  3:15 ` [PATCH 01/15] MIPS: Detect MIPSr6 Virtual Processor support Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 03/15] MIPS: pm-cps: Avoid offset overflow on MIPSr6 Paul Burton
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Markos Chandras, Paul Burton, Leonid Yegoshin, Maciej W. Rozycki,
	linux-kernel, James Hogan, Petri Gynther

From: Markos Chandras <markos.chandras@imgtec.com>

We shouldn't trust that the secondary cores will have a sane ebase register
(either from the bootloader or during the hardware design phase) so use the
ebase address as calculated by the boot CPU.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/traps.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index bafcb7a..1fb5f8a 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -2125,6 +2125,13 @@ void per_cpu_trap_init(bool is_boot_cpu)
 	 *  o read IntCtl.IPFDC to determine the fast debug channel interrupt
 	 */
 	if (cpu_has_mips_r2_r6) {
+		/*
+		 * We shouldn't trust a secondary core has a sane EBASE register
+		 * so use the one calculated by the boot CPU.
+		 */
+		if (!is_boot_cpu)
+			write_c0_ebase(ebase);
+
 		cp0_compare_irq_shift = CAUSEB_TI - CAUSEB_IP;
 		cp0_compare_irq = (read_c0_intctl() >> INTCTLB_IPTI) & 7;
 		cp0_perfcount_irq = (read_c0_intctl() >> INTCTLB_IPPCI) & 7;
-- 
2.7.0

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

* [PATCH 03/15] MIPS: pm-cps: Avoid offset overflow on MIPSr6
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
  2016-02-03  3:15 ` [PATCH 01/15] MIPS: Detect MIPSr6 Virtual Processor support Paul Burton
  2016-02-03  3:15 ` [PATCH 02/15] MIPS: traps: Make sure secondary cores have a sane ebase register Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03 14:48   ` James Hogan
  2016-02-03  3:15 ` [PATCH 04/15] MIPS: CPC: Add start, stop and running CM3 CPC registers Paul Burton
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Markos Chandras, Paul Burton, linux-kernel

From: Markos Chandras <markos.chandras@imgtec.com>

This is similar to commit 934c79231c1b ("MIPS: asm: r4kcache: Add MIPS
R6 cache unroll functions"). The CACHE instruction has been redefined
for MIPSr6 and it reduced its offset field to 8 bits. This leads to
micro-assembler field overflow warnings when booting SMP MIPSr6 cores
like the following one:

Call Trace:
[<ffffffff8010af88>] show_stack+0x68/0x88
[<ffffffff8056ddf0>] dump_stack+0x68/0x88
[<ffffffff801305bc>] warn_slowpath_common+0x8c/0xc8
[<ffffffff80130630>] warn_slowpath_fmt+0x38/0x48
[<ffffffff80125814>] build_insn+0x514/0x5c0
[<ffffffff806ee134>] cps_gen_cache_routine.isra.3+0xe0/0x1b8
[<ffffffff806ee570>] cps_pm_init+0x364/0x9ec
[<ffffffff80100538>] do_one_initcall+0x90/0x1a8
[<ffffffff806e8c14>] kernel_init_freeable+0x160/0x21c
[<ffffffff8056b6a0>] kernel_init+0x10/0xf8
[<ffffffff801059f8>] ret_from_kernel_thread+0x14/0x1c

We fix this by incrementing the base register on every loop.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/pm-cps.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c
index f63a289..524ba11 100644
--- a/arch/mips/kernel/pm-cps.c
+++ b/arch/mips/kernel/pm-cps.c
@@ -224,11 +224,18 @@ static void __init cps_gen_cache_routine(u32 **pp, struct uasm_label **pl,
 	uasm_build_label(pl, *pp, lbl);
 
 	/* Generate the cache ops */
-	for (i = 0; i < unroll_lines; i++)
-		uasm_i_cache(pp, op, i * cache->linesz, t0);
+	for (i = 0; i < unroll_lines; i++) {
+		if (cpu_has_mips_r6) {
+			uasm_i_cache(pp, op, 0, t0);
+			uasm_i_addiu(pp, t0, t0, cache->linesz);
+		} else {
+			uasm_i_cache(pp, op, i * cache->linesz, t0);
+		}
+	}
 
-	/* Update the base address */
-	uasm_i_addiu(pp, t0, t0, unroll_lines * cache->linesz);
+	if (!cpu_has_mips_r6)
+		/* Update the base address */
+		uasm_i_addiu(pp, t0, t0, unroll_lines * cache->linesz);
 
 	/* Loop if we haven't reached the end address yet */
 	uasm_il_bne(pp, pr, t0, t1, lbl);
-- 
2.7.0

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

* [PATCH 04/15] MIPS: CPC: Add start, stop and running CM3 CPC registers
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (2 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 03/15] MIPS: pm-cps: Avoid offset overflow on MIPSr6 Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 05/15] MIPS: CM: Add CM GCR_BEV_BASE accessors Paul Burton
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Markos Chandras, Paul Burton, Bjorn Helgaas, linux-kernel

From: Markos Chandras <markos.chandras@imgtec.com>

Add the new CM3 registers for controlling bringing up and powering down
VPs on MIPSR6 cores.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/include/asm/mips-cpc.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/mips/include/asm/mips-cpc.h b/arch/mips/include/asm/mips-cpc.h
index e090352..8c519f9 100644
--- a/arch/mips/include/asm/mips-cpc.h
+++ b/arch/mips/include/asm/mips-cpc.h
@@ -106,6 +106,9 @@ BUILD_CPC_R_(revision,		MIPS_CPC_GCB_OFS + 0x20)
 BUILD_CPC_Cx_RW(cmd,		0x00)
 BUILD_CPC_Cx_RW(stat_conf,	0x08)
 BUILD_CPC_Cx_RW(other,		0x10)
+BUILD_CPC_Cx_RW(vp_stop,	0x20)
+BUILD_CPC_Cx_RW(vp_run,		0x28)
+BUILD_CPC_Cx_RW(vp_running,	0x30)
 
 /* CPC_Cx_CMD register fields */
 #define CPC_Cx_CMD_SHF				0
-- 
2.7.0

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

* [PATCH 05/15] MIPS: CM: Add CM GCR_BEV_BASE accessors
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (3 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 04/15] MIPS: CPC: Add start, stop and running CM3 CPC registers Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels Paul Burton
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Matt Redfearn, linux-kernel, Thomas Gleixner,
	Markos Chandras

Generate accessor functions for the GCR_BEV_BASE register introduced by
CM3, for use by a later patch.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/include/asm/mips-cm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
index b196825..1395bbc 100644
--- a/arch/mips/include/asm/mips-cm.h
+++ b/arch/mips/include/asm/mips-cm.h
@@ -208,6 +208,7 @@ BUILD_CM_RW(l2_config,		MIPS_CM_GCB_OFS + 0x130)
 BUILD_CM_RW(sys_config2,	MIPS_CM_GCB_OFS + 0x150)
 BUILD_CM_RW(l2_pft_control,	MIPS_CM_GCB_OFS + 0x300)
 BUILD_CM_RW(l2_pft_control_b,	MIPS_CM_GCB_OFS + 0x308)
+BUILD_CM_RW(bev_base,		MIPS_CM_GCB_OFS + 0x680)
 
 /* Core Local & Core Other register accessor functions */
 BUILD_CM_Cx_RW(reset_release,	0x00)
-- 
2.7.0

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

* [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (4 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 05/15] MIPS: CM: Add CM GCR_BEV_BASE accessors Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03 14:58   ` James Hogan
  2016-02-03  3:15 ` [PATCH 07/15] irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR Paul Burton
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Matt Redfearn, linux-kernel, Thomas Gleixner,
	Markos Chandras

Fix mips_cm_max_vp_width for UP kernels where it previously referenced
smp_num_siblings, which is not declared for UP kernels. This led to
build errors such as the following:

  drivers/built-in.o: In function `$L446':
  irq-mips-gic.c:(.text+0x1994): undefined reference to `smp_num_siblings'
  drivers/built-in.o:irq-mips-gic.c:(.text+0x199c): more undefined references to `smp_num_siblings' follow

On UP kernels simply return 1, leaving the reference to smp_num_siblings
in place only for SMP kernels.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/include/asm/mips-cm.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
index 1395bbc..3fdb6c9 100644
--- a/arch/mips/include/asm/mips-cm.h
+++ b/arch/mips/include/asm/mips-cm.h
@@ -462,7 +462,10 @@ static inline unsigned int mips_cm_max_vp_width(void)
 	if (mips_cm_revision() >= CM_REV_CM3)
 		return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW_MSK;
 
-	return smp_num_siblings;
+	if (config_enabled(CONFIG_SMP))
+		return smp_num_siblings;
+
+	return 1;
 }
 
 /**
-- 
2.7.0

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

* [PATCH 07/15] irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (5 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-18  1:47   ` Jason Cooper
  2016-02-03  3:15 ` [PATCH 08/15] irqchip: mips-gic: Provide VP ID accessor Paul Burton
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Marc Zyngier, Jason Cooper, Thomas Gleixner,
	linux-kernel

The Linux CPU number doesn't necessarily match up with the ID used for a
VP by hardware. Convert the CPU number to the HW ID using mips_cm_vp_id
when writing to the VP(E)_OTHER_ADDR register in order to ensure that we
correctly access registers for the VPs of secondary cores. This most
notably affects systems using CM3, such as those based around I6400.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 drivers/irqchip/irq-mips-gic.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index 9e17ef2..787bafc 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -181,7 +181,7 @@ void gic_write_cpu_compare(cycle_t cnt, int cpu)
 
 	local_irq_save(flags);
 
-	gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), cpu);
+	gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), mips_cm_vp_id(cpu));
 
 	if (mips_cm_is64) {
 		gic_write(GIC_REG(VPE_OTHER, GIC_VPE_COMPARE), cnt);
@@ -534,7 +534,8 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d)
 
 	spin_lock_irqsave(&gic_lock, flags);
 	for (i = 0; i < gic_vpes; i++) {
-		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
+		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR),
+			  mips_cm_vp_id(i));
 		gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_RMASK), 1 << intr);
 	}
 	spin_unlock_irqrestore(&gic_lock, flags);
@@ -548,7 +549,8 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
 
 	spin_lock_irqsave(&gic_lock, flags);
 	for (i = 0; i < gic_vpes; i++) {
-		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
+		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR),
+			  mips_cm_vp_id(i));
 		gic_write32(GIC_REG(VPE_OTHER, GIC_VPE_SMASK), 1 << intr);
 	}
 	spin_unlock_irqrestore(&gic_lock, flags);
@@ -665,7 +667,8 @@ static void __init gic_basic_init(void)
 	for (i = 0; i < gic_vpes; i++) {
 		unsigned int j;
 
-		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
+		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR),
+			  mips_cm_vp_id(i));
 		for (j = 0; j < GIC_NUM_LOCAL_INTRS; j++) {
 			if (!gic_local_irq_is_routable(j))
 				continue;
@@ -710,7 +713,8 @@ static int gic_local_irq_domain_map(struct irq_domain *d, unsigned int virq,
 	for (i = 0; i < gic_vpes; i++) {
 		u32 val = GIC_MAP_TO_PIN_MSK | gic_cpu_pin;
 
-		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), i);
+		gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR),
+			  mips_cm_vp_id(i));
 
 		switch (intr) {
 		case GIC_LOCAL_INT_WD:
-- 
2.7.0

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

* [PATCH 08/15] irqchip: mips-gic: Provide VP ID accessor
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (6 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 07/15] irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-18  1:48   ` Jason Cooper
  2016-02-03  3:15 ` [PATCH 09/15] MIPS: smp-cps: Ensure our VP ident calculation is correct Paul Burton
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Andrew Bresticker, Jason Cooper, Thomas Gleixner,
	linux-kernel, James Hogan, Markos Chandras, Marc Zyngier,
	Alex Smith

Provide a gic_read_local_vp_id() function to read the VCNUM field of the
GICs local VP_IDENT register. This will be used by a further patch to
check that the value reported by the GIC matches up with the kernels
calculation.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 drivers/irqchip/irq-mips-gic.c   |  8 ++++++++
 include/linux/irqchip/mips-gic.h | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index 787bafc..e569c52 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -230,6 +230,14 @@ void gic_stop_count(void)
 
 #endif
 
+unsigned gic_read_local_vp_id(void)
+{
+	unsigned long ident;
+
+	ident = gic_read(GIC_REG(VPE_LOCAL, GIC_VP_IDENT));
+	return ident & GIC_VP_IDENT_VCNUM_MSK;
+}
+
 static bool gic_local_irq_is_routable(int intr)
 {
 	u32 vpe_ctl;
diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h
index ce824db..d5d82c7 100644
--- a/include/linux/irqchip/mips-gic.h
+++ b/include/linux/irqchip/mips-gic.h
@@ -103,6 +103,7 @@
 #define GIC_VPE_SWINT0_MAP_OFS		0x0054
 #define GIC_VPE_SWINT1_MAP_OFS		0x0058
 #define GIC_VPE_OTHER_ADDR_OFS		0x0080
+#define GIC_VP_IDENT_OFS		0x0088
 #define GIC_VPE_WD_CONFIG0_OFS		0x0090
 #define GIC_VPE_WD_COUNT0_OFS		0x0094
 #define GIC_VPE_WD_INITIAL0_OFS		0x0098
@@ -211,6 +212,10 @@
 #define GIC_VPE_SMASK_FDC_SHF		6
 #define GIC_VPE_SMASK_FDC_MSK		(MSK(1) << GIC_VPE_SMASK_FDC_SHF)
 
+/* GIC_VP_IDENT fields */
+#define GIC_VP_IDENT_VCNUM_SHF		0
+#define GIC_VP_IDENT_VCNUM_MSK		(MSK(6) << GIC_VP_IDENT_VCNUM_SHF)
+
 /* GIC nomenclature for Core Interrupt Pins. */
 #define GIC_CPU_INT0		0 /* Core Interrupt 2 */
 #define GIC_CPU_INT1		1 /* .		      */
@@ -281,4 +286,16 @@ static inline int gic_get_usm_range(struct resource *gic_usm_res)
 
 #endif /* CONFIG_MIPS_GIC */
 
+/**
+ * gic_read_local_vp_id() - read the local VPs VCNUM
+ *
+ * Read the VCNUM of the local VP from the GIC_VP_IDENT register and
+ * return it to the caller. This ID should be used to refer to the VP
+ * via the GICs VP-other region, or when calculating an offset to a
+ * bit representing the VP in interrupt masks.
+ *
+ * Return: The VCNUM value for the local VP.
+ */
+extern unsigned gic_read_local_vp_id(void);
+
 #endif /* __LINUX_IRQCHIP_MIPS_GIC_H */
-- 
2.7.0

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

* [PATCH 09/15] MIPS: smp-cps: Ensure our VP ident calculation is correct
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (7 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 08/15] irqchip: mips-gic: Provide VP ID accessor Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 10/15] MIPS: smp-cps: Pull cache init into a function Paul Burton
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Rusty Russell, Matt Redfearn, linux-kernel,
	Niklas Cassel, Ezequiel Garcia, Markos Chandras

When bringing up a CPU, ensure that its local ID as provided by the GIC
matches up with our calculation of it. This is vital, since if the
condition doesn't hold then we won't have configured interrupts
correctly for the VP.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/smp-cps.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 2ad4e4c..7b35dec 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -307,6 +307,17 @@ static void cps_init_secondary(void)
 	if (cpu_has_mipsmt)
 		dmt();
 
+	if (mips_cm_revision() >= CM_REV_CM3) {
+		unsigned ident = gic_read_local_vp_id();
+
+		/*
+		 * Ensure that our calculation of the VP ID matches up with
+		 * what the GIC reports, otherwise we'll have configured
+		 * interrupts incorrectly.
+		 */
+		BUG_ON(ident != mips_cm_vp_id(smp_processor_id()));
+	}
+
 	change_c0_status(ST0_IM, STATUSF_IP2 | STATUSF_IP3 | STATUSF_IP4 |
 				 STATUSF_IP5 | STATUSF_IP6 | STATUSF_IP7);
 }
-- 
2.7.0

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

* [PATCH 10/15] MIPS: smp-cps: Pull cache init into a function
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (8 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 09/15] MIPS: smp-cps: Ensure our VP ident calculation is correct Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 11/15] MIPS: smp-cps: Pull boot config retrieval out of mips_cps_boot_vpes Paul Burton
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, Markos Chandras, linux-kernel

In preparation for further modifications to mips_cps_core_entry, pull
the L1 cache initialisation out into a separate function. This both
makes the code in mips_cps_core_entry read more clearly, particularly
when modifying it, and shortens it which will become important as code
is added that needs to continue to fit within the reset vector.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/cps-vec.S | 143 ++++++++++++++++++++++++---------------------
 1 file changed, 76 insertions(+), 67 deletions(-)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index ac81edd..8d5ea4b 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -90,74 +90,9 @@ not_nmi:
 	li	t0, ST0_CU1 | ST0_CU0 | ST0_BEV | STATUS_BITDEPS
 	mtc0	t0, CP0_STATUS
 
-	/*
-	 * Clear the bits used to index the caches. Note that the architecture
-	 * dictates that writing to any of TagLo or TagHi selects 0 or 2 should
-	 * be valid for all MIPS32 CPUs, even those for which said writes are
-	 * unnecessary.
-	 */
-	mtc0	zero, CP0_TAGLO, 0
-	mtc0	zero, CP0_TAGHI, 0
-	mtc0	zero, CP0_TAGLO, 2
-	mtc0	zero, CP0_TAGHI, 2
-	ehb
-
-	/* Primary cache configuration is indicated by Config1 */
-	mfc0	v0, CP0_CONFIG, 1
-
-	/* Detect I-cache line size */
-	_EXT	t0, v0, MIPS_CONF1_IL_SHF, MIPS_CONF1_IL_SZ
-	beqz	t0, icache_done
-	 li	t1, 2
-	sllv	t0, t1, t0
-
-	/* Detect I-cache size */
-	_EXT	t1, v0, MIPS_CONF1_IS_SHF, MIPS_CONF1_IS_SZ
-	xori	t2, t1, 0x7
-	beqz	t2, 1f
-	 li	t3, 32
-	addiu	t1, t1, 1
-	sllv	t1, t3, t1
-1:	/* At this point t1 == I-cache sets per way */
-	_EXT	t2, v0, MIPS_CONF1_IA_SHF, MIPS_CONF1_IA_SZ
-	addiu	t2, t2, 1
-	mul	t1, t1, t0
-	mul	t1, t1, t2
-
-	li	a0, CKSEG0
-	PTR_ADD	a1, a0, t1
-1:	cache	Index_Store_Tag_I, 0(a0)
-	PTR_ADD	a0, a0, t0
-	bne	a0, a1, 1b
+	/* Initialize the L1 caches */
+	jal	mips_cps_cache_init
 	 nop
-icache_done:
-
-	/* Detect D-cache line size */
-	_EXT	t0, v0, MIPS_CONF1_DL_SHF, MIPS_CONF1_DL_SZ
-	beqz	t0, dcache_done
-	 li	t1, 2
-	sllv	t0, t1, t0
-
-	/* Detect D-cache size */
-	_EXT	t1, v0, MIPS_CONF1_DS_SHF, MIPS_CONF1_DS_SZ
-	xori	t2, t1, 0x7
-	beqz	t2, 1f
-	 li	t3, 32
-	addiu	t1, t1, 1
-	sllv	t1, t3, t1
-1:	/* At this point t1 == D-cache sets per way */
-	_EXT	t2, v0, MIPS_CONF1_DA_SHF, MIPS_CONF1_DA_SZ
-	addiu	t2, t2, 1
-	mul	t1, t1, t0
-	mul	t1, t1, t2
-
-	li	a0, CKSEG0
-	PTR_ADDU a1, a0, t1
-	PTR_SUBU a1, a1, t0
-1:	cache	Index_Store_Tag_D, 0(a0)
-	bne	a0, a1, 1b
-	 PTR_ADD a0, a0, t0
-dcache_done:
 
 	/* Set Kseg0 CCA to that in s0 */
 	mfc0	t0, CP0_CONFIG
@@ -486,6 +421,80 @@ LEAF(mips_cps_boot_vpes)
 	 nop
 	END(mips_cps_boot_vpes)
 
+LEAF(mips_cps_cache_init)
+	/*
+	 * Clear the bits used to index the caches. Note that the architecture
+	 * dictates that writing to any of TagLo or TagHi selects 0 or 2 should
+	 * be valid for all MIPS32 CPUs, even those for which said writes are
+	 * unnecessary.
+	 */
+	mtc0	zero, CP0_TAGLO, 0
+	mtc0	zero, CP0_TAGHI, 0
+	mtc0	zero, CP0_TAGLO, 2
+	mtc0	zero, CP0_TAGHI, 2
+	ehb
+
+	/* Primary cache configuration is indicated by Config1 */
+	mfc0	v0, CP0_CONFIG, 1
+
+	/* Detect I-cache line size */
+	_EXT	t0, v0, MIPS_CONF1_IL_SHF, MIPS_CONF1_IL_SZ
+	beqz	t0, icache_done
+	 li	t1, 2
+	sllv	t0, t1, t0
+
+	/* Detect I-cache size */
+	_EXT	t1, v0, MIPS_CONF1_IS_SHF, MIPS_CONF1_IS_SZ
+	xori	t2, t1, 0x7
+	beqz	t2, 1f
+	 li	t3, 32
+	addiu	t1, t1, 1
+	sllv	t1, t3, t1
+1:	/* At this point t1 == I-cache sets per way */
+	_EXT	t2, v0, MIPS_CONF1_IA_SHF, MIPS_CONF1_IA_SZ
+	addiu	t2, t2, 1
+	mul	t1, t1, t0
+	mul	t1, t1, t2
+
+	li	a0, CKSEG0
+	PTR_ADD	a1, a0, t1
+1:	cache	Index_Store_Tag_I, 0(a0)
+	PTR_ADD	a0, a0, t0
+	bne	a0, a1, 1b
+	 nop
+icache_done:
+
+	/* Detect D-cache line size */
+	_EXT	t0, v0, MIPS_CONF1_DL_SHF, MIPS_CONF1_DL_SZ
+	beqz	t0, dcache_done
+	 li	t1, 2
+	sllv	t0, t1, t0
+
+	/* Detect D-cache size */
+	_EXT	t1, v0, MIPS_CONF1_DS_SHF, MIPS_CONF1_DS_SZ
+	xori	t2, t1, 0x7
+	beqz	t2, 1f
+	 li	t3, 32
+	addiu	t1, t1, 1
+	sllv	t1, t3, t1
+1:	/* At this point t1 == D-cache sets per way */
+	_EXT	t2, v0, MIPS_CONF1_DA_SHF, MIPS_CONF1_DA_SZ
+	addiu	t2, t2, 1
+	mul	t1, t1, t0
+	mul	t1, t1, t2
+
+	li	a0, CKSEG0
+	PTR_ADDU a1, a0, t1
+	PTR_SUBU a1, a1, t0
+1:	cache	Index_Store_Tag_D, 0(a0)
+	bne	a0, a1, 1b
+	 PTR_ADD a0, a0, t0
+dcache_done:
+
+	jr	ra
+	 nop
+	END(mips_cps_cache_init)
+
 #if defined(CONFIG_MIPS_CPS_PM) && defined(CONFIG_CPU_PM)
 
 	/* Calculate a pointer to this CPUs struct mips_static_suspend_state */
-- 
2.7.0

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

* [PATCH 11/15] MIPS: smp-cps: Pull boot config retrieval out of mips_cps_boot_vpes
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (9 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 10/15] MIPS: smp-cps: Pull cache init into a function Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 12/15] MIPS: smp-cps: Skip core setup if coherent Paul Burton
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Rusty Russell, Matt Redfearn, linux-kernel,
	Niklas Cassel, Ezequiel Garcia, Markos Chandras

The mips_cps_boot_vpes function previously included code to retrieve
pointers to the core & VPE boot configuration structs. These structures
were used both by mips_cps_boot_vpes and by its mips_cps_core_entry
callsite. In preparation for skipping the call to mips_cps_boot_vpes on
some invocations of mips_cps_core_entry, pull the calculation of those
pointers out into a separate function such that it can continue to be
shared.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/include/asm/smp-cps.h |  2 +-
 arch/mips/kernel/cps-vec.S      | 74 +++++++++++++++++++++++++----------------
 arch/mips/kernel/smp-cps.c      |  7 ++--
 3 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/arch/mips/include/asm/smp-cps.h b/arch/mips/include/asm/smp-cps.h
index 326c16e..2ae1f61 100644
--- a/arch/mips/include/asm/smp-cps.h
+++ b/arch/mips/include/asm/smp-cps.h
@@ -29,7 +29,7 @@ extern struct core_boot_config *mips_cps_core_bootcfg;
 extern void mips_cps_core_entry(void);
 extern void mips_cps_core_init(void);
 
-extern struct vpe_boot_config *mips_cps_boot_vpes(void);
+extern void mips_cps_boot_vpes(struct core_boot_config *cfg, unsigned vpe);
 
 extern void mips_cps_pm_save(void);
 extern void mips_cps_pm_restore(void);
diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 8d5ea4b..2613de9 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -60,6 +60,17 @@
 	 nop
 	.endm
 
+	/* Calculate an uncached address for the CM GCRs */
+	.macro	cmgcrb	dest
+	.set	push
+	.set	noat
+	MFC0	$1, CP0_CMGCRBASE
+	PTR_SLL	$1, $1, 4
+	PTR_LI	\dest, UNCAC_BASE
+	PTR_ADDU \dest, \dest, $1
+	.set	pop
+	.endm
+
 .section .text.cps-vec
 .balign 0x1000
 
@@ -102,13 +113,8 @@ not_nmi:
 	mtc0	t0, CP0_CONFIG
 	ehb
 
-	/* Calculate an uncached address for the CM GCRs */
-	MFC0	v1, CP0_CMGCRBASE
-	PTR_SLL	v1, v1, 4
-	PTR_LI	t0, UNCAC_BASE
-	PTR_ADDU v1, v1, t0
-
 	/* Enter the coherent domain */
+	cmgcrb	v1
 	li	t0, 0xff
 	sw	t0, GCR_CL_COHERENCE_OFS(v1)
 	ehb
@@ -128,17 +134,22 @@ not_nmi:
 	/* Do any EVA initialization if necessary */
 	eva_init
 
+	/* Retrieve boot configuration pointers */
+	jal	mips_cps_get_bootcfg
+	 nop
+
 	/*
 	 * Boot any other VPEs within this core that should be online, and
 	 * deactivate this VPE if it should be offline.
 	 */
+	move	a1, t9
 	jal	mips_cps_boot_vpes
-	 nop
+	 move	a0, v0
 
 	/* Off we go! */
-	PTR_L	t1, VPEBOOTCFG_PC(v0)
-	PTR_L	gp, VPEBOOTCFG_GP(v0)
-	PTR_L	sp, VPEBOOTCFG_SP(v0)
+	PTR_L	t1, VPEBOOTCFG_PC(v1)
+	PTR_L	gp, VPEBOOTCFG_GP(v1)
+	PTR_L	sp, VPEBOOTCFG_SP(v1)
 	jr	t1
 	 nop
 	END(mips_cps_core_entry)
@@ -258,18 +269,21 @@ LEAF(mips_cps_core_init)
 	 nop
 	END(mips_cps_core_init)
 
-LEAF(mips_cps_boot_vpes)
-	/* Retrieve CM base address */
-	PTR_LA	t0, mips_cm_base
-	PTR_L	t0, 0(t0)
-
+/**
+ * mips_cps_get_bootcfg() - retrieve boot configuration pointers
+ *
+ * Returns: pointer to struct core_boot_config in v0, pointer to
+ *          struct vpe_boot_config in v1, VPE ID in t9
+ */
+LEAF(mips_cps_get_bootcfg)
 	/* Calculate a pointer to this cores struct core_boot_config */
+	cmgcrb	t0
 	lw	t0, GCR_CL_ID_OFS(t0)
 	li	t1, COREBOOTCFG_SIZE
 	mul	t0, t0, t1
 	PTR_LA	t1, mips_cps_core_bootcfg
 	PTR_L	t1, 0(t1)
-	PTR_ADDU t0, t0, t1
+	PTR_ADDU v0, t0, t1
 
 	/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
 	li	t9, 0
@@ -297,22 +311,27 @@ LEAF(mips_cps_boot_vpes)
 
 1:	/* Calculate a pointer to this VPEs struct vpe_boot_config */
 	li	t1, VPEBOOTCFG_SIZE
-	mul	v0, t9, t1
-	PTR_L	ta3, COREBOOTCFG_VPECONFIG(t0)
-	PTR_ADDU v0, v0, ta3
-
-#ifdef CONFIG_MIPS_MT_SMP
+	mul	v1, t9, t1
+	PTR_L	ta3, COREBOOTCFG_VPECONFIG(v0)
+	PTR_ADDU v1, v1, ta3
 
-	/* If the core doesn't support MT then return */
-	bnez	ta2, 1f
-	 nop
 	jr	ra
 	 nop
+	END(mips_cps_get_bootcfg)
+
+LEAF(mips_cps_boot_vpes)
+	PTR_L	ta2, COREBOOTCFG_VPEMASK(a0)
+	PTR_L	ta3, COREBOOTCFG_VPECONFIG(a0)
+
+#ifdef CONFIG_MIPS_MT
 
 	.set	push
 	.set	mt
 
-1:	/* Enter VPE configuration state */
+	/* If the core doesn't support MT then return */
+	has_mt	t0, 5f
+
+	/* Enter VPE configuration state */
 	dvpe
 	PTR_LA	t1, 1f
 	jr.hb	t1
@@ -323,7 +342,6 @@ LEAF(mips_cps_boot_vpes)
 	ehb
 
 	/* Loop through each VPE */
-	PTR_L	ta2, COREBOOTCFG_VPEMASK(t0)
 	move	t8, ta2
 	li	ta1, 0
 
@@ -400,7 +418,7 @@ LEAF(mips_cps_boot_vpes)
 
 	/* Check whether this VPE is meant to be running */
 	li	t0, 1
-	sll	t0, t0, t9
+	sll	t0, t0, a1
 	and	t0, t0, t8
 	bnez	t0, 2f
 	 nop
@@ -417,7 +435,7 @@ LEAF(mips_cps_boot_vpes)
 #endif /* CONFIG_MIPS_MT_SMP */
 
 	/* Return */
-	jr	ra
+5:	jr	ra
 	 nop
 	END(mips_cps_boot_vpes)
 
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 7b35dec..afc727f 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -250,7 +250,10 @@ static void boot_core(unsigned core)
 
 static void remote_vpe_boot(void *dummy)
 {
-	mips_cps_boot_vpes();
+	unsigned core = current_cpu_data.core;
+	struct core_boot_config *core_cfg = &mips_cps_core_bootcfg[core];
+
+	mips_cps_boot_vpes(core_cfg, cpu_vpe_id(&current_cpu_data));
 }
 
 static void cps_boot_secondary(int cpu, struct task_struct *idle)
@@ -296,7 +299,7 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
 	BUG_ON(!cpu_has_mipsmt);
 
 	/* Boot a VPE on this core */
-	mips_cps_boot_vpes();
+	mips_cps_boot_vpes(core_cfg, vpe_id);
 out:
 	preempt_enable();
 }
-- 
2.7.0

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

* [PATCH 12/15] MIPS: smp-cps: Skip core setup if coherent
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (10 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 11/15] MIPS: smp-cps: Pull boot config retrieval out of mips_cps_boot_vpes Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 13/15] MIPS: smp-cps: Support MIPSr6 Virtual Processors Paul Burton
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, Markos Chandras, linux-kernel

In preparation for supporting MIPSr6 multithreading (ie. VPs) which will
begin execution from the core reset vector, skip core level setup if the
core is already coherent. This is never the case when a core is first
started, since boot_core explicitly clears the cores GCR_Cx_COH_EN
register, and always the case when secondary VPs start since the first
VP to start will have enabled coherence after initialising the core &
its caches.

One notable side effect of this patch is that eva_init gets called
slightly earlier, prior to mips_cps_core_init rather than after it.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/cps-vec.S | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 2613de9..4849cbd 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -101,43 +101,52 @@ not_nmi:
 	li	t0, ST0_CU1 | ST0_CU0 | ST0_BEV | STATUS_BITDEPS
 	mtc0	t0, CP0_STATUS
 
+	/* Skip cache & coherence setup if we're already coherent */
+	cmgcrb	v1
+	lw	s7, GCR_CL_COHERENCE_OFS(v1)
+	bnez	s7, 1f
+	 nop
+
 	/* Initialize the L1 caches */
 	jal	mips_cps_cache_init
 	 nop
 
+	/* Enter the coherent domain */
+	li	t0, 0xff
+	sw	t0, GCR_CL_COHERENCE_OFS(v1)
+	ehb
+
 	/* Set Kseg0 CCA to that in s0 */
-	mfc0	t0, CP0_CONFIG
+1:	mfc0	t0, CP0_CONFIG
 	ori	t0, 0x7
 	xori	t0, 0x7
 	or	t0, t0, s0
 	mtc0	t0, CP0_CONFIG
 	ehb
 
-	/* Enter the coherent domain */
-	cmgcrb	v1
-	li	t0, 0xff
-	sw	t0, GCR_CL_COHERENCE_OFS(v1)
-	ehb
-
 	/* Jump to kseg0 */
 	PTR_LA	t0, 1f
 	jr	t0
 	 nop
 
 	/*
-	 * We're up, cached & coherent. Perform any further required core-level
-	 * initialisation.
+	 * We're up, cached & coherent. Perform any EVA initialization necessary
+	 * before we access memory.
 	 */
-1:	jal	mips_cps_core_init
-	 nop
-
-	/* Do any EVA initialization if necessary */
-	eva_init
+1:	eva_init
 
 	/* Retrieve boot configuration pointers */
 	jal	mips_cps_get_bootcfg
 	 nop
 
+	/* Skip core-level init if we started up coherent */
+	bnez	s7, 1f
+	 nop
+
+	/* Perform any further required core-level initialisation */
+	jal	mips_cps_core_init
+	 nop
+
 	/*
 	 * Boot any other VPEs within this core that should be online, and
 	 * deactivate this VPE if it should be offline.
@@ -147,7 +156,7 @@ not_nmi:
 	 move	a0, v0
 
 	/* Off we go! */
-	PTR_L	t1, VPEBOOTCFG_PC(v1)
+1:	PTR_L	t1, VPEBOOTCFG_PC(v1)
 	PTR_L	gp, VPEBOOTCFG_GP(v1)
 	PTR_L	sp, VPEBOOTCFG_SP(v1)
 	jr	t1
-- 
2.7.0

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

* [PATCH 13/15] MIPS: smp-cps: Support MIPSr6 Virtual Processors
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (11 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 12/15] MIPS: smp-cps: Skip core setup if coherent Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-03  3:15 ` [PATCH 14/15] MIPS: smp-cps: Add nothreads kernel parameter Paul Burton
  2016-02-03  3:15 ` [PATCH 15/15] MIPS: smp-cps: Stop printing EJTAG exceptions to UART Paul Burton
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Matt Redfearn, Rusty Russell, Maciej W. Rozycki,
	linux-kernel, Niklas Cassel, Ezequiel Garcia, Markos Chandras

Introduce support for bringing up Virtual Processors in MIPSr6 systems
as CPUs, much like their VPE parallel from the now-deprecated MT ASE.
The existing mips_cps_boot_vpes function fits the MIPSr6 architecture
pretty well - it can now simply write the mask of running VPs to the
VC_RUN register, rather than looping through each & starting or stopping
as appropriate as is done for VPEs from the MT ASE. Thus the VP support
is in general an extension & simplification of the existing MT ASE VPE
(aka SMVP) support.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/Kconfig                |  2 +-
 arch/mips/include/asm/cpu-info.h |  4 +--
 arch/mips/kernel/cps-vec.S       | 53 ++++++++++++++++++++++++++++++++++++++--
 arch/mips/kernel/smp-cps.c       | 35 +++++++++++++++++++++++---
 4 files changed, 85 insertions(+), 9 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 57a945e..3edb582 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2283,7 +2283,7 @@ config MIPS_CMP
 
 config MIPS_CPS
 	bool "MIPS Coherent Processing System support"
-	depends on SYS_SUPPORTS_MIPS_CPS && !CPU_MIPSR6
+	depends on SYS_SUPPORTS_MIPS_CPS
 	select MIPS_CM
 	select MIPS_CPC
 	select MIPS_CPS_PM if HOTPLUG_CPU
diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h
index e7dc785..aa526c3 100644
--- a/arch/mips/include/asm/cpu-info.h
+++ b/arch/mips/include/asm/cpu-info.h
@@ -68,7 +68,7 @@ struct cpuinfo_mips {
 #ifdef CONFIG_64BIT
 	int			vmbits; /* Virtual memory size in bits */
 #endif
-#ifdef CONFIG_MIPS_MT_SMP
+#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
 	/*
 	 * There is not necessarily a 1:1 mapping of VPE num to CPU number
 	 * in particular on multi-core systems.
@@ -125,7 +125,7 @@ struct proc_cpuinfo_notifier_args {
 	unsigned long n;
 };
 
-#ifdef CONFIG_MIPS_MT_SMP
+#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
 # define cpu_vpe_id(cpuinfo)	((cpuinfo)->vpe_id)
 #else
 # define cpu_vpe_id(cpuinfo)	({ (void)cpuinfo; 0; })
diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 4849cbd..c28138d 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -18,9 +18,12 @@
 #include <asm/mipsmtregs.h>
 #include <asm/pm.h>
 
+#define GCR_CPC_BASE_OFS	0x0088
 #define GCR_CL_COHERENCE_OFS	0x2008
 #define GCR_CL_ID_OFS		0x2028
 
+#define CPC_CL_VC_RUN_OFS	0x2028
+
 .extern mips_cm_base
 
 .set noreorder
@@ -60,6 +63,26 @@
 	 nop
 	.endm
 
+	/*
+	 * Set dest to non-zero if the core supports MIPSr6 multithreading
+	 * (ie. VPs), else zero. If MIPSr6 multithreading is not supported then
+	 * branch to nomt.
+	 */
+	.macro	has_vp	dest, nomt
+	mfc0	\dest, CP0_CONFIG, 1
+	bgez	\dest, \nomt
+	 mfc0	\dest, CP0_CONFIG, 2
+	bgez	\dest, \nomt
+	 mfc0	\dest, CP0_CONFIG, 3
+	bgez	\dest, \nomt
+	 mfc0	\dest, CP0_CONFIG, 4
+	bgez	\dest, \nomt
+	 mfc0	\dest, CP0_CONFIG, 5
+	andi	\dest, \dest, MIPS_CONF5_VP
+	beqz	\dest, \nomt
+	 nop
+	.endm
+
 	/* Calculate an uncached address for the CM GCRs */
 	.macro	cmgcrb	dest
 	.set	push
@@ -296,7 +319,17 @@ LEAF(mips_cps_get_bootcfg)
 
 	/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
 	li	t9, 0
-#ifdef CONFIG_MIPS_MT_SMP
+#if defined(CONFIG_CPU_MIPSR6)
+	has_vp	ta2, 1f
+
+	/*
+	 * Assume non-contiguous numbering. Perhaps some day we'll need
+	 * to handle contiguous VP numbering, but no such systems yet
+	 * exist.
+	 */
+	mfc0	t9, $3, 1
+	andi	t9, t9, 0xff
+#elif defined(CONFIG_MIPS_MT_SMP)
 	has_mt	ta2, 1f
 
 	/* Find the number of VPEs present in the core */
@@ -332,7 +365,23 @@ LEAF(mips_cps_boot_vpes)
 	PTR_L	ta2, COREBOOTCFG_VPEMASK(a0)
 	PTR_L	ta3, COREBOOTCFG_VPECONFIG(a0)
 
-#ifdef CONFIG_MIPS_MT
+#if defined(CONFIG_CPU_MIPSR6)
+
+	has_vp	t0, 5f
+
+	/* Find base address of CPC */
+	cmgcrb	t3
+	PTR_L	t1, GCR_CPC_BASE_OFS(t3)
+	PTR_LI	t2, ~0x7fff
+	and	t1, t1, t2
+	PTR_LI	t2, UNCAC_BASE
+	PTR_ADD	t1, t1, t2
+
+	/* Set VC_RUN to the VPE mask */
+	PTR_S	ta2, CPC_CL_VC_RUN_OFS(t1)
+	ehb
+
+#elif defined(CONFIG_MIPS_MT)
 
 	.set	push
 	.set	mt
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index afc727f..27f1c04 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -35,7 +35,8 @@ static unsigned core_vpe_count(unsigned core)
 {
 	unsigned cfg;
 
-	if (!config_enabled(CONFIG_MIPS_MT_SMP) || !cpu_has_mipsmt)
+	if ((!config_enabled(CONFIG_MIPS_MT_SMP) || !cpu_has_mipsmt)
+		&& (!config_enabled(CONFIG_CPU_MIPSR6) || !cpu_has_vp))
 		return 1;
 
 	mips_cm_lock_other(core, 0);
@@ -47,11 +48,12 @@ static unsigned core_vpe_count(unsigned core)
 static void __init cps_smp_setup(void)
 {
 	unsigned int ncores, nvpes, core_vpes;
+	unsigned long core_entry;
 	int c, v;
 
 	/* Detect & record VPE topology */
 	ncores = mips_cm_numcores();
-	pr_info("VPE topology ");
+	pr_info("%s topology ", cpu_has_mips_r6 ? "VP" : "VPE");
 	for (c = nvpes = 0; c < ncores; c++) {
 		core_vpes = core_vpe_count(c);
 		pr_cont("%c%u", c ? ',' : '{', core_vpes);
@@ -62,7 +64,7 @@ static void __init cps_smp_setup(void)
 
 		for (v = 0; v < min_t(int, core_vpes, NR_CPUS - nvpes); v++) {
 			cpu_data[nvpes + v].core = c;
-#ifdef CONFIG_MIPS_MT_SMP
+#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
 			cpu_data[nvpes + v].vpe_id = v;
 #endif
 		}
@@ -91,6 +93,11 @@ static void __init cps_smp_setup(void)
 	/* Make core 0 coherent with everything */
 	write_gcr_cl_coherence(0xff);
 
+	if (mips_cm_revision() >= CM_REV_CM3) {
+		core_entry = CKSEG1ADDR((unsigned long)mips_cps_core_entry);
+		write_gcr_bev_base(core_entry);
+	}
+
 #ifdef CONFIG_MIPS_MT_FPAFF
 	/* If we have an FPU, enroll ourselves in the FPU-full mask */
 	if (cpu_has_fpu)
@@ -213,6 +220,18 @@ static void boot_core(unsigned core)
 	if (mips_cpc_present()) {
 		/* Reset the core */
 		mips_cpc_lock_other(core);
+
+		if (mips_cm_revision() >= CM_REV_CM3) {
+			/* Run VP0 following the reset */
+			write_cpc_co_vp_run(0x1);
+
+			/*
+			 * Ensure that the VP_RUN register is written before the
+			 * core leaves reset.
+			 */
+			wmb();
+		}
+
 		write_cpc_co_cmd(CPC_Cx_CMD_RESET);
 
 		timeout = 100;
@@ -262,6 +281,7 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
 	unsigned vpe_id = cpu_vpe_id(&cpu_data[cpu]);
 	struct core_boot_config *core_cfg = &mips_cps_core_bootcfg[core];
 	struct vpe_boot_config *vpe_cfg = &core_cfg->vpe_config[vpe_id];
+	unsigned long core_entry;
 	unsigned int remote;
 	int err;
 
@@ -279,6 +299,13 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
 		goto out;
 	}
 
+	if (cpu_has_vp) {
+		mips_cm_lock_other(core, vpe_id);
+		core_entry = CKSEG1ADDR((unsigned long)mips_cps_core_entry);
+		write_gcr_co_reset_base(core_entry);
+		mips_cm_unlock_other();
+	}
+
 	if (core != current_cpu_data.core) {
 		/* Boot a VPE on another powered up core */
 		for (remote = 0; remote < NR_CPUS; remote++) {
@@ -296,7 +323,7 @@ static void cps_boot_secondary(int cpu, struct task_struct *idle)
 		goto out;
 	}
 
-	BUG_ON(!cpu_has_mipsmt);
+	BUG_ON(!cpu_has_mipsmt && !cpu_has_vp);
 
 	/* Boot a VPE on this core */
 	mips_cps_boot_vpes(core_cfg, vpe_id);
-- 
2.7.0

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

* [PATCH 14/15] MIPS: smp-cps: Add nothreads kernel parameter
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (12 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 13/15] MIPS: smp-cps: Support MIPSr6 Virtual Processors Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  2016-02-18  2:40   ` Florian Fainelli
  2016-02-03  3:15 ` [PATCH 15/15] MIPS: smp-cps: Stop printing EJTAG exceptions to UART Paul Burton
  14 siblings, 1 reply; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Matt Redfearn, Rusty Russell, linux-kernel,
	Niklas Cassel, Ezequiel Garcia, Markos Chandras

When debugging a new system or core it can be useful to disable the use
of multithreading. Introduce a "nothreads" kernel command line parameter
that can be set in order to do so.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/smp-cps.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 27f1c04..23c29fc 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -27,14 +27,25 @@
 #include <asm/time.h>
 #include <asm/uasm.h>
 
+static bool threads_disabled;
 static DECLARE_BITMAP(core_power, NR_CPUS);
 
 struct core_boot_config *mips_cps_core_bootcfg;
 
+static int __init setup_nothreads(char *s)
+{
+	threads_disabled = true;
+	return 0;
+}
+early_param("nothreads", setup_nothreads);
+
 static unsigned core_vpe_count(unsigned core)
 {
 	unsigned cfg;
 
+	if (threads_disabled)
+		return 1;
+
 	if ((!config_enabled(CONFIG_MIPS_MT_SMP) || !cpu_has_mipsmt)
 		&& (!config_enabled(CONFIG_CPU_MIPSR6) || !cpu_has_vp))
 		return 1;
-- 
2.7.0

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

* [PATCH 15/15] MIPS: smp-cps: Stop printing EJTAG exceptions to UART
  2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
                   ` (13 preceding siblings ...)
  2016-02-03  3:15 ` [PATCH 14/15] MIPS: smp-cps: Add nothreads kernel parameter Paul Burton
@ 2016-02-03  3:15 ` Paul Burton
  14 siblings, 0 replies; 23+ messages in thread
From: Paul Burton @ 2016-02-03  3:15 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, Markos Chandras, linux-kernel

When CONFIG_MIPS_CPS_NS16550 is enabled, some register state is dumped
to the UART when an exception is taken via the BEV on secondary cores.
EJTAG exceptions are architecturally expected to be handled by the BEV
even when Status.BEV is 0. This effectively means that if userland
executes an sdbbp instruction on a secondary core then the kernel dumps
register state to the UART even though the exception is perfectly normal
& expected. Prevent this by simply not dumping information to the UART
for EJTAG exceptions.

Fixes: 609cf6f2291a ("MIPS: CPS: Early debug using an ns16550-compatible UART")
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

 arch/mips/kernel/cps-vec.S | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index c28138d..51b98dc 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -223,7 +223,6 @@ LEAF(excep_intex)
 
 .org 0x480
 LEAF(excep_ejtag)
-	DUMP_EXCEP("EJTAG")
 	PTR_LA	k0, ejtag_debug_handler
 	jr	k0
 	 nop
-- 
2.7.0

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

* Re: [PATCH 03/15] MIPS: pm-cps: Avoid offset overflow on MIPSr6
  2016-02-03  3:15 ` [PATCH 03/15] MIPS: pm-cps: Avoid offset overflow on MIPSr6 Paul Burton
@ 2016-02-03 14:48   ` James Hogan
  0 siblings, 0 replies; 23+ messages in thread
From: James Hogan @ 2016-02-03 14:48 UTC (permalink / raw)
  To: Paul Burton; +Cc: linux-mips, Ralf Baechle, Markos Chandras, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2535 bytes --]

On Wed, Feb 03, 2016 at 03:15:23AM +0000, Paul Burton wrote:
> From: Markos Chandras <markos.chandras@imgtec.com>
> 
> This is similar to commit 934c79231c1b ("MIPS: asm: r4kcache: Add MIPS
> R6 cache unroll functions"). The CACHE instruction has been redefined
> for MIPSr6 and it reduced its offset field to 8 bits. This leads to
> micro-assembler field overflow warnings when booting SMP MIPSr6 cores
> like the following one:
> 
> Call Trace:
> [<ffffffff8010af88>] show_stack+0x68/0x88
> [<ffffffff8056ddf0>] dump_stack+0x68/0x88
> [<ffffffff801305bc>] warn_slowpath_common+0x8c/0xc8
> [<ffffffff80130630>] warn_slowpath_fmt+0x38/0x48
> [<ffffffff80125814>] build_insn+0x514/0x5c0
> [<ffffffff806ee134>] cps_gen_cache_routine.isra.3+0xe0/0x1b8
> [<ffffffff806ee570>] cps_pm_init+0x364/0x9ec
> [<ffffffff80100538>] do_one_initcall+0x90/0x1a8
> [<ffffffff806e8c14>] kernel_init_freeable+0x160/0x21c
> [<ffffffff8056b6a0>] kernel_init+0x10/0xf8
> [<ffffffff801059f8>] ret_from_kernel_thread+0x14/0x1c
> 
> We fix this by incrementing the base register on every loop.
> 
> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---
> 
>  arch/mips/kernel/pm-cps.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c
> index f63a289..524ba11 100644
> --- a/arch/mips/kernel/pm-cps.c
> +++ b/arch/mips/kernel/pm-cps.c
> @@ -224,11 +224,18 @@ static void __init cps_gen_cache_routine(u32 **pp, struct uasm_label **pl,
>  	uasm_build_label(pl, *pp, lbl);
>  
>  	/* Generate the cache ops */
> -	for (i = 0; i < unroll_lines; i++)
> -		uasm_i_cache(pp, op, i * cache->linesz, t0);
> +	for (i = 0; i < unroll_lines; i++) {

Maybe worth adding a comment here to mention different immediate field
size in r6 encodings, otherwise it could look a bit mysterious to the
reader.

Cheers
James

> +		if (cpu_has_mips_r6) {
> +			uasm_i_cache(pp, op, 0, t0);
> +			uasm_i_addiu(pp, t0, t0, cache->linesz);
> +		} else {
> +			uasm_i_cache(pp, op, i * cache->linesz, t0);
> +		}
> +	}
>  
> -	/* Update the base address */
> -	uasm_i_addiu(pp, t0, t0, unroll_lines * cache->linesz);
> +	if (!cpu_has_mips_r6)
> +		/* Update the base address */
> +		uasm_i_addiu(pp, t0, t0, unroll_lines * cache->linesz);
>  
>  	/* Loop if we haven't reached the end address yet */
>  	uasm_il_bne(pp, pr, t0, t1, lbl);
> -- 
> 2.7.0
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels
  2016-02-03  3:15 ` [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels Paul Burton
@ 2016-02-03 14:58   ` James Hogan
  2016-02-03 15:46     ` Paul Burton
  0 siblings, 1 reply; 23+ messages in thread
From: James Hogan @ 2016-02-03 14:58 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Ralf Baechle, Matt Redfearn, linux-kernel,
	Thomas Gleixner, Markos Chandras

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

On Wed, Feb 03, 2016 at 03:15:26AM +0000, Paul Burton wrote:
> Fix mips_cm_max_vp_width for UP kernels where it previously referenced
> smp_num_siblings, which is not declared for UP kernels. This led to
> build errors such as the following:
> 
>   drivers/built-in.o: In function `$L446':
>   irq-mips-gic.c:(.text+0x1994): undefined reference to `smp_num_siblings'
>   drivers/built-in.o:irq-mips-gic.c:(.text+0x199c): more undefined references to `smp_num_siblings' follow
> 
> On UP kernels simply return 1, leaving the reference to smp_num_siblings
> in place only for SMP kernels.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>

Need tagging for stable v4.3+?

I do wonder if this should be handled in the header files though...

Cheers
James

> ---
> 
>  arch/mips/include/asm/mips-cm.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
> index 1395bbc..3fdb6c9 100644
> --- a/arch/mips/include/asm/mips-cm.h
> +++ b/arch/mips/include/asm/mips-cm.h
> @@ -462,7 +462,10 @@ static inline unsigned int mips_cm_max_vp_width(void)
>  	if (mips_cm_revision() >= CM_REV_CM3)
>  		return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW_MSK;
>  
> -	return smp_num_siblings;
> +	if (config_enabled(CONFIG_SMP))
> +		return smp_num_siblings;
> +
> +	return 1;
>  }
>  
>  /**
> -- 
> 2.7.0
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels
  2016-02-03 14:58   ` James Hogan
@ 2016-02-03 15:46     ` Paul Burton
  2016-02-03 16:15       ` James Hogan
  0 siblings, 1 reply; 23+ messages in thread
From: Paul Burton @ 2016-02-03 15:46 UTC (permalink / raw)
  To: James Hogan
  Cc: linux-mips, Ralf Baechle, Matt Redfearn, linux-kernel,
	Thomas Gleixner, Markos Chandras

On Wed, Feb 03, 2016 at 02:58:59PM +0000, James Hogan wrote:
> On Wed, Feb 03, 2016 at 03:15:26AM +0000, Paul Burton wrote:
> > Fix mips_cm_max_vp_width for UP kernels where it previously referenced
> > smp_num_siblings, which is not declared for UP kernels. This led to
> > build errors such as the following:
> > 
> >   drivers/built-in.o: In function `$L446':
> >   irq-mips-gic.c:(.text+0x1994): undefined reference to `smp_num_siblings'
> >   drivers/built-in.o:irq-mips-gic.c:(.text+0x199c): more undefined references to `smp_num_siblings' follow
> > 
> > On UP kernels simply return 1, leaving the reference to smp_num_siblings
> > in place only for SMP kernels.
> > 
> > Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> 
> Need tagging for stable v4.3+?

It happens that there were no uses of mips_cm_max_vp_width in UP
kernels, but some are added later in this series (the next patch for
instance). So I don't see a need to backport to stable branches. Sorry
that could have been clearer.

> I do wonder if this should be handled in the header files though...

As in you don't think it should be handled in headers? It seems like the
logical place to do it to me...

Or do you mean smp_num_siblings should be defined as 1 for UP kernels? I
did consider that approach, but thought this possibly more semantically
correct since smp isn't in use at all so neither is smp_num_siblings.

Thanks,
    Paul

> Cheers
> James
> 
> > ---
> > 
> >  arch/mips/include/asm/mips-cm.h | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
> > index 1395bbc..3fdb6c9 100644
> > --- a/arch/mips/include/asm/mips-cm.h
> > +++ b/arch/mips/include/asm/mips-cm.h
> > @@ -462,7 +462,10 @@ static inline unsigned int mips_cm_max_vp_width(void)
> >  	if (mips_cm_revision() >= CM_REV_CM3)
> >  		return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW_MSK;
> >  
> > -	return smp_num_siblings;
> > +	if (config_enabled(CONFIG_SMP))
> > +		return smp_num_siblings;
> > +
> > +	return 1;
> >  }
> >  
> >  /**
> > -- 
> > 2.7.0
> > 
> > 

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

* Re: [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels
  2016-02-03 15:46     ` Paul Burton
@ 2016-02-03 16:15       ` James Hogan
  0 siblings, 0 replies; 23+ messages in thread
From: James Hogan @ 2016-02-03 16:15 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Ralf Baechle, Matt Redfearn, linux-kernel,
	Thomas Gleixner, Markos Chandras

[-- Attachment #1: Type: text/plain, Size: 2497 bytes --]

On Wed, Feb 03, 2016 at 03:46:34PM +0000, Paul Burton wrote:
> On Wed, Feb 03, 2016 at 02:58:59PM +0000, James Hogan wrote:
> > On Wed, Feb 03, 2016 at 03:15:26AM +0000, Paul Burton wrote:
> > > Fix mips_cm_max_vp_width for UP kernels where it previously referenced
> > > smp_num_siblings, which is not declared for UP kernels. This led to
> > > build errors such as the following:
> > > 
> > >   drivers/built-in.o: In function `$L446':
> > >   irq-mips-gic.c:(.text+0x1994): undefined reference to `smp_num_siblings'
> > >   drivers/built-in.o:irq-mips-gic.c:(.text+0x199c): more undefined references to `smp_num_siblings' follow
> > > 
> > > On UP kernels simply return 1, leaving the reference to smp_num_siblings
> > > in place only for SMP kernels.
> > > 
> > > Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> > 
> > Need tagging for stable v4.3+?
> 
> It happens that there were no uses of mips_cm_max_vp_width in UP
> kernels, but some are added later in this series (the next patch for
> instance). So I don't see a need to backport to stable branches. Sorry
> that could have been clearer.
> 
> > I do wonder if this should be handled in the header files though...
> 
> As in you don't think it should be handled in headers? It seems like the
> logical place to do it to me...
> 
> Or do you mean smp_num_siblings should be defined as 1 for UP kernels? I
> did consider that approach, but thought this possibly more semantically
> correct since smp isn't in use at all so neither is smp_num_siblings.

Yeh, I meant this (didn't really register that the code in this patch
was a header too tbh).

Cheers
James

> 
> Thanks,
>     Paul
> 
> > Cheers
> > James
> > 
> > > ---
> > > 
> > >  arch/mips/include/asm/mips-cm.h | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h
> > > index 1395bbc..3fdb6c9 100644
> > > --- a/arch/mips/include/asm/mips-cm.h
> > > +++ b/arch/mips/include/asm/mips-cm.h
> > > @@ -462,7 +462,10 @@ static inline unsigned int mips_cm_max_vp_width(void)
> > >  	if (mips_cm_revision() >= CM_REV_CM3)
> > >  		return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW_MSK;
> > >  
> > > -	return smp_num_siblings;
> > > +	if (config_enabled(CONFIG_SMP))
> > > +		return smp_num_siblings;
> > > +
> > > +	return 1;
> > >  }
> > >  
> > >  /**
> > > -- 
> > > 2.7.0
> > > 
> > > 
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 07/15] irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR
  2016-02-03  3:15 ` [PATCH 07/15] irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR Paul Burton
@ 2016-02-18  1:47   ` Jason Cooper
  0 siblings, 0 replies; 23+ messages in thread
From: Jason Cooper @ 2016-02-18  1:47 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Ralf Baechle, Marc Zyngier, Thomas Gleixner,
	linux-kernel

On Wed, Feb 03, 2016 at 03:15:27AM +0000, Paul Burton wrote:
> The Linux CPU number doesn't necessarily match up with the ID used for a
> VP by hardware. Convert the CPU number to the HW ID using mips_cm_vp_id
> when writing to the VP(E)_OTHER_ADDR register in order to ensure that we
> correctly access registers for the VPs of secondary cores. This most
> notably affects systems using CM3, such as those based around I6400.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---
> 
>  drivers/irqchip/irq-mips-gic.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)

Note: standard subject line for irqchip is 'irqchip/mips-gic: [A-Z]...'
with that small change,

Acked-by: Jason Cooper <jason@lakedaemon.net>

thx,

Jason.

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

* Re: [PATCH 08/15] irqchip: mips-gic: Provide VP ID accessor
  2016-02-03  3:15 ` [PATCH 08/15] irqchip: mips-gic: Provide VP ID accessor Paul Burton
@ 2016-02-18  1:48   ` Jason Cooper
  0 siblings, 0 replies; 23+ messages in thread
From: Jason Cooper @ 2016-02-18  1:48 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Ralf Baechle, Andrew Bresticker, Thomas Gleixner,
	linux-kernel, James Hogan, Markos Chandras, Marc Zyngier,
	Alex Smith

On Wed, Feb 03, 2016 at 03:15:28AM +0000, Paul Burton wrote:
> Provide a gic_read_local_vp_id() function to read the VCNUM field of the
> GICs local VP_IDENT register. This will be used by a further patch to
> check that the value reported by the GIC matches up with the kernels
> calculation.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---
> 
>  drivers/irqchip/irq-mips-gic.c   |  8 ++++++++
>  include/linux/irqchip/mips-gic.h | 17 +++++++++++++++++
>  2 files changed, 25 insertions(+)

Same subject line nit here, otherwise,

Acked-by: Jason Cooper <jason@lakedaemon.net>

thx,

Jason.

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

* Re: [PATCH 14/15] MIPS: smp-cps: Add nothreads kernel parameter
  2016-02-03  3:15 ` [PATCH 14/15] MIPS: smp-cps: Add nothreads kernel parameter Paul Burton
@ 2016-02-18  2:40   ` Florian Fainelli
  0 siblings, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2016-02-18  2:40 UTC (permalink / raw)
  To: Paul Burton, linux-mips, Ralf Baechle
  Cc: Matt Redfearn, Rusty Russell, linux-kernel, Niklas Cassel,
	Ezequiel Garcia, Markos Chandras

Le 02/02/2016 19:15, Paul Burton a écrit :
> When debugging a new system or core it can be useful to disable the use
> of multithreading. Introduce a "nothreads" kernel command line parameter
> that can be set in order to do so.

This should be documented in Documentation/kernel-parameters.txt as well.
-- 
Florian

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

end of thread, other threads:[~2016-02-18  2:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-03  3:15 [PATCH 00/15] Support for MIPSr6 Virtual Processors (multi-threading) Paul Burton
2016-02-03  3:15 ` [PATCH 01/15] MIPS: Detect MIPSr6 Virtual Processor support Paul Burton
2016-02-03  3:15 ` [PATCH 02/15] MIPS: traps: Make sure secondary cores have a sane ebase register Paul Burton
2016-02-03  3:15 ` [PATCH 03/15] MIPS: pm-cps: Avoid offset overflow on MIPSr6 Paul Burton
2016-02-03 14:48   ` James Hogan
2016-02-03  3:15 ` [PATCH 04/15] MIPS: CPC: Add start, stop and running CM3 CPC registers Paul Burton
2016-02-03  3:15 ` [PATCH 05/15] MIPS: CM: Add CM GCR_BEV_BASE accessors Paul Burton
2016-02-03  3:15 ` [PATCH 06/15] MIPS: CM: Fix mips_cm_max_vp_width for UP kernels Paul Burton
2016-02-03 14:58   ` James Hogan
2016-02-03 15:46     ` Paul Burton
2016-02-03 16:15       ` James Hogan
2016-02-03  3:15 ` [PATCH 07/15] irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR Paul Burton
2016-02-18  1:47   ` Jason Cooper
2016-02-03  3:15 ` [PATCH 08/15] irqchip: mips-gic: Provide VP ID accessor Paul Burton
2016-02-18  1:48   ` Jason Cooper
2016-02-03  3:15 ` [PATCH 09/15] MIPS: smp-cps: Ensure our VP ident calculation is correct Paul Burton
2016-02-03  3:15 ` [PATCH 10/15] MIPS: smp-cps: Pull cache init into a function Paul Burton
2016-02-03  3:15 ` [PATCH 11/15] MIPS: smp-cps: Pull boot config retrieval out of mips_cps_boot_vpes Paul Burton
2016-02-03  3:15 ` [PATCH 12/15] MIPS: smp-cps: Skip core setup if coherent Paul Burton
2016-02-03  3:15 ` [PATCH 13/15] MIPS: smp-cps: Support MIPSr6 Virtual Processors Paul Burton
2016-02-03  3:15 ` [PATCH 14/15] MIPS: smp-cps: Add nothreads kernel parameter Paul Burton
2016-02-18  2:40   ` Florian Fainelli
2016-02-03  3:15 ` [PATCH 15/15] MIPS: smp-cps: Stop printing EJTAG exceptions to UART Paul Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox