linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] MIPS Virt board support
@ 2023-03-04 22:15 Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 01/12] MIPS: Move declaration of bcache ops to cache.c Jiaxun Yang
                   ` (11 more replies)
  0 siblings, 12 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Hi all,

This patchset adds support for the MIPS Virt board, which is based
on my QEMU patch [1].

It can work with all CPUs from MIPS Technologies, and also Loongson-2E,
Loongson-2F, Cavium Octeon, R4000.

Thanks to generic platform, there is nothing much to do for the platform
support, mostly decoupling CPU features with platform features, except for
last two patches.

I'm going to send PATCH v2 QEMU soon, and I will drop goldfish-pic based
variant I proposed in the initial QEMU patchset so the platform will purely
based on MIPS CPS (Coherent Processing System).

Note that due to QEMU limitation, SMP support is currently broken for all
processors other than MIPS I6400/I6500. This is because QEMU is now treatiing
secundary CPUs as a VPE (MIPS Release 6 VP). I'm going to fix that after getting
virt board support merged in QEMU.

Thanks.

- Jiaxun

Jiaxun Yang (12):
  MIPS: Move declaration of bcache ops to cache.c
  MIPS: smp-cps: Disable coherence setup for unsupported ISA
  MIPS: mips-cm: Check availability of config registers
  MIPS: Octeon: Opt-out 4k_cache feature
  MIPS: cpu-features: Enable octeon_cache by cpu_type
  MIPS: c-octeon: Provide alternative SMP cache flush function
  MIPS: Octeon: Allow CVMSEG to be disabled
  MIPS: Loongson: Move arch cflags to MIPS top level Makefile
  MIPS: Loongson: Don't select platform features with CPU
  MIPS: Octeon: Disable CVMSEG by default on other platforms
  MIPS: Add board config for virt board
  MIPS: generic: Enable all CPUs supported by virt board in Kconfig

 arch/mips/Kconfig                           |  6 ++--
 arch/mips/Makefile                          | 38 +++++++++++++++++++++
 arch/mips/cavium-octeon/Kconfig             |  3 +-
 arch/mips/configs/generic/board-virt.config | 38 +++++++++++++++++++++
 arch/mips/include/asm/cpu-features.h        | 21 ++++++++++--
 arch/mips/include/asm/processor.h           |  7 +++-
 arch/mips/kernel/asm-offsets.c              |  3 ++
 arch/mips/kernel/cps-vec.S                  |  5 +++
 arch/mips/kernel/cpu-probe.c                |  2 ++
 arch/mips/kernel/mips-cm.c                  |  9 +++--
 arch/mips/kernel/smp-cps.c                  |  5 +++
 arch/mips/loongson2ef/Kconfig               |  3 ++
 arch/mips/loongson2ef/Platform              | 35 -------------------
 arch/mips/loongson64/Platform               | 16 ---------
 arch/mips/mm/c-octeon.c                     |  8 ++++-
 arch/mips/mm/c-r4k.c                        | 14 --------
 arch/mips/mm/cache.c                        | 17 +++++++++
 17 files changed, 156 insertions(+), 74 deletions(-)
 create mode 100644 arch/mips/configs/generic/board-virt.config

-- 
2.34.1


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

* [PATCH 01/12] MIPS: Move declaration of bcache ops to cache.c
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 02/12] MIPS: smp-cps: Disable coherence setup for unsupported ISA Jiaxun Yang
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

bcache is not tied to CPU's cache interface. Just move those
declaration to cache.c so it can be avaialble to CPU with all
cache types.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/mm/c-r4k.c | 14 --------------
 arch/mips/mm/cache.c | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index a549fa98c2f4..fd660d5c5328 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -110,20 +110,6 @@ static unsigned long dcache_size __read_mostly;
 static unsigned long vcache_size __read_mostly;
 static unsigned long scache_size __read_mostly;
 
-/*
- * Dummy cache handling routines for machines without boardcaches
- */
-static void cache_noop(void) {}
-
-static struct bcache_ops no_sc_ops = {
-	.bc_enable = (void *)cache_noop,
-	.bc_disable = (void *)cache_noop,
-	.bc_wback_inv = (void *)cache_noop,
-	.bc_inv = (void *)cache_noop
-};
-
-struct bcache_ops *bcops = &no_sc_ops;
-
 #define cpu_is_r4600_v1_x()	((read_c0_prid() & 0xfffffff0) == 0x00002010)
 #define cpu_is_r4600_v2_x()	((read_c0_prid() & 0xfffffff0) == 0x00002020)
 
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
index 11b3e7ddafd5..25cedd6ee572 100644
--- a/arch/mips/mm/cache.c
+++ b/arch/mips/mm/cache.c
@@ -17,6 +17,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 
+#include <asm/bcache.h>
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
 #include <asm/cpu.h>
@@ -56,6 +57,22 @@ EXPORT_SYMBOL_GPL(local_flush_data_cache_page);
 EXPORT_SYMBOL(flush_data_cache_page);
 EXPORT_SYMBOL(flush_icache_all);
 
+#ifdef CONFIG_BOARD_SCACHE
+/*
+ * Dummy cache handling routines for machines without boardcaches
+ */
+static void cache_noop(void) {}
+
+static struct bcache_ops no_sc_ops = {
+	.bc_enable = (void *)cache_noop,
+	.bc_disable = (void *)cache_noop,
+	.bc_wback_inv = (void *)cache_noop,
+	.bc_inv = (void *)cache_noop
+};
+
+struct bcache_ops *bcops = &no_sc_ops;
+#endif
+
 #ifdef CONFIG_DMA_NONCOHERENT
 
 /* DMA cache operations. */
-- 
2.34.1


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

* [PATCH 02/12] MIPS: smp-cps: Disable coherence setup for unsupported ISA
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 01/12] MIPS: Move declaration of bcache ops to cache.c Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 03/12] MIPS: mips-cm: Check availability of config registers Jiaxun Yang
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

We don't know how to do coherence setup on ISA before MIPS
Release 1.

As CPS support only servers simulation purpose on those cores,
and simulators are always coherent, just disable initialization
code and provide user a warning in case coherence is not setup
properly.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/kernel/cps-vec.S | 5 +++++
 arch/mips/kernel/smp-cps.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index 8ef492da827f..64ecfdac6580 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -116,6 +116,8 @@ not_nmi:
 	li	t0, ST0_CU1 | ST0_CU0 | ST0_BEV | STATUS_BITDEPS
 	mtc0	t0, CP0_STATUS
 
+	/* We don't know how to do coherence setup on earlier ISA */
+#if MIPS_ISA_REV > 0
 	/* Skip cache & coherence setup if we're already coherent */
 	lw	s7, GCR_CL_COHERENCE_OFS(s1)
 	bnez	s7, 1f
@@ -129,6 +131,7 @@ not_nmi:
 	li	t0, 0xff
 	sw	t0, GCR_CL_COHERENCE_OFS(s1)
 	ehb
+#endif /* MIPS_ISA_REV > 0 */
 
 	/* Set Kseg0 CCA to that in s0 */
 1:	mfc0	t0, CP0_CONFIG
@@ -515,6 +518,7 @@ LEAF(mips_cps_boot_vpes)
 	 nop
 	END(mips_cps_boot_vpes)
 
+#if MIPS_ISA_REV > 0
 LEAF(mips_cps_cache_init)
 	/*
 	 * Clear the bits used to index the caches. Note that the architecture
@@ -588,6 +592,7 @@ dcache_done:
 	jr	ra
 	 nop
 	END(mips_cps_cache_init)
+#endif /* MIPS_ISA_REV > 0 */
 
 #if defined(CONFIG_MIPS_CPS_PM) && defined(CONFIG_CPU_PM)
 
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
index 4fc288bb85b9..f968a319d87f 100644
--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -361,6 +361,8 @@ static int cps_boot_secondary(int cpu, struct task_struct *idle)
 
 static void cps_init_secondary(void)
 {
+	int core = cpu_core(&current_cpu_data);
+
 	/* Disable MT - we only want to run 1 TC per VPE */
 	if (cpu_has_mipsmt)
 		dmt();
@@ -376,6 +378,9 @@ static void cps_init_secondary(void)
 		BUG_ON(ident != mips_cm_vp_id(smp_processor_id()));
 	}
 
+	if (core > 0 && !read_gcr_cl_coherence())
+		pr_warn("Core %u is not in coherent domain\n", core);
+
 	if (cpu_has_veic)
 		clear_c0_status(ST0_IM);
 	else
-- 
2.34.1


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

* [PATCH 03/12] MIPS: mips-cm: Check availability of config registers
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 01/12] MIPS: Move declaration of bcache ops to cache.c Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 02/12] MIPS: smp-cps: Disable coherence setup for unsupported ISA Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature Jiaxun Yang
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Prevent reading unsupported config register during probing process.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/kernel/mips-cm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
index b4f7d950c846..3f00788b0871 100644
--- a/arch/mips/kernel/mips-cm.c
+++ b/arch/mips/kernel/mips-cm.c
@@ -181,11 +181,16 @@ static DEFINE_PER_CPU_ALIGNED(unsigned long, cm_core_lock_flags);
 
 phys_addr_t __mips_cm_phys_base(void)
 {
-	u32 config3 = read_c0_config3();
 	unsigned long cmgcr;
 
 	/* Check the CMGCRBase register is implemented */
-	if (!(config3 & MIPS_CONF3_CMGCR))
+	if (!(read_c0_config() & MIPS_CONF_M))
+		return 0;
+
+	if (!(read_c0_config2() & MIPS_CONF_M))
+		return 0;
+
+	if (!(read_c0_config3() & MIPS_CONF3_CMGCR))
 		return 0;
 
 	/* Read the address from CMGCRBase */
-- 
2.34.1


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

* [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (2 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 03/12] MIPS: mips-cm: Check availability of config registers Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-06 14:28   ` Alexander Lobakin
  2023-03-04 22:15 ` [PATCH 05/12] MIPS: cpu-features: Enable octeon_cache by cpu_type Jiaxun Yang
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Octeon has a different cache interface with traditional R4K one,
just opt-out this flag for octeon to avoid run R4K cache initialization
code accidentally.

Also remove ISA level assumption for 4k cache.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/include/asm/cpu-features.h | 2 +-
 arch/mips/kernel/cpu-probe.c         | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index c0983130a44c..c613426b0bfc 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -118,7 +118,7 @@
 #define cpu_has_3k_cache	__isa_lt_and_opt(1, MIPS_CPU_3K_CACHE)
 #endif
 #ifndef cpu_has_4k_cache
-#define cpu_has_4k_cache	__isa_ge_or_opt(1, MIPS_CPU_4K_CACHE)
+#define cpu_has_4k_cache	__opt(MIPS_CPU_4K_CACHE)
 #endif
 #ifndef cpu_has_octeon_cache
 #define cpu_has_octeon_cache	0
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 7ddf07f255f3..6d15a398d389 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -1602,6 +1602,8 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
 static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
 {
 	decode_configs(c);
+	/* Octeon has different cache interface */
+	c->options &= ~MIPS_CPU_4K_CACHE;
 	switch (c->processor_id & PRID_IMP_MASK) {
 	case PRID_IMP_CAVIUM_CN38XX:
 	case PRID_IMP_CAVIUM_CN31XX:
-- 
2.34.1


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

* [PATCH 05/12] MIPS: cpu-features: Enable octeon_cache by cpu_type
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (3 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 06/12] MIPS: c-octeon: Provide alternative SMP cache flush function Jiaxun Yang
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

cpu_has_octeon_cache was tied to 0 for generic cpu-features,
whith this generic kernel built for octeon CPU won't boot.

Just enable this flag by cpu_type. It won't hurt orther platforms
because compiler will eliminate the code path on other processors.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/include/asm/cpu-features.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index c613426b0bfc..51a1737b03d0 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -121,7 +121,24 @@
 #define cpu_has_4k_cache	__opt(MIPS_CPU_4K_CACHE)
 #endif
 #ifndef cpu_has_octeon_cache
-#define cpu_has_octeon_cache	0
+#define cpu_has_octeon_cache						\
+({									\
+	int __res;							\
+									\
+	switch (current_cpu_type()) {					\
+	case CPU_CAVIUM_OCTEON:						\
+	case CPU_CAVIUM_OCTEON_PLUS:					\
+	case CPU_CAVIUM_OCTEON2:					\
+	case CPU_CAVIUM_OCTEON3:					\
+		__res = 1;						\
+		break;							\
+									\
+	default:							\
+		__res = 0;						\
+	}								\
+									\
+	__res;								\
+})
 #endif
 /* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work.  */
 #ifndef cpu_has_fpu
-- 
2.34.1


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

* [PATCH 06/12] MIPS: c-octeon: Provide alternative SMP cache flush function
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (4 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 05/12] MIPS: cpu-features: Enable octeon_cache by cpu_type Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-05  8:41   ` Sergei Shtylyov
  2023-03-04 22:15 ` [PATCH 07/12] MIPS: Octeon: Allow CVMSEG to be disabled Jiaxun Yang
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Curretly c-octeon relies on octeon's own smp function to flush
I-Cache. However this function is not available on generic platform.

Just use smp_call_function_many on generic platform.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/mm/c-octeon.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c
index c7ed589de882..61db09e5044c 100644
--- a/arch/mips/mm/c-octeon.c
+++ b/arch/mips/mm/c-octeon.c
@@ -83,8 +83,14 @@ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma)
 	else
 		mask = *cpu_online_mask;
 	cpumask_clear_cpu(cpu, &mask);
-	for_each_cpu(cpu, &mask)
+#ifdef CONFIG_CAVIUM_OCTEON_SOC
+	for_each_cpu(cpu, &mask) {
 		octeon_send_ipi_single(cpu, SMP_ICACHE_FLUSH);
+	}
+#else
+	smp_call_function_many(&mask, (smp_call_func_t)octeon_local_flush_icache,
+			       NULL, 1);
+#endif
 
 	preempt_enable();
 #endif
-- 
2.34.1


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

* [PATCH 07/12] MIPS: Octeon: Allow CVMSEG to be disabled
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (5 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 06/12] MIPS: c-octeon: Provide alternative SMP cache flush function Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 08/12] MIPS: Loongson: Move arch cflags to MIPS top level Makefile Jiaxun Yang
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Don't include cvmseg states into thread_status when
CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE is not defined or 0.

Fix compile for kernel without this feature.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/include/asm/processor.h | 7 ++++++-
 arch/mips/kernel/asm-offsets.c    | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 3fde1ff72bd1..ae2cd37a38f0 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -202,11 +202,13 @@ struct octeon_cop2_state {
 #define COP2_INIT						\
 	.cp2			= {0,},
 
+#if defined(CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE) && \
+	CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
 struct octeon_cvmseg_state {
 	unsigned long cvmseg[CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE]
 			    [cpu_dcache_line_size() / sizeof(unsigned long)];
 };
-
+#endif
 #else
 #define COP2_INIT
 #endif
@@ -263,7 +265,10 @@ struct thread_struct {
 	unsigned long trap_nr;
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
 	struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128)));
+#if defined(CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE) && \
+	CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
 	struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128)));
+#endif
 #endif
 	struct mips_abi *abi;
 };
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index c4501897b870..40fd4051bb3d 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -306,7 +306,10 @@ void output_octeon_cop2_state_defines(void)
 	OFFSET(OCTEON_CP2_HSH_IVW,	octeon_cop2_state, cop2_hsh_ivw);
 	OFFSET(OCTEON_CP2_SHA3,		octeon_cop2_state, cop2_sha3);
 	OFFSET(THREAD_CP2,	task_struct, thread.cp2);
+#if defined(CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE) && \
+	CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
 	OFFSET(THREAD_CVMSEG,	task_struct, thread.cvmseg.cvmseg);
+#endif
 	BLANK();
 }
 #endif
-- 
2.34.1


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

* [PATCH 08/12] MIPS: Loongson: Move arch cflags to MIPS top level Makefile
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (6 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 07/12] MIPS: Octeon: Allow CVMSEG to be disabled Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 09/12] MIPS: Loongson: Don't select platform features with CPU Jiaxun Yang
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Arch cflags should be independent to Platform.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/Makefile             | 38 ++++++++++++++++++++++++++++++++++
 arch/mips/loongson2ef/Platform | 35 -------------------------------
 arch/mips/loongson64/Platform  | 16 --------------
 3 files changed, 38 insertions(+), 51 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 04e46ec24319..a7a4ee66a9d3 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -181,9 +181,47 @@ endif
 cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
 cflags-$(CONFIG_CPU_BMIPS)	+= -march=mips32 -Wa,-mips32 -Wa,--trap
 
+cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap
+# Some -march= flags enable MMI instructions, and GCC complains about that
+# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
+cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi)
+ifdef CONFIG_CPU_LOONGSON64
+cflags-$(CONFIG_CPU_LOONGSON64)	+= -Wa,--trap
+cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a
+cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2
+endif
+cflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi)
+
 cflags-$(CONFIG_CPU_R4000_WORKAROUNDS)	+= $(call cc-option,-mfix-r4000,)
 cflags-$(CONFIG_CPU_R4400_WORKAROUNDS)	+= $(call cc-option,-mfix-r4400,)
 cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS)	+= $(call cc-option,-mno-daddi,)
+ifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS
+cflags-$(CONFIG_CPU_NOP_WORKAROUNDS) += -Wa,-mfix-loongson2f-nop
+cflags-$(CONFIG_CPU_JUMP_WORKAROUNDS) += -Wa,-mfix-loongson2f-jump
+endif
+
+#
+# Some versions of binutils, not currently mainline as of 2019/02/04, support
+# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction
+# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a
+# description).
+#
+# We disable this in order to prevent the assembler meddling with the
+# instruction that labels refer to, ie. if we label an ll instruction:
+#
+# 1: ll v0, 0(a0)
+#
+# ...then with the assembler fix applied the label may actually point at a sync
+# instruction inserted by the assembler, and if we were using the label in an
+# exception table the table would no longer contain the address of the ll
+# instruction.
+#
+# Avoid this by explicitly disabling that assembler behaviour. If upstream
+# binutils does not merge support for the flag then we can revisit & remove
+# this later - for now it ensures vendor toolchains don't cause problems.
+#
+cflags-$(CONFIG_CPU_LOONGSON64)	+= $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,)
 
 # For smartmips configurations, there are hundreds of warnings due to ISA overrides
 # in assembly and header files. smartmips is only supported for MIPS32r1 onwards
diff --git a/arch/mips/loongson2ef/Platform b/arch/mips/loongson2ef/Platform
index c6f7a4b95997..d446b705fba4 100644
--- a/arch/mips/loongson2ef/Platform
+++ b/arch/mips/loongson2ef/Platform
@@ -2,41 +2,6 @@
 # Loongson Processors' Support
 #
 
-cflags-$(CONFIG_CPU_LOONGSON2EF)	+= -Wa,--trap
-cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e
-cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f
-#
-# Some versions of binutils, not currently mainline as of 2019/02/04, support
-# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction
-# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a
-# description).
-#
-# We disable this in order to prevent the assembler meddling with the
-# instruction that labels refer to, ie. if we label an ll instruction:
-#
-# 1: ll v0, 0(a0)
-#
-# ...then with the assembler fix applied the label may actually point at a sync
-# instruction inserted by the assembler, and if we were using the label in an
-# exception table the table would no longer contain the address of the ll
-# instruction.
-#
-# Avoid this by explicitly disabling that assembler behaviour. If upstream
-# binutils does not merge support for the flag then we can revisit & remove
-# this later - for now it ensures vendor toolchains don't cause problems.
-#
-cflags-$(CONFIG_CPU_LOONGSON2EF)	+= $(call cc-option,-Wa$(comma)-mno-fix-loongson3-llsc,)
-
-# Enable the workarounds for Loongson2f
-ifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS
-cflags-$(CONFIG_CPU_NOP_WORKAROUNDS) += -Wa,-mfix-loongson2f-nop
-cflags-$(CONFIG_CPU_JUMP_WORKAROUNDS) += -Wa,-mfix-loongson2f-jump
-endif
-
-# Some -march= flags enable MMI instructions, and GCC complains about that
-# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
-cflags-y += $(call cc-option,-mno-loongson-mmi)
-
 #
 # Loongson Machines' Support
 #
diff --git a/arch/mips/loongson64/Platform b/arch/mips/loongson64/Platform
index 473404cae1c4..49c9889e3d56 100644
--- a/arch/mips/loongson64/Platform
+++ b/arch/mips/loongson64/Platform
@@ -1,19 +1,3 @@
-#
-# Loongson Processors' Support
-#
-
-
-cflags-$(CONFIG_CPU_LOONGSON64)	+= -Wa,--trap
-
-ifdef CONFIG_CPU_LOONGSON64
-cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a
-cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2
-endif
-
-# Some -march= flags enable MMI instructions, and GCC complains about that
-# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
-cflags-y += $(call cc-option,-mno-loongson-mmi)
-
 #
 # Loongson Machines' Support
 #
-- 
2.34.1


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

* [PATCH 09/12] MIPS: Loongson: Don't select platform features with CPU
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (7 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 08/12] MIPS: Loongson: Move arch cflags to MIPS top level Makefile Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 10/12] MIPS: Octeon: Disable CVMSEG by default on other platforms Jiaxun Yang
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

ARCH_HAS_PHYS_TO_DMA and GPIOLIB are all platform level features
they shouldn't be selected with CPU.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/Kconfig             | 2 --
 arch/mips/loongson2ef/Kconfig | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index e2f3ca73f40d..940ade1c9449 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1366,7 +1366,6 @@ config CPU_LOONGSON2F
 	bool "Loongson 2F"
 	depends on SYS_HAS_CPU_LOONGSON2F
 	select CPU_LOONGSON2EF
-	select GPIOLIB
 	help
 	  The Loongson 2F processor implements the MIPS III instruction set
 	  with many extensions.
@@ -1788,7 +1787,6 @@ config CPU_LOONGSON2EF
 	select CPU_SUPPORTS_64BIT_KERNEL
 	select CPU_SUPPORTS_HIGHMEM
 	select CPU_SUPPORTS_HUGEPAGES
-	select ARCH_HAS_PHYS_TO_DMA
 
 config CPU_LOONGSON32
 	bool
diff --git a/arch/mips/loongson2ef/Kconfig b/arch/mips/loongson2ef/Kconfig
index 96dc6eba4310..f93eb6f42238 100644
--- a/arch/mips/loongson2ef/Kconfig
+++ b/arch/mips/loongson2ef/Kconfig
@@ -7,6 +7,7 @@ choice
 config LEMOTE_FULOONG2E
 	bool "Lemote Fuloong(2e) mini-PC"
 	select ARCH_SPARSEMEM_ENABLE
+	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select CEVT_R4K
@@ -36,6 +37,7 @@ config LEMOTE_FULOONG2E
 config LEMOTE_MACH2F
 	bool "Lemote Loongson 2F family machines"
 	select ARCH_SPARSEMEM_ENABLE
+	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select BOARD_SCACHE
@@ -46,6 +48,7 @@ config LEMOTE_MACH2F
 	select CSRC_R4K if ! MIPS_EXTERNAL_TIMER
 	select DMA_NONCOHERENT
 	select GENERIC_ISA_DMA_SUPPORT_BROKEN
+	select GPIOLIB
 	select FORCE_PCI
 	select I8259
 	select IRQ_MIPS_CPU
-- 
2.34.1


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

* [PATCH 10/12] MIPS: Octeon: Disable CVMSEG by default on other platforms
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (8 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 09/12] MIPS: Loongson: Don't select platform features with CPU Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 11/12] MIPS: Add board config for virt board Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 12/12] MIPS: generic: Enable all CPUs supported by virt board in Kconfig Jiaxun Yang
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

QEMU can't emulate CVMSEG on generic platform for now.

Just disable it by default.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/cavium-octeon/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig
index c1899f109e19..450e979ef5d9 100644
--- a/arch/mips/cavium-octeon/Kconfig
+++ b/arch/mips/cavium-octeon/Kconfig
@@ -14,7 +14,8 @@ config CAVIUM_CN63XXP1
 config CAVIUM_OCTEON_CVMSEG_SIZE
 	int "Number of L1 cache lines reserved for CVMSEG memory"
 	range 0 54
-	default 1
+	default 0 if !CAVIUM_OCTEON_SOC
+	default 1 if CAVIUM_OCTEON_SOC
 	help
 	  CVMSEG LM is a segment that accesses portions of the dcache as a
 	  local memory; the larger CVMSEG is, the smaller the cache is.
-- 
2.34.1


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

* [PATCH 11/12] MIPS: Add board config for virt board
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (9 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 10/12] MIPS: Octeon: Disable CVMSEG by default on other platforms Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  2023-03-04 22:15 ` [PATCH 12/12] MIPS: generic: Enable all CPUs supported by virt board in Kconfig Jiaxun Yang
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Aligned with QEMU MIPS virt board.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/configs/generic/board-virt.config | 38 +++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 arch/mips/configs/generic/board-virt.config

