Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/i386 _bus_dmamem_unmap():



details:   https://anonhg.NetBSD.org/src/rev/a5c76016aa1a
branches:  trunk
changeset: 542418:a5c76016aa1a
user:      kent <kent%NetBSD.org@localhost>
date:      Tue Jan 28 08:46:53 2003 +0000

description:
_bus_dmamem_unmap():
 Sets the specified pages cacheable again because _bus_dmamem_map() might
change them uncacheable.
 The code was provided by Dhoyashiki-san in kern/19919.

diffstat:

 sys/arch/i386/i386/bus_machdep.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (52 lines):

diff -r 1f8cd3bc6624 -r a5c76016aa1a sys/arch/i386/i386/bus_machdep.c
--- a/sys/arch/i386/i386/bus_machdep.c  Tue Jan 28 08:34:17 2003 +0000
+++ b/sys/arch/i386/i386/bus_machdep.c  Tue Jan 28 08:46:53 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_machdep.c,v 1.18 2003/01/28 01:07:52 kent Exp $    */
+/*     $NetBSD: bus_machdep.c,v 1.19 2003/01/28 08:46:53 kent Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_machdep.c,v 1.18 2003/01/28 01:07:52 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_machdep.c,v 1.19 2003/01/28 08:46:53 kent Exp $");
 
 #include "opt_largepages.h"
 
@@ -867,13 +867,33 @@
        caddr_t kva;
        size_t size;
 {
+       pt_entry_t *pte;
+       vaddr_t va, endva;
+       int cpumask;
+       int marked;
 
+       cpumask = 0;
+       marked = 0;
 #ifdef DIAGNOSTIC
        if ((u_long)kva & PGOFSET)
                panic("_bus_dmamem_unmap");
 #endif
 
        size = round_page(size);
+       /*
+         * mark pages cacheable again.
+         */
+       for (va = (vaddr_t)kva, endva = (vaddr_t)kva + size;
+            va < endva; va += PAGE_SIZE) {
+               pte = kvtopte(va);
+               if ((*pte & PG_N) != 0) {
+                       *pte &= ~PG_N;
+                       pmap_tlb_shootdown(pmap_kernel(), va, *pte, &cpumask);
+                       marked = 1;
+               }
+       }
+       if (marked)
+               pmap_tlb_shootnow(cpumask);
 
        uvm_km_free(kernel_map, (vaddr_t)kva, size);
 }



Home | Main Index | Thread Index | Old Index