diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index c10bad3ea092..65836113ade1 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -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) { diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index 82ebc7a81a4a..d76e33c564e2 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -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