OSDN Git Service

lz4: fix wrong compress buffer size for 64-bits
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / iommu.h
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
22 #include <linux/errno.h>
23 #include <linux/err.h>
24 #include <linux/of.h>
25 #include <linux/types.h>
26 #include <trace/events/iommu.h>
27
28 #define IOMMU_READ      (1 << 0)
29 #define IOMMU_WRITE     (1 << 1)
30 #define IOMMU_CACHE     (1 << 2) /* DMA cache coherency */
31 #define IOMMU_NOEXEC    (1 << 3)
32 #define IOMMU_PRIV      (1 << 4)
33 #define IOMMU_DEVICE    (1 << 5) /* Indicates access to device memory */
34
35 struct iommu_ops;
36 struct iommu_group;
37 struct bus_type;
38 struct device;
39 struct iommu_domain;
40 struct notifier_block;
41
42 /* iommu fault flags */
43 #define IOMMU_FAULT_READ                (1 << 0)
44 #define IOMMU_FAULT_WRITE               (1 << 1)
45 #define IOMMU_FAULT_TRANSLATION         (1 << 2)
46 #define IOMMU_FAULT_PERMISSION          (1 << 3)
47 #define IOMMU_FAULT_EXTERNAL            (1 << 4)
48 #define IOMMU_FAULT_TRANSACTION_STALLED (1 << 5)
49
50 typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
51                         struct device *, unsigned long, int, void *);
52
53 struct iommu_domain_geometry {
54         dma_addr_t aperture_start; /* First address that can be mapped    */
55         dma_addr_t aperture_end;   /* Last address that can be mapped     */
56         bool force_aperture;       /* DMA only allowed in mappable range? */
57 };
58
59 struct iommu_pgtbl_info {
60         void *pmds;
61 };
62
63 /* Domain feature flags */
64 #define __IOMMU_DOMAIN_PAGING   (1U << 0)  /* Support for iommu_map/unmap */
65 #define __IOMMU_DOMAIN_DMA_API  (1U << 1)  /* Domain for use in DMA-API
66                                               implementation              */
67 #define __IOMMU_DOMAIN_PT       (1U << 2)  /* Domain is identity mapped   */
68
69 /*
70  * This are the possible domain-types
71  *
72  *      IOMMU_DOMAIN_BLOCKED    - All DMA is blocked, can be used to isolate
73  *                                devices
74  *      IOMMU_DOMAIN_IDENTITY   - DMA addresses are system physical addresses
75  *      IOMMU_DOMAIN_UNMANAGED  - DMA mappings managed by IOMMU-API user, used
76  *                                for VMs
77  *      IOMMU_DOMAIN_DMA        - Internally used for DMA-API implementations.
78  *                                This flag allows IOMMU drivers to implement
79  *                                certain optimizations for these domains
80  */
81 #define IOMMU_DOMAIN_BLOCKED    (0U)
82 #define IOMMU_DOMAIN_IDENTITY   (__IOMMU_DOMAIN_PT)
83 #define IOMMU_DOMAIN_UNMANAGED  (__IOMMU_DOMAIN_PAGING)
84 #define IOMMU_DOMAIN_DMA        (__IOMMU_DOMAIN_PAGING |        \
85                                  __IOMMU_DOMAIN_DMA_API)
86
87 struct iommu_domain {
88         unsigned type;
89         const struct iommu_ops *ops;
90         iommu_fault_handler_t handler;
91         void *handler_token;
92         struct iommu_domain_geometry geometry;
93         void *iova_cookie;
94 };
95
96 enum iommu_cap {
97         IOMMU_CAP_CACHE_COHERENCY,      /* IOMMU can enforce cache coherent DMA
98                                            transactions */
99         IOMMU_CAP_INTR_REMAP,           /* IOMMU supports interrupt isolation */
100         IOMMU_CAP_NOEXEC,               /* IOMMU_NOEXEC flag */
101 };
102
103 /*
104  * Following constraints are specifc to FSL_PAMUV1:
105  *  -aperture must be power of 2, and naturally aligned
106  *  -number of windows must be power of 2, and address space size
107  *   of each window is determined by aperture size / # of windows
108  *  -the actual size of the mapped region of a window must be power
109  *   of 2 starting with 4KB and physical address must be naturally
110  *   aligned.
111  * DOMAIN_ATTR_FSL_PAMUV1 corresponds to the above mentioned contraints.
112  * The caller can invoke iommu_domain_get_attr to check if the underlying
113  * iommu implementation supports these constraints.
114  */
115
116 enum iommu_attr {
117         DOMAIN_ATTR_GEOMETRY,
118         DOMAIN_ATTR_PAGING,
119         DOMAIN_ATTR_WINDOWS,
120         DOMAIN_ATTR_FSL_PAMU_STASH,
121         DOMAIN_ATTR_FSL_PAMU_ENABLE,
122         DOMAIN_ATTR_FSL_PAMUV1,
123         DOMAIN_ATTR_NESTING,    /* two stages of translation */
124         DOMAIN_ATTR_PT_BASE_ADDR,
125         DOMAIN_ATTR_SECURE_VMID,
126         DOMAIN_ATTR_ATOMIC,
127         DOMAIN_ATTR_CONTEXT_BANK,
128         DOMAIN_ATTR_TTBR0,
129         DOMAIN_ATTR_CONTEXTIDR,
130         DOMAIN_ATTR_PROCID,
131         DOMAIN_ATTR_DYNAMIC,
132         DOMAIN_ATTR_NON_FATAL_FAULTS,
133         DOMAIN_ATTR_S1_BYPASS,
134         DOMAIN_ATTR_FAST,
135         DOMAIN_ATTR_PGTBL_INFO,
136         DOMAIN_ATTR_EARLY_MAP,
137         DOMAIN_ATTR_PAGE_TABLE_IS_COHERENT,
138         DOMAIN_ATTR_PAGE_TABLE_FORCE_COHERENT,
139         DOMAIN_ATTR_ENABLE_TTBR1,
140         DOMAIN_ATTR_CB_STALL_DISABLE,
141         DOMAIN_ATTR_MAX,
142 };
143
144 extern struct dentry *iommu_debugfs_top;
145
146 /**
147  * struct iommu_dm_region - descriptor for a direct mapped memory region
148  * @list: Linked list pointers
149  * @start: System physical start address of the region
150  * @length: Length of the region in bytes
151  * @prot: IOMMU Protection flags (READ/WRITE/...)
152  */
153 struct iommu_dm_region {
154         struct list_head        list;
155         phys_addr_t             start;
156         size_t                  length;
157         int                     prot;
158 };
159
160 #ifdef CONFIG_IOMMU_API
161
162 /**
163  * struct iommu_ops - iommu ops and capabilities
164  * @domain_init: init iommu domain
165  * @domain_destroy: destroy iommu domain
166  * @attach_dev: attach device to an iommu domain
167  * @detach_dev: detach device from an iommu domain
168  * @map: map a physically contiguous memory region to an iommu domain
169  * @unmap: unmap a physically contiguous memory region from an iommu domain
170  * @map_sg: map a scatter-gather list of physically contiguous memory chunks
171  * to an iommu domain
172  * @iova_to_phys: translate iova to physical address
173  * @iova_to_phys_hard: translate iova to physical address using IOMMU hardware
174  * @add_device: add device to iommu grouping
175  * @remove_device: remove device from iommu grouping
176  * @domain_get_attr: Query domain attributes
177  * @domain_set_attr: Change domain attributes
178  * @of_xlate: add OF master IDs to iommu grouping
179  * @pgsize_bitmap: bitmap of supported page sizes
180  * @get_pgsize_bitmap: gets a bitmap of supported page sizes for a domain
181  *                     This takes precedence over @pgsize_bitmap.
182  * @trigger_fault: trigger a fault on the device attached to an iommu domain
183  * @reg_read: read an IOMMU register
184  * @reg_write: write an IOMMU register
185  * @tlbi_domain: Invalidate all TLBs covering an iommu domain
186  * @enable_config_clocks: Enable all config clocks for this domain's IOMMU
187  * @disable_config_clocks: Disable all config clocks for this domain's IOMMU
188  * @priv: per-instance data private to the iommu driver
189  */
190 struct iommu_ops {
191         bool (*capable)(enum iommu_cap);
192
193         /* Domain allocation and freeing by the iommu driver */
194         struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
195         void (*domain_free)(struct iommu_domain *);
196
197         int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
198         void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
199         int (*map)(struct iommu_domain *domain, unsigned long iova,
200                    phys_addr_t paddr, size_t size, int prot);
201         size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
202                      size_t size);
203         size_t (*map_sg)(struct iommu_domain *domain, unsigned long iova,
204                          struct scatterlist *sg, unsigned int nents, int prot);
205         phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
206         phys_addr_t (*iova_to_phys_hard)(struct iommu_domain *domain,
207                                          dma_addr_t iova);
208         int (*add_device)(struct device *dev);
209         void (*remove_device)(struct device *dev);
210         struct iommu_group *(*device_group)(struct device *dev);
211         int (*domain_get_attr)(struct iommu_domain *domain,
212                                enum iommu_attr attr, void *data);
213         int (*domain_set_attr)(struct iommu_domain *domain,
214                                enum iommu_attr attr, void *data);
215
216         /* Request/Free a list of direct mapping requirements for a device */
217         void (*get_dm_regions)(struct device *dev, struct list_head *list);
218         void (*put_dm_regions)(struct device *dev, struct list_head *list);
219
220         /* Window handling functions */
221         int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
222                                     phys_addr_t paddr, u64 size, int prot);
223         void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);
224         /* Set the numer of window per domain */
225         int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count);
226         /* Get the numer of window per domain */
227         u32 (*domain_get_windows)(struct iommu_domain *domain);
228         int (*dma_supported)(struct iommu_domain *domain, struct device *dev,
229                              u64 mask);
230         void (*trigger_fault)(struct iommu_domain *domain, unsigned long flags);
231         unsigned long (*reg_read)(struct iommu_domain *domain,
232                                   unsigned long offset);
233         void (*reg_write)(struct iommu_domain *domain, unsigned long val,
234                           unsigned long offset);
235         void (*tlbi_domain)(struct iommu_domain *domain);
236         int (*enable_config_clocks)(struct iommu_domain *domain);
237         void (*disable_config_clocks)(struct iommu_domain *domain);
238         uint64_t (*iova_to_pte)(struct iommu_domain *domain,
239                          dma_addr_t iova);
240
241 #ifdef CONFIG_OF_IOMMU
242         int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
243 #endif
244
245         unsigned long (*get_pgsize_bitmap)(struct iommu_domain *domain);
246         bool (*is_iova_coherent)(struct iommu_domain *domain, dma_addr_t iova);
247         unsigned long pgsize_bitmap;
248         void *priv;
249 };
250
251 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE           1 /* Device added */
252 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE           2 /* Pre Device removed */
253 #define IOMMU_GROUP_NOTIFY_BIND_DRIVER          3 /* Pre Driver bind */
254 #define IOMMU_GROUP_NOTIFY_BOUND_DRIVER         4 /* Post Driver bind */
255 #define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER        5 /* Pre Driver unbind */
256 #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER       6 /* Post Driver unbind */
257
258 extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
259 extern bool iommu_present(struct bus_type *bus);
260 extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
261 extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
262 extern struct iommu_group *iommu_group_get_by_id(int id);
263 extern void iommu_domain_free(struct iommu_domain *domain);
264 extern int iommu_attach_device(struct iommu_domain *domain,
265                                struct device *dev);
266 extern void iommu_detach_device(struct iommu_domain *domain,
267                                 struct device *dev);
268 extern size_t iommu_pgsize(unsigned long pgsize_bitmap,
269                            unsigned long addr_merge, size_t size);
270 extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
271 extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
272                      phys_addr_t paddr, size_t size, int prot);
273 extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
274                        size_t size);
275 extern int iommu_unmap_range(struct iommu_domain *domain, unsigned int iova,
276                       unsigned int len);
277 extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
278                                 struct scatterlist *sg,unsigned int nents,
279                                 int prot);
280 extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
281 extern phys_addr_t iommu_iova_to_phys_hard(struct iommu_domain *domain,
282                                            dma_addr_t iova);
283 extern bool iommu_is_iova_coherent(struct iommu_domain *domain,
284                                 dma_addr_t iova);
285 extern void iommu_set_fault_handler(struct iommu_domain *domain,
286                         iommu_fault_handler_t handler, void *token);
287 extern void iommu_trigger_fault(struct iommu_domain *domain,
288                                 unsigned long flags);
289 extern unsigned long iommu_reg_read(struct iommu_domain *domain,
290                                     unsigned long offset);
291 extern void iommu_reg_write(struct iommu_domain *domain, unsigned long offset,
292                             unsigned long val);
293
294 extern void iommu_get_dm_regions(struct device *dev, struct list_head *list);
295 extern void iommu_put_dm_regions(struct device *dev, struct list_head *list);
296 extern int iommu_request_dm_for_dev(struct device *dev);
297
298 extern int iommu_attach_group(struct iommu_domain *domain,
299                               struct iommu_group *group);
300 extern void iommu_detach_group(struct iommu_domain *domain,
301                                struct iommu_group *group);
302 extern struct iommu_group *iommu_group_alloc(void);
303 extern void *iommu_group_get_iommudata(struct iommu_group *group);
304 extern void iommu_group_set_iommudata(struct iommu_group *group,
305                                       void *iommu_data,
306                                       void (*release)(void *iommu_data));
307 extern int iommu_group_set_name(struct iommu_group *group, const char *name);
308 extern int iommu_group_add_device(struct iommu_group *group,
309                                   struct device *dev);
310 extern void iommu_group_remove_device(struct device *dev);
311 extern int iommu_group_for_each_dev(struct iommu_group *group, void *data,
312                                     int (*fn)(struct device *, void *));
313 extern struct iommu_group *iommu_group_get(struct device *dev);
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);
320 extern struct iommu_group *iommu_group_get_for_dev(struct device *dev);
321 extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
322
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);
327 struct device *iommu_device_create(struct device *parent, void *drvdata,
328                                    const struct attribute_group **groups,
329                                    const char *fmt, ...) __printf(4, 5);
330 void iommu_device_destroy(struct device *dev);
331 int iommu_device_link(struct device *dev, struct device *link);
332 void iommu_device_unlink(struct device *dev, struct device *link);
333
334 /* Window handling function prototypes */
335 extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
336                                       phys_addr_t offset, u64 size,
337                                       int prot);
338 extern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr);
339
340 extern uint64_t iommu_iova_to_pte(struct iommu_domain *domain,
341             dma_addr_t iova);
342 /**
343  * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework
344  * @domain: the iommu domain where the fault has happened
345  * @dev: the device where the fault has happened
346  * @iova: the faulting address
347  * @flags: mmu fault flags (e.g. IOMMU_FAULT_READ/IOMMU_FAULT_WRITE/...)
348  *
349  * This function should be called by the low-level IOMMU implementations
350  * whenever IOMMU faults happen, to allow high-level users, that are
351  * interested in such events, to know about them.
352  *
353  * This event may be useful for several possible use cases:
354  * - mere logging of the event
355  * - dynamic TLB/PTE loading
356  * - if restarting of the faulting device is required
357  *
358  * Returns 0 on success and an appropriate error code otherwise (if dynamic
359  * PTE/TLB loading will one day be supported, implementations will be able
360  * to tell whether it succeeded or not according to this return value).
361  *
362  * Specifically, -ENOSYS is returned if a fault handler isn't installed
363  * (though fault handlers can also return -ENOSYS, in case they want to
364  * elicit the default behavior of the IOMMU drivers).
365
366  * Client fault handler returns -EBUSY to signal to the IOMMU driver
367  * that the client will take responsibility for any further fault
368  * handling, including clearing fault status registers or retrying
369  * the faulting transaction.
370  */
371 static inline int report_iommu_fault(struct iommu_domain *domain,
372                 struct device *dev, unsigned long iova, int flags)
373 {
374         int ret = -ENOSYS;
375
376         /*
377          * if upper layers showed interest and installed a fault handler,
378          * invoke it.
379          */
380         if (domain->handler)
381                 ret = domain->handler(domain, dev, iova, flags,
382                                                 domain->handler_token);
383
384         trace_io_page_fault(dev, iova, flags);
385         return ret;
386 }
387
388 static inline size_t iommu_map_sg(struct iommu_domain *domain,
389                                   unsigned long iova, struct scatterlist *sg,
390                                   unsigned int nents, int prot)
391 {
392         size_t ret;
393
394         trace_map_sg_start(iova, nents);
395         ret = domain->ops->map_sg(domain, iova, sg, nents, prot);
396         trace_map_sg_end(iova, nents);
397         return ret;
398 }
399
400 extern int iommu_dma_supported(struct iommu_domain *domain, struct device *dev,
401                                u64 mask);
402
403 /* PCI device grouping function */
404 extern struct iommu_group *pci_device_group(struct device *dev);
405 /* Generic device grouping function */
406 extern struct iommu_group *generic_device_group(struct device *dev);
407
408 static inline void iommu_tlbiall(struct iommu_domain *domain)
409 {
410         if (domain->ops->tlbi_domain)
411                 domain->ops->tlbi_domain(domain);
412 }
413
414 static inline int iommu_enable_config_clocks(struct iommu_domain *domain)
415 {
416         if (domain->ops->enable_config_clocks)
417                 return domain->ops->enable_config_clocks(domain);
418         return 0;
419 }
420
421 static inline void iommu_disable_config_clocks(struct iommu_domain *domain)
422 {
423         if (domain->ops->disable_config_clocks)
424                 domain->ops->disable_config_clocks(domain);
425 }
426
427 #else /* CONFIG_IOMMU_API */
428
429 struct iommu_ops {};
430 struct iommu_group {};
431
432 static inline bool iommu_present(struct bus_type *bus)
433 {
434         return false;
435 }
436
437 static inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
438 {
439         return false;
440 }
441
442 static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
443 {
444         return NULL;
445 }
446
447 static inline struct iommu_group *iommu_group_get_by_id(int id)
448 {
449         return NULL;
450 }
451
452 static inline void iommu_domain_free(struct iommu_domain *domain)
453 {
454 }
455
456 static inline int iommu_attach_device(struct iommu_domain *domain,
457                                       struct device *dev)
458 {
459         return -ENODEV;
460 }
461
462 static inline void iommu_detach_device(struct iommu_domain *domain,
463                                        struct device *dev)
464 {
465 }
466
467 static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
468 {
469         return NULL;
470 }
471
472 static inline int iommu_map(struct iommu_domain *domain, unsigned long iova,
473                             phys_addr_t paddr, int gfp_order, int prot)
474 {
475         return -ENODEV;
476 }
477
478 static inline int iommu_unmap(struct iommu_domain *domain, unsigned long iova,
479                               int gfp_order)
480 {
481         return -ENODEV;
482 }
483
484 static inline int iommu_unmap_range(struct iommu_domain *domain,
485                                 unsigned int iova, unsigned int len)
486 {
487         return -ENODEV;
488 }
489
490 static inline size_t iommu_map_sg(struct iommu_domain *domain,
491                                   unsigned long iova, struct scatterlist *sg,
492                                   unsigned int nents, int prot)
493 {
494         return -ENODEV;
495 }
496
497 static inline int iommu_domain_window_enable(struct iommu_domain *domain,
498                                              u32 wnd_nr, phys_addr_t paddr,
499                                              u64 size, int prot)
500 {
501         return -ENODEV;
502 }
503
504 static inline void iommu_domain_window_disable(struct iommu_domain *domain,
505                                                u32 wnd_nr)
506 {
507 }
508
509 static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
510 {
511         return 0;
512 }
513
514 static inline phys_addr_t iommu_iova_to_phys_hard(struct iommu_domain *domain,
515                                                   dma_addr_t iova)
516 {
517         return 0;
518 }
519
520 static inline bool iommu_is_iova_coherent(struct iommu_domain *domain,
521                                           dma_addr_t iova)
522 {
523         return 0;
524 }
525
526 static inline void iommu_set_fault_handler(struct iommu_domain *domain,
527                                 iommu_fault_handler_t handler, void *token)
528 {
529 }
530
531 static inline void iommu_trigger_fault(struct iommu_domain *domain,
532                                        unsigned long flags)
533 {
534 }
535
536 static inline unsigned long iommu_reg_read(struct iommu_domain *domain,
537                                            unsigned long offset)
538 {
539         return 0;
540 }
541
542 static inline void iommu_reg_write(struct iommu_domain *domain,
543                                    unsigned long val, unsigned long offset)
544 {
545 }
546
547 static inline void iommu_get_dm_regions(struct device *dev,
548                                         struct list_head *list)
549 {
550 }
551
552 static inline void iommu_put_dm_regions(struct device *dev,
553                                         struct list_head *list)
554 {
555 }
556
557 static inline int iommu_request_dm_for_dev(struct device *dev)
558 {
559         return -ENODEV;
560 }
561
562 static inline int iommu_attach_group(struct iommu_domain *domain,
563                                      struct iommu_group *group)
564 {
565         return -ENODEV;
566 }
567
568 static inline void iommu_detach_group(struct iommu_domain *domain,
569                                       struct iommu_group *group)
570 {
571 }
572
573 static inline struct iommu_group *iommu_group_alloc(void)
574 {
575         return ERR_PTR(-ENODEV);
576 }
577
578 static inline void *iommu_group_get_iommudata(struct iommu_group *group)
579 {
580         return NULL;
581 }
582
583 static inline void iommu_group_set_iommudata(struct iommu_group *group,
584                                              void *iommu_data,
585                                              void (*release)(void *iommu_data))
586 {
587 }
588
589 static inline int iommu_group_set_name(struct iommu_group *group,
590                                        const char *name)
591 {
592         return -ENODEV;
593 }
594
595 static inline int iommu_group_add_device(struct iommu_group *group,
596                                          struct device *dev)
597 {
598         return -ENODEV;
599 }
600
601 static inline void iommu_group_remove_device(struct device *dev)
602 {
603 }
604
605 static inline int iommu_group_for_each_dev(struct iommu_group *group,
606                                            void *data,
607                                            int (*fn)(struct device *, void *))
608 {
609         return -ENODEV;
610 }
611
612 static inline struct iommu_group *iommu_group_get(struct device *dev)
613 {
614         return NULL;
615 }
616
617 static inline void iommu_group_put(struct iommu_group *group)
618 {
619 }
620
621 static inline int iommu_group_register_notifier(struct iommu_group *group,
622                                                 struct notifier_block *nb)
623 {
624         return -ENODEV;
625 }
626
627 static inline int iommu_group_unregister_notifier(struct iommu_group *group,
628                                                   struct notifier_block *nb)
629 {
630         return 0;
631 }
632
633 static inline int iommu_group_id(struct iommu_group *group)
634 {
635         return -ENODEV;
636 }
637
638 static inline int iommu_domain_get_attr(struct iommu_domain *domain,
639                                         enum iommu_attr attr, void *data)
640 {
641         return -EINVAL;
642 }
643
644 static inline int iommu_domain_set_attr(struct iommu_domain *domain,
645                                         enum iommu_attr attr, void *data)
646 {
647         return -EINVAL;
648 }
649
650 static inline struct device *iommu_device_create(struct device *parent,
651                                         void *drvdata,
652                                         const struct attribute_group **groups,
653                                         const char *fmt, ...)
654 {
655         return ERR_PTR(-ENODEV);
656 }
657
658 static inline void iommu_device_destroy(struct device *dev)
659 {
660 }
661
662 static inline int iommu_device_link(struct device *dev, struct device *link)
663 {
664         return -EINVAL;
665 }
666
667 static inline void iommu_device_unlink(struct device *dev, struct device *link)
668 {
669 }
670
671 static inline int iommu_dma_supported(struct iommu_domain *domain,
672                                       struct device *dev, u64 mask)
673 {
674         return -EINVAL;
675 }
676
677 static inline void iommu_tlbiall(struct iommu_domain *domain)
678 {
679 }
680
681 static inline int iommu_enable_config_clocks(struct iommu_domain *domain)
682 {
683         return 0;
684 }
685
686 static inline void iommu_disable_config_clocks(struct iommu_domain *domain)
687 {
688 }
689
690 #endif /* CONFIG_IOMMU_API */
691
692 #endif /* __LINUX_IOMMU_H */