5 * Public API for use by IOMMU drivers
16 * struct iommu_gather_ops - IOMMU callbacks for TLB and page table management.
18 * @tlb_flush_all: Synchronously invalidate the entire TLB context.
19 * @tlb_add_flush: Queue up a TLB invalidation for a virtual address range.
20 * @tlb_sync: Ensure any queued TLB invalidation has taken effect, and
21 * any corresponding page table updates are visible to the
24 * Note that these can all be called in atomic context and must therefore
27 struct iommu_gather_ops
{
28 void (*tlb_flush_all
)(void *cookie
);
29 void (*tlb_add_flush
)(unsigned long iova
, size_t size
, bool leaf
,
31 void (*tlb_sync
)(void *cookie
);
35 * struct io_pgtable_cfg - Configuration data for a set of page tables.
37 * @quirks: A bitmap of hardware quirks that require some special
38 * action by the low-level page table allocator.
39 * @pgsize_bitmap: A bitmap of page sizes supported by this set of page
41 * @ias: Input address (iova) size, in bits.
42 * @oas: Output address (paddr) size, in bits.
43 * @tlb: TLB management callbacks for this set of tables.
44 * @iommu_dev: The device representing the DMA configuration for the
47 struct io_pgtable_cfg
{
48 #define IO_PGTABLE_QUIRK_ARM_NS (1 << 0) /* Set NS bit in PTEs */
50 unsigned long pgsize_bitmap
;
53 const struct iommu_gather_ops
*tlb
;
54 struct device
*iommu_dev
;
56 /* Low-level data specific to the table format */
72 * struct io_pgtable_ops - Page table manipulation API for IOMMU drivers.
74 * @map: Map a physically contiguous memory region.
75 * @unmap: Unmap a physically contiguous memory region.
76 * @iova_to_phys: Translate iova to physical address.
78 * These functions map directly onto the iommu_ops member functions with
81 struct io_pgtable_ops
{
82 int (*map
)(struct io_pgtable_ops
*ops
, unsigned long iova
,
83 phys_addr_t paddr
, size_t size
, int prot
);
84 int (*unmap
)(struct io_pgtable_ops
*ops
, unsigned long iova
,
86 phys_addr_t (*iova_to_phys
)(struct io_pgtable_ops
*ops
,
91 * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
93 * @fmt: The page table format.
94 * @cfg: The page table configuration. This will be modified to represent
95 * the configuration actually provided by the allocator (e.g. the
96 * pgsize_bitmap may be restricted).
97 * @cookie: An opaque token provided by the IOMMU driver and passed back to
98 * the callback routines in cfg->tlb.
100 struct io_pgtable_ops
*alloc_io_pgtable_ops(enum io_pgtable_fmt fmt
,
101 struct io_pgtable_cfg
*cfg
,
105 * free_io_pgtable_ops() - Free an io_pgtable_ops structure. The caller
106 * *must* ensure that the page table is no longer
107 * live, but the TLB can be dirty.
109 * @ops: The ops returned from alloc_io_pgtable_ops.
111 void free_io_pgtable_ops(struct io_pgtable_ops
*ops
);
115 * Internal structures for page table allocator implementations.
119 * struct io_pgtable - Internal structure describing a set of page tables.
121 * @fmt: The page table format.
122 * @cookie: An opaque token provided by the IOMMU driver and passed back to
123 * any callback routines.
124 * @cfg: A copy of the page table configuration.
125 * @ops: The page table operations in use for this set of page tables.
128 enum io_pgtable_fmt fmt
;
130 struct io_pgtable_cfg cfg
;
131 struct io_pgtable_ops ops
;
135 * struct io_pgtable_init_fns - Alloc/free a set of page tables for a
138 * @alloc: Allocate a set of page tables described by cfg.
139 * @free: Free the page tables associated with iop.
141 struct io_pgtable_init_fns
{
142 struct io_pgtable
*(*alloc
)(struct io_pgtable_cfg
*cfg
, void *cookie
);
143 void (*free
)(struct io_pgtable
*iop
);
146 extern struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s1_init_fns
;
147 extern struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s2_init_fns
;
148 extern struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s1_init_fns
;
149 extern struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s2_init_fns
;
151 #endif /* __IO_PGTABLE_H */