Commit:     aa24886e379d2b641c5117e178b15ce1d5d366ba
Parent:     fa007d8bebc5d812a445c48664b5bcad81f1351c
Author:     David Brownell <[EMAIL PROTECTED]>
AuthorDate: Fri Aug 10 13:10:27 2007 -0700
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Oct 12 15:03:15 2007 -0700

    dma_free_coherent() needs irqs enabled (sigh)
    On at least ARM (and I'm told MIPS too) dma_free_coherent() has a newish
    call context requirement: unlike its dma_alloc_coherent() sibling, it may
    not be called with IRQs disabled.  (This was new behavior on ARM as of late
    2005, caused by ARM SMP updates.) This little surprise can be annoyingly
    Since it looks like that restriction won't be removed, this patch changes
    the definition of the API to include that requirement.  Also, to help catch
    nonportable drivers, it updates the x86 and swiotlb versions to include the
    relevant warnings.  (I already observed that it trips on the
    bus_reset_tasklet of the new firewire_ohci driver.)
    Signed-off-by: David Brownell <[EMAIL PROTECTED]>
    Cc: David Miller <[EMAIL PROTECTED]>
    Acked-by: Russell King <[EMAIL PROTECTED]>
    Cc: Andi Kleen <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
 Documentation/DMA-API.txt    |    3 +++
 arch/x86/kernel/pci-dma_32.c |    3 ++-
 arch/x86/kernel/pci-dma_64.c |    1 +
 lib/swiotlb.c                |    1 +
 4 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index cc7a8c3..b939ebb 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -68,6 +68,9 @@ size and dma_handle must all be the same as those passed into 
 consistent allocate.  cpu_addr must be the virtual address returned by
 the consistent allocate.
+Note that unlike their sibling allocation calls, these routines
+may only be called with IRQs enabled.
 Part Ib - Using small dma-coherent buffers
diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 048f09b..0aae2f3 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -63,7 +63,8 @@ void dma_free_coherent(struct device *dev, size_t size,
        struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
        int order = get_order(size);
+       WARN_ON(irqs_disabled());       /* for portability */
        if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + 
(mem->size << PAGE_SHIFT))) {
                int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
diff --git a/arch/x86/kernel/pci-dma_64.c b/arch/x86/kernel/pci-dma_64.c
index 2971144..9576a2e 100644
--- a/arch/x86/kernel/pci-dma_64.c
+++ b/arch/x86/kernel/pci-dma_64.c
@@ -167,6 +167,7 @@ EXPORT_SYMBOL(dma_alloc_coherent);
 void dma_free_coherent(struct device *dev, size_t size,
                         void *vaddr, dma_addr_t bus)
+       WARN_ON(irqs_disabled());       /* for portability */
        if (dma_ops->unmap_single)
                dma_ops->unmap_single(dev, bus, size, 0);
        free_pages((unsigned long)vaddr, get_order(size));
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a7381d5..30c1400 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -497,6 +497,7 @@ void
 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
                      dma_addr_t dma_handle)
+       WARN_ON(irqs_disabled());
        if (!(vaddr >= (void *)io_tlb_start
                     && vaddr < (void *)io_tlb_end))
                free_pages((unsigned long) vaddr, get_order(size));
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to