Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / include / linux / dma-direct.h
blobbcdb1a3e4b1f78dc2afb94bde11629fddedd08c3
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_DMA_DIRECT_H
3 #define _LINUX_DMA_DIRECT_H 1
5 #include <linux/dma-mapping.h>
7 #ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
8 #include <asm/dma-direct.h>
9 #else
10 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
12 dma_addr_t dev_addr = (dma_addr_t)paddr;
14 return dev_addr - ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
17 static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
19 phys_addr_t paddr = (phys_addr_t)dev_addr;
21 return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
24 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
26 if (!dev->dma_mask)
27 return false;
29 return addr + size - 1 <= *dev->dma_mask;
31 #endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
33 #ifdef CONFIG_ARCH_HAS_DMA_MARK_CLEAN
34 void dma_mark_clean(void *addr, size_t size);
35 #else
36 static inline void dma_mark_clean(void *addr, size_t size)
39 #endif /* CONFIG_ARCH_HAS_DMA_MARK_CLEAN */
41 void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
42 gfp_t gfp, unsigned long attrs);
43 void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,
44 dma_addr_t dma_addr, unsigned long attrs);
45 int dma_direct_supported(struct device *dev, u64 mask);
47 #endif /* _LINUX_DMA_DIRECT_H */