]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - lib/swiotlb.c
dma_free_coherent() needs irqs enabled (sigh)
[linux-2.6-omap-h63xx.git] / lib / swiotlb.c
index 9970e55c90bd7b28d90c5912bf3f63da3a4c7dc2..30c1400e749e8299be6767e32e9f3531ae18a0a4 100644 (file)
@@ -357,7 +357,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
         * This is needed when we sync the memory.  Then we sync the buffer if
         * needed.
         */
-       io_tlb_orig_addr[index] = buffer;
+       for (i = 0; i < nslots; i++)
+               io_tlb_orig_addr[index+i] = buffer + (i << IO_TLB_SHIFT);
        if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
                memcpy(dma_addr, buffer, size);
 
@@ -418,6 +419,8 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
        int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
        char *buffer = io_tlb_orig_addr[index];
 
+       buffer += ((unsigned long)dma_addr & ((1 << IO_TLB_SHIFT) - 1));
+
        switch (target) {
        case SYNC_FOR_CPU:
                if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
@@ -494,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));
@@ -778,7 +782,6 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask)
        return virt_to_bus(io_tlb_end - 1) <= mask;
 }
 
-EXPORT_SYMBOL(swiotlb_init);
 EXPORT_SYMBOL(swiotlb_map_single);
 EXPORT_SYMBOL(swiotlb_unmap_single);
 EXPORT_SYMBOL(swiotlb_map_sg);