1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
4 * Author: Joerg Roedel <joerg.roedel@amd.com>
7 #ifndef __LINUX_IOMMU_H
8 #define __LINUX_IOMMU_H
10 #include <linux/scatterlist.h>
11 #include <linux/device.h>
12 #include <linux/types.h>
13 #include <linux/errno.h>
14 #include <linux/err.h>
17 #define IOMMU_READ (1 << 0)
18 #define IOMMU_WRITE (1 << 1)
19 #define IOMMU_CACHE (1 << 2) /* DMA cache coherency */
20 #define IOMMU_NOEXEC (1 << 3)
21 #define IOMMU_MMIO (1 << 4) /* e.g. things like MSI doorbells */
23 * Where the bus hardware includes a privilege level as part of its access type
24 * markings, and certain devices are capable of issuing transactions marked as
25 * either 'supervisor' or 'user', the IOMMU_PRIV flag requests that the other
26 * given permission flags only apply to accesses at the higher privilege level,
27 * and that unprivileged transactions should have as little access as possible.
28 * This would usually imply the same permissions as kernel mappings on the CPU,
29 * if the IOMMU page table format is equivalent.
31 #define IOMMU_PRIV (1 << 5)
38 struct notifier_block;
41 /* iommu fault flags */
42 #define IOMMU_FAULT_READ 0x0
43 #define IOMMU_FAULT_WRITE 0x1
45 typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
46 struct device *, unsigned long, int, void *);
47 typedef int (*iommu_mm_exit_handler_t)(struct device *dev, struct iommu_sva *,
50 struct iommu_domain_geometry {
51 dma_addr_t aperture_start; /* First address that can be mapped */
52 dma_addr_t aperture_end; /* Last address that can be mapped */
53 bool force_aperture; /* DMA only allowed in mappable range? */
56 /* Domain feature flags */
57 #define __IOMMU_DOMAIN_PAGING (1U << 0) /* Support for iommu_map/unmap */
58 #define __IOMMU_DOMAIN_DMA_API (1U << 1) /* Domain for use in DMA-API
60 #define __IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped */
63 * This are the possible domain-types
65 * IOMMU_DOMAIN_BLOCKED - All DMA is blocked, can be used to isolate
67 * IOMMU_DOMAIN_IDENTITY - DMA addresses are system physical addresses
68 * IOMMU_DOMAIN_UNMANAGED - DMA mappings managed by IOMMU-API user, used
70 * IOMMU_DOMAIN_DMA - Internally used for DMA-API implementations.
71 * This flag allows IOMMU drivers to implement
72 * certain optimizations for these domains
74 #define IOMMU_DOMAIN_BLOCKED (0U)
75 #define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT)
76 #define IOMMU_DOMAIN_UNMANAGED (__IOMMU_DOMAIN_PAGING)
77 #define IOMMU_DOMAIN_DMA (__IOMMU_DOMAIN_PAGING | \
78 __IOMMU_DOMAIN_DMA_API)
82 const struct iommu_ops *ops;
83 unsigned long pgsize_bitmap; /* Bitmap of page sizes in use */
84 iommu_fault_handler_t handler;
86 struct iommu_domain_geometry geometry;
91 IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
93 IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
94 IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */
98 * Following constraints are specifc to FSL_PAMUV1:
99 * -aperture must be power of 2, and naturally aligned
100 * -number of windows must be power of 2, and address space size
101 * of each window is determined by aperture size / # of windows
102 * -the actual size of the mapped region of a window must be power
103 * of 2 starting with 4KB and physical address must be naturally
105 * DOMAIN_ATTR_FSL_PAMUV1 corresponds to the above mentioned contraints.
106 * The caller can invoke iommu_domain_get_attr to check if the underlying
107 * iommu implementation supports these constraints.
111 DOMAIN_ATTR_GEOMETRY,
114 DOMAIN_ATTR_FSL_PAMU_STASH,
115 DOMAIN_ATTR_FSL_PAMU_ENABLE,
116 DOMAIN_ATTR_FSL_PAMUV1,
117 DOMAIN_ATTR_NESTING, /* two stages of translation */
118 DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,
122 /* These are the possible reserved region types */
123 enum iommu_resv_type {
124 /* Memory regions which must be mapped 1:1 at all times */
126 /* Arbitrary "never map this or give it to a device" address ranges */
128 /* Hardware MSI region (untranslated) */
130 /* Software-managed MSI translation window */
135 * struct iommu_resv_region - descriptor for a reserved memory region
136 * @list: Linked list pointers
137 * @start: System physical start address of the region
138 * @length: Length of the region in bytes
139 * @prot: IOMMU Protection flags (READ/WRITE/...)
140 * @type: Type of the reserved region
142 struct iommu_resv_region {
143 struct list_head list;
147 enum iommu_resv_type type;
150 /* Per device IOMMU features */
151 enum iommu_dev_features {
152 IOMMU_DEV_FEAT_AUX, /* Aux-domain feature */
153 IOMMU_DEV_FEAT_SVA, /* Shared Virtual Addresses */
156 #define IOMMU_PASID_INVALID (-1U)
159 * struct iommu_sva_ops - device driver callbacks for an SVA context
161 * @mm_exit: called when the mm is about to be torn down by exit_mmap. After
162 * @mm_exit returns, the device must not issue any more transaction
163 * with the PASID given as argument.
165 * The @mm_exit handler is allowed to sleep. Be careful about the
166 * locks taken in @mm_exit, because they might lead to deadlocks if
167 * they are also held when dropping references to the mm. Consider the
168 * following call chain:
169 * mutex_lock(A); mmput(mm) -> exit_mm() -> @mm_exit() -> mutex_lock(A)
170 * Using mmput_async() prevents this scenario.
173 struct iommu_sva_ops {
174 iommu_mm_exit_handler_t mm_exit;
177 #ifdef CONFIG_IOMMU_API
180 * struct iommu_ops - iommu ops and capabilities
181 * @capable: check capability
182 * @domain_alloc: allocate iommu domain
183 * @domain_free: free iommu domain
184 * @attach_dev: attach device to an iommu domain
185 * @detach_dev: detach device from an iommu domain
186 * @map: map a physically contiguous memory region to an iommu domain
187 * @unmap: unmap a physically contiguous memory region from an iommu domain
188 * @flush_iotlb_all: Synchronously flush all hardware TLBs for this domain
189 * @iotlb_range_add: Add a given iova range to the flush queue for this domain
190 * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
191 * @iotlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
193 * @iova_to_phys: translate iova to physical address
194 * @add_device: add device to iommu grouping
195 * @remove_device: remove device from iommu grouping
196 * @device_group: find iommu group for a particular device
197 * @domain_get_attr: Query domain attributes
198 * @domain_set_attr: Change domain attributes
199 * @get_resv_regions: Request list of reserved regions for a device
200 * @put_resv_regions: Free list of reserved regions for a device
201 * @apply_resv_region: Temporary helper call-back for iova reserved ranges
202 * @domain_window_enable: Configure and enable a particular window for a domain
203 * @domain_window_disable: Disable a particular window for a domain
204 * @of_xlate: add OF master IDs to iommu grouping
205 * @is_attach_deferred: Check if domain attach should be deferred from iommu
206 * driver init to device driver init (default no)
207 * @dev_has/enable/disable_feat: per device entries to check/enable/disable
208 * iommu specific features.
209 * @dev_feat_enabled: check enabled feature
210 * @aux_attach/detach_dev: aux-domain specific attach/detach entries.
211 * @aux_get_pasid: get the pasid given an aux-domain
212 * @sva_bind: Bind process address space to device
213 * @sva_unbind: Unbind process address space from device
214 * @sva_get_pasid: Get PASID associated to a SVA handle
215 * @pgsize_bitmap: bitmap of all possible supported page sizes
218 bool (*capable)(enum iommu_cap);
220 /* Domain allocation and freeing by the iommu driver */
221 struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
222 void (*domain_free)(struct iommu_domain *);
224 int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
225 void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
226 int (*map)(struct iommu_domain *domain, unsigned long iova,
227 phys_addr_t paddr, size_t size, int prot);
228 size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
230 void (*flush_iotlb_all)(struct iommu_domain *domain);
231 void (*iotlb_range_add)(struct iommu_domain *domain,
232 unsigned long iova, size_t size);
233 void (*iotlb_sync_map)(struct iommu_domain *domain);
234 void (*iotlb_sync)(struct iommu_domain *domain);
235 phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
236 int (*add_device)(struct device *dev);
237 void (*remove_device)(struct device *dev);
238 struct iommu_group *(*device_group)(struct device *dev);
239 int (*domain_get_attr)(struct iommu_domain *domain,
240 enum iommu_attr attr, void *data);
241 int (*domain_set_attr)(struct iommu_domain *domain,
242 enum iommu_attr attr, void *data);
244 /* Request/Free a list of reserved regions for a device */
245 void (*get_resv_regions)(struct device *dev, struct list_head *list);
246 void (*put_resv_regions)(struct device *dev, struct list_head *list);
247 void (*apply_resv_region)(struct device *dev,
248 struct iommu_domain *domain,
249 struct iommu_resv_region *region);
251 /* Window handling functions */
252 int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
253 phys_addr_t paddr, u64 size, int prot);
254 void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);
256 int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
257 bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);
259 /* Per device IOMMU features */
260 bool (*dev_has_feat)(struct device *dev, enum iommu_dev_features f);
261 bool (*dev_feat_enabled)(struct device *dev, enum iommu_dev_features f);
262 int (*dev_enable_feat)(struct device *dev, enum iommu_dev_features f);
263 int (*dev_disable_feat)(struct device *dev, enum iommu_dev_features f);
265 /* Aux-domain specific attach/detach entries */
266 int (*aux_attach_dev)(struct iommu_domain *domain, struct device *dev);
267 void (*aux_detach_dev)(struct iommu_domain *domain, struct device *dev);
268 int (*aux_get_pasid)(struct iommu_domain *domain, struct device *dev);
270 struct iommu_sva *(*sva_bind)(struct device *dev, struct mm_struct *mm,
272 void (*sva_unbind)(struct iommu_sva *handle);
273 int (*sva_get_pasid)(struct iommu_sva *handle);
275 unsigned long pgsize_bitmap;
279 * struct iommu_device - IOMMU core representation of one IOMMU hardware
281 * @list: Used by the iommu-core to keep a list of registered iommus
282 * @ops: iommu-ops for talking to this iommu
283 * @dev: struct device for sysfs handling
285 struct iommu_device {
286 struct list_head list;
287 const struct iommu_ops *ops;
288 struct fwnode_handle *fwnode;
292 int iommu_device_register(struct iommu_device *iommu);
293 void iommu_device_unregister(struct iommu_device *iommu);
294 int iommu_device_sysfs_add(struct iommu_device *iommu,
295 struct device *parent,
296 const struct attribute_group **groups,
297 const char *fmt, ...) __printf(4, 5);
298 void iommu_device_sysfs_remove(struct iommu_device *iommu);
299 int iommu_device_link(struct iommu_device *iommu, struct device *link);
300 void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
302 static inline void iommu_device_set_ops(struct iommu_device *iommu,
303 const struct iommu_ops *ops)
308 static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
309 struct fwnode_handle *fwnode)
311 iommu->fwnode = fwnode;
314 static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
316 return (struct iommu_device *)dev_get_drvdata(dev);
319 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
320 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
321 #define IOMMU_GROUP_NOTIFY_BIND_DRIVER 3 /* Pre Driver bind */
322 #define IOMMU_GROUP_NOTIFY_BOUND_DRIVER 4 /* Post Driver bind */
323 #define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER 5 /* Pre Driver unbind */
324 #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */
326 extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
327 extern bool iommu_present(struct bus_type *bus);
328 extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
329 extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
330 extern struct iommu_group *iommu_group_get_by_id(int id);
331 extern void iommu_domain_free(struct iommu_domain *domain);
332 extern int iommu_attach_device(struct iommu_domain *domain,
334 extern void iommu_detach_device(struct iommu_domain *domain,
336 extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
337 extern struct iommu_domain *iommu_get_dma_domain(struct device *dev);
338 extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
339 phys_addr_t paddr, size_t size, int prot);
340 extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
342 extern size_t iommu_unmap_fast(struct iommu_domain *domain,
343 unsigned long iova, size_t size);
344 extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
345 struct scatterlist *sg,unsigned int nents, int prot);
346 extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
347 extern void iommu_set_fault_handler(struct iommu_domain *domain,
348 iommu_fault_handler_t handler, void *token);
350 extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
351 extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
352 extern int iommu_request_dm_for_dev(struct device *dev);
353 extern struct iommu_resv_region *
354 iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,
355 enum iommu_resv_type type);
356 extern int iommu_get_group_resv_regions(struct iommu_group *group,
357 struct list_head *head);
359 extern int iommu_attach_group(struct iommu_domain *domain,
360 struct iommu_group *group);
361 extern void iommu_detach_group(struct iommu_domain *domain,
362 struct iommu_group *group);
363 extern struct iommu_group *iommu_group_alloc(void);
364 extern void *iommu_group_get_iommudata(struct iommu_group *group);
365 extern void iommu_group_set_iommudata(struct iommu_group *group,
367 void (*release)(void *iommu_data));
368 extern int iommu_group_set_name(struct iommu_group *group, const char *name);
369 extern int iommu_group_add_device(struct iommu_group *group,
371 extern void iommu_group_remove_device(struct device *dev);
372 extern int iommu_group_for_each_dev(struct iommu_group *group, void *data,
373 int (*fn)(struct device *, void *));
374 extern struct iommu_group *iommu_group_get(struct device *dev);
375 extern struct iommu_group *iommu_group_ref_get(struct iommu_group *group);
376 extern void iommu_group_put(struct iommu_group *group);
377 extern int iommu_group_register_notifier(struct iommu_group *group,
378 struct notifier_block *nb);
379 extern int iommu_group_unregister_notifier(struct iommu_group *group,
380 struct notifier_block *nb);
381 extern int iommu_group_id(struct iommu_group *group);
382 extern struct iommu_group *iommu_group_get_for_dev(struct device *dev);
383 extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
385 extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr,
387 extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
390 /* Window handling function prototypes */
391 extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
392 phys_addr_t offset, u64 size,
394 extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr);
396 extern int report_iommu_fault(struct iommu_domain *domain, struct device *dev,
397 unsigned long iova, int flags);
399 static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
401 if (domain->ops->flush_iotlb_all)
402 domain->ops->flush_iotlb_all(domain);
405 static inline void iommu_tlb_range_add(struct iommu_domain *domain,
406 unsigned long iova, size_t size)
408 if (domain->ops->iotlb_range_add)
409 domain->ops->iotlb_range_add(domain, iova, size);
412 static inline void iommu_tlb_sync(struct iommu_domain *domain)
414 if (domain->ops->iotlb_sync)
415 domain->ops->iotlb_sync(domain);
418 /* PCI device grouping function */
419 extern struct iommu_group *pci_device_group(struct device *dev);
420 /* Generic device grouping function */
421 extern struct iommu_group *generic_device_group(struct device *dev);
422 /* FSL-MC device grouping function */
423 struct iommu_group *fsl_mc_device_group(struct device *dev);
426 * struct iommu_fwspec - per-device IOMMU instance data
427 * @ops: ops for this device's IOMMU
428 * @iommu_fwnode: firmware handle for this device's IOMMU
429 * @iommu_priv: IOMMU driver private data for this device
430 * @num_ids: number of associated device IDs
431 * @ids: IDs which this device may present to the IOMMU
433 struct iommu_fwspec {
434 const struct iommu_ops *ops;
435 struct fwnode_handle *iommu_fwnode;
438 unsigned int num_ids;
442 /* ATS is supported */
443 #define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0)
446 * struct iommu_sva - handle to a device-mm bond
450 const struct iommu_sva_ops *ops;
453 int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
454 const struct iommu_ops *ops);
455 void iommu_fwspec_free(struct device *dev);
456 int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids);
457 const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
459 static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
461 return dev->iommu_fwspec;
464 static inline void dev_iommu_fwspec_set(struct device *dev,
465 struct iommu_fwspec *fwspec)
467 dev->iommu_fwspec = fwspec;
470 int iommu_probe_device(struct device *dev);
471 void iommu_release_device(struct device *dev);
473 bool iommu_dev_has_feature(struct device *dev, enum iommu_dev_features f);
474 int iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features f);
475 int iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features f);
476 bool iommu_dev_feature_enabled(struct device *dev, enum iommu_dev_features f);
477 int iommu_aux_attach_device(struct iommu_domain *domain, struct device *dev);
478 void iommu_aux_detach_device(struct iommu_domain *domain, struct device *dev);
479 int iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev);
481 struct iommu_sva *iommu_sva_bind_device(struct device *dev,
482 struct mm_struct *mm,
484 void iommu_sva_unbind_device(struct iommu_sva *handle);
485 int iommu_sva_set_ops(struct iommu_sva *handle,
486 const struct iommu_sva_ops *ops);
487 int iommu_sva_get_pasid(struct iommu_sva *handle);
489 #else /* CONFIG_IOMMU_API */
492 struct iommu_group {};
493 struct iommu_fwspec {};
494 struct iommu_device {};
496 static inline bool iommu_present(struct bus_type *bus)
501 static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
506 static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
511 static inline struct iommu_group *iommu_group_get_by_id(int id)
516 static inline void iommu_domain_free(struct iommu_domain *domain)
520 static inline int iommu_attach_device(struct iommu_domain *domain,
526 static inline void iommu_detach_device(struct iommu_domain *domain,
531 static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
536 static inline int iommu_map(struct iommu_domain *domain, unsigned long iova,
537 phys_addr_t paddr, size_t size, int prot)
542 static inline size_t iommu_unmap(struct iommu_domain *domain,
543 unsigned long iova, size_t size)
548 static inline size_t iommu_unmap_fast(struct iommu_domain *domain,
549 unsigned long iova, int gfp_order)
554 static inline size_t iommu_map_sg(struct iommu_domain *domain,
555 unsigned long iova, struct scatterlist *sg,
556 unsigned int nents, int prot)
561 static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
565 static inline void iommu_tlb_range_add(struct iommu_domain *domain,
566 unsigned long iova, size_t size)
570 static inline void iommu_tlb_sync(struct iommu_domain *domain)
574 static inline int iommu_domain_window_enable(struct iommu_domain *domain,
575 u32 wnd_nr, phys_addr_t paddr,
581 static inline void iommu_domain_window_disable(struct iommu_domain *domain,
586 static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
591 static inline void iommu_set_fault_handler(struct iommu_domain *domain,
592 iommu_fault_handler_t handler, void *token)
596 static inline void iommu_get_resv_regions(struct device *dev,
597 struct list_head *list)
601 static inline void iommu_put_resv_regions(struct device *dev,
602 struct list_head *list)
606 static inline int iommu_get_group_resv_regions(struct iommu_group *group,
607 struct list_head *head)
612 static inline int iommu_request_dm_for_dev(struct device *dev)
617 static inline int iommu_attach_group(struct iommu_domain *domain,
618 struct iommu_group *group)
623 static inline void iommu_detach_group(struct iommu_domain *domain,
624 struct iommu_group *group)
628 static inline struct iommu_group *iommu_group_alloc(void)
630 return ERR_PTR(-ENODEV);
633 static inline void *iommu_group_get_iommudata(struct iommu_group *group)
638 static inline void iommu_group_set_iommudata(struct iommu_group *group,
640 void (*release)(void *iommu_data))
644 static inline int iommu_group_set_name(struct iommu_group *group,
650 static inline int iommu_group_add_device(struct iommu_group *group,
656 static inline void iommu_group_remove_device(struct device *dev)
660 static inline int iommu_group_for_each_dev(struct iommu_group *group,
662 int (*fn)(struct device *, void *))
667 static inline struct iommu_group *iommu_group_get(struct device *dev)
672 static inline void iommu_group_put(struct iommu_group *group)
676 static inline int iommu_group_register_notifier(struct iommu_group *group,
677 struct notifier_block *nb)
682 static inline int iommu_group_unregister_notifier(struct iommu_group *group,
683 struct notifier_block *nb)
688 static inline int iommu_group_id(struct iommu_group *group)
693 static inline int iommu_domain_get_attr(struct iommu_domain *domain,
694 enum iommu_attr attr, void *data)
699 static inline int iommu_domain_set_attr(struct iommu_domain *domain,
700 enum iommu_attr attr, void *data)
705 static inline int iommu_device_register(struct iommu_device *iommu)
710 static inline void iommu_device_set_ops(struct iommu_device *iommu,
711 const struct iommu_ops *ops)
715 static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
716 struct fwnode_handle *fwnode)
720 static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
725 static inline void iommu_device_unregister(struct iommu_device *iommu)
729 static inline int iommu_device_sysfs_add(struct iommu_device *iommu,
730 struct device *parent,
731 const struct attribute_group **groups,
732 const char *fmt, ...)
737 static inline void iommu_device_sysfs_remove(struct iommu_device *iommu)
741 static inline int iommu_device_link(struct device *dev, struct device *link)
746 static inline void iommu_device_unlink(struct device *dev, struct device *link)
750 static inline int iommu_fwspec_init(struct device *dev,
751 struct fwnode_handle *iommu_fwnode,
752 const struct iommu_ops *ops)
757 static inline void iommu_fwspec_free(struct device *dev)
761 static inline int iommu_fwspec_add_ids(struct device *dev, u32 *ids,
768 const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
774 iommu_dev_has_feature(struct device *dev, enum iommu_dev_features feat)
780 iommu_dev_feature_enabled(struct device *dev, enum iommu_dev_features feat)
786 iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features feat)
792 iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features feat)
798 iommu_aux_attach_device(struct iommu_domain *domain, struct device *dev)
804 iommu_aux_detach_device(struct iommu_domain *domain, struct device *dev)
809 iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev)
814 static inline struct iommu_sva *
815 iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata)
820 static inline void iommu_sva_unbind_device(struct iommu_sva *handle)
824 static inline int iommu_sva_set_ops(struct iommu_sva *handle,
825 const struct iommu_sva_ops *ops)
830 static inline int iommu_sva_get_pasid(struct iommu_sva *handle)
832 return IOMMU_PASID_INVALID;
835 #endif /* CONFIG_IOMMU_API */
837 #ifdef CONFIG_IOMMU_DEBUGFS
838 extern struct dentry *iommu_debugfs_dir;
839 void iommu_debugfs_setup(void);
841 static inline void iommu_debugfs_setup(void) {}
844 #endif /* __LINUX_IOMMU_H */