x86/CPU: Use correct Cyrix-specific macros
cover x86/CPU: Use correct Cyrix-specific macros
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(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 x86/CPU: Use correct macros for Cyrix calls on Geode processors
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.
--- arch/x86/kernel/cpu/cyrix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/cyrix.c +7 -7
@@ -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 );
Signature · 1 line
1.8.3.1
tip-bot for Matthew Whitehead
merge bot[tip:x86/urgent] x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
Commit-ID: 18fb053f9b827bd98cfc64f2a35df8ab19745a1d Gitweb: https://git.kernel.org/tip/18fb053f9b827bd98cfc64f2a35df8ab19745a1d Author: Matthew Whitehead <[email protected]> AuthorDate: Thu, 14 Mar 2019 16:46:00 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 21 Mar 2019 12:28:50 +0100
x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
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.
--- arch/x86/kernel/cpu/cyrix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/cyrix.c +7 -7
@@ -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 );
PATCH 2/2 x86/CPU: Remove {get,set}Cx86_old macros used for Cyrix processors
In reply to Matthew WhiteheadThe getCx86_old() and setCx86_old() macros have been replaced with correctly working getCx86() and setCx86(), so remove these unused macros.
--- arch/x86/include/asm/processor-cyrix.h | 21 --------------------- 1 file changed, 21 deletions(-)
arch/x86/include/asm/processor-cyrix.h +0 -21
@@ -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) -
Signature · 1 line
1.8.3.1
tip-bot for Matthew Whitehead
merge bot[tip:x86/urgent] x86/cpu/cyrix: Remove {get,set}Cx86_old macros used for Cyrix processors
x86/cpu/cyrix: Remove {get,set}Cx86_old macros used for Cyrix processors
Commit-ID: 0f4d3aa761b71cd6984330baca1e18bf0590e441 Gitweb: https://git.kernel.org/tip/0f4d3aa761b71cd6984330baca1e18bf0590e441 Author: Matthew Whitehead <[email protected]> AuthorDate: Thu, 14 Mar 2019 16:46:01 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 21 Mar 2019 12:28:50 +0100
x86/cpu/cyrix: Remove {get,set}Cx86_old macros used for Cyrix processors
The getCx86_old() and setCx86_old() macros have been replaced with correctly working getCx86() and setCx86(), so remove these unused macros.
--- arch/x86/include/asm/processor-cyrix.h | 21 --------------------- 1 file changed, 21 deletions(-)
arch/x86/include/asm/processor-cyrix.h +0 -21
@@ -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) -
Quoted 8 lines · Matthew Whitehead
Replace the incorrect Cyrix-specific macro calls with the correct
setCx86()andgetCx86()calls. Also remove the unusedsetCx86_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
This series looks reasonable to me. Also, Matthew seems to be the best tester around for this old hardware, so, if he says it works, I believe him :) I certainly can't test this stuff.
--Andy