kernel - Fix spin lock held across contigfree/kfree in bounce code
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 4 Oct 2011 14:58:38 +0000 (07:58 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 4 Oct 2011 14:58:38 +0000 (07:58 -0700)
* Fix an issue where a spin lock is being held across too-complex a
  procedure call.  The bounce page is isolated once removed from its
  list so we can release the lock while issuing the calls, then
  re-acquire it.

Reported-by: Antonio Huete Jimenez <tuxillo@quantumachine.net>
sys/platform/pc32/i386/busdma_machdep.c
sys/platform/pc64/x86_64/busdma_machdep.c

index 7d3708f..8788ea5 100644 (file)
@@ -1259,8 +1259,10 @@ free_bounce_pages_all(bus_dma_tag_t dmat)
                KKASSERT(bz->free_bpages > 0);
                bz->free_bpages--;
 
+               BZ_UNLOCK(bz);
                contigfree((void *)bpage->vaddr, PAGE_SIZE, M_DEVBUF);
                kfree(bpage, M_DEVBUF);
+               BZ_LOCK(bz);
        }
        if (bz->total_bpages) {
                kprintf("#%d bounce pages are still in use\n",
index 187122e..9ada35a 100644 (file)
@@ -1259,8 +1259,10 @@ free_bounce_pages_all(bus_dma_tag_t dmat)
                KKASSERT(bz->free_bpages > 0);
                bz->free_bpages--;
 
+               BZ_UNLOCK(bz);
                contigfree((void *)bpage->vaddr, PAGE_SIZE, M_DEVBUF);
                kfree(bpage, M_DEVBUF);
+               BZ_LOCK(bz);
        }
        if (bz->total_bpages) {
                kprintf("#%d bounce pages are still in use\n",