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
This commit is contained in:
adrian 2016-11-03 23:11:33 +00:00
parent 806cb8b636
commit ffebdbc604

View File

@ -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));
}