Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Huacai Chen <chenhc@lemote.com>
Cc: John Crispin <john@phrozen.org>,
	"Steven J. Hill" <Steven.Hill@imgtec.com>,
	linux-mips@linux-mips.org, Fuxin Zhang <zhangfx@lemote.com>,
	Zhangjin Wu <wuzhangjin@gmail.com>
Subject: Re: [PATCH V2 02/12] MIPS: Loongson: set Loongson-3's ISA level to MIPS64R1
Date: Mon, 10 Nov 2014 17:59:07 +0100	[thread overview]
Message-ID: <20141110165907.GA11091@linux-mips.org> (raw)
In-Reply-To: <1415081610-25639-3-git-send-email-chenhc@lemote.com>

On Tue, Nov 04, 2014 at 02:13:23PM +0800, Huacai Chen wrote:

> In CPU manual Loongson-3 is MIPS64R2 compatible, but during tests we
> found that its EI/DI instructions have problems. So we just set the ISA
> level to MIPS64R1.

That's a bit a heavyhanded move - it will disable ALL R2 optimizations
and feature support - try running git grep -w cpu_has_mips_r2 arch/mips.
Also it will cause the kernel to missreport the CPU has R1 or as in
case of the Loongson 2 with this patch even as MIPS III which in turn
will mean certain programs will fail to detect and exploit the full
capabilities of the CPU.

Was this really intended?  I doubt it.

I suggest a bit of a less heavy-handed approach as illustrated in below
incomplete patch.

Would that work for you?

  Ralf

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

 arch/mips/include/asm/asmmacro.h          | 3 ++-
 arch/mips/include/asm/irqflags.h          | 7 ++++---
 arch/mips/include/asm/mach-ip22/war.h     | 1 +
 arch/mips/include/asm/mach-loongson/war.h | 1 +
 arch/mips/include/asm/war.h               | 7 +++++++
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
index 6caf876..d477c34 100644
--- a/arch/mips/include/asm/asmmacro.h
+++ b/arch/mips/include/asm/asmmacro.h
@@ -11,6 +11,7 @@
 #include <asm/hazards.h>
 #include <asm/asm-offsets.h>
 #include <asm/msa.h>
+#include <asm/war.h>
 
 #ifdef CONFIG_32BIT
 #include <asm/asmmacro-32.h>
@@ -19,7 +20,7 @@
 #include <asm/asmmacro-64.h>
 #endif
 
-#ifdef CONFIG_CPU_MIPSR2
+#if defined(CONFIG_CPU_MIPSR2) && !LOONGSON3_EI_DI_WAR
 	.macro	local_irq_enable reg=t0
 	ei
 	irq_enable_hazard
diff --git a/arch/mips/include/asm/irqflags.h b/arch/mips/include/asm/irqflags.h
index 0fa5fdc..fcfd371 100644
--- a/arch/mips/include/asm/irqflags.h
+++ b/arch/mips/include/asm/irqflags.h
@@ -16,6 +16,7 @@
 #include <linux/compiler.h>
 #include <linux/stringify.h>
 #include <asm/hazards.h>
+#include <asm/war.h>
 
 #ifdef CONFIG_CPU_MIPSR2
 
@@ -59,7 +60,7 @@ static inline void arch_local_irq_restore(unsigned long flags)
 	"	.set	push						\n"
 	"	.set	noreorder					\n"
 	"	.set	noat						\n"
