Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha Add some bus_dma instrumentation.
details: https://anonhg.NetBSD.org/src/rev/8179ece72618
branches: trunk
changeset: 940591:8179ece72618
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Oct 11 00:33:30 2020 +0000
description:
Add some bus_dma instrumentation.
diffstat:
sys/arch/alpha/common/bus_dma.c | 37 ++++++++++++++++++++----
sys/arch/alpha/common/sgmap_typedep.c | 52 ++++++++++++++++++++++++++++------
sys/arch/alpha/include/bus_funcs.h | 11 ++++++-
sys/arch/alpha/pci/apecs_dma.c | 6 ++--
sys/arch/alpha/pci/cia_dma.c | 6 ++--
sys/arch/alpha/pci/dwlpx_dma.c | 6 ++--
sys/arch/alpha/pci/lca_dma.c | 6 ++--
sys/arch/alpha/pci/mcpcia_dma.c | 6 ++--
sys/arch/alpha/pci/pci_sgmap_pte32.c | 5 ++-
sys/arch/alpha/pci/pci_sgmap_pte64.c | 5 ++-
sys/arch/alpha/pci/tsp_dma.c | 6 ++--
sys/arch/alpha/pci/ttwoga_dma.c | 6 ++--
sys/arch/alpha/tc/tc_dma_3000_500.c | 6 ++--
sys/arch/alpha/tc/tc_sgmap.c | 5 ++-
14 files changed, 116 insertions(+), 47 deletions(-)
diffs (truncated from 622 to 300 lines):
diff -r 8f429cf3c565 -r 8179ece72618 sys/arch/alpha/common/bus_dma.c
--- a/sys/arch/alpha/common/bus_dma.c Sat Oct 10 21:59:03 2020 +0000
+++ b/sys/arch/alpha/common/bus_dma.c Sun Oct 11 00:33:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.69 2012/10/02 23:54:51 christos Exp $ */
+/* $NetBSD: bus_dma.c,v 1.70 2020/10/11 00:33:30 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.69 2012/10/02 23:54:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.70 2020/10/11 00:33:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -56,6 +56,9 @@
extern paddr_t avail_start, avail_end; /* from pmap.c */
+#define DMA_COUNT_DECL(cnt) _DMA_COUNT_DECL(dma_direct, cnt)
+#define DMA_COUNT(cnt) _DMA_COUNT(dma_direct, cnt)
+
/*
* Common function for DMA map creation. May be called by bus-specific
* DMA map creation functions.
@@ -218,6 +221,9 @@
return (0);
}
+DMA_COUNT_DECL(load);
+DMA_COUNT_DECL(load_next_window);
+
/*
* Common function for loading a direct-mapped DMA map with a linear
* buffer. Called by bus-specific DMA map load functions with the
@@ -252,6 +258,7 @@
error = _bus_dmamap_load_buffer_direct(t, map, buf, buflen,
vm, flags, &lastaddr, &seg, 1);
if (error == 0) {
+ DMA_COUNT(load);
map->dm_mapsize = buflen;
map->dm_nsegs = seg + 1;
map->_dm_window = t;
@@ -259,12 +266,16 @@
/*
* Give the next window a chance.
*/
+ DMA_COUNT(load_next_window);
error = bus_dmamap_load(t->_next_window, map, buf, buflen,
p, flags);
}
return (error);
}
+DMA_COUNT_DECL(load_mbuf);
+DMA_COUNT_DECL(load_mbuf_next_window);
+
/*
* Like _bus_dmamap_load_direct(), but for mbufs.
*/
@@ -341,6 +352,7 @@
first = 0;
}
if (error == 0) {
+ DMA_COUNT(load_mbuf);
map->dm_mapsize = m0->m_pkthdr.len;
map->dm_nsegs = seg + 1;
map->_dm_window = t;
@@ -348,11 +360,15 @@
/*
* Give the next window a chance.
*/
+ DMA_COUNT(load_mbuf_next_window);
error = bus_dmamap_load_mbuf(t->_next_window, map, m0, flags);
}
return (error);
}
+DMA_COUNT_DECL(load_uio);
+DMA_COUNT_DECL(load_uio_next_window);
+
/*
* Like _bus_dmamap_load_direct(), but for uios.
*/
@@ -398,6 +414,7 @@
resid -= minlen;
}
if (error == 0) {
+ DMA_COUNT(load_uio);
map->dm_mapsize = uio->uio_resid;
map->dm_nsegs = seg + 1;
map->_dm_window = t;
@@ -405,6 +422,7 @@
/*
* Give the next window a chance.
*/
+ DMA_COUNT(load_uio_next_window);
error = bus_dmamap_load_uio(t->_next_window, map, uio, flags);
}
return (error);
@@ -426,7 +444,7 @@
* chipset-specific DMA map unload functions.
*/
void
-_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
+_bus_dmamap_unload_common(bus_dma_tag_t t, bus_dmamap_t map)
{
/*
@@ -440,6 +458,16 @@
map->_dm_flags &= ~(BUS_DMA_READ|BUS_DMA_WRITE);
}
+DMA_COUNT_DECL(unload);
+
+void
+_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
+{
+ KASSERT(map->_dm_window == t);
+ DMA_COUNT(unload);
+ _bus_dmamap_unload_common(t, map);
+}
+
/*
* Common function for DMA map synchronization. May be called
* by chipset-specific DMA map synchronization functions.
@@ -449,9 +477,6 @@
bus_size_t len, int ops)
{
- /*
- * Flush the store buffer.
- */
alpha_mb();
}
diff -r 8f429cf3c565 -r 8179ece72618 sys/arch/alpha/common/sgmap_typedep.c
--- a/sys/arch/alpha/common/sgmap_typedep.c Sat Oct 10 21:59:03 2020 +0000
+++ b/sys/arch/alpha/common/sgmap_typedep.c Sun Oct 11 00:33:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.39 2020/06/17 05:52:13 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.40 2020/10/11 00:33:30 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,21 +31,24 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.39 2020/06/17 05:52:13 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.40 2020/10/11 00:33:30 thorpej Exp $");
#include "opt_ddb.h"
+#include <sys/evcnt.h>
#include <uvm/uvm_extern.h>
+#define DMA_COUNT_DECL(cnt) _DMA_COUNT_DECL(dma_sgmap, cnt)
+#define DMA_COUNT(cnt) _DMA_COUNT(dma_sgmap, cnt)
+
#ifdef SGMAP_DEBUG
int __C(SGMAP_TYPE,_debug) = 0;
#endif
SGMAP_PTE_TYPE __C(SGMAP_TYPE,_prefetch_spill_page_pte);
-int __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t,
- bus_dmamap_t, void *buf, size_t buflen,
- struct vmspace *, int, int, struct alpha_sgmap *);
+static void __C(SGMAP_TYPE,_do_unload)(bus_dma_tag_t, bus_dmamap_t,
+ struct alpha_sgmap *);
void
__C(SGMAP_TYPE,_init_spill_page_pte)(void)
@@ -56,7 +59,9 @@
SGPTE_PGADDR_SHIFT) | SGPTE_VALID;
}
-int
+DMA_COUNT_DECL(spill_page);
+
+static int
__C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
size_t buflen, struct vmspace *vm, int flags, int seg,
struct alpha_sgmap *sgmap)
@@ -109,6 +114,7 @@
sgvalen = (endva - va);
if (spill) {
+ DMA_COUNT(spill_page);
sgvalen += PAGE_SIZE;
/*
@@ -197,6 +203,9 @@
return (0);
}
+DMA_COUNT_DECL(load);
+DMA_COUNT_DECL(load_next_window);
+
int
__C(SGMAP_TYPE,_load)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
bus_size_t buflen, struct proc *p, int flags, struct alpha_sgmap *sgmap)
@@ -236,6 +245,7 @@
#endif
if (error == 0) {
+ DMA_COUNT(load);
map->dm_mapsize = buflen;
map->dm_nsegs = 1;
map->_dm_window = t;
@@ -243,6 +253,7 @@
map->_dm_flags &= ~(BUS_DMA_READ|BUS_DMA_WRITE);
if (t->_next_window != NULL) {
/* Give the next window a chance. */
+ DMA_COUNT(load_next_window);
error = bus_dmamap_load(t->_next_window, map, buf,
buflen, p, flags);
}
@@ -250,6 +261,9 @@
return (error);
}
+DMA_COUNT_DECL(load_mbuf);
+DMA_COUNT_DECL(load_mbuf_next_window);
+
int
__C(SGMAP_TYPE,_load_mbuf)(bus_dma_tag_t t, bus_dmamap_t map,
struct mbuf *m0, int flags, struct alpha_sgmap *sgmap)
@@ -295,16 +309,18 @@
#endif
if (error == 0) {
+ DMA_COUNT(load_mbuf);
map->dm_mapsize = m0->m_pkthdr.len;
map->dm_nsegs = seg;
map->_dm_window = t;
} else {
/* Need to back out what we've done so far. */
map->dm_nsegs = seg - 1;
- __C(SGMAP_TYPE,_unload)(t, map, sgmap);
+ __C(SGMAP_TYPE,_do_unload)(t, map, sgmap);
map->_dm_flags &= ~(BUS_DMA_READ|BUS_DMA_WRITE);
if (t->_next_window != NULL) {
/* Give the next window a chance. */
+ DMA_COUNT(load_mbuf_next_window);
error = bus_dmamap_load_mbuf(t->_next_window, map,
m0, flags);
}
@@ -313,6 +329,9 @@
return (error);
}
+DMA_COUNT_DECL(load_uio);
+DMA_COUNT_DECL(load_uio_next_window);
+
int
__C(SGMAP_TYPE,_load_uio)(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
int flags, struct alpha_sgmap *sgmap)
@@ -365,16 +384,18 @@
#endif
if (error == 0) {
+ DMA_COUNT(load_uio);
map->dm_mapsize = uio->uio_resid;
map->dm_nsegs = seg;
map->_dm_window = t;
} else {
/* Need to back out what we've done so far. */
map->dm_nsegs = seg - 1;
- __C(SGMAP_TYPE,_unload)(t, map, sgmap);
+ __C(SGMAP_TYPE,_do_unload)(t, map, sgmap);
map->_dm_flags &= ~(BUS_DMA_READ|BUS_DMA_WRITE);
if (t->_next_window != NULL) {
/* Give the next window a chance. */
+ DMA_COUNT(load_uio_next_window);
error = bus_dmamap_load_uio(t->_next_window, map,
uio, flags);
}
@@ -396,8 +417,8 @@
panic(__S(__C(SGMAP_TYPE,_load_raw)) ": not implemented");
}
-void
-__C(SGMAP_TYPE,_unload)(bus_dma_tag_t t, bus_dmamap_t map,
+static void
+__C(SGMAP_TYPE,_do_unload)(bus_dma_tag_t t, bus_dmamap_t map,
struct alpha_sgmap *sgmap)
{
SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
@@ -448,3 +469,14 @@
map->dm_nsegs = 0;
map->_dm_window = NULL;
}
+
+DMA_COUNT_DECL(unload);
+
Home |
Main Index |
Thread Index |
Old Index