public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/CPU: Use correct Cyrix-specific macros
@ 2019-03-06 20:49 Matthew Whitehead
  2019-03-06 20:49 ` [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors Matthew Whitehead
  2019-03-06 20:49 ` [PATCH 2/2] x86/CPU: Remove {get,set}Cx86_old macros used for Cyrix processors Matthew Whitehead
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Whitehead @ 2019-03-06 20:49 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, luto; +Cc: Matthew Whitehead

Replace the incorrect Cyrix-specific macro calls with the correct
setCx86() and getCx86() calls. Also remove the unused setCx86_old(),
getCx86_old() and their related comments in the code.

Matthew Whitehead (2):
  x86/CPU: Use correct macros for Cyrix calls on Geode processors
  x86/CPU: Remove {get,set}Cx86_old macros used for Cyrix processors

 arch/x86/include/asm/processor-cyrix.h | 21 ---------------------
 arch/x86/kernel/cpu/cyrix.c            | 14 +++++++-------
 2 files changed, 7 insertions(+), 28 deletions(-)

-- 
1.8.3.1


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

* [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors
  2019-03-06 20:49 [PATCH 0/2] x86/CPU: Use correct Cyrix-specific macros Matthew Whitehead
@ 2019-03-06 20:49 ` Matthew Whitehead
  2019-03-06 20:49 ` [PATCH 2/2] x86/CPU: Remove {get,set}Cx86_old macros used for Cyrix processors Matthew Whitehead
  1 sibling, 0 replies; 6+ messages in thread
From: Matthew Whitehead @ 2019-03-06 20:49 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, luto; +Cc: Matthew Whitehead

There are comments in processor-cyrix.h advising you to _not_ make calls
using the deprecated macros in this style:

  setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);

This is because it expands the macro into a non-functioning calling
sequence. The calling order must be:

  outb(CX86_CCR2, 0x22);
  inb(0x23);

From the comments:

 * When using the old macros a line like
 *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
 * gets expanded to:
 *  do {
 *    outb((CX86_CCR2), 0x22);
 *    outb((({
 *        outb((CX86_CCR2), 0x22);
 *        inb(0x23);
 *    }) | 0x88), 0x23);
 *  } while (0);

The new macros fix this problem, so use them instead. Tested on an
actual Geode processor.

Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
---
 arch/x86/kernel/cpu/cyrix.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index d12226f..1d9b8aa 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -124,7 +124,7 @@ static void set_cx86_reorder(void)
 	setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */
 
 	/* Load/Store Serialize to mem access disable (=reorder it) */
-	setCx86_old(CX86_PCR0, getCx86_old(CX86_PCR0) & ~0x80);
+	setCx86(CX86_PCR0, getCx86(CX86_PCR0) & ~0x80);
 	/* set load/store serialize from 1GB to 4GB */
 	ccr3 |= 0xe0;
 	setCx86(CX86_CCR3, ccr3);
@@ -135,11 +135,11 @@ static void set_cx86_memwb(void)
 	pr_info("Enable Memory-Write-back mode on Cyrix/NSC processor.\n");
 
 	/* CCR2 bit 2: unlock NW bit */
-	setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) & ~0x04);
+	setCx86(CX86_CCR2, getCx86(CX86_CCR2) & ~0x04);
 	/* set 'Not Write-through' */
 	write_cr0(read_cr0() | X86_CR0_NW);
 	/* CCR2 bit 2: lock NW bit and set WT1 */
-	setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x14);
+	setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14);
 }
 
 /*
@@ -153,14 +153,14 @@ static void geode_configure(void)
 	local_irq_save(flags);
 
 	/* Suspend on halt power saving and enable #SUSP pin */
-	setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x88);
+	setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
 
 	ccr3 = getCx86(CX86_CCR3);
 	setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);	/* enable MAPEN */
 
 
 	/* FPU fast, DTE cache, Mem bypass */
-	setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x38);
+	setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x38);
 	setCx86(CX86_CCR3, ccr3);			/* disable MAPEN */
 
 	set_cx86_memwb();
@@ -296,7 +296,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)
 		/* GXm supports extended cpuid levels 'ala' AMD */
 		if (c->cpuid_level == 2) {
 			/* Enable cxMMX extensions (GX1 Datasheet 54) */
-			setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7) | 1);
+			setCx86(CX86_CCR7, getCx86(CX86_CCR7) | 1);
 
 			/*
 			 * GXm : 0x30 ... 0x5f GXm  datasheet 51
@@ -319,7 +319,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)
 		if (dir1 > 7) {
 			dir0_msn++;  /* M II */
 			/* Enable MMX extensions (App note 108) */