diff --git a/arch/mips/configs/generic/board-virt.config b/arch/mips/configs/generic/board-virt.config
new file mode 100644
index 000000000000..5594f9e5c3a8
--- /dev/null
+++ b/arch/mips/configs/generic/board-virt.config
@@ -0,0 +1,38 @@
+CONFIG_COMMON_CLK=y
+
+CONFIG_GOLDFISH=y
+CONFIG_GOLDFISH_PIC=y
+
+CONFIG_PCI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_HOST_GENERIC=y
+
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_SYSCON=y
+CONFIG_POWER_RESET_SYSCON_POWEROFF=y
+CONFIG_SYSCON_REBOOT_MODE=y
+
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_GOLDFISH=y
+
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+
+CONFIG_MTD=y
+CONFIG_MTD_CFI=y
+
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_XHCI_HCD=y
+
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
+CONFIG_VIRTIO_BALLOON=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_NET=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
-- 
2.34.1


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

* [PATCH 12/12] MIPS: generic: Enable all CPUs supported by virt board in Kconfig
  2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
                   ` (10 preceding siblings ...)
  2023-03-04 22:15 ` [PATCH 11/12] MIPS: Add board config for virt board Jiaxun Yang
@ 2023-03-04 22:15 ` Jiaxun Yang
  11 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-04 22:15 UTC (permalink / raw)
  To: linux-mips; +Cc: tsbogend, philmd, Jiaxun Yang

Enable extra CPUs that may be supported by virt board, including
R4x00 (R4000 in QEMU), Cavium Octeon (Octeon68XX in QEMU), loongson2e,
loongson2f.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 940ade1c9449..53160d49387c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -155,12 +155,16 @@ config MIPS_GENERIC_KERNEL
 	select PCI_DRIVERS_GENERIC
 	select SMP_UP if SMP
 	select SWAP_IO_SPACE
+	select SYS_HAS_CPU_CAVIUM_OCTEON
+	select SYS_HAS_CPU_LOONGSON2E
+	select SYS_HAS_CPU_LOONGSON2F
 	select SYS_HAS_CPU_MIPS32_R1
 	select SYS_HAS_CPU_MIPS32_R2
 	select SYS_HAS_CPU_MIPS32_R6
 	select SYS_HAS_CPU_MIPS64_R1
 	select SYS_HAS_CPU_MIPS64_R2
 	select SYS_HAS_CPU_MIPS64_R6
+	select SYS_HAS_CPU_R4X00
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
-- 
2.34.1


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

* Re: [PATCH 06/12] MIPS: c-octeon: Provide alternative SMP cache flush function
  2023-03-04 22:15 ` [PATCH 06/12] MIPS: c-octeon: Provide alternative SMP cache flush function Jiaxun Yang
