Re: [PATCH] [POWERPC] Port fixmap from x86 and use for kmap_atomic

2008-04-21 Thread Kumar Gala


On Apr 19, 2008, at 6:07 AM, Gerhard Pircher wrote:


 Original-Nachricht 

Datum: Thu, 17 Apr 2008 21:57:05 -0500 (CDT)
Von: Kumar Gala [EMAIL PROTECTED]
An: Paul Mackerras [EMAIL PROTECTED]
CC: linuxppc-dev@ozlabs.org
Betreff: [PATCH] [POWERPC] Port fixmap from x86 and use for  
kmap_atomic


The fixmap code from x86 allows us to have compile time virtual  
addresses

that we change the physical addresses of at run time.

...

+/*
+ * Here we define all the compile-time 'special' virtual
+ * addresses. The point is to have a constant address at
+ * compile time, but to set the physical address only
+ * in the boot process. We allocate these special addresses
+ * from the end of virtual memory (0xf000) backwards.
+ * Also this lets us do fail-safe vmalloc(), we
+ * can guarantee that these special addresses and
+ * vmalloc()-ed addresses never overlap.
I don't understand how highmem works, but I'm just interested to  
know, if

this implementation could conflict somehow with the non coherent DMA
implementation in dma-noncoherent.c (which uses address space from
0xff10 to 0xff30 for DMA memory).


if the size is fixed we can easily change it so the Kconfig options  
aren't needed anymore.


On the other side could dma-noncoherent.c benefit from fixmaps so  
that it

isn't necessary to configure a start address for DMA allocations?


Its possible however the fixmap is all about keeping the VA the same  
while changing the PA. I think some work that is being done for the SW  
IOMMU might be more useful to your needs.


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


Re: [PATCH] [POWERPC] Port fixmap from x86 and use for kmap_atomic

2008-04-19 Thread Gerhard Pircher

 Original-Nachricht 
 Datum: Thu, 17 Apr 2008 21:57:05 -0500 (CDT)
 Von: Kumar Gala [EMAIL PROTECTED]
 An: Paul Mackerras [EMAIL PROTECTED]
 CC: linuxppc-dev@ozlabs.org
 Betreff: [PATCH] [POWERPC] Port fixmap from x86 and use for kmap_atomic

 The fixmap code from x86 allows us to have compile time virtual addresses
 that we change the physical addresses of at run time.
...
 +/*
 + * Here we define all the compile-time 'special' virtual
 + * addresses. The point is to have a constant address at
 + * compile time, but to set the physical address only
 + * in the boot process. We allocate these special addresses
 + * from the end of virtual memory (0xf000) backwards.
 + * Also this lets us do fail-safe vmalloc(), we
 + * can guarantee that these special addresses and
 + * vmalloc()-ed addresses never overlap.
I don't understand how highmem works, but I'm just interested to know, if
this implementation could conflict somehow with the non coherent DMA
implementation in dma-noncoherent.c (which uses address space from
0xff10 to 0xff30 for DMA memory).
On the other side could dma-noncoherent.c benefit from fixmaps so that it
isn't necessary to configure a start address for DMA allocations?

Thanks!

best regards,

Gerhard
-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] [POWERPC] Port fixmap from x86 and use for kmap_atomic

2008-04-17 Thread Kumar Gala
The fixmap code from x86 allows us to have compile time virtual addresses
that we change the physical addresses of at run time.

This is useful for applications like kmap_atomic, PCI config that is done
via direct memory map, kexec/kdump.

We got ride of CONFIG_HIGHMEM_START as we can now determine a more optimal
location for PKMAP_BASE based on where the fixmap addresses start and
working back from there.

Additionally, the kmap code in asm-powerpc/highmem.h always had debug
enabled.  Moved to using CONFIG_DEBUG_HIGHMEM to determine if we should
have the extra debug checking.

Signed-off-by: Kumar Gala [EMAIL PROTECTED]
---
 arch/powerpc/Kconfig  |   14 -
 arch/powerpc/mm/init_32.c |8 ---
 arch/powerpc/mm/mem.c |   32 ++--
 arch/powerpc/mm/pgtable_32.c  |   23 
 include/asm-powerpc/fixmap.h  |  112 +
 include/asm-powerpc/highmem.h |   41 ---
 6 files changed, 183 insertions(+), 47 deletions(-)
 create mode 100644 include/asm-powerpc/fixmap.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 10e9df7..96cc0ad 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -613,20 +613,6 @@ config ADVANCED_OPTIONS
 comment Default settings for advanced configuration options are used
depends on !ADVANCED_OPTIONS

-config HIGHMEM_START_BOOL
-   bool Set high memory pool address
-   depends on ADVANCED_OPTIONS  HIGHMEM
-   help
- This option allows you to set the base address of the kernel virtual
- area used to map high memory pages.  This can be useful in
- optimizing the layout of kernel virtual memory.
-
- Say N here unless you know what you are doing.
-
-config HIGHMEM_START
-   hex Virtual start address of high memory pool if HIGHMEM_START_BOOL
-   default 0xfe00
-
 config LOWMEM_SIZE_BOOL
bool Set maximum low memory
depends on ADVANCED_OPTIONS
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 578750e..1952b4d 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -71,14 +71,6 @@ unsigned long agp_special_page;
 EXPORT_SYMBOL(agp_special_page);
 #endif

-#ifdef CONFIG_HIGHMEM
-pte_t *kmap_pte;
-pgprot_t kmap_prot;
-
-EXPORT_SYMBOL(kmap_prot);
-EXPORT_SYMBOL(kmap_pte);
-#endif
-
 void MMU_init(void);

 /* XXX should be in current.h  -- paulus */
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 0062e6b..5ccb579 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -45,6 +45,7 @@
 #include asm/tlb.h
 #include asm/sections.h
 #include asm/vdso.h
