]> err.no Git - linux-2.6/commitdiff
[MIPS] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols
authorFranck Bui-Huu <fbuihuu@gmail.com>
Mon, 4 Jun 2007 15:46:35 +0000 (17:46 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 10 Jul 2007 16:32:57 +0000 (17:32 +0100)
The current implementation of __pa() for 64-bits kernels with 32-bits
symbols is broken. In this configuration, we need 2 values for
PAGE_OFFSET, one in XKPHYS and the other in CKSEG0 space.

When the value in CKSEG0 space is used, it doesn't take into account
of PHYS_OFFSET. Even worse we can't redefine this value.

The patch restores CPHYSADDR() but in __pa()'s implementation because
it removes the need of 2 PAGE_OFFSET.

OTOH, CPHYSADDR() is quite bad when dealing with mapped kernels. So
this patch assumes there's no need to deal with such kernel in 64-bits
world.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
include/asm-mips/page.h

index c56c6a85908d1f367aaa3109ed01fcf4a473d20e..b92dd8c760da5d8a600f6abb33bd62b9bc6c1146 100644 (file)
@@ -35,7 +35,7 @@
 #ifndef __ASSEMBLY__
 
 #include <linux/pfn.h>
-#include <linux/io.h>
+#include <asm/io.h>
 
 /*
  * It's normally defined only for FLATMEM config but it's
@@ -143,11 +143,15 @@ typedef struct { unsigned long pgprot; } pgprot_t;
  * __pa()/__va() should be used only during mem init.
  */
 #if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
-#define __pa_page_offset(x)    ((unsigned long)(x) < CKSEG0 ? PAGE_OFFSET : CKSEG0)
+#define __pa(x)                                                                \
+({                                                                     \
+    unsigned long __x = (unsigned long)(x);                            \
+    __x < CKSEG0 ? XPHYSADDR(__x) : CPHYSADDR(__x);                    \
+})
 #else
-#define __pa_page_offset(x)    PAGE_OFFSET
+#define __pa(x)                                                                \
+    ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
 #endif
-#define __pa(x)                ((unsigned long)(x) - __pa_page_offset(x) + PHYS_OFFSET)
 #define __va(x)                ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET))
 #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))