powerpc/powernv: Use CPU-endian PEST in pnv_pci_dump_p7ioc_diag_data()
[cascardo/linux.git] / lib / swiotlb.c
index 3c365ab..22e13a0 100644 (file)
 #include <linux/ctype.h>
 #include <linux/highmem.h>
 #include <linux/gfp.h>
+#include <linux/scatterlist.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/scatterlist.h>
 
 #include <linux/init.h>
 #include <linux/bootmem.h>
@@ -656,7 +656,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                 */
                phys_addr_t paddr = map_single(hwdev, 0, size, DMA_FROM_DEVICE);
                if (paddr == SWIOTLB_MAP_ERROR)
-                       return NULL;
+                       goto err_warn;
 
                ret = phys_to_virt(paddr);
                dev_addr = phys_to_dma(hwdev, paddr);
@@ -670,7 +670,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                        /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
                        swiotlb_tbl_unmap_single(hwdev, paddr,
                                                 size, DMA_TO_DEVICE);
-                       return NULL;
+                       goto err_warn;
                }
        }
 
@@ -678,6 +678,13 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
        memset(ret, 0, size);
 
        return ret;
+
+err_warn:
+       pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n",
+               dev_name(hwdev), size);
+       dump_stack();
+
+       return NULL;
 }
 EXPORT_SYMBOL(swiotlb_alloc_coherent);
 
@@ -731,7 +738,7 @@ swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir,
 dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
                            unsigned long offset, size_t size,
                            enum dma_data_direction dir,
-                           struct dma_attrs *attrs)
+                           unsigned long attrs)
 {
        phys_addr_t map, phys = page_to_phys(page) + offset;
        dma_addr_t dev_addr = phys_to_dma(dev, phys);
@@ -800,7 +807,7 @@ static void unmap_single(struct device *hwdev, dma_addr_t dev_addr,
 
 void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
                        size_t size, enum dma_data_direction dir,
-                       struct dma_attrs *attrs)
+                       unsigned long attrs)
 {
        unmap_single(hwdev, dev_addr, size, dir);
 }
@@ -870,7 +877,7 @@ EXPORT_SYMBOL(swiotlb_sync_single_for_device);
  */
 int
 swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
-                    enum dma_data_direction dir, struct dma_attrs *attrs)
+                    enum dma_data_direction dir, unsigned long attrs)
 {
        struct scatterlist *sg;
        int i;
@@ -907,7 +914,7 @@ int
 swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
               enum dma_data_direction dir)
 {
-       return swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, NULL);
+       return swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, 0);
 }
 EXPORT_SYMBOL(swiotlb_map_sg);
 
@@ -917,7 +924,8 @@ EXPORT_SYMBOL(swiotlb_map_sg);
  */
 void
 swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
-                      int nelems, enum dma_data_direction dir, struct dma_attrs *attrs)
+                      int nelems, enum dma_data_direction dir,
+                      unsigned long attrs)
 {
        struct scatterlist *sg;
        int i;
@@ -934,7 +942,7 @@ void
 swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
                 enum dma_data_direction dir)
 {
-       return swiotlb_unmap_sg_attrs(hwdev, sgl, nelems, dir, NULL);
+       return swiotlb_unmap_sg_attrs(hwdev, sgl, nelems, dir, 0);
 }
 EXPORT_SYMBOL(swiotlb_unmap_sg);