Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
4 * Author: Joerg Roedel <joerg.roedel@amd.com>
5 */
6
7#ifndef __LINUX_IOMMU_H
8#define __LINUX_IOMMU_H
9
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>
15#include <linux/of.h>
16
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 */
22/*
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.
30 */
31#define IOMMU_PRIV (1 << 5)
32
33struct iommu_ops;
34struct iommu_group;
35struct bus_type;
36struct device;
37struct iommu_domain;
38struct notifier_block;
39struct iommu_sva;
40
41/* iommu fault flags */
42#define IOMMU_FAULT_READ 0x0
43#define IOMMU_FAULT_WRITE 0x1
44
45typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
46 struct device *, unsigned long, int, void *);
47typedef int (*iommu_mm_exit_handler_t)(struct device *dev, struct iommu_sva *,
48 void *);
49
50struct 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? */
54};
55
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
59 implementation */
60#define __IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped */
61
62/*
63 * This are the possible domain-types
64 *
65 * IOMMU_DOMAIN_BLOCKED - All DMA is blocked, can be used to isolate
66 * devices
67 * IOMMU_DOMAIN_IDENTITY - DMA addresses are system physical addresses
68 * IOMMU_DOMAIN_UNMANAGED - DMA mappings managed by IOMMU-API user, used
69 * for VMs
70 * IOMMU_DOMAIN_DMA - Internally used for DMA-API implementations.
71 * This flag allows IOMMU drivers to implement
72 * certain optimizations for these domains
73 */
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)
79
80struct iommu_domain {
81 unsigned type;
82 const struct iommu_ops *ops;
83 unsigned long pgsize_bitmap; /* Bitmap of page sizes in use */
84 iommu_fault_handler_t handler;
85 void *handler_token;
86 struct iommu_domain_geometry geometry;
87 void *iova_cookie;
88};
89
90enum iommu_cap {
91 IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
92 transactions */
93 IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
94 IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */
95};
96
97/*
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
104 * aligned.
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.
108 */
109
110enum iommu_attr {
111 DOMAIN_ATTR_GEOMETRY,
112 DOMAIN_ATTR_PAGING,
113 DOMAIN_ATTR_WINDOWS,
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,
119 DOMAIN_ATTR_MAX,
120};
121
122/* These are the possible reserved region types */
123enum iommu_resv_type {
124 /* Memory regions which must be mapped 1:1 at all times */
125 IOMMU_RESV_DIRECT,
126 /* Arbitrary "never map this or give it to a device" address ranges */
127 IOMMU_RESV_RESERVED,
128 /* Hardware MSI region (untranslated) */
129 IOMMU_RESV_MSI,
130 /* Software-managed MSI translation window */
131 IOMMU_RESV_SW_MSI,
132};
133
134/**
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
141 */
142struct iommu_resv_region {
143 struct list_head list;
144 phys_addr_t start;
145 size_t length;
146 int prot;
147 enum iommu_resv_type type;
148};
149
150/* Per device IOMMU features */
151enum iommu_dev_features {
152 IOMMU_DEV_FEAT_AUX, /* Aux-domain feature */
153 IOMMU_DEV_FEAT_SVA, /* Shared Virtual Addresses */
154};
155
156#define IOMMU_PASID_INVALID (-1U)
157
158/**
159 * struct iommu_sva_ops - device driver callbacks for an SVA context
160 *
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.
164 *
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.
171 *
172 */
173struct iommu_sva_ops {
174 iommu_mm_exit_handler_t mm_exit;
175};
176
177#ifdef CONFIG_IOMMU_API
178
179/**
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
192 * queue
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
216 */
217struct iommu_ops {
218 bool (*capable)(enum iommu_cap);
219
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 *);
223
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,
229 size_t size);
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);
243
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);
250
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);
255
256 int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
257 bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);
258
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);
264
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);
269
270 struct iommu_sva *(*sva_bind)(struct device *dev, struct mm_struct *mm,
271 void *drvdata);
272 void (*sva_unbind)(struct iommu_sva *handle);
273 int (*sva_get_pasid)(struct iommu_sva *handle);
274
275 unsigned long pgsize_bitmap;
276};
277
278/**
279 * struct iommu_device - IOMMU core representation of one IOMMU hardware
280 * instance
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
284 */
285struct iommu_device {
286 struct list_head list;
287 const struct iommu_ops *ops;
288 struct fwnode_handle *fwnode;
289 struct device *dev;
290};
291
292int iommu_device_register(struct iommu_device *iommu);
293void iommu_device_unregister(struct iommu_device *iommu);
294int 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);
298void iommu_device_sysfs_remove(struct iommu_device *iommu);
299int iommu_device_link(struct iommu_device *iommu, struct device *link);
300void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
301
302static inline void iommu_device_set_ops(struct iommu_device *iommu,
303 const struct iommu_ops *ops)
304{
305 iommu->ops = ops;
306}
307
308static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
309 struct fwnode_handle *fwnode)
310{
311 iommu->fwnode = fwnode;
312}
313
314static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
315{
316 return (struct iommu_device *)dev_get_drvdata(dev);
317}
318
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 */
325
326extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
327extern bool iommu_present(struct bus_type *bus);
328extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
329extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
330extern struct iommu_group *iommu_group_get_by_id(int id);
331extern void iommu_domain_free(struct iommu_domain *domain);
332extern int iommu_attach_device(struct iommu_domain *domain,
333 struct device *dev);
334extern void iommu_detach_device(struct iommu_domain *domain,
335 struct device *dev);
336extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
337extern struct iommu_domain *iommu_get_dma_domain(struct device *dev);
338extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
339 phys_addr_t paddr, size_t size, int prot);
340extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
341 size_t size);
342extern size_t iommu_unmap_fast(struct iommu_domain *domain,
343 unsigned long iova, size_t size);
344extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
345 struct scatterlist *sg,unsigned int nents, int prot);
346extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
347extern void iommu_set_fault_handler(struct iommu_domain *domain,
348 iommu_fault_handler_t handler, void *token);
349
350extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
351extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
352extern int iommu_request_dm_for_dev(struct device *dev);
353extern struct iommu_resv_region *
354iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,
355 enum iommu_resv_type type);
356extern int iommu_get_group_resv_regions(struct iommu_group *group,
357 struct list_head *head);
358
359extern int iommu_attach_group(struct iommu_domain *domain,
360 struct iommu_group *group);
361extern void iommu_detach_group(struct iommu_domain *domain,
362 struct iommu_group *group);
363extern struct iommu_group *iommu_group_alloc(void);
364extern void *iommu_group_get_iommudata(struct iommu_group *group);
365extern void iommu_group_set_iommudata(struct iommu_group *group,
366 void *iommu_data,
367 void (*release)(void *iommu_data));
368extern int iommu_group_set_name(struct iommu_group *group, const char *name);
369extern int iommu_group_add_device(struct iommu_group *group,
370 struct device *dev);
371extern void iommu_group_remove_device(struct device *dev);
372extern int iommu_group_for_each_dev(struct iommu_group *group, void *data,
373 int (*fn)(struct device *, void *));
374extern struct iommu_group *iommu_group_get(struct device *dev);
375extern struct iommu_group *iommu_group_ref_get(struct iommu_group *group);
376extern void iommu_group_put(struct iommu_group *group);
377extern int iommu_group_register_notifier(struct iommu_group *group,
378 struct notifier_block *nb);
379extern int iommu_group_unregister_notifier(struct iommu_group *group,
380 struct notifier_block *nb);
381extern int iommu_group_id(struct iommu_group *group);
382extern struct iommu_group *iommu_group_get_for_dev(struct device *dev);
383extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
384
385extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr,
386 void *data);
387extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
388 void *data);
389
390/* Window handling function prototypes */
391extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
392 phys_addr_t offset, u64 size,
393 int prot);
394extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr);
395
396extern int report_iommu_fault(struct iommu_domain *domain, struct device *dev,
397 unsigned long iova, int flags);
398
399static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
400{
401 if (domain->ops->flush_iotlb_all)
402 domain->ops->flush_iotlb_all(domain);
403}
404
405static inline void iommu_tlb_range_add(struct iommu_domain *domain,
406 unsigned long iova, size_t size)
407{
408 if (domain->ops->iotlb_range_add)
409 domain->ops->iotlb_range_add(domain, iova, size);
410}
411
412static inline void iommu_tlb_sync(struct iommu_domain *domain)
413{
414 if (domain->ops->iotlb_sync)
415 domain->ops->iotlb_sync(domain);
416}
417
418/* PCI device grouping function */
419extern struct iommu_group *pci_device_group(struct device *dev);
420/* Generic device grouping function */
421extern struct iommu_group *generic_device_group(struct device *dev);
422/* FSL-MC device grouping function */
423struct iommu_group *fsl_mc_device_group(struct device *dev);
424
425/**
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
432 */
433struct iommu_fwspec {
434 const struct iommu_ops *ops;
435 struct fwnode_handle *iommu_fwnode;
436 void *iommu_priv;
437 u32 flags;
438 unsigned int num_ids;
439 u32 ids[1];
440};
441
442/* ATS is supported */
443#define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0)
444
445/**
446 * struct iommu_sva - handle to a device-mm bond
447 */
448struct iommu_sva {
449 struct device *dev;
450 const struct iommu_sva_ops *ops;
451};
452
453int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
454 const struct iommu_ops *ops);
455void iommu_fwspec_free(struct device *dev);
456int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids);
457const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
458
459static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
460{
461 return dev->iommu_fwspec;
462}
463
464static inline void dev_iommu_fwspec_set(struct device *dev,
465 struct iommu_fwspec *fwspec)
466{
467 dev->iommu_fwspec = fwspec;
468}
469
470int iommu_probe_device(struct device *dev);
471void iommu_release_device(struct device *dev);
472
473bool iommu_dev_has_feature(struct device *dev, enum iommu_dev_features f);
474int iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features f);
475int iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features f);
476bool iommu_dev_feature_enabled(struct device *dev, enum iommu_dev_features f);
477int iommu_aux_attach_device(struct iommu_domain *domain, struct device *dev);
478void iommu_aux_detach_device(struct iommu_domain *domain, struct device *dev);
479int iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev);
480
481struct iommu_sva *iommu_sva_bind_device(struct device *dev,
482 struct mm_struct *mm,
483 void *drvdata);
484void iommu_sva_unbind_device(struct iommu_sva *handle);
485int iommu_sva_set_ops(struct iommu_sva *handle,
486 const struct iommu_sva_ops *ops);
487int iommu_sva_get_pasid(struct iommu_sva *handle);
488
489#else /* CONFIG_IOMMU_API */
490
491struct iommu_ops {};
492struct iommu_group {};
493struct iommu_fwspec {};
494struct iommu_device {};
495
496static inline bool iommu_present(struct bus_type *bus)
497{
498 return false;
499}
500
501static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
502{
503 return false;
504}
505
506static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
507{
508 return NULL;
509}
510
511static inline struct iommu_group *iommu_group_get_by_id(int id)
512{
513 return NULL;
514}
515
516static inline void iommu_domain_free(struct iommu_domain *domain)
517{
518}
519
520static inline int iommu_attach_device(struct iommu_domain *domain,
521 struct device *dev)
522{
523 return -ENODEV;
524}
525
526static inline void iommu_detach_device(struct iommu_domain *domain,
527 struct device *dev)
528{
529}
530
531static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
532{
533 return NULL;
534}
535
536static inline int iommu_map(struct iommu_domain *domain, unsigned long iova,
537 phys_addr_t paddr, size_t size, int prot)
538{
539 return -ENODEV;
540}
541
542static inline size_t iommu_unmap(struct iommu_domain *domain,
543 unsigned long iova, size_t size)
544{
545 return 0;
546}
547
548static inline size_t iommu_unmap_fast(struct iommu_domain *domain,
549 unsigned long iova, int gfp_order)
550{
551 return 0;
552}
553
554static inline size_t iommu_map_sg(struct iommu_domain *domain,
555 unsigned long iova, struct scatterlist *sg,
556 unsigned int nents, int prot)
557{
558 return 0;
559}
560
561static inline void iommu_flush_tlb_all(struct iommu_domain *domain)
562{
563}
564
565static inline void iommu_tlb_range_add(struct iommu_domain *domain,
566 unsigned long iova, size_t size)
567{
568}
569
570static inline void iommu_tlb_sync(struct iommu_domain *domain)
571{
572}
573
574static inline int iommu_domain_window_enable(struct iommu_domain *domain,
575 u32 wnd_nr, phys_addr_t paddr,
576 u64 size, int prot)
577{
578 return -ENODEV;
579}
580
581static inline void iommu_domain_window_disable(struct iommu_domain *domain,
582 u32 wnd_nr)
583{
584}
585
586static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
587{
588 return 0;
589}
590
591static inline void iommu_set_fault_handler(struct iommu_domain *domain,
592 iommu_fault_handler_t handler, void *token)
593{
594}
595
596static inline void iommu_get_resv_regions(struct device *dev,
597 struct list_head *list)
598{
599}
600
601static inline void iommu_put_resv_regions(struct device *dev,
602 struct list_head *list)
603{
604}
605
606static inline int iommu_get_group_resv_regions(struct iommu_group *group,
607 struct list_head *head)
608{
609 return -ENODEV;
610}
611
612static inline int iommu_request_dm_for_dev(struct device *dev)
613{
614 return -ENODEV;
615}
616
617static inline int iommu_attach_group(struct iommu_domain *domain,
618 struct iommu_group *group)
619{
620 return -ENODEV;
621}
622
623static inline void iommu_detach_group(struct iommu_domain *domain,
624 struct iommu_group *group)
625{
626}
627
628static inline struct iommu_group *iommu_group_alloc(void)
629{
630 return ERR_PTR(-ENODEV);
631}
632
633static inline void *iommu_group_get_iommudata(struct iommu_group *group)
634{
635 return NULL;
636}
637
638static inline void iommu_group_set_iommudata(struct iommu_group *group,
639 void *iommu_data,
640 void (*release)(void *iommu_data))
641{
642}
643
644static inline int iommu_group_set_name(struct iommu_group *group,
645 const char *name)
646{
647 return -ENODEV;
648}
649
650static inline int iommu_group_add_device(struct iommu_group *group,
651 struct device *dev)
652{
653 return -ENODEV;
654}
655
656static inline void iommu_group_remove_device(struct device *dev)
657{
658}
659
660static inline int iommu_group_for_each_dev(struct iommu_group *group,
661 void *data,
662 int (*fn)(struct device *, void *))
663{
664 return -ENODEV;
665}
666
667static inline struct iommu_group *iommu_group_get(struct device *dev)
668{
669 return NULL;
670}
671
672static inline void iommu_group_put(struct iommu_group *group)
673{
674}
675
676static inline int iommu_group_register_notifier(struct iommu_group *group,
677 struct notifier_block *nb)
678{
679 return -ENODEV;
680}
681
682static inline int iommu_group_unregister_notifier(struct iommu_group *group,
683 struct notifier_block *nb)
684{
685 return 0;
686}
687
688static inline int iommu_group_id(struct iommu_group *group)
689{
690 return -ENODEV;
691}
692
693static inline int iommu_domain_get_attr(struct iommu_domain *domain,
694 enum iommu_attr attr, void *data)
695{
696 return -EINVAL;
697}
698
699static inline int iommu_domain_set_attr(struct iommu_domain *domain,
700 enum iommu_attr attr, void *data)
701{
702 return -EINVAL;
703}
704
705static inline int iommu_device_register(struct iommu_device *iommu)
706{
707 return -ENODEV;
708}
709
710static inline void iommu_device_set_ops(struct iommu_device *iommu,
711 const struct iommu_ops *ops)
712{
713}
714
715static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
716 struct fwnode_handle *fwnode)
717{
718}
719
720static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
721{
722 return NULL;
723}
724
725static inline void iommu_device_unregister(struct iommu_device *iommu)
726{
727}
728
729static inline int iommu_device_sysfs_add(struct iommu_device *iommu,
730 struct device *parent,
731 const struct attribute_group **groups,
732 const char *fmt, ...)
733{
734 return -ENODEV;
735}
736
737static inline void iommu_device_sysfs_remove(struct iommu_device *iommu)
738{
739}
740
741static inline int iommu_device_link(struct device *dev, struct device *link)
742{
743 return -EINVAL;
744}
745
746static inline void iommu_device_unlink(struct device *dev, struct device *link)
747{
748}
749
750static inline int iommu_fwspec_init(struct device *dev,
751 struct fwnode_handle *iommu_fwnode,
752 const struct iommu_ops *ops)
753{
754 return -ENODEV;
755}
756
757static inline void iommu_fwspec_free(struct device *dev)
758{
759}
760
761static inline int iommu_fwspec_add_ids(struct device *dev, u32 *ids,
762 int num_ids)
763{
764 return -ENODEV;
765}
766
767static inline
768const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
769{
770 return NULL;
771}
772
773static inline bool
774iommu_dev_has_feature(struct device *dev, enum iommu_dev_features feat)
775{
776 return false;
777}
778
779static inline bool
780iommu_dev_feature_enabled(struct device *dev, enum iommu_dev_features feat)
781{
782 return false;
783}
784
785static inline int
786iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features feat)
787{
788 return -ENODEV;
789}
790
791static inline int
792iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features feat)
793{
794 return -ENODEV;
795}
796
797static inline int
798iommu_aux_attach_device(struct iommu_domain *domain, struct device *dev)
799{
800 return -ENODEV;
801}
802
803static inline void
804iommu_aux_detach_device(struct iommu_domain *domain, struct device *dev)
805{
806}
807
808static inline int
809iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev)
810{
811 return -ENODEV;
812}
813
814static inline struct iommu_sva *
815iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata)
816{
817 return NULL;
818}
819
820static inline void iommu_sva_unbind_device(struct iommu_sva *handle)
821{
822}
823
824static inline int iommu_sva_set_ops(struct iommu_sva *handle,
825 const struct iommu_sva_ops *ops)
826{
827 return -EINVAL;
828}
829
830static inline int iommu_sva_get_pasid(struct iommu_sva *handle)
831{
832 return IOMMU_PASID_INVALID;
833}
834
835#endif /* CONFIG_IOMMU_API */
836
837#ifdef CONFIG_IOMMU_DEBUGFS
838extern struct dentry *iommu_debugfs_dir;
839void iommu_debugfs_setup(void);
840#else
841static inline void iommu_debugfs_setup(void) {}
842#endif
843
844#endif /* __LINUX_IOMMU_H */