@ 2023-03-05  8:41   ` Sergei Shtylyov
  0 siblings, 0 replies; 17+ messages in thread
From: Sergei Shtylyov @ 2023-03-05  8:41 UTC (permalink / raw)
  To: Jiaxun Yang, linux-mips; +Cc: tsbogend, philmd

Hello!

On 3/5/23 1:15 AM, Jiaxun Yang wrote:

> Curretly c-octeon relies on octeon's own smp function to flush

   Currently.

> I-Cache. However this function is not available on generic platform.
> 
> Just use smp_call_function_many on generic platform.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  arch/mips/mm/c-octeon.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c
> index c7ed589de882..61db09e5044c 100644
> --- a/arch/mips/mm/c-octeon.c
> +++ b/arch/mips/mm/c-octeon.c
> @@ -83,8 +83,14 @@ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma)
>  	else
>  		mask = *cpu_online_mask;
>  	cpumask_clear_cpu(cpu, &mask);
> -	for_each_cpu(cpu, &mask)
> +#ifdef CONFIG_CAVIUM_OCTEON_SOC
> +	for_each_cpu(cpu, &mask) {
>  		octeon_send_ipi_single(cpu, SMP_ICACHE_FLUSH);
> +	}

   I think {} aren't needed here.

> +#else
> +	smp_call_function_many(&mask, (smp_call_func_t)octeon_local_flush_icache,
> +			       NULL, 1);
> +#endif
>  
>  	preempt_enable();
>  #endif

MBR, Sergey

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

* Re: [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature
  2023-03-04 22:15 ` [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature Jiaxun Yang
@ 2023-03-06 14:28   ` Alexander Lobakin
  2023-03-06 19:55     ` Jiaxun Yang
  0 siblings, 1 reply; 17+ messages in thread
From: Alexander Lobakin @ 2023-03-06 14:28 UTC (permalink / raw)
  To: Jiaxun Yang; +Cc: linux-mips, tsbogend, philmd

From: Jiaxun Yang <jiaxun.yang@flygoat.com>
Date: Sat,  4 Mar 2023 22:15:16 +0000

> Octeon has a different cache interface with traditional R4K one,
> just opt-out this flag for octeon to avoid run R4K cache initialization
> code accidentally.
> 
> Also remove ISA level assumption for 4k cache.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  arch/mips/include/asm/cpu-features.h | 2 +-
>  arch/mips/kernel/cpu-probe.c         | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
> index c0983130a44c..c613426b0bfc 100644
> --- a/arch/mips/include/asm/cpu-features.h
> +++ b/arch/mips/include/asm/cpu-features.h
> @@ -118,7 +118,7 @@
>  #define cpu_has_3k_cache	__isa_lt_and_opt(1, MIPS_CPU_3K_CACHE)
>  #endif
>  #ifndef cpu_has_4k_cache
> -#define cpu_has_4k_cache	__isa_ge_or_opt(1, MIPS_CPU_4K_CACHE)
> +#define cpu_has_4k_cache	__opt(MIPS_CPU_4K_CACHE)

This breaks compile-time optimization for this feature => hurts
performance on non-Octeon machines. Could this be done some other way?
E.g. could this be defined depending on
CONFIG_SYS_HAS_CPU_OCTEON_WHATEVER? Via its own cpu-features.h or here,
that's the second question. So that the platforms which 100% can't have
this family of CPUs wouldn't get affected.


>  #endif
>  #ifndef cpu_has_octeon_cache
>  #define cpu_has_octeon_cache	0
> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
> index 7ddf07f255f3..6d15a398d389 100644
> --- a/arch/mips/kernel/cpu-probe.c
> +++ b/arch/mips/kernel/cpu-probe.c
> @@ -1602,6 +1602,8 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
>  static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
>  {
>  	decode_configs(c);
> +	/* Octeon has different cache interface */
> +	c->options &= ~MIPS_CPU_4K_CACHE;
>  	switch (c->processor_id & PRID_IMP_MASK) {
>  	case PRID_IMP_CAVIUM_CN38XX:
>  	case PRID_IMP_CAVIUM_CN31XX:

Thanks,
Olek

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

* Re: [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature
  2023-03-06 14:28   ` Alexander Lobakin
@ 2023-03-06 19:55     ` Jiaxun Yang
  2023-03-07 16:51       ` Alexander Lobakin
  0 siblings, 1 reply; 17+ messages in thread
From: Jiaxun Yang @ 2023-03-06 19:55 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: linux-mips, Thomas Bogendoerfer, Philippe Mathieu-Daudé



> 2023年3月6日 14:28,Alexander Lobakin <aleksander.lobakin@intel.com> 写道:
> 
> From: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Date: Sat,  4 Mar 2023 22:15:16 +0000
> 
>> Octeon has a different cache interface with traditional R4K one,
>> just opt-out this flag for octeon to avoid run R4K cache initialization
>> code accidentally.
>> 
>> Also remove ISA level assumption for 4k cache.
>> 
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>> arch/mips/include/asm/cpu-features.h | 2 +-
>> arch/mips/kernel/cpu-probe.c         | 2 ++
>> 2 files changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
>> index c0983130a44c..c613426b0bfc 100644
>> --- a/arch/mips/include/asm/cpu-features.h
>> +++ b/arch/mips/include/asm/cpu-features.h
>> @@ -118,7 +118,7 @@
>> #define cpu_has_3k_cache __isa_lt_and_opt(1, MIPS_CPU_3K_CACHE)
>> #endif
>> #ifndef cpu_has_4k_cache
>> -#define cpu_has_4k_cache __isa_ge_or_opt(1, MIPS_CPU_4K_CACHE)
>> +#define cpu_has_4k_cache __opt(MIPS_CPU_4K_CACHE)
> 
> This breaks compile-time optimization for this feature => hurts
> performance on non-Octeon machines. Could this be done some other way?
> E.g. could this be defined depending on
> CONFIG_SYS_HAS_CPU_OCTEON_WHATEVER? Via its own cpu-features.h or here,
> that's the second question. So that the platforms which 100% can't have
> this family of CPUs wouldn't get affected.

Thanks for the comment.

This feature is only checked once during boot and never checked at runtime so I think impact
should be negligible.

Just don’t want to have another ifdef here :-)


Thanks
- Jiaxun

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

* Re: [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature
  2023-03-06 19:55     ` Jiaxun Yang
@ 2023-03-07 16:51       ` Alexander Lobakin
  0 siblings, 0 replies; 17+ messages in thread
From: Alexander Lobakin @ 2023-03-07 16:51 UTC (permalink / raw)
  To: Jiaxun Yang; +Cc: linux-mips, Thomas Bogendoerfer, Philippe Mathieu-Daudé

From: Jiaxun Yang <jiaxun.yang@flygoat.com>
Date: Mon, 6 Mar 2023 19:55:23 +0000

> 
> 
>> 2023年3月6日 14:28,Alexander Lobakin <aleksander.lobakin@intel.com> 写道:
>>
>> From: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> Date: Sat,  4 Mar 2023 22:15:16 +0000
>>
>>> Octeon has a different cache interface with traditional R4K one,
>>> just opt-out this flag for octeon to avoid run R4K cache initialization
>>> code accidentally.
>>>
>>> Also remove ISA level assumption for 4k cache.
>>>
>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>> ---
>>> arch/mips/include/asm/cpu-features.h | 2 +-
>>> arch/mips/kernel/cpu-probe.c         | 2 ++
>>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
>>> index c0983130a44c..c613426b0bfc 100644
>>> --- a/arch/mips/include/asm/cpu-features.h
>>> +++ b/arch/mips/include/asm/cpu-features.h
>>> @@ -118,7 +118,7 @@
>>> #define cpu_has_3k_cache __isa_lt_and_opt(1, MIPS_CPU_3K_CACHE)
>>> #endif
>>> #ifndef cpu_has_4k_cache
>>> -#define cpu_has_4k_cache __isa_ge_or_opt(1, MIPS_CPU_4K_CACHE)
>>> +#define cpu_has_4k_cache __opt(MIPS_CPU_4K_CACHE)
>>
>> This breaks compile-time optimization for this feature => hurts
>> performance on non-Octeon machines. Could this be done some other way?
>> E.g. could this be defined depending on
>> CONFIG_SYS_HAS_CPU_OCTEON_WHATEVER? Via its own cpu-features.h or here,
>> that's the second question. So that the platforms which 100% can't have
>> this family of CPUs wouldn't get affected.
> 
> Thanks for the comment.
> 
> This feature is only checked once during boot and never checked at runtime so I think impact
> should be negligible.

Ah, didn't notice it's not used anywhere on hotpath. Just forgot that
MIPS installs cache sync callbacks once at boot and then use them.

> 
> Just don’t want to have another ifdef here :-)

I'm not sure one ifdef would hurt, we probably need a third opinion here
:D Maybe Thomas'. But I'm fine with the current implementation.

> 
> 
> Thanks
> - Jiaxun

Thanks,
Olek

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

end of thread, other threads:[~2023-03-07 16:56 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-04 22:15 [PATCH 00/12] MIPS Virt board support Jiaxun Yang
2023-03-04 22:15 ` [PATCH 01/12] MIPS: Move declaration of bcache ops to cache.c Jiaxun Yang
2023-03-04 22:15 ` [PATCH 02/12] MIPS: smp-cps: Disable coherence setup for unsupported ISA Jiaxun Yang
2023-03-04 22:15 ` [PATCH 03/12] MIPS: mips-cm: Check availability of config registers Jiaxun Yang
2023-03-04 22:15 ` [PATCH 04/12] MIPS: Octeon: Opt-out 4k_cache feature Jiaxun Yang
2023-03-06 14:28   ` Alexander Lobakin
2023-03-06 19:55     ` Jiaxun Yang
2023-03-07 16:51       ` Alexander Lobakin
2023-03-04 22:15 ` [PATCH 05/12] MIPS: cpu-features: Enable octeon_cache by cpu_type Jiaxun Yang
2023-03-04 22:15 ` [PATCH 06/12] MIPS: c-octeon: Provide alternative SMP cache flush function Jiaxun Yang
2023-03-05  8:41   ` Sergei Shtylyov
2023-03-04 22:15 ` [PATCH 07/12] MIPS: Octeon: Allow CVMSEG to be disabled Jiaxun Yang
2023-03-04 22:15 ` [PATCH 08/12] MIPS: Loongson: Move arch cflags to MIPS top level Makefile Jiaxun Yang
2023-03-04 22:15 ` [PATCH 09/12] MIPS: Loongson: Don't select platform features with CPU Jiaxun Yang
2023-03-04 22:15 ` [PATCH 10/12] MIPS: Octeon: Disable CVMSEG by default on other platforms Jiaxun Yang
2023-03-04 22:15 ` [PATCH 11/12] MIPS: Add board config for virt board Jiaxun Yang
2023-03-04 22:15 ` [PATCH 12/12] MIPS: generic: Enable all CPUs supported by virt board in Kconfig Jiaxun Yang

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