Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc implement pmap_mmap_flags() and teach Power...



details:   https://anonhg.NetBSD.org/src/rev/3c515263fb2f
branches:  trunk
changeset: 762108:3c515263fb2f
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Feb 15 19:39:12 2011 +0000

description:
implement pmap_mmap_flags() and teach PowerPC's bus_space_mmap() to actually
use BUS_SPACE_MAP_PREFETCHABLE which, now that /dev/pci* knows how to use it,
helps improve X performance

diffstat:

 sys/arch/powerpc/include/oea/pmap.h  |  13 ++++++++++---
 sys/arch/powerpc/oea/pmap.c          |  25 ++++++++++++++++++++++---
 sys/arch/powerpc/powerpc/bus_space.c |  13 +++++++++++--
 3 files changed, 43 insertions(+), 8 deletions(-)

diffs (139 lines):

diff -r a8e9a59c7a3b -r 3c515263fb2f sys/arch/powerpc/include/oea/pmap.h
--- a/sys/arch/powerpc/include/oea/pmap.h       Tue Feb 15 19:38:54 2011 +0000
+++ b/sys/arch/powerpc/include/oea/pmap.h       Tue Feb 15 19:39:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.21 2011/02/12 18:23:10 matt Exp $   */
+/*     $NetBSD: pmap.h,v 1.22 2011/02/15 19:39:12 macallan Exp $       */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -117,8 +117,6 @@
 #define        pmap_is_modified(pg)            (pmap_query_bit((pg), PTE_CHG))
 #define        pmap_is_referenced(pg)          (pmap_query_bit((pg), PTE_REF))
 
-#define        pmap_phys_address(x)            (x)
-
 #define        pmap_resident_count(pmap)       ((pmap)->pm_stats.resident_count)
 #define        pmap_wired_count(pmap)          ((pmap)->pm_stats.wired_count)
 
@@ -142,6 +140,14 @@
 int pmap_pte_spill(pmap_t, vaddr_t, bool);
 void pmap_pinit(pmap_t);
 
+u_int powerpc_mmap_flags(paddr_t);
+#define POWERPC_MMAP_FLAG_MASK 0xf
+#define POWERPC_MMAP_FLAG_PREFETCHABLE 0x1
+#define POWERPC_MMAP_FLAG_CACHEABLE    0x2
+
+#define pmap_phys_address(ppn)         (ppn & ~POWERPC_MMAP_FLAG_MASK)
+#define pmap_mmap_flags(ppn)           powerpc_mmap_flags(ppn)
+
 static inline paddr_t vtophys (vaddr_t);
 
 /*
@@ -208,6 +214,7 @@
 #endif
 
 #define PMAP_MD_NOCACHE                        0x1000000
+#define PMAP_MD_PREFETCHABLE           0x2000000
 #define PMAP_STEAL_MEMORY
 #define PMAP_NEED_PROCWR
 
diff -r a8e9a59c7a3b -r 3c515263fb2f sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c       Tue Feb 15 19:38:54 2011 +0000
+++ b/sys/arch/powerpc/oea/pmap.c       Tue Feb 15 19:39:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.76 2011/02/12 18:23:10 matt Exp $   */
+/*     $NetBSD: pmap.c,v 1.77 2011/02/15 19:39:12 macallan Exp $       */
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76 2011/02/12 18:23:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77 2011/02/15 19:39:12 macallan Exp $");
 
 #define        PMAP_NOOPNAMES
 
@@ -1927,7 +1927,11 @@
         * it's in our available memory array.  If it is in the memory array,
         * asssume it's in memory coherent memory.
         */
-       pte_lo = PTE_IG;
+       if (flags & PMAP_MD_PREFETCHABLE) {
+               pte_lo = 0;
+       } else
+               pte_lo = PTE_G;
+
        if ((flags & PMAP_MD_NOCACHE) == 0) {
                for (mp = mem; mp->size; mp++) {
                        if (pa >= mp->start && pa < mp->start + mp->size) {
@@ -1935,6 +1939,8 @@
                                break;
                        }
                }
+       } else {
+               pte_lo |= PTE_I;
        }
 
        if (prot & VM_PROT_WRITE)
@@ -3514,3 +3520,16 @@
        }
 #endif
 }
+
+u_int
+powerpc_mmap_flags(paddr_t pa)
+{
+       u_int flags = PMAP_MD_NOCACHE;
+
+       if (pa & POWERPC_MMAP_FLAG_PREFETCHABLE)
+               flags |= PMAP_MD_PREFETCHABLE;
+       if (pa & POWERPC_MMAP_FLAG_CACHEABLE)
+               flags &= ~PMAP_MD_NOCACHE;
+       return flags;
+}
+
diff -r a8e9a59c7a3b -r 3c515263fb2f sys/arch/powerpc/powerpc/bus_space.c
--- a/sys/arch/powerpc/powerpc/bus_space.c      Tue Feb 15 19:38:54 2011 +0000
+++ b/sys/arch/powerpc/powerpc/bus_space.c      Tue Feb 15 19:39:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.c,v 1.24 2011/01/18 01:02:55 matt Exp $      */
+/*     $NetBSD: bus_space.c,v 1.25 2011/02/15 19:39:12 macallan Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.24 2011/01/18 01:02:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.25 2011/02/15 19:39:12 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -499,6 +499,7 @@
        paddr_t ret;
        /* XXX what about stride? */
        ret = trunc_page(t->pbs_offset + bpa + offset);
+
 #ifdef DEBUG
        if (ret == 0) {
                printf("%s: [%08x, %08x %08x] mmaps to 0?!\n", __func__,
@@ -506,6 +507,14 @@
                return -1;
        }
 #endif
+
+#ifdef POWERPC_MMAP_FLAG_MASK
+       if (flags & BUS_SPACE_MAP_PREFETCHABLE)
+               ret |= POWERPC_MMAP_FLAG_PREFETCHABLE;
+       if (flags & BUS_SPACE_MAP_CACHEABLE)
+               ret |= POWERPC_MMAP_FLAG_CACHEABLE;
+#endif
+
        return ret;
 }
 



Home | Main Index | Thread Index | Old Index