]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
x86: Replace NSC/Cyrix specific chipset access macros by inlined functions.
authorJuergen Beisert <juergen@kreuzholzen.de>
Sun, 6 Jul 2008 15:17:23 +0000 (18:17 +0300)
committerAdrian Bunk <bunk@kernel.org>
Mon, 14 Jul 2008 18:08:34 +0000 (21:08 +0300)
Due to index register access ordering problems, when using macros a line
like this fails (and does nothing):

    setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);

With inlined functions this line will work as expected.

Note about a side effect: Seems on Geode GX1 based systems the
"suspend on halt power saving feature" was never enabled due to this
wrong macro expansion. With inlined functions it will be enabled, but
this will stop the TSC when the CPU runs into a HLT instruction.
Kernel output something like this:
    Clocksource tsc unstable (delta = -472746897 ns)

This is the 3rd version of this patch.

 - Adding missed arch/i386/kernel/cpu/mtrr/state.c
    Thanks to Andres Salomon
 - Adding some big fat comments into the new header file
    Suggested by Andi Kleen

AK: fixed x86-64 compilation

Adrian Bunk:
Added workaround for x86_64 compilation.

Signed-off-by: Juergen Beisert <juergen@kreuzholzen.de>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
arch/i386/kernel/cpu/cyrix.c
arch/i386/kernel/cpu/mtrr/cyrix.c
arch/i386/kernel/cpu/mtrr/state.c
include/asm-i386/processor-cyrix.h [new file with mode: 0644]
include/asm-i386/processor.h
include/asm-x86_64/processor-cyrix.h [new file with mode: 0644]
include/asm-x86_64/processor.h

index e86ea486c31135fd989e93a82627ae457ad0bafc..1b5ef86ae17228b4a00925ef62f50d355a0744a7 100644 (file)
@@ -80,6 +80,7 @@
 #include <linux/cpufreq.h>
 #include <linux/pci.h>
 #include <asm/processor.h> 
+#include <asm/processor-cyrix.h>
 #include <asm/errno.h>
 
 /* PCI config registers, all at F0 */
index 00f2e058797cffd8019b08ecfb1fdbdc3215e7a1..b3e6b585b3bd85800bd29dc6f3c4f501d7cb4485 100644 (file)
@@ -4,7 +4,7 @@
 #include <linux/pci.h>
 #include <asm/dma.h>
 #include <asm/io.h>
-#include <asm/processor.h>
+#include <asm/processor-cyrix.h>
 #include <asm/timer.h>
 
 #include "cpu.h"
index 9027a987006b93890f17363f2d4fac4c749e7f23..b51f8dea9efae2e49337f693c92415de13b87f75 100644 (file)
@@ -3,6 +3,7 @@
 #include <asm/mtrr.h>
 #include <asm/msr.h>
 #include <asm/io.h>
+#include <asm/processor-cyrix.h>
 #include "mtrr.h"
 
 int arr3_protected;
index f62ecd15811a9adae409c24c15a2892690e977cd..a28b5fc1f32a4215e93f78c02e5fb2835a5daee4 100644 (file)
@@ -3,6 +3,7 @@
 #include <asm/io.h>
 #include <asm/mtrr.h>
 #include <asm/msr.h>
+#include <asm-i386/processor-cyrix.h>
 #include "mtrr.h"
 
 
diff --git a/include/asm-i386/processor-cyrix.h b/include/asm-i386/processor-cyrix.h
new file mode 100644 (file)
index 0000000..97568ad
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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)
+{
+       outb(reg, 0x22);
+       return inb(0x23);
+}
+
+static inline void setCx86(u8 reg, u8 data)
+{
+       outb(reg, 0x22);
+       outb(data, 0x23);
+}
index feca5d961e2b0c26a20c89f2b67c1cac230866fc..aa85bbb6ae298975c065c149c9938a4f07252a31 100644 (file)
@@ -270,17 +270,6 @@ static inline void clear_in_cr4 (unsigned long mask)
 #define CX86_ARR_BASE 0xc4
 #define CX86_RCR_BASE 0xdc
 
-/*
- *      NSC/Cyrix CPU indexed register access macros
- */
-
-#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
-
-#define setCx86(reg, data) do { \
-       outb((reg), 0x22); \
-       outb((data), 0x23); \
-} while (0)
-
 /* Stop speculative execution */
 static inline void sync_core(void)
 {
diff --git a/include/asm-x86_64/processor-cyrix.h b/include/asm-x86_64/processor-cyrix.h
new file mode 100644 (file)
index 0000000..f31e73e
--- /dev/null
@@ -0,0 +1,2 @@
+#include <asm-i386/processor-cyrix.h>
+
index 8c8d88c036ed07d037f55435196b91aba545c586..88d6bd08600894295c77de887bdfe88faf15795b 100644 (file)
@@ -431,17 +431,6 @@ static inline void prefetchw(void *x)
 #define CX86_ARR_BASE 0xc4
 #define CX86_RCR_BASE 0xdc
 
-/*
- *      NSC/Cyrix CPU indexed register access macros
- */
-
-#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
-
-#define setCx86(reg, data) do { \
-       outb((reg), 0x22); \
-       outb((data), 0x23); \
-} while (0)
-
 static inline void serialize_cpu(void)
 {
        __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");