All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] PHYS_OFFSET fix and cleanup
@ 2007-03-27  9:19 Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 1/4] Allow generic spaces.h to be included by platform specific ones Franck Bui-Huu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2007-03-27  9:19 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

Ralf,

This small patchset deals with PHYS_OFFSET (last) issue.

Most of the patch are clean up and ease PHYS_OFFSET use except for the
last one which is a real fix for 64-bits kernels with 32-bits
symbols. Basically we now use CPHYSADDR() in __pa(). But this change
implies that we could no more handle mapped kernel in this config. Do
you think it's a real issue ?

Please consider,

		Franck

---

 include/asm-mips/mach-generic/spaces.h |   30 +++++++++++++++++++++++++++---
 include/asm-mips/page.h                |   21 +++++++++------------
 2 files changed, 36 insertions(+), 15 deletions(-)

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

* [PATCH 1/4] Allow generic spaces.h to be included by platform specific ones
  2007-03-27  9:19 [PATCH 0/4] PHYS_OFFSET fix and cleanup Franck Bui-Huu
@ 2007-03-27  9:19 ` Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 2/4] Make PAGE_OFFSET aware of PHYS_OFFSET Franck Bui-Huu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2007-03-27  9:19 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

From: Franck Bui-Huu <fbuihuu@gmail.com>

Before this patch, when a platform needed to customize one constant in
spaces.h, they need to redefine all of them.

Now they can just redefine one constant and include the generic file
header at the end:

	#include <asm/mach-generic/spaces.h>

This patch doesn't allow to redefine CAC_BASE, IO_BASE and UNCAC_BASE
for 32 bits platforms because there's no need to do so.

This will avoid some macro duplications. It's important specially if
we'll add complex macros.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
 include/asm-mips/mach-generic/spaces.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/include/asm-mips/mach-generic/spaces.h b/include/asm-mips/mach-generic/spaces.h
index 0ae9997..9a3c521 100644
--- a/include/asm-mips/mach-generic/spaces.h
+++ b/include/asm-mips/mach-generic/spaces.h
@@ -16,13 +16,18 @@
 #define CAC_BASE		0x80000000
 #define IO_BASE			0xa0000000
 #define UNCAC_BASE		0xa0000000
+
+#ifndef MAP_BASE
 #define MAP_BASE		0xc0000000
+#endif
 
 /*
  * This handles the memory map.
  * We handle pages at KSEG0 for kernels with 32 bit address space.
  */
+#ifndef PAGE_OFFSET
 #define PAGE_OFFSET		0x80000000UL
+#endif
 
 /*
  * Memory above this physical address will be considered highmem.
@@ -38,11 +43,13 @@
 /*
  * This handles the memory map.
  */
+#ifndef PAGE_OFFSET
 #ifdef CONFIG_DMA_NONCOHERENT
 #define PAGE_OFFSET	0x9800000000000000UL
 #else
 #define PAGE_OFFSET	0xa800000000000000UL
 #endif
+#endif
 
 /*
  * Memory above this physical address will be considered highmem.
@@ -53,14 +60,25 @@
 #define HIGHMEM_START		(1UL << 59UL)
 #endif
 
+#ifndef CAC_BASE
 #ifdef CONFIG_DMA_NONCOHERENT
 #define CAC_BASE		0x9800000000000000UL
 #else
 #define CAC_BASE		0xa800000000000000UL
 #endif
+#endif
+
+#ifndef IO_BASE
 #define IO_BASE			0x9000000000000000UL
+#endif
+
+#ifndef UNCAC_BASE
 #define UNCAC_BASE		0x9000000000000000UL
+#endif
+
+#ifndef MAP_BASE
 #define MAP_BASE		0xc000000000000000UL
+#endif
 
 #define TO_PHYS(x)		(             ((x) & TO_PHYS_MASK))
 #define TO_CAC(x)		(CAC_BASE   | ((x) & TO_PHYS_MASK))
-- 
1.5.1.rc1.27.g1d848

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

* [PATCH 2/4] Make PAGE_OFFSET aware of PHYS_OFFSET
  2007-03-27  9:19 [PATCH 0/4] PHYS_OFFSET fix and cleanup Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 1/4] Allow generic spaces.h to be included by platform specific ones Franck Bui-Huu
@ 2007-03-27  9:19 ` Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 3/4] Move PHY_OFFSET definition in spaces.h Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 4/4] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols Franck Bui-Huu
  3 siblings, 0 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2007-03-27  9:19 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

From: Franck Bui-Huu <fbuihuu@gmail.com>

For platforms that use PHYS_OFFSET and do not use a mapped kernel,
this patch automatically adds PHYS_OFFSET into PAGE_OFFSET.
Therefore there are no more needs for them to redefine PAGE_OFFSET.

For mapped kernel, they need to redefine PAGE_OFFSET anyways.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
 include/asm-mips/mach-generic/spaces.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/asm-mips/mach-generic/spaces.h b/include/asm-mips/mach-generic/spaces.h
index 9a3c521..512bca5 100644
--- a/include/asm-mips/mach-generic/spaces.h
+++ b/include/asm-mips/mach-generic/spaces.h
@@ -26,7 +26,7 @@
  * We handle pages at KSEG0 for kernels with 32 bit address space.
  */
 #ifndef PAGE_OFFSET
-#define PAGE_OFFSET		0x80000000UL
+#define PAGE_OFFSET		(0x80000000UL + PHYS_OFFSET)
 #endif
 
 /*
@@ -45,9 +45,9 @@
  */
 #ifndef PAGE_OFFSET
 #ifdef CONFIG_DMA_NONCOHERENT
-#define PAGE_OFFSET	0x9800000000000000UL
+#define PAGE_OFFSET		(0x9800000000000000UL + PHYS_OFFSET)
 #else
-#define PAGE_OFFSET	0xa800000000000000UL
+#define PAGE_OFFSET		(0xa800000000000000UL + PHYS_OFFSET)
 #endif
 #endif
 
-- 
1.5.1.rc1.27.g1d848

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

* [PATCH 3/4] Move PHY_OFFSET definition in spaces.h
  2007-03-27  9:19 [PATCH 0/4] PHYS_OFFSET fix and cleanup Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 1/4] Allow generic spaces.h to be included by platform specific ones Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 2/4] Make PAGE_OFFSET aware of PHYS_OFFSET Franck Bui-Huu
@ 2007-03-27  9:19 ` Franck Bui-Huu
  2007-03-27  9:19 ` [PATCH 4/4] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols Franck Bui-Huu
  3 siblings, 0 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2007-03-27  9:19 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

From: Franck Bui-Huu <fbuihuu@gmail.com>

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
 include/asm-mips/mach-generic/spaces.h |    6 ++++++
 include/asm-mips/page.h                |   11 ++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/include/asm-mips/mach-generic/spaces.h b/include/asm-mips/mach-generic/spaces.h
index 512bca5..8b5e432 100644
--- a/include/asm-mips/mach-generic/spaces.h
+++ b/include/asm-mips/mach-generic/spaces.h
@@ -10,6 +10,12 @@
 #ifndef _ASM_MACH_GENERIC_SPACES_H
 #define _ASM_MACH_GENERIC_SPACES_H
 
+/*
+ * This gives the physical RAM offset.
+ */
+#ifndef PHYS_OFFSET
+#define PHYS_OFFSET		0UL
+#endif
 
 #ifdef CONFIG_32BIT
 
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index d3fbd83..cc28a4f 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -34,12 +34,8 @@
 
 #ifndef __ASSEMBLY__
 
-/*
- * This gives the physical RAM offset.
- */
-#ifndef PHYS_OFFSET
-#define PHYS_OFFSET		0UL
-#endif
+#include <linux/pfn.h>
+#include <asm/io.h>
 
 /*
  * It's normally defined only for FLATMEM config but it's
@@ -48,9 +44,6 @@
  */
 #define ARCH_PFN_OFFSET		PFN_UP(PHYS_OFFSET)
 
-#include <linux/pfn.h>
-#include <asm/io.h>
-
 extern void clear_page(void * page);
 extern void copy_page(void * to, void * from);
 
-- 
1.5.1.rc1.27.g1d848

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

* [PATCH 4/4] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols
  2007-03-27  9:19 [PATCH 0/4] PHYS_OFFSET fix and cleanup Franck Bui-Huu
                   ` (2 preceding siblings ...)
  2007-03-27  9:19 ` [PATCH 3/4] Move PHY_OFFSET definition in spaces.h Franck Bui-Huu
@ 2007-03-27  9:19 ` Franck Bui-Huu
  3 siblings, 0 replies; 5+ messages in thread
From: Franck Bui-Huu @ 2007-03-27  9:19 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

From: Franck Bui-Huu <fbuihuu@gmail.com>

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>
---
 include/asm-mips/page.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index cc28a4f..62ee3d5 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -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))
 
-- 
1.5.1.rc1.27.g1d848

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

end of thread, other threads:[~2007-03-27 10:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-27  9:19 [PATCH 0/4] PHYS_OFFSET fix and cleanup Franck Bui-Huu
2007-03-27  9:19 ` [PATCH 1/4] Allow generic spaces.h to be included by platform specific ones Franck Bui-Huu
2007-03-27  9:19 ` [PATCH 2/4] Make PAGE_OFFSET aware of PHYS_OFFSET Franck Bui-Huu
2007-03-27  9:19 ` [PATCH 3/4] Move PHY_OFFSET definition in spaces.h Franck Bui-Huu
2007-03-27  9:19 ` [PATCH 4/4] Fix PHYS_OFFSET for 64-bits kernels with 32-bits symbols Franck Bui-Huu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.