-			setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7)|1);
+			setCx86(CX86_CCR7, getCx86(CX86_CCR7)|1);
 		} else {
 			/* A 6x86MX - it has the bug. */
 			set_cpu_bug(c, X86_BUG_COMA);
-- 
1.8.3.1


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

* [PATCH 2/2] x86/CPU: Remove {get,set}Cx86_old macros used for Cyrix processors
  2019-03-06 20:49 [PATCH 0/2] x86/CPU: Use correct Cyrix-specific macros Matthew Whitehead
  2019-03-06 20:49 ` [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors Matthew Whitehead
@ 2019-03-06 20:49 ` Matthew Whitehead
  1 sibling, 0 replies; 6+ messages in thread
From: Matthew Whitehead @ 2019-03-06 20:49 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, luto; +Cc: Matthew Whitehead

The getCx86_old() and setCx86_old() macros have been replaced with
correctly working getCx86() and setCx86(), so remove these unused macros.

Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
---
 arch/x86/include/asm/processor-cyrix.h | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/arch/x86/include/asm/processor-cyrix.h b/arch/x86/include/asm/processor-cyrix.h
index aaedd73..df700a6 100644
--- a/arch/x86/include/asm/processor-cyrix.h
+++ b/arch/x86/include/asm/processor-cyrix.h
@@ -3,19 +3,6 @@
  * NSC/Cyrix CPU indexed register access. Must be inlined instead of
  * macros to ensure correct access ordering
  * Access order is always 0x22 (=offset), 0x23 (=value)
- *
- * When using the old macros a line like
- *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
- * gets expanded to:
- *  do {
- *    outb((CX86_CCR2), 0x22);
- *    outb((({
- *        outb((CX86_CCR2), 0x22);
- *        inb(0x23);
- *    }) | 0x88), 0x23);
- *  } while (0);
- *
- * which in fact violates the access order (= 0x22, 0x22, 0x23, 0x23).
  */
 
 static inline u8 getCx86(u8 reg)
@@ -29,11 +16,3 @@ static inline void setCx86(u8 reg, u8 data)
 	outb(reg, 0x22);
 	outb(data, 0x23);
 }
-
-#define getCx86_old(reg) ({ outb((reg), 0x22); inb(0x23); })
-
-#define setCx86_old(reg, data) do { \
-	outb((reg), 0x22); \
-	outb((data), 0x23); \
-} while (0)
-
-- 
1.8.3.1


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

