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 queue TLB invalidation has taken effect.
21 * @flush_pgtable: Ensure page table updates are visible to the IOMMU.
23 * Note that these can all be called in atomic context and must therefore
26 struct iommu_gather_ops
{
27 void (*tlb_flush_all
)(void *cookie
);
28 void (*tlb_add_flush
)(unsigned long iova
, size_t size
, bool leaf
,
30 void (*tlb_sync
)(void *cookie
);
31 void (*flush_pgtable
)(void *ptr
, size_t size
, 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.
45 struct io_pgtable_cfg
{
46 #define IO_PGTABLE_QUIRK_ARM_NS (1 << 0) /* Set NS bit in PTEs */
48 unsigned long pgsize_bitmap
;
51 const struct iommu_gather_ops
*tlb
;
53 /* Low-level data specific to the table format */
69 * struct io_pgtable_ops - Page table manipulation API for IOMMU drivers.
71 * @map: Map a physically contiguous memory region.
72 * @unmap: Unmap a physically contiguous memory region.
73 * @iova_to_phys: Translate iova to physical address.
75 * These functions map directly onto the iommu_ops member functions with
78 struct io_pgtable_ops
{
79 int (*map
)(struct io_pgtable_ops
*ops
, unsigned long iova
,
80 phys_addr_t paddr
, size_t size
, int prot
);
81 int (*unmap
)(struct io_pgtable_ops
*ops
, unsigned long iova
,
83 phys_addr_t (*iova_to_phys
)(struct io_pgtable_ops
*ops
,
88 * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
90 * @fmt: The page table format.
91 * @cfg: The page table configuration. This will be modified to represent
92 * the configuration actually provided by the allocator (e.g. the
93 * pgsize_bitmap may be restricted).
94 * @cookie: An opaque token provided by the IOMMU driver and passed back to
95 * the callback routines in cfg->tlb.
97 struct io_pgtable_ops
*alloc_io_pgtable_ops(enum io_pgtable_fmt fmt
,
98 struct io_pgtable_cfg
*cfg
,
102 * free_io_pgtable_ops() - Free an io_pgtable_ops structure. The caller
103 * *must* ensure that the page table is no longer
104 * live, but the TLB can be dirty.
106 * @ops: The ops returned from alloc_io_pgtable_ops.
108 void free_io_pgtable_ops(struct io_pgtable_ops
*ops
);
112 * Internal structures for page table allocator implementations.
116 * struct io_pgtable - Internal structure describing a set of page tables.
118 * @fmt: The page table format.
119 * @cookie: An opaque token provided by the IOMMU driver and passed back to
120 * any callback routines.
121 * @cfg: A copy of the page table configuration.
122 * @ops: The page table operations in use for this set of page tables.
125 enum io_pgtable_fmt fmt
;
127 struct io_pgtable_cfg cfg
;
128 struct io_pgtable_ops ops
;
132 * struct io_pgtable_init_fns - Alloc/free a set of page tables for a
135 * @alloc: Allocate a set of page tables described by cfg.
136 * @free: Free the page tables associated with iop.
138 struct io_pgtable_init_fns
{
139 struct io_pgtable
*(*alloc
)(struct io_pgtable_cfg
*cfg
, void *cookie
);
140 void (*free
)(struct io_pgtable
*iop
);
143 #endif /* __IO_PGTABLE_H */