dma-direct: remove the mapping_error dma_map_ops method
authorChristoph Hellwig <hch@lst.de>
Wed, 21 Nov 2018 17:52:35 +0000 (18:52 +0100)
committerChristoph Hellwig <hch@lst.de>
Thu, 6 Dec 2018 14:56:36 +0000 (06:56 -0800)
The dma-direct code already returns (~(dma_addr_t)0x0) on mapping
failures, so we can switch over to returning DMA_MAPPING_ERROR and let
the core dma-mapping code handle the rest.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/powerpc/kernel/dma-swiotlb.c
include/linux/dma-direct.h
kernel/dma/direct.c
kernel/dma/swiotlb.c

index 5fc335f4d9cd0f561dfa3a947e2502e7de88e658..3d8df2cf8be9a6ab04f8047d8c024c66d819b5b3 100644 (file)
@@ -59,7 +59,6 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = {
        .sync_single_for_device = swiotlb_sync_single_for_device,
        .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
        .sync_sg_for_device = swiotlb_sync_sg_for_device,
-       .mapping_error = dma_direct_mapping_error,
        .get_required_mask = swiotlb_powerpc_get_required,
 };
 
index 61b78f934f6498dfe2bac7acf04ef8fb40d20094..6e5a47ae7d64b8216d3c30a0404b95c43d7d3eaf 100644 (file)
@@ -5,8 +5,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/mem_encrypt.h>
 
-#define DIRECT_MAPPING_ERROR           (~(dma_addr_t)0)
-
 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
 #include <asm/dma-direct.h>
 #else
@@ -76,5 +74,4 @@ dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
 int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
                enum dma_data_direction dir, unsigned long attrs);
 int dma_direct_supported(struct device *dev, u64 mask);
-int dma_direct_mapping_error(struct device *dev, dma_addr_t dma_addr);
 #endif /* _LINUX_DMA_DIRECT_H */
index c49849bcced6a37265b1af1ec80650bd258bbdf0..308f88a750c8b1540a0b3780ef10d09c5b26d60d 100644 (file)
@@ -289,7 +289,7 @@ dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
        dma_addr_t dma_addr = phys_to_dma(dev, phys);
 
        if (!check_addr(dev, dma_addr, size, __func__))
-               return DIRECT_MAPPING_ERROR;
+               return DMA_MAPPING_ERROR;
 
        if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
                dma_direct_sync_single_for_device(dev, dma_addr, size, dir);
@@ -336,11 +336,6 @@ int dma_direct_supported(struct device *dev, u64 mask)
        return mask >= phys_to_dma(dev, min_mask);
 }
 
-int dma_direct_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
-       return dma_addr == DIRECT_MAPPING_ERROR;
-}
-
 const struct dma_map_ops dma_direct_ops = {
        .alloc                  = dma_direct_alloc,
        .free                   = dma_direct_free,
@@ -359,7 +354,6 @@ const struct dma_map_ops dma_direct_ops = {
 #endif
        .get_required_mask      = dma_direct_get_required_mask,
        .dma_supported          = dma_direct_supported,
-       .mapping_error          = dma_direct_mapping_error,
        .cache_sync             = arch_dma_cache_sync,
 };
 EXPORT_SYMBOL(dma_direct_ops);
index 045930e32c0e93d91fab9b28a4329f5b2dc1c356..ff1ce81bb62344ba600613a7394dfab782b0a7c8 100644 (file)
@@ -631,21 +631,21 @@ static dma_addr_t swiotlb_bounce_page(struct device *dev, phys_addr_t *phys,
        if (unlikely(swiotlb_force == SWIOTLB_NO_FORCE)) {
                dev_warn_ratelimited(dev,
                        "Cannot do DMA to address %pa\n", phys);
-               return DIRECT_MAPPING_ERROR;
+               return DMA_MAPPING_ERROR;
        }
 
        /* Oh well, have to allocate and map a bounce buffer. */
        *phys = swiotlb_tbl_map_single(dev, __phys_to_dma(dev, io_tlb_start),
                        *phys, size, dir, attrs);
        if (*phys == SWIOTLB_MAP_ERROR)
-               return DIRECT_MAPPING_ERROR;
+               return DMA_MAPPING_ERROR;
 
        /* Ensure that the address returned is DMA'ble */
        dma_addr = __phys_to_dma(dev, *phys);
        if (unlikely(!dma_capable(dev, dma_addr, size))) {
                swiotlb_tbl_unmap_single(dev, *phys, size, dir,
                        attrs | DMA_ATTR_SKIP_CPU_SYNC);
-               return DIRECT_MAPPING_ERROR;
+               return DMA_MAPPING_ERROR;
        }
 
        return dma_addr;
@@ -680,7 +680,7 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
 
        if (!dev_is_dma_coherent(dev) &&
            (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0 &&
-           dev_addr != DIRECT_MAPPING_ERROR)
+           dev_addr != DMA_MAPPING_ERROR)
                arch_sync_dma_for_device(dev, phys, size, dir);
 
        return dev_addr;
@@ -789,7 +789,7 @@ swiotlb_map_sg_attrs(struct device *dev, struct scatterlist *sgl, int nelems,
        for_each_sg(sgl, sg, nelems, i) {
                sg->dma_address = swiotlb_map_page(dev, sg_page(sg), sg->offset,
                                sg->length, dir, attrs);
-               if (sg->dma_address == DIRECT_MAPPING_ERROR)
+               if (sg->dma_address == DMA_MAPPING_ERROR)
                        goto out_error;
                sg_dma_len(sg) = sg->length;
        }
@@ -869,7 +869,6 @@ swiotlb_dma_supported(struct device *hwdev, u64 mask)
 }
 
 const struct dma_map_ops swiotlb_dma_ops = {
-       .mapping_error          = dma_direct_mapping_error,
        .alloc                  = dma_direct_alloc,
        .free                   = dma_direct_free,
        .sync_single_for_cpu    = swiotlb_sync_single_for_cpu,