drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / include / linux / iommu-dma.h
blob508beaa44c39e82567ae22a30ed806813a951cc4
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved
5 * DMA operations that map physical memory through IOMMU.
6 */
7 #ifndef _LINUX_IOMMU_DMA_H
8 #define _LINUX_IOMMU_DMA_H
10 #include <linux/dma-direction.h>
12 #ifdef CONFIG_IOMMU_DMA
13 static inline bool use_dma_iommu(struct device *dev)
15 return dev->dma_iommu;
17 #else
18 static inline bool use_dma_iommu(struct device *dev)
20 return false;
22 #endif /* CONFIG_IOMMU_DMA */
24 dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
25 unsigned long offset, size_t size, enum dma_data_direction dir,
26 unsigned long attrs);
27 void iommu_dma_unmap_page(struct device *dev, dma_addr_t dma_handle,
28 size_t size, enum dma_data_direction dir, unsigned long attrs);
29 int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
30 enum dma_data_direction dir, unsigned long attrs);
31 void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
32 enum dma_data_direction dir, unsigned long attrs);
33 void *iommu_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
34 gfp_t gfp, unsigned long attrs);
35 int iommu_dma_mmap(struct device *dev, struct vm_area_struct *vma,
36 void *cpu_addr, dma_addr_t dma_addr, size_t size,
37 unsigned long attrs);
38 int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
39 void *cpu_addr, dma_addr_t dma_addr, size_t size,
40 unsigned long attrs);
41 unsigned long iommu_dma_get_merge_boundary(struct device *dev);
42 size_t iommu_dma_opt_mapping_size(void);
43 size_t iommu_dma_max_mapping_size(struct device *dev);
44 void iommu_dma_free(struct device *dev, size_t size, void *cpu_addr,
45 dma_addr_t handle, unsigned long attrs);
46 dma_addr_t iommu_dma_map_resource(struct device *dev, phys_addr_t phys,
47 size_t size, enum dma_data_direction dir, unsigned long attrs);
48 void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle,
49 size_t size, enum dma_data_direction dir, unsigned long attrs);
50 struct sg_table *iommu_dma_alloc_noncontiguous(struct device *dev, size_t size,
51 enum dma_data_direction dir, gfp_t gfp, unsigned long attrs);
52 void iommu_dma_free_noncontiguous(struct device *dev, size_t size,
53 struct sg_table *sgt, enum dma_data_direction dir);
54 void *iommu_dma_vmap_noncontiguous(struct device *dev, size_t size,
55 struct sg_table *sgt);
56 #define iommu_dma_vunmap_noncontiguous(dev, vaddr) \
57 vunmap(vaddr);
58 int iommu_dma_mmap_noncontiguous(struct device *dev, struct vm_area_struct *vma,
59 size_t size, struct sg_table *sgt);
60 void iommu_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
61 size_t size, enum dma_data_direction dir);
62 void iommu_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
63 size_t size, enum dma_data_direction dir);
64 void iommu_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sgl,
65 int nelems, enum dma_data_direction dir);
66 void iommu_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sgl,
67 int nelems, enum dma_data_direction dir);
69 #endif /* _LINUX_IOMMU_DMA_H */