* [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors
  2019-03-14 20:45 [PATCH 0/2] x86/CPU: Use correct Cyrix-specific macros Matthew Whitehead
@ 2019-03-14 20:46 ` Matthew Whitehead
  0 siblings, 0 replies; 6+ messages in thread
From: Matthew Whitehead @ 2019-03-14 20:46 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, luto; +Cc: Matthew Whitehead

There are comments in processor-cyrix.h advising you to _not_ make calls
using the deprecated macros in this style:

  setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);

This is because it expands the macro into a non-functioning calling
sequence. The calling order must be:

  outb(CX86_CCR2, 0x22);
  inb(0x23);

From the comments:

 * When using the old macros a line like
 *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
 * gets expanded to:
 *  do {
 *    outb((CX86_CCR2), 0x22);
 *    outb((({
 *        outb((CX86_CCR2), 0x22);
 *        inb(0x23);
 *    }) | 0x88), 0x23);
 *  } while (0);

The new macros fix this problem, so use them instead. Tested on an
actual Geode processor.

Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
---
 arch/x86/kernel/cpu/cyrix.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index d12226f..1d9b8aa 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -124,7 +124,7 @@ static void set_cx86_reorder(void)
 	setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */
 
 	/* Load/Store Serialize to mem access disable (=reorder it) */
-	setCx86_old(CX86_PCR0, getCx86_old(CX86_PCR0) & ~0x80);
+	setCx86(CX86_PCR0, getCx86(CX86_PCR0) & ~0x80);
 	/* set load/store serialize from 1GB to 4GB */
 	ccr3 |= 0xe0;
 	setCx86(CX86_CCR3, ccr3);
@@ -135,11 +135,11 @@ static void set_cx86_memwb(void)
 	pr_info("Enable Memory-Write-back mode on Cyrix/NSC processor.\n");
 
 	/* CCR2 bit 2: unlock NW bit */
-	setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) & ~0x04);
+	setCx86(CX86_CCR2, getCx86(CX86_CCR2) & ~0x04);
 	/* set 'Not Write-through' */
 	write_cr0(read_cr0() | X86_CR0_NW);
 	/* CCR2 bit 2: lock NW bit and set WT1 */
-	setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x14);
+	setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14);
 }
 
 /*
@@ -153,14 +153,14 @@ static void geode_configure(void)
 	local_irq_save(flags);
 
 	/* Suspend on halt power saving and enable #SUSP pin */
-	setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x88);
+	setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
 
 	ccr3 = getCx86(CX86_CCR3);
 	setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);	/* enable MAPEN */
 
 
 	/* FPU fast, DTE cache, Mem bypass */
-	setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x38);
+	setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x38);
 	setCx86(CX86_CCR3, ccr3);			/* disable MAPEN */
 
 	set_cx86_memwb();
@@ -296,7 +296,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)
 		/* GXm supports extended cpuid levels 'ala' AMD */
 		if (c->cpuid_level == 2) {
 			/* Enable cxMMX extensions (GX1 Datasheet 54) */
-			setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7) | 1);
+			setCx86(CX86_CCR7, getCx86(CX86_CCR7) | 1);
 
 			/*
 			 * GXm : 0x30 ... 0x5f GXm  datasheet 51
@@ -319,7 +319,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)
 		if (dir1 > 7) {
 			dir0_msn++;  /* M II */
 			/* Enable MMX extensions (App note 108) */
-			setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7)|1);
+			setCx86(CX86_CCR7, getCx86(CX86_CCR7)|1);
 		} else {
 			/* A 6x86MX - it has the bug. */
 			set_cpu_bug(c, X86_BUG_COMA);
-- 
1.8.3.1


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

* Re: [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors
@ 2024-12-24  1:04 Russell Senior
  2024-12-24 12:17 ` Russell Senior
  0 siblings, 1 reply; 6+ messages in thread
From: Russell Senior @ 2024-12-24  1:04 UTC (permalink / raw)
  To: Matthew Whitehead; +Cc: linux-kernel, tglx, mingo, luto, Jonas Gorski

Hi,

I still have some Soekris net4826 in a Community Wireless Network I
volunteer with. These devices use an AMD SC1100 SoC. I am running
OpenWrt on them, which uses a patched kernel, that naturally has
evolved over time.  I haven't updated the ones in the field in a
number of years (circa 2017), but have one in a test bed, where I have
intermittently tried out test builds.

A few years ago, I noticed some trouble, particularly when "warm
booting", that is, doing a reboot without removing power, and noticed
the device was hanging after the kernel message:

  [    0.081615] Working around Cyrix MediaGX virtual DMA bugs.

If I removed power and then restarted, it would boot fine, continuing
through the message above, thusly:

  [    0.081615] Working around Cyrix MediaGX virtual DMA bugs.
  [    0.090076] Enable Memory-Write-back mode on Cyrix/NSC processor.
  [    0.100000] Enable Memory access reorder on Cyrix/NSC processor.
  [    0.100070] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
  [    0.110058] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
  [    0.120037] CPU: NSC Geode(TM) Integrated Processor by National
Semi (family: 0x5, model: 0x9, stepping: 0x1)
  [...]

In order to continue using modern tools, like ssh, to interact with
the software on these old devices, I need modern builds of the OpenWrt
firmware on the devices. I confirmed that the warm boot hang was still
an issue in modern OpenWrt builds (currently using a patched linux
v6.6.65).

Last night, I decided it was time to get to the bottom of the warm
boot hang, and began bisecting. From preserved builds, I narrowed down
the bisection window from late February to late May 2019. During this
period, the OpenWrt builds were using 4.14.x. I was able to build
using period-correct Ubuntu 18.04.6. After a number of bisection
iterations, I identified a kernel bump from 4.14.112 to 4.14.113 as
the commit that introduced the warm boot hang.

  https://github.com/openwrt/openwrt/commit/07aaa7e3d62ad32767d7067107db64b6ade81537

Looking at the upstream changes in the stable kernel between 4.14.112
and 4.14.113 (tig v4.14.112..v4.14.113), I spotted a likely suspect:

  https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=20afb90f730982882e65b01fb8bdfe83914339c5

So, I tried reverting just that kernel change on top of the breaking
OpenWrt commit, and my warm boot hang went away.

Presumably, the warm boot hang is due to some register not getting
cleared in the same way that a loss of power does. That is
approximately as much as I understand about the problem.

Can you suggest a patch to try to either clarify what is going wrong
and/or to potentially fix the problem in a more appropriate way?

Thanks!

-- 
Russell Senior
russell@personaltelco.net

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

* Re: [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors
  2024-12-24  1:04 Russell Senior
@ 2024-12-24 12:17 ` Russell Senior
  0 siblings, 0 replies; 6+ messages in thread
From: Russell Senior @ 2024-12-24 12:17 UTC (permalink / raw)
  To: Matthew Whitehead; +Cc: linux-kernel, tglx, mingo, luto, Jonas Gorski

More poking/prodding and coaching from Jonas Gorski (cc'd), it looks
like this test patch fixes the problem on my board: Tested against
v6.6.67 and v4.14.113:

--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -153,8 +153,8 @@ static void geode_configure(void)
        u8 ccr3;
        local_irq_save(flags);

-       /* Suspend on halt power saving and enable #SUSP pin */
-       setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
+       /* Suspend on halt power saving */
+       setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x08);

        ccr3 = getCx86(CX86_CCR3);
        setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10);       /* enable MAPEN */


On Mon, Dec 23, 2024 at 5:04 PM Russell Senior
<russell@personaltelco.net> wrote:
>
> Hi,
>
> I still have some Soekris net4826 in a Community Wireless Network I
> volunteer with. These devices use an AMD SC1100 SoC. I am running
> OpenWrt on them, which uses a patched kernel, that naturally has
> evolved over time.  I haven't updated the ones in the field in a
> number of years (circa 2017), but have one in a test bed, where I have
> intermittently tried out test builds.
>
> A few years ago, I noticed some trouble, particularly when "warm
> booting", that is, doing a reboot without removing power, and noticed
> the device was hanging after the kernel message:
>
>   [    0.081615] Working around Cyrix MediaGX virtual DMA bugs.
>
> If I removed power and then restarted, it would boot fine, continuing
> through the message above, thusly:
>
>   [    0.081615] Working around Cyrix MediaGX virtual DMA bugs.
>   [    0.090076] Enable Memory-Write-back mode on Cyrix/NSC processor.
>   [    0.100000] Enable Memory access reorder on Cyrix/NSC processor.
>   [    0.100070] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
>   [    0.110058] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
>   [    0.120037] CPU: NSC Geode(TM) Integrated Processor by National
> Semi (family: 0x5, model: 0x9, stepping: 0x1)
>   [...]
>
> In order to continue using modern tools, like ssh, to interact with
> the software on these old devices, I need modern builds of the OpenWrt
> firmware on the devices. I confirmed that the warm boot hang was still
> an issue in modern OpenWrt builds (currently using a patched linux
> v6.6.65).
>
> Last night, I decided it was time to get to the bottom of the warm
> boot hang, and began bisecting. From preserved builds, I narrowed down
> the bisection window from late February to late May 2019. During this
> period, the OpenWrt builds were using 4.14.x. I was able to build
> using period-correct Ubuntu 18.04.6. After a number of bisection
> iterations, I identified a kernel bump from 4.14.112 to 4.14.113 as
> the commit that introduced the warm boot hang.
>
>   https://github.com/openwrt/openwrt/commit/07aaa7e3d62ad32767d7067107db64b6ade81537
>
> Looking at the upstream changes in the stable kernel between 4.14.112
> and 4.14.113 (tig v4.14.112..v4.14.113), I spotted a likely suspect:
>
>   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=20afb90f730982882e65b01fb8bdfe83914339c5
>
> So, I tried reverting just that kernel change on top of the breaking
> OpenWrt commit, and my warm boot hang went away.
>
> Presumably, the warm boot hang is due to some register not getting
> cleared in the same way that a loss of power does. That is
> approximately as much as I understand about the problem.
>
> Can you suggest a patch to try to either clarify what is going wrong
> and/or to potentially fix the problem in a more appropriate way?
>
> Thanks!
>
> --
> Russell Senior
> russell@personaltelco.net

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

end of thread, other threads:[~2024-12-24 12:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-06 20:49 [PATCH 0/2] x86/CPU: Use correct Cyrix-specific macros Matthew Whitehead
2019-03-06 20:49 ` [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors Matthew Whitehead
2019-03-06 20:49 ` [PATCH 2/2] x86/CPU: Remove {get,set}Cx86_old macros used for Cyrix processors Matthew Whitehead
  -- strict thread matches above, loose matches on Subject: below --
2019-03-14 20:45 [PATCH 0/2] x86/CPU: Use correct Cyrix-specific macros Matthew Whitehead
2019-03-14 20:46 ` [PATCH 1/2] x86/CPU: Use correct macros for Cyrix calls on Geode processors Matthew Whitehead
2024-12-24  1:04 Russell Senior
2024-12-24 12:17 ` Russell Senior

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