+#include asm/fixmap.h

 #include mmu_decl.h

@@ -57,6 +58,20 @@ int init_bootmem_done;
 int mem_init_done;
 unsigned long memory_limit;

+#ifdef CONFIG_HIGHMEM
+pte_t *kmap_pte;
+pgprot_t kmap_prot;
+
+EXPORT_SYMBOL(kmap_prot);
+EXPORT_SYMBOL(kmap_pte);
+
+static inline pte_t *virt_to_kpte(unsigned long vaddr)
+{
+   return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr),
+   vaddr), vaddr), vaddr);
+}
+#endif
+
 int page_is_ram(unsigned long pfn)
 {
unsigned long paddr = (pfn  PAGE_SHIFT);
@@ -311,14 +326,19 @@ void __init paging_init(void)
unsigned long top_of_ram = lmb_end_of_DRAM();
unsigned long max_zone_pfns[MAX_NR_ZONES];

+#ifdef CONFIG_PPC32
+   unsigned long v = __fix_to_virt(__end_of_fixed_addresses - 1);
+   unsigned long end = __fix_to_virt(FIX_HOLE);
+
+   for (; v  end; v += PAGE_SIZE)
+   map_page(v, 0, 0); /* XXX gross */
+#endif
+
 #ifdef CONFIG_HIGHMEM
map_page(PKMAP_BASE, 0, 0); /* XXX gross */
-   pkmap_page_table = pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k
-   (PKMAP_BASE), PKMAP_BASE), PKMAP_BASE), PKMAP_BASE);
-   map_page(KMAP_FIX_BEGIN, 0, 0); /* XXX gross */
-   kmap_pte = pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k
-   (KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN),
-KMAP_FIX_BEGIN);
+   pkmap_page_table = virt_to_kpte(PKMAP_BASE);
+
+   kmap_pte = virt_to_kpte(__fix_to_virt(FIX_KMAP_BEGIN));
kmap_prot = PAGE_KERNEL;
 #endif /* CONFIG_HIGHMEM */

diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 64c44bc..5d0a601 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -29,6 +29,7 @@

 #include asm/pgtable.h
 #include asm/pgalloc.h
+#include asm/fixmap.h
 #include asm/io.h

 #include mmu_decl.h
@@ -387,3 +388,25 @@ void kernel_map_pages(struct page *page, int numpages, int 
enable)
change_page_attr(page, numpages, enable ? PAGE_KERNEL : __pgprot(0));
 }
 #endif /* CONFIG_DEBUG_PAGEALLOC */
+
+static int fixmaps;
+unsigned long __FIXADDR_TOP = 0xf000;
+EXPORT_SYMBOL(__FIXADDR_TOP);
+
+void __set_fixmap (enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
+{
+   unsigned long address =