mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
Add some basic KTR tracing to busdma on i386. This is likely not
the final set of traces -- someone with more busdma background will probably want to review and expand this, as well as port to other platforms. This tracing is sufficient to identify key busdma events on i386, and in particular to draw attention to bounce buffering events that may have a substantial performance impact.
This commit is contained in:
parent
f16b4811d2
commit
16aebf571f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=136805
@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/interrupt.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mutex.h>
|
||||
@ -218,8 +219,11 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
||||
*dmat = NULL;
|
||||
|
||||
newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF, M_NOWAIT);
|
||||
if (newtag == NULL)
|
||||
if (newtag == NULL) {
|
||||
CTR3(KTR_BUSDMA, "bus_dma_tag_create returned tag %p tag "
|
||||
"flags 0x%x error %d", newtag, 0, error);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
newtag->parent = parent;
|
||||
newtag->alignment = alignment;
|
||||
@ -296,16 +300,26 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
||||
} else {
|
||||
*dmat = newtag;
|
||||
}
|
||||
CTR3(KTR_BUSDMA, "bus_dma_tag_create returned tag %p tag flags 0x%x "
|
||||
"error %d", newtag, (newtag != NULL ? newtag->flags : 0), error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
{
|
||||
bus_dma_tag_t dmat_copy;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
dmat_copy = dmat;
|
||||
|
||||
if (dmat != NULL) {
|
||||
|
||||
if (dmat->map_count != 0)
|
||||
return (EBUSY);
|
||||
if (dmat->map_count != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (dmat != NULL) {
|
||||
bus_dma_tag_t parent;
|
||||
@ -326,7 +340,10 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
dmat = NULL;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
out:
|
||||
CTR2(KTR_BUSDMA, "bus_dma_tag_destroy tag %p error %d", dmat_copy,
|
||||
error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -344,8 +361,11 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
|
||||
dmat->segments = (bus_dma_segment_t *)malloc(
|
||||
sizeof(bus_dma_segment_t) * dmat->nsegments, M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (dmat->segments == NULL)
|
||||
if (dmat->segments == NULL) {
|
||||
CTR2(KTR_BUSDMA, "bus_dmamap_create: tag %p error %d",
|
||||
dmat, ENOMEM);
|
||||
return (ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -360,8 +380,11 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
|
||||
|
||||
*mapp = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF,
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (*mapp == NULL)
|
||||
if (*mapp == NULL) {
|
||||
CTR2(KTR_BUSDMA, "bus_dmamap_create: tag %p error %d",
|
||||
dmat, ENOMEM);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
/* Initialize the new map */
|
||||
STAILQ_INIT(&((*mapp)->bpages));
|
||||
@ -400,6 +423,8 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
|
||||
}
|
||||
if (error == 0)
|
||||
dmat->map_count++;
|
||||
CTR3(KTR_BUSDMA, "bus_dmamap_create: tag %p tag flags 0x%x error %d",
|
||||
dmat, dmat->flags, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -411,11 +436,15 @@ int
|
||||
bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
|
||||
{
|
||||
if (map != NULL && map != &nobounce_dmamap) {
|
||||
if (STAILQ_FIRST(&map->bpages) != NULL)
|
||||
if (STAILQ_FIRST(&map->bpages) != NULL) {
|
||||
CTR2(KTR_BUSDMA, "bus_dmamap_destroy: tag %p error %d",
|
||||
dmat, EBUSY);
|
||||
return (EBUSY);
|
||||
}
|
||||
free(map, M_DEVBUF);
|
||||
}
|
||||
dmat->map_count--;
|
||||
CTR1(KTR_BUSDMA, "bus_dmamap_destroy: tag %p error 0", dmat);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -445,8 +474,11 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
dmat->segments = (bus_dma_segment_t *)malloc(
|
||||
sizeof(bus_dma_segment_t) * dmat->nsegments, M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (dmat->segments == NULL)
|
||||
if (dmat->segments == NULL) {
|
||||
CTR3(KTR_BUSDMA, "bus_dmamem_alloc: tag %p tag "
|
||||
"flags 0x%x error %d", dmat, dmat->flags, ENOMEM);
|
||||
return (ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
if ((dmat->maxsize <= PAGE_SIZE) &&
|
||||
@ -463,8 +495,13 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
|
||||
dmat->boundary);
|
||||
}
|
||||
if (*vaddr == NULL)
|
||||
if (*vaddr == NULL) {
|
||||
CTR3(KTR_BUSDMA, "bus_dmamem_alloc: tag %p tag flags 0x%x "
|
||||
"error %d", dmat, dmat->flags, ENOMEM);
|
||||
return (ENOMEM);
|
||||
}
|
||||
CTR3(KTR_BUSDMA, "bus_dmamem_alloc: tag %p tag flags 0x%x error %d",
|
||||
dmat, dmat->flags, ENOMEM);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -487,6 +524,8 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
|
||||
else {
|
||||
contigfree(vaddr, dmat->maxsize, M_DEVBUF);
|
||||
}
|
||||
CTR2(KTR_BUSDMA, "bus_dmamem_free: tag %p flags 0x%x", dmat,
|
||||
dmat->flags);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -658,14 +697,19 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
|
||||
error = _bus_dmamap_load_buffer(dmat, map, buf, buflen, NULL, flags,
|
||||
&lastaddr, &nsegs, 1);
|
||||
|
||||
if (error == EINPROGRESS)
|
||||
if (error == EINPROGRESS) {
|
||||
CTR3(KTR_BUSDMA, "bus_dmamap_load: tag %p tag flags 0x%x "
|
||||
"error %d", dmat, dmat->flags, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if (error)
|
||||
(*callback)(callback_arg, dmat->segments, 0, error);
|
||||
else
|
||||
(*callback)(callback_arg, dmat->segments, nsegs + 1, 0);
|
||||
|
||||
CTR2(KTR_BUSDMA, "bus_dmamap_load: tag %p tag flags 0x%x error 0",
|
||||
dmat, dmat->flags);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -711,6 +755,8 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||
(*callback)(callback_arg, dmat->segments,
|
||||
nsegs+1, m0->m_pkthdr.len, error);
|
||||
}
|
||||
CTR3(KTR_BUSDMA, "bus_dmamap_load_mbuf: tag %p tag flags 0x%x "
|
||||
"error %d", dmat, dmat->flags, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -768,6 +814,8 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||
(*callback)(callback_arg, dmat->segments,
|
||||
nsegs+1, uio->uio_resid, error);
|
||||
}
|
||||
CTR3(KTR_BUSDMA, "bus_dmamap_load_uio: tag %p tag flags 0x%x "
|
||||
"error %d", dmat, dmat->flags, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -797,6 +845,8 @@ _bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
|
||||
* the caches on broken hardware
|
||||
*/
|
||||
total_bounced++;
|
||||
CTR3(KTR_BUSDMA, "_bus_dmamap_sync: tag %p tag flags 0x%x "
|
||||
"op 0x%x performing bounce", op, dmat, dmat->flags);
|
||||
|
||||
if (op & BUS_DMASYNC_PREWRITE) {
|
||||
while (bpage != NULL) {
|
||||
|
@ -75,7 +75,8 @@
|
||||
#define KTR_UMA 0x01000000 /* UMA slab allocator */
|
||||
#define KTR_CALLOUT 0x02000000 /* Callouts and timeouts */
|
||||
#define KTR_GEOM 0x04000000 /* GEOM I/O events */
|
||||
#define KTR_ALL 0x04ffffff
|
||||
#define KTR_BUSDMA 0x08000000 /* busdma(9) events */
|
||||
#define KTR_ALL 0x0fffffff
|
||||
|
||||
/*
|
||||
* Trace classes which can be assigned to particular use at compile time
|
||||
|
Loading…
Reference in New Issue
Block a user