-#if defined(CONFIG_IRQ_CPU)
+#if defined(CONFIG_IRQ_CPU) && !LOONGSON3_EI_DI_WAR
 	/*
 	 * Slow, but doesn't suffer from a relatively unlikely race
 	 * condition we're having since days 1.
@@ -89,7 +90,7 @@ static inline void __arch_local_irq_restore(unsigned long flags)
 	"	.set	push						\n"
 	"	.set	noreorder					\n"
 	"	.set	noat						\n"
-#if defined(CONFIG_IRQ_CPU)
+#if defined(CONFIG_IRQ_CPU) && !LOONGSON3_EI_DI_WAR
 	/*
 	 * Slow, but doesn't suffer from a relatively unlikely race
 	 * condition we're having since days 1.
@@ -126,7 +127,7 @@ static inline void arch_local_irq_enable(void)
 	"	.set	push						\n"
 	"	.set	reorder						\n"
 	"	.set	noat						\n"
-#if   defined(CONFIG_CPU_MIPSR2)
+#if defined(CONFIG_CPU_MIPSR2) && !LOONGSON3_EI_DI_WAR
 	"	ei							\n"
 #else
 	"	mfc0	$1,$12						\n"
diff --git a/arch/mips/include/asm/mach-ip22/war.h b/arch/mips/include/asm/mach-ip22/war.h
index fba6405..3520b0a 100644
--- a/arch/mips/include/asm/mach-ip22/war.h
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -18,6 +18,7 @@
 #define R5432_CP0_INTERRUPT_WAR		0
 #define BCM1250_M3_WAR			0
 #define SIBYTE_1956_WAR			0
+#define LOONGSON3_EI_DI_WAR		0
 #define MIPS4K_ICACHE_REFILL_WAR	0
 #define MIPS_CACHE_SYNC_WAR		0
 #define TX49XX_ICACHE_INDEX_INV_WAR	0
diff --git a/arch/mips/include/asm/mach-loongson/war.h b/arch/mips/include/asm/mach-loongson/war.h
index f2570df..cf5385f 100644
--- a/arch/mips/include/asm/mach-loongson/war.h
+++ b/arch/mips/include/asm/mach-loongson/war.h
@@ -14,6 +14,7 @@
 #define R5432_CP0_INTERRUPT_WAR		0
 #define BCM1250_M3_WAR			0
 #define SIBYTE_1956_WAR			0
+#define LOONGSON3_EI_DI_WAR		1
 #define MIPS4K_ICACHE_REFILL_WAR	0
 #define MIPS_CACHE_SYNC_WAR		0
 #define TX49XX_ICACHE_INDEX_INV_WAR	0
diff --git a/arch/mips/include/asm/war.h b/arch/mips/include/asm/war.h
index 9344e24..ceb9030 100644
--- a/arch/mips/include/asm/war.h
+++ b/arch/mips/include/asm/war.h
@@ -233,4 +233,11 @@
 #error Check setting of MIPS34K_MISSED_ITLB_WAR for your platform
 #endif
 
+/*
+ * On certain Loongson 3 cores DI/EI don't work properly.
+ */
+#ifndef LOONGSON3_EI_DI_WAR
+#error Check setting of LOONGSON3_EI_DI_WAR for your platform
+#endif
+
 #endif /* _ASM_WAR_H */

  reply	other threads:[~2014-11-10 16:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04  6:13 [PATCH V2 00/12] MIPS: Loongson-3: Improve kernel functionality Huacai Chen
2014-11-04  6:13 ` [PATCH V2 01/12] MIPS: Loongson: Fix the write-combine CCA value setting Huacai Chen
2014-11-11 10:13   ` Ralf Baechle
2014-11-04  6:13 ` [PATCH V2 02/12] MIPS: Loongson: set Loongson-3's ISA level to MIPS64R1 Huacai Chen
2014-11-10 16:59   ` Ralf Baechle [this message]
2014-11-11  1:14     ` Huacai Chen
2014-11-11  9:33       ` Ralf Baechle
2014-11-04  6:13 ` [PATCH V2 03/12] MIPS: Loongson-3: Add PHYS48_TO_HT40 support Huacai Chen
2014-11-11 10:15   ` Ralf Baechle
2014-11-04  6:13 ` [PATCH V2 04/12] MIPS: Loongson: Introduce and use cpu_has_coherent_cache feature Huacai Chen
2014-11-11 10:05   ` Ralf Baechle
2014-11-04  6:13 ` [PATCH V2 05/12] MIPS: Loongson: Allow booting from any core Huacai Chen
2014-11-11 10:15   ` Ralf Baechle
2014-11-04  6:13 ` [PATCH V2 06/12] MIPS: Loongson: Improve LEFI firmware interface Huacai Chen
2014-11-11 10:16   ` Ralf Baechle
2014-11-04  6:13 ` [PATCH V2 07/12] MIPS: Loongson: Add Loongson-3A/3B GPIO support Huacai Chen
2014-11-11 10:18   ` Ralf Baechle
2014-11-11 12:45     ` Huacai Chen
2014-11-04  6:13 ` [PATCH V2 08/12] MIPS: Loongson-3: Add CPU Hwmon platform driver Huacai Chen
2014-11-11 10:23   ` Ralf Baechle
2014-11-11 12:44     ` Huacai Chen
2014-11-04  6:13 ` [PATCH V2 09/12] MIPS: Loongson-3: Add chipset ACPI " Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141110165907.GA11091@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=Steven.Hill@imgtec.com \
    --cc=chenhc@lemote.com \
    --cc=john@phrozen.org \
    --cc=linux-mips@linux-mips.org \
    --cc=wuzhangjin@gmail.com \
    --cc=zhangfx@lemote.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox