[RFC/PATCH] powerpc: consistent memory mapping.

2008-12-09 Thread Ilya Yanok
 Defining the start virtual address of the consistent memory
in configs leads to overlapping of the consistent area with
the other virtual regions (fixmap, pkmap, vmalloc). Defaults from
current kernel just set consistent memory area to be somewhere
high in the vmalloc area and then you need to pray there will be
not enough vmalloc allocations to overlap.

 So, this patch makes the virtual address of the consistent memory
to be assigned dynamically, at the end of the virtual address area.
The fixmap area is now shifted to the low addresses, and ends before
start of the consistent virtual addresses. User is now allowed to
configure the size of the consistent memory area only.

 The exception has been made for 8xx archs, where the start
of the consistent memory is still configurable: this is to avoid
overlapping with the IMM space of 8xx. Actually this is wrong. We
have a possibility to overlap not only for consistent memory but
for IMM space too. But we don't have much expertise in 8xx so we
are looking forward for some advice here.

 The following items remain to be done to complete supporting of
the consistent memory fully:

a) we missing 1 (last) page of addresses at the end of the consistent
memory area;

b) if CONFIG_CONSISTENT_SIZE is such that we cover more address
regions than served by 1 pgd level, then mapping of the pages to
these additional areas won't work (this 'feature' isn't introduced
by this patch, but is the consequence of the current consistent
memory support code, where consistent_pte is set in dma_alloc_init()
in accordance with the pgd of the CONSISTENT_BASE address).

Signed-off-by: Ilya Yanok [EMAIL PROTECTED]
Signed-off-by: Yuri Tikhonov [EMAIL PROTECTED]
---
 arch/powerpc/Kconfig   |7 ---
 arch/powerpc/lib/dma-noncoherent.c |5 +
 arch/powerpc/mm/pgtable_32.c   |2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index aa2eb46..4d62446 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -809,7 +809,7 @@ config TASK_SIZE
 
 config CONSISTENT_START_BOOL
bool Set custom consistent memory pool address
-   depends on ADVANCED_OPTIONS  NOT_COHERENT_CACHE
+   depends on ADVANCED_OPTIONS  NOT_COHERENT_CACHE  8xx
help
  This option allows you to set the base virtual address
  of the consistent memory pool.  This pool of virtual
@@ -817,8 +817,8 @@ config CONSISTENT_START_BOOL
 
 config CONSISTENT_START
hex Base virtual address of consistent memory pool if 
CONSISTENT_START_BOOL
-   default 0xfd00 if (NOT_COHERENT_CACHE  8xx)
-   default 0xff10 if NOT_COHERENT_CACHE
+   depends on 8xx
+   default 0xfd00 if NOT_COHERENT_CACHE
 
 config CONSISTENT_SIZE_BOOL
bool Set custom consistent memory pool size
@@ -831,6 +831,7 @@ config CONSISTENT_SIZE_BOOL
 config CONSISTENT_SIZE
hex Size of consistent memory pool if CONSISTENT_SIZE_BOOL
default 0x0020 if NOT_COHERENT_CACHE
+   default 0x if !NOT_COHERENT_CACHE
 
 config PIN_TLB
bool Pinned Kernel TLBs (860 ONLY)
diff --git a/arch/powerpc/lib/dma-noncoherent.c 
b/arch/powerpc/lib/dma-noncoherent.c
index 31734c0..3c12577 100644
--- a/arch/powerpc/lib/dma-noncoherent.c
+++ b/arch/powerpc/lib/dma-noncoherent.c
@@ -38,8 +38,13 @@
  * can be further configured for specific applications under
  * the Advanced Setup menu. -Matt
  */
+#ifdef CONFIG_CONSISTENT_START
 #define CONSISTENT_BASE(CONFIG_CONSISTENT_START)
 #define CONSISTENT_END (CONFIG_CONSISTENT_START + CONFIG_CONSISTENT_SIZE)
+#else
+#define CONSISTENT_BASE((unsigned long)(-CONFIG_CONSISTENT_SIZE))
+#define CONSISTENT_END ((unsigned long)(-PAGE_SIZE))
+#endif /* CONFIG_CONSISTENT_START */
 #define CONSISTENT_OFFSET(x)   (((unsigned long)(x) - CONSISTENT_BASE)  
PAGE_SHIFT)
 
 /*
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 10d21c3..fda24c7 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -395,7 +395,7 @@ void kernel_map_pages(struct page *page, int numpages, int 
enable)
 #endif /* CONFIG_DEBUG_PAGEALLOC */
 
 static int fixmaps;
-unsigned long FIXADDR_TOP = (-PAGE_SIZE);
+unsigned long FIXADDR_TOP = (-PAGE_SIZE-CONFIG_CONSISTENT_SIZE);
 EXPORT_SYMBOL(FIXADDR_TOP);
 
 void __set_fixmap (enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
-- 
1.5.6.1

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC/PATCH] powerpc: consistent memory mapping.

2008-12-09 Thread Benjamin Herrenschmidt
On Tue, 2008-12-09 at 21:23 +0300, Ilya Yanok wrote:
 Defining the start virtual address of the consistent memory
 in configs leads to overlapping of the consistent area with
 the other virtual regions (fixmap, pkmap, vmalloc). Defaults from
 current kernel just set consistent memory area to be somewhere
 high in the vmalloc area and then you need to pray there will be
 not enough vmalloc allocations to overlap.

 .../...

What about just ripping that consistent memory implementation out
completely and using the normal vmalloc/ioremap allocator instead ?

Any reason not to ?

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev