#include <linux/memblock.h>
#include <linux/acpi.h>
#include <linux/dma-map-ops.h>
#include <linux/export.h>
#include <linux/gfp.h>
#include <linux/kmsan.h>
#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include "debug.h"
#include "direct.h"
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
bool dma_default_coherent = IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
#endif
struct dma_devres { … };
static void dmam_release(struct device *dev, void *res)
{ … }
static int dmam_match(struct device *dev, void *res, void *match_data)
{ … }
void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle)
{ … }
EXPORT_SYMBOL(…);
void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t gfp, unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
static bool dma_go_direct(struct device *dev, dma_addr_t mask,
const struct dma_map_ops *ops)
{ … }
static inline bool dma_alloc_direct(struct device *dev,
const struct dma_map_ops *ops)
{ … }
static inline bool dma_map_direct(struct device *dev,
const struct dma_map_ops *ops)
{ … }
dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page,
size_t offset, size_t size, enum dma_data_direction dir,
unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
void dma_unmap_page_attrs(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir, unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, unsigned long attrs)
{ … }
unsigned int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
int dma_map_sgtable(struct device *dev, struct sg_table *sgt,
enum dma_data_direction dir, unsigned long attrs)
{ … }
EXPORT_SYMBOL_GPL(…);
void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir,
unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
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)
{ … }
EXPORT_SYMBOL(…);
void dma_unmap_resource(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir, unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
#ifdef CONFIG_DMA_NEED_SYNC
void __dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir)
{ … }
EXPORT_SYMBOL(…);
void __dma_sync_single_for_device(struct device *dev, dma_addr_t addr,
size_t size, enum dma_data_direction dir)
{ … }
EXPORT_SYMBOL(…);
void __dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{ … }
EXPORT_SYMBOL(…);
void __dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
int nelems, enum dma_data_direction dir)
{ … }
EXPORT_SYMBOL(…);
bool __dma_need_sync(struct device *dev, dma_addr_t dma_addr)
{ … }
EXPORT_SYMBOL_GPL(…);
static void dma_setup_need_sync(struct device *dev)
{ … }
#else
static inline void dma_setup_need_sync(struct device *dev) { }
#endif
int dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt,
void *cpu_addr, dma_addr_t dma_addr, size_t size,
unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
#ifdef CONFIG_MMU
pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs)
{ … }
#endif
bool dma_can_mmap(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
void *cpu_addr, dma_addr_t dma_addr, size_t size,
unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
u64 dma_get_required_mask(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
gfp_t flag, unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t dma_handle, unsigned long attrs)
{ … }
EXPORT_SYMBOL(…);
static struct page *__dma_alloc_pages(struct device *dev, size_t size,
dma_addr_t *dma_handle, enum dma_data_direction dir, gfp_t gfp)
{ … }
struct page *dma_alloc_pages(struct device *dev, size_t size,
dma_addr_t *dma_handle, enum dma_data_direction dir, gfp_t gfp)
{ … }
EXPORT_SYMBOL_GPL(…);
static void __dma_free_pages(struct device *dev, size_t size, struct page *page,
dma_addr_t dma_handle, enum dma_data_direction dir)
{ … }
void dma_free_pages(struct device *dev, size_t size, struct page *page,
dma_addr_t dma_handle, enum dma_data_direction dir)
{ … }
EXPORT_SYMBOL_GPL(…);
int dma_mmap_pages(struct device *dev, struct vm_area_struct *vma,
size_t size, struct page *page)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct sg_table *alloc_single_sgt(struct device *dev, size_t size,
enum dma_data_direction dir, gfp_t gfp)
{ … }
struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
enum dma_data_direction dir, gfp_t gfp, unsigned long attrs)
{ … }
EXPORT_SYMBOL_GPL(…);
static void free_single_sgt(struct device *dev, size_t size,
struct sg_table *sgt, enum dma_data_direction dir)
{ … }
void dma_free_noncontiguous(struct device *dev, size_t size,
struct sg_table *sgt, enum dma_data_direction dir)
{ … }
EXPORT_SYMBOL_GPL(…);
void *dma_vmap_noncontiguous(struct device *dev, size_t size,
struct sg_table *sgt)
{ … }
EXPORT_SYMBOL_GPL(…);
void dma_vunmap_noncontiguous(struct device *dev, void *vaddr)
{ … }
EXPORT_SYMBOL_GPL(…);
int dma_mmap_noncontiguous(struct device *dev, struct vm_area_struct *vma,
size_t size, struct sg_table *sgt)
{ … }
EXPORT_SYMBOL_GPL(…);
static int dma_supported(struct device *dev, u64 mask)
{ … }
bool dma_pci_p2pdma_supported(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
int dma_set_mask(struct device *dev, u64 mask)
{ … }
EXPORT_SYMBOL(…);
int dma_set_coherent_mask(struct device *dev, u64 mask)
{ … }
EXPORT_SYMBOL(…);
bool dma_addressing_limited(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
size_t dma_max_mapping_size(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
size_t dma_opt_mapping_size(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
unsigned long dma_get_merge_boundary(struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);