Merge tag 'dma-mapping-4.20-3' of git://git.infradead.org/users/hch/dma-mapping
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 25 Nov 2018 17:24:40 +0000 (09:24 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 25 Nov 2018 17:24:40 +0000 (09:24 -0800)
Pull dma-mapping fixes from Christoph Hellwig:
 "Two dma-direct / swiotlb regressions fixes:

   - zero is a valid physical address on some arm boards, we can't use
     it as the error value

   - don't try to cache flush the error return value (no matter what it
     is)"

* tag 'dma-mapping-4.20-3' of git://git.infradead.org/users/hch/dma-mapping:
  swiotlb: Skip cache maintenance on map error
  dma-direct: Make DIRECT_MAPPING_ERROR viable for SWIOTLB

include/linux/dma-direct.h
kernel/dma/swiotlb.c

index bd73e7a9141076389ad638cc8fe4f48515331711..9e66bfe369aa057ac9d285d1f3cede42e54387cf 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mem_encrypt.h>
 
-#define DIRECT_MAPPING_ERROR           0
+#define DIRECT_MAPPING_ERROR           (~(dma_addr_t)0)
 
 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
 #include <asm/dma-direct.h>
index 5731daa09a32edc2175657384aee68b60a365a2a..045930e32c0e93d91fab9b28a4329f5b2dc1c356 100644 (file)
@@ -679,7 +679,8 @@ 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)
+           (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0 &&
+           dev_addr != DIRECT_MAPPING_ERROR)
                arch_sync_dma_for_device(dev, phys, size, dir);
 
        return dev_addr;