Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007-2008 Advanced Micro Devices, Inc. |
| 3 | * Author: Joerg Roedel <joerg.roedel@amd.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published |
| 7 | * by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | #ifndef __LINUX_IOMMU_H |
| 20 | #define __LINUX_IOMMU_H |
| 21 | |
Joerg Roedel | e8245c1 | 2017-04-26 15:34:06 +0200 | [diff] [blame] | 22 | #include <linux/scatterlist.h> |
| 23 | #include <linux/device.h> |
| 24 | #include <linux/types.h> |
Laura Abbott | 74315cc | 2011-06-08 17:29:11 -0400 | [diff] [blame] | 25 | #include <linux/errno.h> |
Wang YanQing | 9a08d37 | 2013-04-19 09:38:04 +0800 | [diff] [blame] | 26 | #include <linux/err.h> |
Will Deacon | d0f60a4 | 2014-08-27 16:15:59 +0100 | [diff] [blame] | 27 | #include <linux/of.h> |
Joerg Roedel | e8245c1 | 2017-04-26 15:34:06 +0200 | [diff] [blame] | 28 | |
Shuah Khan | 56fa484 | 2013-09-24 15:21:20 -0600 | [diff] [blame] | 29 | #include <trace/events/iommu.h> |
Laura Abbott | 74315cc | 2011-06-08 17:29:11 -0400 | [diff] [blame] | 30 | |
Will Deacon | ca13bb3 | 2013-11-05 15:59:53 +0000 | [diff] [blame] | 31 | #define IOMMU_READ (1 << 0) |
| 32 | #define IOMMU_WRITE (1 << 1) |
| 33 | #define IOMMU_CACHE (1 << 2) /* DMA cache coherency */ |
Antonios Motakis | a720b41 | 2014-10-13 14:06:16 +0100 | [diff] [blame] | 34 | #define IOMMU_NOEXEC (1 << 3) |
Robin Murphy | 31e6850 | 2016-04-05 12:39:30 +0100 | [diff] [blame] | 35 | #define IOMMU_MMIO (1 << 4) /* e.g. things like MSI doorbells */ |
Mitchel Humpherys | 579b2a6 | 2017-01-06 18:58:08 +0530 | [diff] [blame] | 36 | /* |
| 37 | * This is to make the IOMMU API setup privileged |
| 38 | * mapppings accessible by the master only at higher |
| 39 | * privileged execution level and inaccessible at |
| 40 | * less privileged levels. |
| 41 | */ |
| 42 | #define IOMMU_PRIV (1 << 5) |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 43 | |
Joerg Roedel | 905d66c | 2011-09-06 16:03:26 +0200 | [diff] [blame] | 44 | struct iommu_ops; |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 45 | struct iommu_group; |
Joerg Roedel | ff21776 | 2011-08-26 16:48:26 +0200 | [diff] [blame] | 46 | struct bus_type; |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 47 | struct device; |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 48 | struct iommu_domain; |
Joerg Roedel | ba1eabfa | 2012-08-03 15:55:41 +0200 | [diff] [blame] | 49 | struct notifier_block; |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 50 | |
| 51 | /* iommu fault flags */ |
| 52 | #define IOMMU_FAULT_READ 0x0 |
| 53 | #define IOMMU_FAULT_WRITE 0x1 |
| 54 | |
| 55 | typedef int (*iommu_fault_handler_t)(struct iommu_domain *, |
Ohad Ben-Cohen | 77ca233 | 2012-05-21 20:20:05 +0300 | [diff] [blame] | 56 | struct device *, unsigned long, int, void *); |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 57 | |
Joerg Roedel | 0ff64f8 | 2012-01-26 19:40:53 +0100 | [diff] [blame] | 58 | struct iommu_domain_geometry { |
| 59 | dma_addr_t aperture_start; /* First address that can be mapped */ |
| 60 | dma_addr_t aperture_end; /* Last address that can be mapped */ |
| 61 | bool force_aperture; /* DMA only allowed in mappable range? */ |
| 62 | }; |
| 63 | |
Joerg Roedel | 8539c7c | 2015-03-26 13:43:05 +0100 | [diff] [blame] | 64 | /* Domain feature flags */ |
| 65 | #define __IOMMU_DOMAIN_PAGING (1U << 0) /* Support for iommu_map/unmap */ |
| 66 | #define __IOMMU_DOMAIN_DMA_API (1U << 1) /* Domain for use in DMA-API |
| 67 | implementation */ |
| 68 | #define __IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped */ |
| 69 | |
| 70 | /* |
| 71 | * This are the possible domain-types |
| 72 | * |
| 73 | * IOMMU_DOMAIN_BLOCKED - All DMA is blocked, can be used to isolate |
| 74 | * devices |
| 75 | * IOMMU_DOMAIN_IDENTITY - DMA addresses are system physical addresses |
| 76 | * IOMMU_DOMAIN_UNMANAGED - DMA mappings managed by IOMMU-API user, used |
| 77 | * for VMs |
| 78 | * IOMMU_DOMAIN_DMA - Internally used for DMA-API implementations. |
| 79 | * This flag allows IOMMU drivers to implement |
| 80 | * certain optimizations for these domains |
| 81 | */ |
| 82 | #define IOMMU_DOMAIN_BLOCKED (0U) |
| 83 | #define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT) |
| 84 | #define IOMMU_DOMAIN_UNMANAGED (__IOMMU_DOMAIN_PAGING) |
| 85 | #define IOMMU_DOMAIN_DMA (__IOMMU_DOMAIN_PAGING | \ |
| 86 | __IOMMU_DOMAIN_DMA_API) |
| 87 | |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 88 | struct iommu_domain { |
Joerg Roedel | 8539c7c | 2015-03-26 13:43:05 +0100 | [diff] [blame] | 89 | unsigned type; |
Thierry Reding | b22f643 | 2014-06-27 09:03:12 +0200 | [diff] [blame] | 90 | const struct iommu_ops *ops; |
Robin Murphy | d16e0fa | 2016-04-07 18:42:06 +0100 | [diff] [blame] | 91 | unsigned long pgsize_bitmap; /* Bitmap of page sizes in use */ |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 92 | iommu_fault_handler_t handler; |
Ohad Ben-Cohen | 77ca233 | 2012-05-21 20:20:05 +0300 | [diff] [blame] | 93 | void *handler_token; |
Joerg Roedel | 0ff64f8 | 2012-01-26 19:40:53 +0100 | [diff] [blame] | 94 | struct iommu_domain_geometry geometry; |
Robin Murphy | 0db2e5d | 2015-10-01 20:13:58 +0100 | [diff] [blame] | 95 | void *iova_cookie; |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
Joerg Roedel | 1aed074 | 2014-09-03 18:34:04 +0200 | [diff] [blame] | 98 | enum iommu_cap { |
| 99 | IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA |
| 100 | transactions */ |
| 101 | IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */ |
Antonios Motakis | c498664 | 2014-10-13 14:06:17 +0100 | [diff] [blame] | 102 | IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */ |
Joerg Roedel | 1aed074 | 2014-09-03 18:34:04 +0200 | [diff] [blame] | 103 | }; |
Sheng Yang | dbb9fd8 | 2009-03-18 15:33:06 +0800 | [diff] [blame] | 104 | |
Varun Sethi | 7cabf49 | 2013-07-15 10:20:56 +0530 | [diff] [blame] | 105 | /* |
| 106 | * Following constraints are specifc to FSL_PAMUV1: |
| 107 | * -aperture must be power of 2, and naturally aligned |
| 108 | * -number of windows must be power of 2, and address space size |
| 109 | * of each window is determined by aperture size / # of windows |
| 110 | * -the actual size of the mapped region of a window must be power |
| 111 | * of 2 starting with 4KB and physical address must be naturally |
| 112 | * aligned. |
| 113 | * DOMAIN_ATTR_FSL_PAMUV1 corresponds to the above mentioned contraints. |
| 114 | * The caller can invoke iommu_domain_get_attr to check if the underlying |
| 115 | * iommu implementation supports these constraints. |
| 116 | */ |
| 117 | |
Joerg Roedel | 0cd76dd | 2012-01-26 19:40:52 +0100 | [diff] [blame] | 118 | enum iommu_attr { |
Joerg Roedel | 0ff64f8 | 2012-01-26 19:40:53 +0100 | [diff] [blame] | 119 | DOMAIN_ATTR_GEOMETRY, |
Joerg Roedel | d2e1216 | 2013-01-29 13:49:04 +0100 | [diff] [blame] | 120 | DOMAIN_ATTR_PAGING, |
Joerg Roedel | 6935671 | 2013-02-04 14:00:01 +0100 | [diff] [blame] | 121 | DOMAIN_ATTR_WINDOWS, |
Varun Sethi | 7cabf49 | 2013-07-15 10:20:56 +0530 | [diff] [blame] | 122 | DOMAIN_ATTR_FSL_PAMU_STASH, |
| 123 | DOMAIN_ATTR_FSL_PAMU_ENABLE, |
| 124 | DOMAIN_ATTR_FSL_PAMUV1, |
Will Deacon | c02607a | 2014-09-29 10:05:06 -0600 | [diff] [blame] | 125 | DOMAIN_ATTR_NESTING, /* two stages of translation */ |
Joerg Roedel | a8b8a88a | 2013-01-29 14:36:31 +0100 | [diff] [blame] | 126 | DOMAIN_ATTR_MAX, |
Joerg Roedel | 0cd76dd | 2012-01-26 19:40:52 +0100 | [diff] [blame] | 127 | }; |
| 128 | |
Eric Auger | d30ddca | 2017-01-19 20:57:48 +0000 | [diff] [blame] | 129 | /* These are the possible reserved region types */ |
| 130 | #define IOMMU_RESV_DIRECT (1 << 0) |
| 131 | #define IOMMU_RESV_RESERVED (1 << 1) |
| 132 | #define IOMMU_RESV_MSI (1 << 2) |
| 133 | |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 134 | /** |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 135 | * struct iommu_resv_region - descriptor for a reserved memory region |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 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/...) |
Eric Auger | d30ddca | 2017-01-19 20:57:48 +0000 | [diff] [blame] | 140 | * @type: Type of the reserved region |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 141 | */ |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 142 | struct iommu_resv_region { |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 143 | struct list_head list; |
| 144 | phys_addr_t start; |
| 145 | size_t length; |
| 146 | int prot; |
Eric Auger | d30ddca | 2017-01-19 20:57:48 +0000 | [diff] [blame] | 147 | int type; |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 148 | }; |
| 149 | |
Joerg Roedel | 39d4ebb | 2011-09-06 16:48:40 +0200 | [diff] [blame] | 150 | #ifdef CONFIG_IOMMU_API |
| 151 | |
Ohad Ben-Cohen | 7d3002c | 2011-11-10 11:32:26 +0200 | [diff] [blame] | 152 | /** |
| 153 | * struct iommu_ops - iommu ops and capabilities |
Magnus Damm | 0d9bacb | 2016-01-19 14:28:48 +0900 | [diff] [blame] | 154 | * @capable: check capability |
| 155 | * @domain_alloc: allocate iommu domain |
| 156 | * @domain_free: free iommu domain |
Ohad Ben-Cohen | 7d3002c | 2011-11-10 11:32:26 +0200 | [diff] [blame] | 157 | * @attach_dev: attach device to an iommu domain |
| 158 | * @detach_dev: detach device from an iommu domain |
| 159 | * @map: map a physically contiguous memory region to an iommu domain |
| 160 | * @unmap: unmap a physically contiguous memory region from an iommu domain |
Olav Haugan | 315786e | 2014-10-25 09:55:16 -0700 | [diff] [blame] | 161 | * @map_sg: map a scatter-gather list of physically contiguous memory chunks |
| 162 | * to an iommu domain |
Ohad Ben-Cohen | 7d3002c | 2011-11-10 11:32:26 +0200 | [diff] [blame] | 163 | * @iova_to_phys: translate iova to physical address |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 164 | * @add_device: add device to iommu grouping |
| 165 | * @remove_device: remove device from iommu grouping |
Magnus Damm | 0d9bacb | 2016-01-19 14:28:48 +0900 | [diff] [blame] | 166 | * @device_group: find iommu group for a particular device |
Joerg Roedel | 0cd76dd | 2012-01-26 19:40:52 +0100 | [diff] [blame] | 167 | * @domain_get_attr: Query domain attributes |
| 168 | * @domain_set_attr: Change domain attributes |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 169 | * @get_resv_regions: Request list of reserved regions for a device |
| 170 | * @put_resv_regions: Free list of reserved regions for a device |
| 171 | * @apply_resv_region: Temporary helper call-back for iova reserved ranges |
Magnus Damm | 0d9bacb | 2016-01-19 14:28:48 +0900 | [diff] [blame] | 172 | * @domain_window_enable: Configure and enable a particular window for a domain |
| 173 | * @domain_window_disable: Disable a particular window for a domain |
| 174 | * @domain_set_windows: Set the number of windows for a domain |
| 175 | * @domain_get_windows: Return the number of windows for a domain |
Will Deacon | d0f60a4 | 2014-08-27 16:15:59 +0100 | [diff] [blame] | 176 | * @of_xlate: add OF master IDs to iommu grouping |
Robin Murphy | d16e0fa | 2016-04-07 18:42:06 +0100 | [diff] [blame] | 177 | * @pgsize_bitmap: bitmap of all possible supported page sizes |
Ohad Ben-Cohen | 7d3002c | 2011-11-10 11:32:26 +0200 | [diff] [blame] | 178 | */ |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 179 | struct iommu_ops { |
Joerg Roedel | 3c0e0ca | 2014-09-03 18:47:25 +0200 | [diff] [blame] | 180 | bool (*capable)(enum iommu_cap); |
Joerg Roedel | 938c470 | 2015-03-26 13:43:04 +0100 | [diff] [blame] | 181 | |
| 182 | /* Domain allocation and freeing by the iommu driver */ |
Joerg Roedel | 8539c7c | 2015-03-26 13:43:05 +0100 | [diff] [blame] | 183 | struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type); |
Joerg Roedel | 938c470 | 2015-03-26 13:43:04 +0100 | [diff] [blame] | 184 | void (*domain_free)(struct iommu_domain *); |
| 185 | |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 186 | int (*attach_dev)(struct iommu_domain *domain, struct device *dev); |
| 187 | void (*detach_dev)(struct iommu_domain *domain, struct device *dev); |
Joerg Roedel | 6765178 | 2010-01-21 16:32:27 +0100 | [diff] [blame] | 188 | int (*map)(struct iommu_domain *domain, unsigned long iova, |
Ohad Ben-Cohen | 5009065 | 2011-11-10 11:32:25 +0200 | [diff] [blame] | 189 | phys_addr_t paddr, size_t size, int prot); |
| 190 | size_t (*unmap)(struct iommu_domain *domain, unsigned long iova, |
| 191 | size_t size); |
Olav Haugan | 315786e | 2014-10-25 09:55:16 -0700 | [diff] [blame] | 192 | size_t (*map_sg)(struct iommu_domain *domain, unsigned long iova, |
| 193 | struct scatterlist *sg, unsigned int nents, int prot); |
Varun Sethi | bb5547a | 2013-03-29 01:23:58 +0530 | [diff] [blame] | 194 | phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 195 | int (*add_device)(struct device *dev); |
| 196 | void (*remove_device)(struct device *dev); |
Joerg Roedel | 46c6b2b | 2015-10-21 23:51:36 +0200 | [diff] [blame] | 197 | struct iommu_group *(*device_group)(struct device *dev); |
Joerg Roedel | 0cd76dd | 2012-01-26 19:40:52 +0100 | [diff] [blame] | 198 | int (*domain_get_attr)(struct iommu_domain *domain, |
| 199 | enum iommu_attr attr, void *data); |
| 200 | int (*domain_set_attr)(struct iommu_domain *domain, |
| 201 | enum iommu_attr attr, void *data); |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 202 | |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 203 | /* Request/Free a list of reserved regions for a device */ |
| 204 | void (*get_resv_regions)(struct device *dev, struct list_head *list); |
| 205 | void (*put_resv_regions)(struct device *dev, struct list_head *list); |
| 206 | void (*apply_resv_region)(struct device *dev, |
| 207 | struct iommu_domain *domain, |
| 208 | struct iommu_resv_region *region); |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 209 | |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 210 | /* Window handling functions */ |
| 211 | int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, |
Varun Sethi | 80f97f0 | 2013-03-29 01:24:00 +0530 | [diff] [blame] | 212 | phys_addr_t paddr, u64 size, int prot); |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 213 | void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr); |
Magnus Damm | 0d9bacb | 2016-01-19 14:28:48 +0900 | [diff] [blame] | 214 | /* Set the number of windows per domain */ |
Joerg Roedel | 6935671 | 2013-02-04 14:00:01 +0100 | [diff] [blame] | 215 | int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count); |
Magnus Damm | 0d9bacb | 2016-01-19 14:28:48 +0900 | [diff] [blame] | 216 | /* Get the number of windows per domain */ |
Joerg Roedel | 6935671 | 2013-02-04 14:00:01 +0100 | [diff] [blame] | 217 | u32 (*domain_get_windows)(struct iommu_domain *domain); |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 218 | |
Will Deacon | d0f60a4 | 2014-08-27 16:15:59 +0100 | [diff] [blame] | 219 | int (*of_xlate)(struct device *dev, struct of_phandle_args *args); |
Will Deacon | d0f60a4 | 2014-08-27 16:15:59 +0100 | [diff] [blame] | 220 | |
Ohad Ben-Cohen | 7d3002c | 2011-11-10 11:32:26 +0200 | [diff] [blame] | 221 | unsigned long pgsize_bitmap; |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 222 | }; |
| 223 | |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 224 | /** |
| 225 | * struct iommu_device - IOMMU core representation of one IOMMU hardware |
| 226 | * instance |
| 227 | * @list: Used by the iommu-core to keep a list of registered iommus |
| 228 | * @ops: iommu-ops for talking to this iommu |
Joerg Roedel | 39ab955 | 2017-02-01 16:56:46 +0100 | [diff] [blame] | 229 | * @dev: struct device for sysfs handling |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 230 | */ |
| 231 | struct iommu_device { |
| 232 | struct list_head list; |
| 233 | const struct iommu_ops *ops; |
Joerg Roedel | c73e1ac | 2017-02-07 18:18:46 +0100 | [diff] [blame] | 234 | struct fwnode_handle *fwnode; |
Joerg Roedel | 39ab955 | 2017-02-01 16:56:46 +0100 | [diff] [blame] | 235 | struct device dev; |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | int iommu_device_register(struct iommu_device *iommu); |
| 239 | void iommu_device_unregister(struct iommu_device *iommu); |
Joerg Roedel | 39ab955 | 2017-02-01 16:56:46 +0100 | [diff] [blame] | 240 | int iommu_device_sysfs_add(struct iommu_device *iommu, |
| 241 | struct device *parent, |
| 242 | const struct attribute_group **groups, |
| 243 | const char *fmt, ...) __printf(4, 5); |
| 244 | void iommu_device_sysfs_remove(struct iommu_device *iommu); |
Joerg Roedel | e3d10af | 2017-02-01 17:23:22 +0100 | [diff] [blame] | 245 | int iommu_device_link(struct iommu_device *iommu, struct device *link); |
| 246 | void iommu_device_unlink(struct iommu_device *iommu, struct device *link); |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 247 | |
| 248 | static inline void iommu_device_set_ops(struct iommu_device *iommu, |
| 249 | const struct iommu_ops *ops) |
| 250 | { |
| 251 | iommu->ops = ops; |
| 252 | } |
| 253 | |
Joerg Roedel | c73e1ac | 2017-02-07 18:18:46 +0100 | [diff] [blame] | 254 | static inline void iommu_device_set_fwnode(struct iommu_device *iommu, |
| 255 | struct fwnode_handle *fwnode) |
| 256 | { |
| 257 | iommu->fwnode = fwnode; |
| 258 | } |
| 259 | |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 260 | #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */ |
| 261 | #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */ |
| 262 | #define IOMMU_GROUP_NOTIFY_BIND_DRIVER 3 /* Pre Driver bind */ |
| 263 | #define IOMMU_GROUP_NOTIFY_BOUND_DRIVER 4 /* Post Driver bind */ |
| 264 | #define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER 5 /* Pre Driver unbind */ |
| 265 | #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */ |
| 266 | |
Thierry Reding | b22f643 | 2014-06-27 09:03:12 +0200 | [diff] [blame] | 267 | extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops); |
Joerg Roedel | a1b60c1 | 2011-09-06 18:46:34 +0200 | [diff] [blame] | 268 | extern bool iommu_present(struct bus_type *bus); |
Joerg Roedel | 3c0e0ca | 2014-09-03 18:47:25 +0200 | [diff] [blame] | 269 | extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap); |
Joerg Roedel | 905d66c | 2011-09-06 16:03:26 +0200 | [diff] [blame] | 270 | extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); |
Alexey Kardashevskiy | aa16bea | 2013-03-25 10:23:49 +1100 | [diff] [blame] | 271 | extern struct iommu_group *iommu_group_get_by_id(int id); |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 272 | extern void iommu_domain_free(struct iommu_domain *domain); |
| 273 | extern int iommu_attach_device(struct iommu_domain *domain, |
| 274 | struct device *dev); |
| 275 | extern void iommu_detach_device(struct iommu_domain *domain, |
| 276 | struct device *dev); |
Joerg Roedel | 2c1296d | 2015-05-28 18:41:32 +0200 | [diff] [blame] | 277 | extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev); |
Joerg Roedel | cefc53c | 2010-01-08 13:35:09 +0100 | [diff] [blame] | 278 | extern int iommu_map(struct iommu_domain *domain, unsigned long iova, |
Ohad Ben-Cohen | 7d3002c | 2011-11-10 11:32:26 +0200 | [diff] [blame] | 279 | phys_addr_t paddr, size_t size, int prot); |
| 280 | extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, |
| 281 | size_t size); |
Olav Haugan | 315786e | 2014-10-25 09:55:16 -0700 | [diff] [blame] | 282 | extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, |
| 283 | struct scatterlist *sg,unsigned int nents, |
| 284 | int prot); |
Varun Sethi | bb5547a | 2013-03-29 01:23:58 +0530 | [diff] [blame] | 285 | extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova); |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 286 | extern void iommu_set_fault_handler(struct iommu_domain *domain, |
Ohad Ben-Cohen | 77ca233 | 2012-05-21 20:20:05 +0300 | [diff] [blame] | 287 | iommu_fault_handler_t handler, void *token); |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 288 | |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 289 | extern void iommu_get_resv_regions(struct device *dev, struct list_head *list); |
| 290 | extern void iommu_put_resv_regions(struct device *dev, struct list_head *list); |
Joerg Roedel | d290f1e | 2015-05-28 18:41:36 +0200 | [diff] [blame] | 291 | extern int iommu_request_dm_for_dev(struct device *dev); |
Eric Auger | 2b20cbb | 2017-01-19 20:57:49 +0000 | [diff] [blame] | 292 | extern struct iommu_resv_region * |
| 293 | iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot, int type); |
Eric Auger | 6c65fb3 | 2017-01-19 20:57:51 +0000 | [diff] [blame] | 294 | extern int iommu_get_group_resv_regions(struct iommu_group *group, |
| 295 | struct list_head *head); |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 296 | |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 297 | extern int iommu_attach_group(struct iommu_domain *domain, |
| 298 | struct iommu_group *group); |
| 299 | extern void iommu_detach_group(struct iommu_domain *domain, |
| 300 | struct iommu_group *group); |
| 301 | extern struct iommu_group *iommu_group_alloc(void); |
| 302 | extern void *iommu_group_get_iommudata(struct iommu_group *group); |
| 303 | extern void iommu_group_set_iommudata(struct iommu_group *group, |
| 304 | void *iommu_data, |
| 305 | void (*release)(void *iommu_data)); |
| 306 | extern int iommu_group_set_name(struct iommu_group *group, const char *name); |
| 307 | extern int iommu_group_add_device(struct iommu_group *group, |
| 308 | struct device *dev); |
| 309 | extern void iommu_group_remove_device(struct device *dev); |
| 310 | extern int iommu_group_for_each_dev(struct iommu_group *group, void *data, |
| 311 | int (*fn)(struct device *, void *)); |
| 312 | extern struct iommu_group *iommu_group_get(struct device *dev); |
Robin Murphy | 13f59a7 | 2016-11-11 17:59:21 +0000 | [diff] [blame] | 313 | extern struct iommu_group *iommu_group_ref_get(struct iommu_group *group); |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 314 | extern void iommu_group_put(struct iommu_group *group); |
| 315 | extern int iommu_group_register_notifier(struct iommu_group *group, |
| 316 | struct notifier_block *nb); |
| 317 | extern int iommu_group_unregister_notifier(struct iommu_group *group, |
| 318 | struct notifier_block *nb); |
| 319 | extern int iommu_group_id(struct iommu_group *group); |
Alex Williamson | 104a1c1 | 2014-07-03 09:51:18 -0600 | [diff] [blame] | 320 | extern struct iommu_group *iommu_group_get_for_dev(struct device *dev); |
Joerg Roedel | 6827ca8 | 2015-05-28 18:41:35 +0200 | [diff] [blame] | 321 | extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *); |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 322 | |
Joerg Roedel | 0cd76dd | 2012-01-26 19:40:52 +0100 | [diff] [blame] | 323 | extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr, |
| 324 | void *data); |
| 325 | extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr, |
| 326 | void *data); |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 327 | |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 328 | /* Window handling function prototypes */ |
| 329 | extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr, |
Varun Sethi | 80f97f0 | 2013-03-29 01:24:00 +0530 | [diff] [blame] | 330 | phys_addr_t offset, u64 size, |
| 331 | int prot); |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 332 | extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr); |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 333 | |
Joerg Roedel | 207c6e3 | 2017-04-26 15:39:28 +0200 | [diff] [blame^] | 334 | extern int report_iommu_fault(struct iommu_domain *domain, struct device *dev, |
| 335 | unsigned long iova, int flags); |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 336 | |
Olav Haugan | 315786e | 2014-10-25 09:55:16 -0700 | [diff] [blame] | 337 | static inline size_t iommu_map_sg(struct iommu_domain *domain, |
| 338 | unsigned long iova, struct scatterlist *sg, |
| 339 | unsigned int nents, int prot) |
| 340 | { |
| 341 | return domain->ops->map_sg(domain, iova, sg, nents, prot); |
| 342 | } |
| 343 | |
Joerg Roedel | 5e62292 | 2015-10-21 23:51:37 +0200 | [diff] [blame] | 344 | /* PCI device grouping function */ |
| 345 | extern struct iommu_group *pci_device_group(struct device *dev); |
Joerg Roedel | 6eab556 | 2015-10-21 23:51:38 +0200 | [diff] [blame] | 346 | /* Generic device grouping function */ |
| 347 | extern struct iommu_group *generic_device_group(struct device *dev); |
Joerg Roedel | 5e62292 | 2015-10-21 23:51:37 +0200 | [diff] [blame] | 348 | |
Robin Murphy | 57f98d2 | 2016-09-13 10:54:14 +0100 | [diff] [blame] | 349 | /** |
| 350 | * struct iommu_fwspec - per-device IOMMU instance data |
| 351 | * @ops: ops for this device's IOMMU |
| 352 | * @iommu_fwnode: firmware handle for this device's IOMMU |
| 353 | * @iommu_priv: IOMMU driver private data for this device |
| 354 | * @num_ids: number of associated device IDs |
| 355 | * @ids: IDs which this device may present to the IOMMU |
| 356 | */ |
| 357 | struct iommu_fwspec { |
| 358 | const struct iommu_ops *ops; |
| 359 | struct fwnode_handle *iommu_fwnode; |
| 360 | void *iommu_priv; |
| 361 | unsigned int num_ids; |
| 362 | u32 ids[1]; |
| 363 | }; |
| 364 | |
| 365 | int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, |
| 366 | const struct iommu_ops *ops); |
| 367 | void iommu_fwspec_free(struct device *dev); |
| 368 | int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids); |
Joerg Roedel | 534766d | 2017-01-31 16:58:42 +0100 | [diff] [blame] | 369 | const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode); |
Robin Murphy | 57f98d2 | 2016-09-13 10:54:14 +0100 | [diff] [blame] | 370 | |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 371 | #else /* CONFIG_IOMMU_API */ |
| 372 | |
Joerg Roedel | 39d4ebb | 2011-09-06 16:48:40 +0200 | [diff] [blame] | 373 | struct iommu_ops {}; |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 374 | struct iommu_group {}; |
Robin Murphy | 57f98d2 | 2016-09-13 10:54:14 +0100 | [diff] [blame] | 375 | struct iommu_fwspec {}; |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 376 | struct iommu_device {}; |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 377 | |
Joerg Roedel | a1b60c1 | 2011-09-06 18:46:34 +0200 | [diff] [blame] | 378 | static inline bool iommu_present(struct bus_type *bus) |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 379 | { |
| 380 | return false; |
| 381 | } |
| 382 | |
Joerg Roedel | 3c0e0ca | 2014-09-03 18:47:25 +0200 | [diff] [blame] | 383 | static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap) |
| 384 | { |
| 385 | return false; |
| 386 | } |
| 387 | |
Joerg Roedel | 905d66c | 2011-09-06 16:03:26 +0200 | [diff] [blame] | 388 | static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 389 | { |
| 390 | return NULL; |
| 391 | } |
| 392 | |
Alexey Kardashevskiy | b62dfd2 | 2013-11-21 17:41:14 +1100 | [diff] [blame] | 393 | static inline struct iommu_group *iommu_group_get_by_id(int id) |
| 394 | { |
| 395 | return NULL; |
| 396 | } |
| 397 | |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 398 | static inline void iommu_domain_free(struct iommu_domain *domain) |
| 399 | { |
| 400 | } |
| 401 | |
| 402 | static inline int iommu_attach_device(struct iommu_domain *domain, |
| 403 | struct device *dev) |
| 404 | { |
| 405 | return -ENODEV; |
| 406 | } |
| 407 | |
| 408 | static inline void iommu_detach_device(struct iommu_domain *domain, |
| 409 | struct device *dev) |
| 410 | { |
| 411 | } |
| 412 | |
Joerg Roedel | 2c1296d | 2015-05-28 18:41:32 +0200 | [diff] [blame] | 413 | static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev) |
| 414 | { |
| 415 | return NULL; |
| 416 | } |
| 417 | |
Joerg Roedel | cefc53c | 2010-01-08 13:35:09 +0100 | [diff] [blame] | 418 | static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, |
| 419 | phys_addr_t paddr, int gfp_order, int prot) |
| 420 | { |
| 421 | return -ENODEV; |
| 422 | } |
| 423 | |
| 424 | static inline int iommu_unmap(struct iommu_domain *domain, unsigned long iova, |
| 425 | int gfp_order) |
| 426 | { |
| 427 | return -ENODEV; |
| 428 | } |
| 429 | |
Olav Haugan | 315786e | 2014-10-25 09:55:16 -0700 | [diff] [blame] | 430 | static inline size_t iommu_map_sg(struct iommu_domain *domain, |
| 431 | unsigned long iova, struct scatterlist *sg, |
| 432 | unsigned int nents, int prot) |
| 433 | { |
| 434 | return -ENODEV; |
| 435 | } |
| 436 | |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 437 | static inline int iommu_domain_window_enable(struct iommu_domain *domain, |
| 438 | u32 wnd_nr, phys_addr_t paddr, |
Varun Sethi | 80f97f0 | 2013-03-29 01:24:00 +0530 | [diff] [blame] | 439 | u64 size, int prot) |
Joerg Roedel | d7787d5 | 2013-01-29 14:26:20 +0100 | [diff] [blame] | 440 | { |
| 441 | return -ENODEV; |
| 442 | } |
| 443 | |
| 444 | static inline void iommu_domain_window_disable(struct iommu_domain *domain, |
| 445 | u32 wnd_nr) |
| 446 | { |
| 447 | } |
| 448 | |
Varun Sethi | bb5547a | 2013-03-29 01:23:58 +0530 | [diff] [blame] | 449 | static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 450 | { |
| 451 | return 0; |
| 452 | } |
| 453 | |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 454 | static inline void iommu_set_fault_handler(struct iommu_domain *domain, |
Ohad Ben-Cohen | 77ca233 | 2012-05-21 20:20:05 +0300 | [diff] [blame] | 455 | iommu_fault_handler_t handler, void *token) |
Ohad Ben-Cohen | 4f3f8d9 | 2011-09-13 15:25:23 -0400 | [diff] [blame] | 456 | { |
| 457 | } |
| 458 | |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 459 | static inline void iommu_get_resv_regions(struct device *dev, |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 460 | struct list_head *list) |
| 461 | { |
| 462 | } |
| 463 | |
Eric Auger | e5b5234 | 2017-01-19 20:57:47 +0000 | [diff] [blame] | 464 | static inline void iommu_put_resv_regions(struct device *dev, |
Joerg Roedel | a1015c2 | 2015-05-28 18:41:33 +0200 | [diff] [blame] | 465 | struct list_head *list) |
| 466 | { |
| 467 | } |
| 468 | |
Eric Auger | 6c65fb3 | 2017-01-19 20:57:51 +0000 | [diff] [blame] | 469 | static inline int iommu_get_group_resv_regions(struct iommu_group *group, |
| 470 | struct list_head *head) |
| 471 | { |
| 472 | return -ENODEV; |
| 473 | } |
| 474 | |
Joerg Roedel | d290f1e | 2015-05-28 18:41:36 +0200 | [diff] [blame] | 475 | static inline int iommu_request_dm_for_dev(struct device *dev) |
| 476 | { |
| 477 | return -ENODEV; |
| 478 | } |
| 479 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 480 | static inline int iommu_attach_group(struct iommu_domain *domain, |
| 481 | struct iommu_group *group) |
Alex Williamson | 1460432 | 2011-10-21 15:56:05 -0400 | [diff] [blame] | 482 | { |
| 483 | return -ENODEV; |
| 484 | } |
| 485 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 486 | static inline void iommu_detach_group(struct iommu_domain *domain, |
| 487 | struct iommu_group *group) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 488 | { |
| 489 | } |
| 490 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 491 | static inline struct iommu_group *iommu_group_alloc(void) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 492 | { |
| 493 | return ERR_PTR(-ENODEV); |
| 494 | } |
| 495 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 496 | static inline void *iommu_group_get_iommudata(struct iommu_group *group) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 497 | { |
| 498 | return NULL; |
| 499 | } |
| 500 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 501 | static inline void iommu_group_set_iommudata(struct iommu_group *group, |
| 502 | void *iommu_data, |
| 503 | void (*release)(void *iommu_data)) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 504 | { |
| 505 | } |
| 506 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 507 | static inline int iommu_group_set_name(struct iommu_group *group, |
| 508 | const char *name) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 509 | { |
| 510 | return -ENODEV; |
| 511 | } |
| 512 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 513 | static inline int iommu_group_add_device(struct iommu_group *group, |
| 514 | struct device *dev) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 515 | { |
| 516 | return -ENODEV; |
| 517 | } |
| 518 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 519 | static inline void iommu_group_remove_device(struct device *dev) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 520 | { |
| 521 | } |
| 522 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 523 | static inline int iommu_group_for_each_dev(struct iommu_group *group, |
| 524 | void *data, |
| 525 | int (*fn)(struct device *, void *)) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 526 | { |
| 527 | return -ENODEV; |
| 528 | } |
| 529 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 530 | static inline struct iommu_group *iommu_group_get(struct device *dev) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 531 | { |
| 532 | return NULL; |
| 533 | } |
| 534 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 535 | static inline void iommu_group_put(struct iommu_group *group) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 536 | { |
| 537 | } |
| 538 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 539 | static inline int iommu_group_register_notifier(struct iommu_group *group, |
| 540 | struct notifier_block *nb) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 541 | { |
| 542 | return -ENODEV; |
| 543 | } |
| 544 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 545 | static inline int iommu_group_unregister_notifier(struct iommu_group *group, |
| 546 | struct notifier_block *nb) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 547 | { |
| 548 | return 0; |
| 549 | } |
| 550 | |
Alex Williamson | bef83de | 2012-09-24 21:23:25 -0600 | [diff] [blame] | 551 | static inline int iommu_group_id(struct iommu_group *group) |
Alex Williamson | d72e31c | 2012-05-30 14:18:53 -0600 | [diff] [blame] | 552 | { |
| 553 | return -ENODEV; |
| 554 | } |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 555 | |
Joerg Roedel | 0cd76dd | 2012-01-26 19:40:52 +0100 | [diff] [blame] | 556 | static inline int iommu_domain_get_attr(struct iommu_domain *domain, |
| 557 | enum iommu_attr attr, void *data) |
| 558 | { |
| 559 | return -EINVAL; |
| 560 | } |
| 561 | |
| 562 | static inline int iommu_domain_set_attr(struct iommu_domain *domain, |
| 563 | enum iommu_attr attr, void *data) |
| 564 | { |
| 565 | return -EINVAL; |
| 566 | } |
| 567 | |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 568 | static inline int iommu_device_register(struct iommu_device *iommu) |
Alex Williamson | c61959e | 2014-06-12 16:12:24 -0600 | [diff] [blame] | 569 | { |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 570 | return -ENODEV; |
Alex Williamson | c61959e | 2014-06-12 16:12:24 -0600 | [diff] [blame] | 571 | } |
| 572 | |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 573 | static inline void iommu_device_set_ops(struct iommu_device *iommu, |
| 574 | const struct iommu_ops *ops) |
| 575 | { |
| 576 | } |
| 577 | |
Joerg Roedel | c73e1ac | 2017-02-07 18:18:46 +0100 | [diff] [blame] | 578 | static inline void iommu_device_set_fwnode(struct iommu_device *iommu, |
| 579 | struct fwnode_handle *fwnode) |
| 580 | { |
| 581 | } |
| 582 | |
Joerg Roedel | b0119e8 | 2017-02-01 13:23:08 +0100 | [diff] [blame] | 583 | static inline void iommu_device_unregister(struct iommu_device *iommu) |
| 584 | { |
| 585 | } |
| 586 | |
Joerg Roedel | 39ab955 | 2017-02-01 16:56:46 +0100 | [diff] [blame] | 587 | static inline int iommu_device_sysfs_add(struct iommu_device *iommu, |
| 588 | struct device *parent, |
| 589 | const struct attribute_group **groups, |
| 590 | const char *fmt, ...) |
| 591 | { |
| 592 | return -ENODEV; |
| 593 | } |
| 594 | |
| 595 | static inline void iommu_device_sysfs_remove(struct iommu_device *iommu) |
Alex Williamson | c61959e | 2014-06-12 16:12:24 -0600 | [diff] [blame] | 596 | { |
| 597 | } |
| 598 | |
Alex Williamson | e09f8ea | 2014-07-07 14:31:36 -0600 | [diff] [blame] | 599 | static inline int iommu_device_link(struct device *dev, struct device *link) |
Alex Williamson | c61959e | 2014-06-12 16:12:24 -0600 | [diff] [blame] | 600 | { |
| 601 | return -EINVAL; |
| 602 | } |
| 603 | |
Alex Williamson | e09f8ea | 2014-07-07 14:31:36 -0600 | [diff] [blame] | 604 | static inline void iommu_device_unlink(struct device *dev, struct device *link) |
Alex Williamson | c61959e | 2014-06-12 16:12:24 -0600 | [diff] [blame] | 605 | { |
| 606 | } |
| 607 | |
Robin Murphy | 57f98d2 | 2016-09-13 10:54:14 +0100 | [diff] [blame] | 608 | static inline int iommu_fwspec_init(struct device *dev, |
| 609 | struct fwnode_handle *iommu_fwnode, |
| 610 | const struct iommu_ops *ops) |
| 611 | { |
| 612 | return -ENODEV; |
| 613 | } |
| 614 | |
| 615 | static inline void iommu_fwspec_free(struct device *dev) |
| 616 | { |
| 617 | } |
| 618 | |
| 619 | static inline int iommu_fwspec_add_ids(struct device *dev, u32 *ids, |
| 620 | int num_ids) |
| 621 | { |
| 622 | return -ENODEV; |
| 623 | } |
| 624 | |
Lorenzo Pieralisi | e4f10ff | 2016-11-21 10:01:36 +0000 | [diff] [blame] | 625 | static inline |
Joerg Roedel | 534766d | 2017-01-31 16:58:42 +0100 | [diff] [blame] | 626 | const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode) |
Lorenzo Pieralisi | e4f10ff | 2016-11-21 10:01:36 +0000 | [diff] [blame] | 627 | { |
| 628 | return NULL; |
| 629 | } |
| 630 | |
Joerg Roedel | 4a77a6c | 2008-11-26 17:02:33 +0100 | [diff] [blame] | 631 | #endif /* CONFIG_IOMMU_API */ |
| 632 | |
| 633 | #endif /* __LINUX_IOMMU_H */ |