Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Introduce BUS_DMA_NOCACHE, and bus_dmamem_map() of i386 supp...
details: https://anonhg.NetBSD.org/src/rev/cac5dcdf1ff4
branches: trunk
changeset: 542410:cac5dcdf1ff4
user: kent <kent%NetBSD.org@localhost>
date: Tue Jan 28 01:07:51 2003 +0000
description:
Introduce BUS_DMA_NOCACHE, and bus_dmamem_map() of i386 supports it.
diffstat:
share/man/man9/bus_dma.9 | 13 ++++++++++++-
sys/arch/algor/include/bus.h | 3 ++-
sys/arch/alpha/include/bus.h | 3 ++-
sys/arch/arc/include/bus.h | 19 ++++++++++---------
sys/arch/arm/include/bus.h | 3 ++-
sys/arch/atari/include/bus.h | 3 ++-
sys/arch/cobalt/include/bus.h | 3 ++-
sys/arch/dreamcast/include/bus.h | 3 ++-
sys/arch/hp700/include/bus.h | 3 ++-
sys/arch/hpcmips/include/bus.h | 3 ++-
sys/arch/hpcsh/include/bus.h | 3 ++-
sys/arch/i386/i386/bus_machdep.c | 26 ++++++++++++++++++++++++--
sys/arch/i386/include/bus.h | 3 ++-
sys/arch/m68k/include/bus_dma.h | 3 ++-
sys/arch/macppc/include/bus.h | 19 ++++++++++---------
sys/arch/mips/include/bus_dma.h | 3 ++-
sys/arch/mipsco/include/bus.h | 19 ++++++++++---------
sys/arch/mvme68k/include/bus_dma.h | 3 ++-
sys/arch/newsmips/include/bus.h | 3 ++-
sys/arch/ofppc/include/bus.h | 3 ++-
sys/arch/playstation2/include/bus.h | 3 ++-
sys/arch/pmax/include/bus.h | 3 ++-
sys/arch/powerpc/include/bus.h | 3 ++-
sys/arch/sgimips/include/bus.h | 3 ++-
sys/arch/sh5/include/bus.h | 3 ++-
sys/arch/sparc/include/bus.h | 3 ++-
sys/arch/sparc64/include/bus.h | 3 ++-
sys/arch/sun68k/include/bus.h | 3 ++-
sys/arch/vax/include/bus.h | 3 ++-
sys/arch/x68k/include/bus.h | 3 ++-
sys/arch/x86_64/include/bus.h | 3 ++-
31 files changed, 118 insertions(+), 56 deletions(-)
diffs (truncated from 649 to 300 lines):
diff -r 049c33c7f93a -r cac5dcdf1ff4 share/man/man9/bus_dma.9
--- a/share/man/man9/bus_dma.9 Tue Jan 28 00:33:23 2003 +0000
+++ b/share/man/man9/bus_dma.9 Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: bus_dma.9,v 1.25 2002/10/14 13:43:16 wiz Exp $
+.\" $NetBSD: bus_dma.9,v 1.26 2003/01/28 01:07:51 kent Exp $
.\"
.\" Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -677,6 +677,13 @@
See the description of the
.Fn bus_dmamap_load
function.
+.It Dv BUS_DMA_NOCACHE
+This flag is a
+.Em hint
+to machine-dependent code.
+If possible, map the unchached memory.
+This flag may be useful in the case that the memory cache causes unexpected
+behavior of the device.
.El
.El
.Pp
@@ -744,6 +751,10 @@
See
.Fn bus_dmamem_map
above for a description of this flag.
+.It Dv BUS_DMA_NOCACHE
+See
+.Fn bus_dmamem_map
+above for a description of this flag.
.El
.El
.Pp
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/algor/include/bus.h
--- a/sys/arch/algor/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/algor/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.6 2002/03/17 21:45:06 simonb Exp $ */
+/* $NetBSD: bus.h,v 1.7 2003/01/28 01:07:52 kent Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -507,6 +507,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/*
* Private flags stored in the DMA map.
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/alpha/include/bus.h
--- a/sys/arch/alpha/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/alpha/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.47 2002/04/26 04:15:19 thorpej Exp $ */
+/* $NetBSD: bus.h,v 1.48 2003/01/28 01:07:52 kent Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -511,6 +511,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/*
* Private flags stored in the DMA map.
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/arc/include/bus.h
--- a/sys/arch/arc/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/arc/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.14 2002/03/17 21:45:06 simonb Exp $ */
+/* $NetBSD: bus.h,v 1.15 2003/01/28 01:07:53 kent Exp $ */
/* NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp */
/* $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */
@@ -681,17 +681,18 @@
/*
* Flags used in various bus DMA methods.
*/
-#define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
-#define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
+#define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
+#define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
+#define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
+#define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
#define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
-#define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x020
-#define BUS_DMA_BUS3 0x040
-#define BUS_DMA_BUS4 0x080
+#define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
+#define BUS_DMA_BUS2 0x020
+#define BUS_DMA_BUS3 0x040
+#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
#define ARC_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/arm/include/bus.h
--- a/sys/arch/arm/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/arm/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.8 2002/08/17 20:46:27 thorpej Exp $ */
+/* $NetBSD: bus.h,v 1.9 2003/01/28 01:07:53 kent Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -633,6 +633,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/*
* Private flags stored in the DMA map.
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/atari/include/bus.h
--- a/sys/arch/atari/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/atari/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.28 2002/01/07 07:17:17 thorpej Exp $ */
+/* $NetBSD: bus.h,v 1.29 2003/01/28 01:07:56 kent Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -557,6 +557,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/* Forwards needed by prototypes below. */
struct mbuf;
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/cobalt/include/bus.h
--- a/sys/arch/cobalt/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/cobalt/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.8 2002/03/17 21:45:07 simonb Exp $ */
+/* $NetBSD: bus.h,v 1.9 2003/01/28 01:07:56 kent Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -486,6 +486,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
#define COBALT_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/dreamcast/include/bus.h
--- a/sys/arch/dreamcast/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/dreamcast/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.6 2002/03/25 18:59:40 uch Exp $ */
+/* $NetBSD: bus.h,v 1.7 2003/01/28 01:07:57 kent Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -464,6 +464,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/* Forwards needed by prototypes below. */
struct mbuf;
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/hp700/include/bus.h
--- a/sys/arch/hp700/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/hp700/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.3 2002/08/25 20:20:01 fredette Exp $ */
+/* $NetBSD: bus.h,v 1.4 2003/01/28 01:07:58 kent Exp $ */
/* $OpenBSD: bus.h,v 1.13 2001/07/30 14:15:59 art Exp $ */
@@ -312,6 +312,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/* For devices that have a 24-bit address space */
#define BUS_DMA_24BIT BUS_DMA_BUS1
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/hpcmips/include/bus.h
--- a/sys/arch/hpcmips/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/hpcmips/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.15 2002/04/14 07:59:59 takemura Exp $ */
+/* $NetBSD: bus.h,v 1.16 2003/01/28 01:07:58 kent Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -931,6 +931,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/*
* Operations performed by bus_dmamap_sync().
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/hpcsh/include/bus.h
--- a/sys/arch/hpcsh/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/hpcsh/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.7 2002/03/17 21:45:07 simonb Exp $ */
+/* $NetBSD: bus.h,v 1.8 2003/01/28 01:07:59 kent Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -604,6 +604,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
+#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/*
* Private flags stored in the DMA map.
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/i386/i386/bus_machdep.c
--- a/sys/arch/i386/i386/bus_machdep.c Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/i386/i386/bus_machdep.c Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_machdep.c,v 1.17 2002/10/01 12:56:48 fvdl Exp $ */
+/* $NetBSD: bus_machdep.c,v 1.18 2003/01/28 01:07:52 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.17 2002/10/01 12:56:48 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_machdep.c,v 1.18 2003/01/28 01:07:52 kent Exp $");
#include "opt_largepages.h"
@@ -796,6 +796,7 @@
/*
* Common function for mapping DMA-safe memory. May be called by
* bus-specific DMA memory map functions.
+ * This supports BUS_DMA_NOCACHE.
*/
int
_bus_dmamem_map(t, segs, nsegs, size, kvap, flags)
@@ -809,8 +810,15 @@
vaddr_t va;
bus_addr_t addr;
int curseg;
+ int32_t cpumask;
+ int nocache;
+ int marked;
+ pt_entry_t *pte;
size = round_page(size);
+ cpumask = 0;
+ nocache = (flags & BUS_DMA_NOCACHE) != 0 && cpu_class != CPUCLASS_386;
+ marked = 0;
va = uvm_km_valloc(kernel_map, size);
@@ -828,8 +836,22 @@
pmap_enter(pmap_kernel(), va, addr,
VM_PROT_READ | VM_PROT_WRITE,
PMAP_WIRED | VM_PROT_READ | VM_PROT_WRITE);
+ /*
+ * mark page as non-cacheable
+ */
+ if (nocache) {
+ 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);
pmap_update(pmap_kernel());
return (0);
diff -r 049c33c7f93a -r cac5dcdf1ff4 sys/arch/i386/include/bus.h
--- a/sys/arch/i386/include/bus.h Tue Jan 28 00:33:23 2003 +0000
+++ b/sys/arch/i386/include/bus.h Tue Jan 28 01:07:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.39 2002/10/01 12:57:03 fvdl Exp $ */
+/* $NetBSD: bus.h,v 1.40 2003/01/28 01:08:00 kent Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -1027,6 +1027,7 @@
#define BUS_DMA_BUS4 0x080
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
Home |
Main Index |
Thread Index |
Old Index