wish to take advantage of it, you should issue a dma_set_mask()
 call to set the mask to the value returned.
 
+::
+
+       size_t
+       dma_direct_max_mapping_size(struct device *dev);
+
+Returns the maximum size of a mapping for the device. The size parameter
+of the mapping functions like dma_map_single(), dma_map_page() and
+others should not be larger than the returned value.
 
 Part Id - Streaming DMA mappings
 --------------------------------
 
                        enum dma_data_direction direction);
        int (*dma_supported)(struct device *dev, u64 mask);
        u64 (*get_required_mask)(struct device *dev);
+       size_t (*max_mapping_size)(struct device *dev);
 };
 
 #define DMA_MAPPING_ERROR              (~(dma_addr_t)0)
 }
 #endif
 
+size_t dma_direct_max_mapping_size(struct device *dev);
+
 #ifdef CONFIG_HAS_DMA
 #include <asm/dma-mapping.h>
 
 int dma_set_mask(struct device *dev, u64 mask);
 int dma_set_coherent_mask(struct device *dev, u64 mask);
 u64 dma_get_required_mask(struct device *dev);
+size_t dma_max_mapping_size(struct device *dev);
 #else /* CONFIG_HAS_DMA */
 static inline dma_addr_t dma_map_page_attrs(struct device *dev,
                struct page *page, size_t offset, size_t size,
 {
        return 0;
 }
+static inline size_t dma_max_mapping_size(struct device *dev)
+{
+       return 0;
+}
 #endif /* CONFIG_HAS_DMA */
 
 static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
 
         */
        return mask >= __phys_to_dma(dev, min_mask);
 }
+
+size_t dma_direct_max_mapping_size(struct device *dev)
+{
+       size_t size = SIZE_MAX;
+
+       /* If SWIOTLB is active, use its maximum mapping size */
+       if (is_swiotlb_active())
+               size = swiotlb_max_mapping_size(dev);
+
+       return size;
+}
 
                ops->cache_sync(dev, vaddr, size, dir);
 }
 EXPORT_SYMBOL(dma_cache_sync);
+
+size_t dma_max_mapping_size(struct device *dev)
+{
+       const struct dma_map_ops *ops = get_dma_ops(dev);
+       size_t size = SIZE_MAX;
+
+       if (dma_is_direct(ops))
+               size = dma_direct_max_mapping_size(dev);
+       else if (ops && ops->max_mapping_size)
+               size = ops->max_mapping_size(dev);
+
+       return size;
+}
+EXPORT_SYMBOL_GPL(dma_max_mapping_size);