Merge branch 'akpm' (patches from Andrew)
[cascardo/linux.git] / include / linux / dma-mapping.h
index dc69df0..08528af 100644 (file)
  * that gives better TLB efficiency.
  */
 #define DMA_ATTR_ALLOC_SINGLE_PAGES    (1UL << 7)
+/*
+ * DMA_ATTR_NO_WARN: This tells the DMA-mapping subsystem to suppress
+ * allocation failure reports (similarly to __GFP_NOWARN).
+ */
+#define DMA_ATTR_NO_WARN       (1UL << 8)
 
 /*
  * A dma_addr_t can hold any valid DMA or bus address for the platform.
@@ -95,6 +100,12 @@ struct dma_map_ops {
                         struct scatterlist *sg, int nents,
                         enum dma_data_direction dir,
                         unsigned long attrs);
+       dma_addr_t (*map_resource)(struct device *dev, phys_addr_t phys_addr,
+                              size_t size, enum dma_data_direction dir,
+                              unsigned long attrs);
+       void (*unmap_resource)(struct device *dev, dma_addr_t dma_handle,
+                          size_t size, enum dma_data_direction dir,
+                          unsigned long attrs);
        void (*sync_single_for_cpu)(struct device *dev,
                                    dma_addr_t dma_handle, size_t size,
                                    enum dma_data_direction dir);
@@ -258,6 +269,41 @@ static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
        debug_dma_unmap_page(dev, addr, size, dir, false);
 }
 
+static inline dma_addr_t dma_map_resource(struct device *dev,
+                                         phys_addr_t phys_addr,
+                                         size_t size,
+                                         enum dma_data_direction dir,
+                                         unsigned long attrs)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+       dma_addr_t addr;
+
+       BUG_ON(!valid_dma_direction(dir));
+
+       /* Don't allow RAM to be mapped */
+       BUG_ON(pfn_valid(PHYS_PFN(phys_addr)));
+
+       addr = phys_addr;
+       if (ops->map_resource)
+               addr = ops->map_resource(dev, phys_addr, size, dir, attrs);
+
+       debug_dma_map_resource(dev, phys_addr, size, dir, addr);
+
+       return addr;
+}
+
+static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr,
+                                     size_t size, enum dma_data_direction dir,
+                                     unsigned long attrs)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+
+       BUG_ON(!valid_dma_direction(dir));
+       if (ops->unmap_resource)
+               ops->unmap_resource(dev, addr, size, dir, attrs);
+       debug_dma_unmap_resource(dev, addr, size, dir);
+}
+
 static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
                                           size_t size,
                                           enum dma_data_direction dir)