From 7cfecbb95b9adcb85efef92cbc33c6030483fc9a Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Thu, 3 Nov 2016 23:11:33 +0000 Subject: [PATCH] Add a witness check to enforce that no non-sleeping locks are held when they shouldn't be. I used this during driver bring-up to find that the Linux driver holds a whole lot of locks whilst doing their equivalent of busdma operations. If this works out well, it should be added to the other architecture busdma implementations to aid in similar debugging. Tested: * bounce buffer and dmar busdma, Lenovo X230 laptop, all the internal hardware * ath(4) too Discussed with: jhb --- sys/x86/x86/busdma_machdep.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/x86/x86/busdma_machdep.c b/sys/x86/x86/busdma_machdep.c index c96b26d579f..aa9e36d3e97 100644 --- a/sys/x86/x86/busdma_machdep.c +++ b/sys/x86/x86/busdma_machdep.c @@ -197,6 +197,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, struct bus_dma_tag_common *tc; int error; + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); + if (parent == NULL) { error = bus_dma_bounce_impl.tag_create(parent, alignment, boundary, lowaddr, highaddr, filter, filterarg, maxsize, @@ -228,6 +230,8 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) { struct bus_dma_tag_common *tc; + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); + tc = (struct bus_dma_tag_common *)dmat; return (tc->impl->map_create(dmat, flags, mapp)); } @@ -257,6 +261,8 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, { struct bus_dma_tag_common *tc; + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); + tc = (struct bus_dma_tag_common *)dmat; return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp)); }