blob: e552c3b63f6f014808e13ebc052517f2cb2eb5bd [file] [log] [blame]
Thomas Gleixner45051532019-05-29 16:57:47 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Joerg Roedel4a77a6c2008-11-26 17:02:33 +01002/*
3 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
4 * Author: Joerg Roedel <joerg.roedel@amd.com>
Joerg Roedel4a77a6c2008-11-26 17:02:33 +01005 */
6
7#ifndef __LINUX_IOMMU_H
8#define __LINUX_IOMMU_H
9
Joerg Roedele8245c12017-04-26 15:34:06 +020010#include <linux/scatterlist.h>
11#include <linux/device.h>
12#include <linux/types.h>
Laura Abbott74315cc2011-06-08 17:29:11 -040013#include <linux/errno.h>
Wang YanQing9a08d372013-04-19 09:38:04 +080014#include <linux/err.h>
Will Deacond0f60a42014-08-27 16:15:59 +010015#include <linux/of.h>
Laura Abbott74315cc2011-06-08 17:29:11 -040016
Will Deaconca13bb32013-11-05 15:59:53 +000017#define IOMMU_READ (1 << 0)
18#define IOMMU_WRITE (1 << 1)
19#define IOMMU_CACHE (1 << 2) /* DMA cache coherency */
Antonios Motakisa720b412014-10-13 14:06:16 +010020#define IOMMU_NOEXEC (1 << 3)
Robin Murphy31e68502016-04-05 12:39:30 +010021#define IOMMU_MMIO (1 << 4) /* e.g. things like MSI doorbells */
Mitchel Humpherys579b2a62017-01-06 18:58:08 +053022/*
Robin Murphyadf5e512017-01-27 12:22:54 +000023 * 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.
Mitchel Humpherys579b2a62017-01-06 18:58:08 +053030 */
31#define IOMMU_PRIV (1 << 5)
Joerg Roedel4a77a6c2008-11-26 17:02:33 +010032
Joerg Roedel905d66c2011-09-06 16:03:26 +020033struct iommu_ops;
Alex Williamsond72e31c2012-05-30 14:18:53 -060034struct iommu_group;
Joerg Roedelff217762011-08-26 16:48:26 +020035struct bus_type;
Joerg Roedel4a77a6c2008-11-26 17:02:33 +010036struct device;
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -040037struct iommu_domain;
Joerg Roedelba1eabfa2012-08-03 15:55:41 +020038struct notifier_block;
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +010039struct iommu_sva;
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -040040
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 *,
Ohad Ben-Cohen77ca2332012-05-21 20:20:05 +030046 struct device *, unsigned long, int, void *);
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +010047typedef int (*iommu_mm_exit_handler_t)(struct device *dev, struct iommu_sva *,
48 void *);
Joerg Roedel4a77a6c2008-11-26 17:02:33 +010049
Joerg Roedel0ff64f82012-01-26 19:40:53 +010050struct 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
Joerg Roedel8539c7c2015-03-26 13:43:05 +010056/* 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
Joerg Roedel4a77a6c2008-11-26 17:02:33 +010080struct iommu_domain {
Joerg Roedel8539c7c2015-03-26 13:43:05 +010081 unsigned type;
Thierry Redingb22f6432014-06-27 09:03:12 +020082 const struct iommu_ops *ops;
Robin Murphyd16e0fa2016-04-07 18:42:06 +010083 unsigned long pgsize_bitmap; /* Bitmap of page sizes in use */
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -040084 iommu_fault_handler_t handler;
Ohad Ben-Cohen77ca2332012-05-21 20:20:05 +030085 void *handler_token;
Joerg Roedel0ff64f82012-01-26 19:40:53 +010086 struct iommu_domain_geometry geometry;
Robin Murphy0db2e5d2015-10-01 20:13:58 +010087 void *iova_cookie;
Joerg Roedel4a77a6c2008-11-26 17:02:33 +010088};
89
Joerg Roedel1aed0742014-09-03 18:34:04 +020090enum iommu_cap {
91 IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
92 transactions */
93 IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
Antonios Motakisc4986642014-10-13 14:06:17 +010094 IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */
Joerg Roedel1aed0742014-09-03 18:34:04 +020095};
Sheng Yangdbb9fd82009-03-18 15:33:06 +080096
Varun Sethi7cabf492013-07-15 10:20:56 +053097/*
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
Joerg Roedel0cd76dd2012-01-26 19:40:52 +0100110enum iommu_attr {
Joerg Roedel0ff64f82012-01-26 19:40:53 +0100111 DOMAIN_ATTR_GEOMETRY,
Joerg Roedeld2e12162013-01-29 13:49:04 +0100112 DOMAIN_ATTR_PAGING,
Joerg Roedel69356712013-02-04 14:00:01 +0100113 DOMAIN_ATTR_WINDOWS,
Varun Sethi7cabf492013-07-15 10:20:56 +0530114 DOMAIN_ATTR_FSL_PAMU_STASH,
115 DOMAIN_ATTR_FSL_PAMU_ENABLE,
116 DOMAIN_ATTR_FSL_PAMUV1,
Will Deaconc02607a2014-09-29 10:05:06 -0600117 DOMAIN_ATTR_NESTING, /* two stages of translation */
Zhen Lei2da274c2018-09-20 17:10:22 +0100118 DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,
Joerg Roedela8b8a88a2013-01-29 14:36:31 +0100119 DOMAIN_ATTR_MAX,
Joerg Roedel0cd76dd2012-01-26 19:40:52 +0100120};
121
Eric Augerd30ddca2017-01-19 20:57:48 +0000122/* These are the possible reserved region types */
Robin Murphy9d3a4de2017-03-16 17:00:16 +0000123enum 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};
Eric Augerd30ddca2017-01-19 20:57:48 +0000133
Joerg Roedela1015c22015-05-28 18:41:33 +0200134/**
Eric Augere5b52342017-01-19 20:57:47 +0000135 * struct iommu_resv_region - descriptor for a reserved memory region
Joerg Roedela1015c22015-05-28 18:41:33 +0200136 * @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/...)
Eric Augerd30ddca2017-01-19 20:57:48 +0000140 * @type: Type of the reserved region
Joerg Roedela1015c22015-05-28 18:41:33 +0200141 */
Eric Augere5b52342017-01-19 20:57:47 +0000142struct iommu_resv_region {
Joerg Roedela1015c22015-05-28 18:41:33 +0200143 struct list_head list;
144 phys_addr_t start;
145 size_t length;
146 int prot;
Robin Murphy9d3a4de2017-03-16 17:00:16 +0000147 enum iommu_resv_type type;
Joerg Roedela1015c22015-05-28 18:41:33 +0200148};
149
Lu Baolua3a19592019-03-25 09:30:28 +0800150/* Per device IOMMU features */
151enum iommu_dev_features {
152 IOMMU_DEV_FEAT_AUX, /* Aux-domain feature */
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +0100153 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;
Lu Baolua3a19592019-03-25 09:30:28 +0800175};
176
Joerg Roedel39d4ebb2011-09-06 16:48:40 +0200177#ifdef CONFIG_IOMMU_API
178
Ohad Ben-Cohen7d3002c2011-11-10 11:32:26 +0200179/**
180 * struct iommu_ops - iommu ops and capabilities
Magnus Damm0d9bacb2016-01-19 14:28:48 +0900181 * @capable: check capability
182 * @domain_alloc: allocate iommu domain
183 * @domain_free: free iommu domain
Ohad Ben-Cohen7d3002c2011-11-10 11:32:26 +0200184 * @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
Tom Murphydb04d4a2019-02-11 15:50:33 +0000188 * @flush_iotlb_all: Synchronously flush all hardware TLBs for this domain
tom51eb7802018-12-04 18:27:34 +0000189 * @iotlb_range_add: Add a given iova range to the flush queue for this domain
Geert Uytterhoeven2405bc12019-02-20 14:00:52 +0100190 * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
tom51eb7802018-12-04 18:27:34 +0000191 * @iotlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
Joerg Roedeladd02cfd2017-08-23 15:50:04 +0200192 * queue
Ohad Ben-Cohen7d3002c2011-11-10 11:32:26 +0200193 * @iova_to_phys: translate iova to physical address
Alex Williamsond72e31c2012-05-30 14:18:53 -0600194 * @add_device: add device to iommu grouping
195 * @remove_device: remove device from iommu grouping
Magnus Damm0d9bacb2016-01-19 14:28:48 +0900196 * @device_group: find iommu group for a particular device
Joerg Roedel0cd76dd2012-01-26 19:40:52 +0100197 * @domain_get_attr: Query domain attributes
198 * @domain_set_attr: Change domain attributes
Eric Augere5b52342017-01-19 20:57:47 +0000199 * @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
Magnus Damm0d9bacb2016-01-19 14:28:48 +0900202 * @domain_window_enable: Configure and enable a particular window for a domain
203 * @domain_window_disable: Disable a particular window for a domain
Will Deacond0f60a42014-08-27 16:15:59 +0100204 * @of_xlate: add OF master IDs to iommu grouping
Geert Uytterhoevena7055d52019-02-20 14:00:53 +0100205 * @is_attach_deferred: Check if domain attach should be deferred from iommu
206 * driver init to device driver init (default no)
Lu Baolua3a19592019-03-25 09:30:28 +0800207 * @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
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +0100212 * @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
Robin Murphyd16e0fa2016-04-07 18:42:06 +0100215 * @pgsize_bitmap: bitmap of all possible supported page sizes
Ohad Ben-Cohen7d3002c2011-11-10 11:32:26 +0200216 */
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100217struct iommu_ops {
Joerg Roedel3c0e0ca2014-09-03 18:47:25 +0200218 bool (*capable)(enum iommu_cap);
Joerg Roedel938c4702015-03-26 13:43:04 +0100219
220 /* Domain allocation and freeing by the iommu driver */
Joerg Roedel8539c7c2015-03-26 13:43:05 +0100221 struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
Joerg Roedel938c4702015-03-26 13:43:04 +0100222 void (*domain_free)(struct iommu_domain *);
223
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100224 int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
225 void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
Joerg Roedel67651782010-01-21 16:32:27 +0100226 int (*map)(struct iommu_domain *domain, unsigned long iova,
Ohad Ben-Cohen50090652011-11-10 11:32:25 +0200227 phys_addr_t paddr, size_t size, int prot);
228 size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
229 size_t size);
Joerg Roedeladd02cfd2017-08-23 15:50:04 +0200230 void (*flush_iotlb_all)(struct iommu_domain *domain);
231 void (*iotlb_range_add)(struct iommu_domain *domain,
232 unsigned long iova, size_t size);
Dmitry Osipenko1d7ae532018-12-12 23:38:47 +0300233 void (*iotlb_sync_map)(struct iommu_domain *domain);
Joerg Roedeladd02cfd2017-08-23 15:50:04 +0200234 void (*iotlb_sync)(struct iommu_domain *domain);
Varun Sethibb5547a2013-03-29 01:23:58 +0530235 phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
Alex Williamsond72e31c2012-05-30 14:18:53 -0600236 int (*add_device)(struct device *dev);
237 void (*remove_device)(struct device *dev);
Joerg Roedel46c6b2b2015-10-21 23:51:36 +0200238 struct iommu_group *(*device_group)(struct device *dev);
Joerg Roedel0cd76dd2012-01-26 19:40:52 +0100239 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);
Joerg Roedeld7787d52013-01-29 14:26:20 +0100243
Eric Augere5b52342017-01-19 20:57:47 +0000244 /* 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);
Joerg Roedela1015c22015-05-28 18:41:33 +0200250
Joerg Roedeld7787d52013-01-29 14:26:20 +0100251 /* Window handling functions */
252 int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
Varun Sethi80f97f02013-03-29 01:24:00 +0530253 phys_addr_t paddr, u64 size, int prot);
Joerg Roedeld7787d52013-01-29 14:26:20 +0100254 void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);
255
Will Deacond0f60a42014-08-27 16:15:59 +0100256 int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
Baoquan Hee01d1912017-08-09 16:33:40 +0800257 bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);
Will Deacond0f60a42014-08-27 16:15:59 +0100258
Lu Baolua3a19592019-03-25 09:30:28 +0800259 /* 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
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +0100270 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
Ohad Ben-Cohen7d3002c2011-11-10 11:32:26 +0200275 unsigned long pgsize_bitmap;
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100276};
277
Joerg Roedelb0119e82017-02-01 13:23:08 +0100278/**
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
Joerg Roedel39ab9552017-02-01 16:56:46 +0100283 * @dev: struct device for sysfs handling
Joerg Roedelb0119e82017-02-01 13:23:08 +0100284 */
285struct iommu_device {
286 struct list_head list;
287 const struct iommu_ops *ops;
Joerg Roedelc73e1ac2017-02-07 18:18:46 +0100288 struct fwnode_handle *fwnode;
Joerg Roedel2926a2aa2017-08-14 17:19:26 +0200289 struct device *dev;
Joerg Roedelb0119e82017-02-01 13:23:08 +0100290};
291
292int iommu_device_register(struct iommu_device *iommu);
293void iommu_device_unregister(struct iommu_device *iommu);
Joerg Roedel39ab9552017-02-01 16:56:46 +0100294int 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);
Joerg Roedele3d10af2017-02-01 17:23:22 +0100299int iommu_device_link(struct iommu_device *iommu, struct device *link);
300void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
Joerg Roedelb0119e82017-02-01 13:23:08 +0100301
302static inline void iommu_device_set_ops(struct iommu_device *iommu,
303 const struct iommu_ops *ops)
304{
305 iommu->ops = ops;
306}
307
Joerg Roedelc73e1ac2017-02-07 18:18:46 +0100308static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
309 struct fwnode_handle *fwnode)
310{
311 iommu->fwnode = fwnode;
312}
313
Joerg Roedel2926a2aa2017-08-14 17:19:26 +0200314static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
315{
316 return (struct iommu_device *)dev_get_drvdata(dev);
317}
318
Alex Williamsond72e31c2012-05-30 14:18:53 -0600319#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
Thierry Redingb22f6432014-06-27 09:03:12 +0200326extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
Joerg Roedela1b60c12011-09-06 18:46:34 +0200327extern bool iommu_present(struct bus_type *bus);
Joerg Roedel3c0e0ca2014-09-03 18:47:25 +0200328extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
Joerg Roedel905d66c2011-09-06 16:03:26 +0200329extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
Alexey Kardashevskiyaa16bea2013-03-25 10:23:49 +1100330extern struct iommu_group *iommu_group_get_by_id(int id);
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100331extern 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);
Joerg Roedel2c1296d2015-05-28 18:41:32 +0200336extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
Robin Murphy6af588f2018-09-12 16:24:12 +0100337extern struct iommu_domain *iommu_get_dma_domain(struct device *dev);
Joerg Roedelcefc53c2010-01-08 13:35:09 +0100338extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
Ohad Ben-Cohen7d3002c2011-11-10 11:32:26 +0200339 phys_addr_t paddr, size_t size, int prot);
340extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
Joerg Roedeladd02cfd2017-08-23 15:50:04 +0200341 size_t size);
342extern size_t iommu_unmap_fast(struct iommu_domain *domain,
343 unsigned long iova, size_t size);
Christoph Hellwigd88e61f2018-07-30 09:36:26 +0200344extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
345 struct scatterlist *sg,unsigned int nents, int prot);
Varun Sethibb5547a2013-03-29 01:23:58 +0530346extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -0400347extern void iommu_set_fault_handler(struct iommu_domain *domain,
Ohad Ben-Cohen77ca2332012-05-21 20:20:05 +0300348 iommu_fault_handler_t handler, void *token);
Alex Williamsond72e31c2012-05-30 14:18:53 -0600349
Eric Augere5b52342017-01-19 20:57:47 +0000350extern 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);
Joerg Roedeld290f1e2015-05-28 18:41:36 +0200352extern int iommu_request_dm_for_dev(struct device *dev);
Eric Auger2b20cbb2017-01-19 20:57:49 +0000353extern struct iommu_resv_region *
Robin Murphy9d3a4de2017-03-16 17:00:16 +0000354iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,
355 enum iommu_resv_type type);
Eric Auger6c65fb32017-01-19 20:57:51 +0000356extern int iommu_get_group_resv_regions(struct iommu_group *group,
357 struct list_head *head);
Joerg Roedela1015c22015-05-28 18:41:33 +0200358
Alex Williamsond72e31c2012-05-30 14:18:53 -0600359extern 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);
Robin Murphy13f59a72016-11-11 17:59:21 +0000375extern struct iommu_group *iommu_group_ref_get(struct iommu_group *group);
Alex Williamsond72e31c2012-05-30 14:18:53 -0600376extern 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);
Alex Williamson104a1c12014-07-03 09:51:18 -0600382extern struct iommu_group *iommu_group_get_for_dev(struct device *dev);
Joerg Roedel6827ca82015-05-28 18:41:35 +0200383extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -0400384
Joerg Roedel0cd76dd2012-01-26 19:40:52 +0100385extern 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);
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -0400389
Joerg Roedeld7787d52013-01-29 14:26:20 +0100390/* Window handling function prototypes */
391extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
Varun Sethi80f97f02013-03-29 01:24:00 +0530392 phys_addr_t offset, u64 size,
393 int prot);
Joerg Roedeld7787d52013-01-29 14:26:20 +0100394extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr);
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -0400395
Joerg Roedel207c6e32017-04-26 15:39:28 +0200396extern int report_iommu_fault(struct iommu_domain *domain, struct device *dev,
397 unsigned long iova, int flags);
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100398
Joerg Roedeladd02cfd2017-08-23 15:50:04 +0200399static 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
Joerg Roedel5e622922015-10-21 23:51:37 +0200418/* PCI device grouping function */
419extern struct iommu_group *pci_device_group(struct device *dev);
Joerg Roedel6eab5562015-10-21 23:51:38 +0200420/* Generic device grouping function */
421extern struct iommu_group *generic_device_group(struct device *dev);
Nipun Guptaeab03e22018-09-10 19:19:18 +0530422/* FSL-MC device grouping function */
423struct iommu_group *fsl_mc_device_group(struct device *dev);
Joerg Roedel5e622922015-10-21 23:51:37 +0200424
Robin Murphy57f98d22016-09-13 10:54:14 +0100425/**
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;
Jean-Philippe Brucker5702ee22019-04-17 19:24:42 +0100437 u32 flags;
Robin Murphy57f98d22016-09-13 10:54:14 +0100438 unsigned int num_ids;
439 u32 ids[1];
440};
441
Jean-Philippe Brucker5702ee22019-04-17 19:24:42 +0100442/* ATS is supported */
443#define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0)
444
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +0100445/**
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
Robin Murphy57f98d22016-09-13 10:54:14 +0100453int 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);
Joerg Roedel534766d2017-01-31 16:58:42 +0100457const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
Robin Murphy57f98d22016-09-13 10:54:14 +0100458
Joerg Roedelb4ef7252018-11-28 13:35:24 +0100459static 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
Joerg Roedelcc5aed42018-11-30 10:31:59 +0100470int iommu_probe_device(struct device *dev);
471void iommu_release_device(struct device *dev);
472
Lu Baolua3a19592019-03-25 09:30:28 +0800473bool 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
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +0100481struct 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
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100489#else /* CONFIG_IOMMU_API */
490
Joerg Roedel39d4ebb2011-09-06 16:48:40 +0200491struct iommu_ops {};
Alex Williamsond72e31c2012-05-30 14:18:53 -0600492struct iommu_group {};
Robin Murphy57f98d22016-09-13 10:54:14 +0100493struct iommu_fwspec {};
Joerg Roedelb0119e82017-02-01 13:23:08 +0100494struct iommu_device {};
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100495
Joerg Roedela1b60c12011-09-06 18:46:34 +0200496static inline bool iommu_present(struct bus_type *bus)
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100497{
498 return false;
499}
500
Joerg Roedel3c0e0ca2014-09-03 18:47:25 +0200501static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
502{
503 return false;
504}
505
Joerg Roedel905d66c2011-09-06 16:03:26 +0200506static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100507{
508 return NULL;
509}
510
Alexey Kardashevskiyb62dfd22013-11-21 17:41:14 +1100511static inline struct iommu_group *iommu_group_get_by_id(int id)
512{
513 return NULL;
514}
515
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100516static 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
Joerg Roedel2c1296d2015-05-28 18:41:32 +0200531static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
532{
533 return NULL;
534}
535
Joerg Roedelcefc53c2010-01-08 13:35:09 +0100536static inline int iommu_map(struct iommu_domain *domain, unsigned long iova,
Dmitry Osipenkoebae3e82017-07-05 20:27:53 +0300537 phys_addr_t paddr, size_t size, int prot)
Joerg Roedelcefc53c2010-01-08 13:35:09 +0100538{
539 return -ENODEV;
540}
541
Suravee Suthikulpanitc5611a82018-02-05 05:45:53 -0500542static inline size_t iommu_unmap(struct iommu_domain *domain,
543 unsigned long iova, size_t size)
Joerg Roedelcefc53c2010-01-08 13:35:09 +0100544{
Suravee Suthikulpanitc5611a82018-02-05 05:45:53 -0500545 return 0;
Joerg Roedelcefc53c2010-01-08 13:35:09 +0100546}
547
Suravee Suthikulpanitc5611a82018-02-05 05:45:53 -0500548static inline size_t iommu_unmap_fast(struct iommu_domain *domain,
549 unsigned long iova, int gfp_order)
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100550{
Suravee Suthikulpanitc5611a82018-02-05 05:45:53 -0500551 return 0;
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100552}
553
Olav Haugan315786e2014-10-25 09:55:16 -0700554static inline size_t iommu_map_sg(struct iommu_domain *domain,
555 unsigned long iova, struct scatterlist *sg,
556 unsigned int nents, int prot)
557{
Suravee Suthikulpanitc5611a82018-02-05 05:45:53 -0500558 return 0;
Olav Haugan315786e2014-10-25 09:55:16 -0700559}
560
Joerg Roedeladd02cfd2017-08-23 15:50:04 +0200561static 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
Joerg Roedeld7787d52013-01-29 14:26:20 +0100574static inline int iommu_domain_window_enable(struct iommu_domain *domain,
575 u32 wnd_nr, phys_addr_t paddr,
Varun Sethi80f97f02013-03-29 01:24:00 +0530576 u64 size, int prot)
Joerg Roedeld7787d52013-01-29 14:26:20 +0100577{
578 return -ENODEV;
579}
580
581static inline void iommu_domain_window_disable(struct iommu_domain *domain,
582 u32 wnd_nr)
583{
584}
585
Varun Sethibb5547a2013-03-29 01:23:58 +0530586static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100587{
588 return 0;
589}
590
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -0400591static inline void iommu_set_fault_handler(struct iommu_domain *domain,
Ohad Ben-Cohen77ca2332012-05-21 20:20:05 +0300592 iommu_fault_handler_t handler, void *token)
Ohad Ben-Cohen4f3f8d92011-09-13 15:25:23 -0400593{
594}
595
Eric Augere5b52342017-01-19 20:57:47 +0000596static inline void iommu_get_resv_regions(struct device *dev,
Joerg Roedela1015c22015-05-28 18:41:33 +0200597 struct list_head *list)
598{
599}
600
Eric Augere5b52342017-01-19 20:57:47 +0000601static inline void iommu_put_resv_regions(struct device *dev,
Joerg Roedela1015c22015-05-28 18:41:33 +0200602 struct list_head *list)
603{
604}
605
Eric Auger6c65fb32017-01-19 20:57:51 +0000606static inline int iommu_get_group_resv_regions(struct iommu_group *group,
607 struct list_head *head)
608{
609 return -ENODEV;
610}
611
Joerg Roedeld290f1e2015-05-28 18:41:36 +0200612static inline int iommu_request_dm_for_dev(struct device *dev)
613{
614 return -ENODEV;
615}
616
Alex Williamsonbef83de2012-09-24 21:23:25 -0600617static inline int iommu_attach_group(struct iommu_domain *domain,
618 struct iommu_group *group)
Alex Williamson14604322011-10-21 15:56:05 -0400619{
620 return -ENODEV;
621}
622
Alex Williamsonbef83de2012-09-24 21:23:25 -0600623static inline void iommu_detach_group(struct iommu_domain *domain,
624 struct iommu_group *group)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600625{
626}
627
Alex Williamsonbef83de2012-09-24 21:23:25 -0600628static inline struct iommu_group *iommu_group_alloc(void)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600629{
630 return ERR_PTR(-ENODEV);
631}
632
Alex Williamsonbef83de2012-09-24 21:23:25 -0600633static inline void *iommu_group_get_iommudata(struct iommu_group *group)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600634{
635 return NULL;
636}
637
Alex Williamsonbef83de2012-09-24 21:23:25 -0600638static inline void iommu_group_set_iommudata(struct iommu_group *group,
639 void *iommu_data,
640 void (*release)(void *iommu_data))
Alex Williamsond72e31c2012-05-30 14:18:53 -0600641{
642}
643
Alex Williamsonbef83de2012-09-24 21:23:25 -0600644static inline int iommu_group_set_name(struct iommu_group *group,
645 const char *name)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600646{
647 return -ENODEV;
648}
649
Alex Williamsonbef83de2012-09-24 21:23:25 -0600650static inline int iommu_group_add_device(struct iommu_group *group,
651 struct device *dev)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600652{
653 return -ENODEV;
654}
655
Alex Williamsonbef83de2012-09-24 21:23:25 -0600656static inline void iommu_group_remove_device(struct device *dev)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600657{
658}
659
Alex Williamsonbef83de2012-09-24 21:23:25 -0600660static inline int iommu_group_for_each_dev(struct iommu_group *group,
661 void *data,
662 int (*fn)(struct device *, void *))
Alex Williamsond72e31c2012-05-30 14:18:53 -0600663{
664 return -ENODEV;
665}
666
Alex Williamsonbef83de2012-09-24 21:23:25 -0600667static inline struct iommu_group *iommu_group_get(struct device *dev)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600668{
669 return NULL;
670}
671
Alex Williamsonbef83de2012-09-24 21:23:25 -0600672static inline void iommu_group_put(struct iommu_group *group)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600673{
674}
675
Alex Williamsonbef83de2012-09-24 21:23:25 -0600676static inline int iommu_group_register_notifier(struct iommu_group *group,
677 struct notifier_block *nb)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600678{
679 return -ENODEV;
680}
681
Alex Williamsonbef83de2012-09-24 21:23:25 -0600682static inline int iommu_group_unregister_notifier(struct iommu_group *group,
683 struct notifier_block *nb)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600684{
685 return 0;
686}
687
Alex Williamsonbef83de2012-09-24 21:23:25 -0600688static inline int iommu_group_id(struct iommu_group *group)
Alex Williamsond72e31c2012-05-30 14:18:53 -0600689{
690 return -ENODEV;
691}
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100692
Joerg Roedel0cd76dd2012-01-26 19:40:52 +0100693static 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
Joerg Roedelb0119e82017-02-01 13:23:08 +0100705static inline int iommu_device_register(struct iommu_device *iommu)
Alex Williamsonc61959e2014-06-12 16:12:24 -0600706{
Joerg Roedelb0119e82017-02-01 13:23:08 +0100707 return -ENODEV;
Alex Williamsonc61959e2014-06-12 16:12:24 -0600708}
709
Joerg Roedelb0119e82017-02-01 13:23:08 +0100710static inline void iommu_device_set_ops(struct iommu_device *iommu,
711 const struct iommu_ops *ops)
712{
713}
714
Joerg Roedelc73e1ac2017-02-07 18:18:46 +0100715static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
716 struct fwnode_handle *fwnode)
717{
718}
719
Joerg Roedel2926a2aa2017-08-14 17:19:26 +0200720static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
721{
722 return NULL;
723}
724
Joerg Roedelb0119e82017-02-01 13:23:08 +0100725static inline void iommu_device_unregister(struct iommu_device *iommu)
726{
727}
728
Joerg Roedel39ab9552017-02-01 16:56:46 +0100729static 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)
Alex Williamsonc61959e2014-06-12 16:12:24 -0600738{
739}
740
Alex Williamsone09f8ea2014-07-07 14:31:36 -0600741static inline int iommu_device_link(struct device *dev, struct device *link)
Alex Williamsonc61959e2014-06-12 16:12:24 -0600742{
743 return -EINVAL;
744}
745
Alex Williamsone09f8ea2014-07-07 14:31:36 -0600746static inline void iommu_device_unlink(struct device *dev, struct device *link)
Alex Williamsonc61959e2014-06-12 16:12:24 -0600747{
748}
749
Robin Murphy57f98d22016-09-13 10:54:14 +0100750static 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
Lorenzo Pieralisie4f10ff2016-11-21 10:01:36 +0000767static inline
Joerg Roedel534766d2017-01-31 16:58:42 +0100768const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
Lorenzo Pieralisie4f10ff2016-11-21 10:01:36 +0000769{
770 return NULL;
771}
772
Lu Baolua3a19592019-03-25 09:30:28 +0800773static 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
Jean-Philippe Brucker26b25a22019-04-10 16:15:16 +0100814static 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
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100835#endif /* CONFIG_IOMMU_API */
836
Gary R Hookbad614b2018-06-12 16:41:21 -0500837#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
Joerg Roedel4a77a6c2008-11-26 17:02:33 +0100844#endif /* __LINUX_IOMMU_H */