aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iommu.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-08-20 15:26:04 -0400
committerTakashi Iwai <tiwai@suse.de>2012-08-20 15:26:04 -0400
commitf0b433e9f362e0b7f0ce7d1489dd7feba068605d (patch)
treed4bfd9489cf4a96a55d83af20919f477a846d585 /include/linux/iommu.h
parentfa2f5bf09610d3c216d4c74855edbe00d636467c (diff)
parent28c42c28309244d0b15d1b385e33429d59997679 (diff)
Merge tag 'asoc-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Additional updates for 3.6 A batch more bugfixes, all driver-specific and fairly small and unremarkable in a global context. The biggest batch are for the newly added Arizona drivers.
Diffstat (limited to 'include/linux/iommu.h')
-rw-r--r--include/linux/iommu.h140
1 files changed, 137 insertions, 3 deletions
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 450293f6d68b..54d6d690073c 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -26,6 +26,7 @@
26#define IOMMU_CACHE (4) /* DMA cache coherency */ 26#define IOMMU_CACHE (4) /* DMA cache coherency */
27 27
28struct iommu_ops; 28struct iommu_ops;
29struct iommu_group;
29struct bus_type; 30struct bus_type;
30struct device; 31struct device;
31struct iommu_domain; 32struct iommu_domain;
@@ -37,16 +38,28 @@ struct iommu_domain;
37typedef int (*iommu_fault_handler_t)(struct iommu_domain *, 38typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
38 struct device *, unsigned long, int, void *); 39 struct device *, unsigned long, int, void *);
39 40
41struct iommu_domain_geometry {
42 dma_addr_t aperture_start; /* First address that can be mapped */
43 dma_addr_t aperture_end; /* Last address that can be mapped */
44 bool force_aperture; /* DMA only allowed in mappable range? */
45};
46
40struct iommu_domain { 47struct iommu_domain {
41 struct iommu_ops *ops; 48 struct iommu_ops *ops;
42 void *priv; 49 void *priv;
43 iommu_fault_handler_t handler; 50 iommu_fault_handler_t handler;
44 void *handler_token; 51 void *handler_token;
52 struct iommu_domain_geometry geometry;
45}; 53};
46 54
47#define IOMMU_CAP_CACHE_COHERENCY 0x1 55#define IOMMU_CAP_CACHE_COHERENCY 0x1
48#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */ 56#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */
49 57
58enum iommu_attr {
59 DOMAIN_ATTR_MAX,
60 DOMAIN_ATTR_GEOMETRY,
61};
62
50#ifdef CONFIG_IOMMU_API 63#ifdef CONFIG_IOMMU_API
51 64
52/** 65/**
@@ -59,7 +72,10 @@ struct iommu_domain {
59 * @unmap: unmap a physically contiguous memory region from an iommu domain 72 * @unmap: unmap a physically contiguous memory region from an iommu domain
60 * @iova_to_phys: translate iova to physical address 73 * @iova_to_phys: translate iova to physical address
61 * @domain_has_cap: domain capabilities query 74 * @domain_has_cap: domain capabilities query
62 * @commit: commit iommu domain 75 * @add_device: add device to iommu grouping
76 * @remove_device: remove device from iommu grouping
77 * @domain_get_attr: Query domain attributes
78 * @domain_set_attr: Change domain attributes
63 * @pgsize_bitmap: bitmap of supported page sizes 79 * @pgsize_bitmap: bitmap of supported page sizes
64 */ 80 */
65struct iommu_ops { 81struct iommu_ops {
@@ -75,10 +91,23 @@ struct iommu_ops {
75 unsigned long iova); 91 unsigned long iova);
76 int (*domain_has_cap)(struct iommu_domain *domain, 92 int (*domain_has_cap)(struct iommu_domain *domain,
77 unsigned long cap); 93 unsigned long cap);
94 int (*add_device)(struct device *dev);
95 void (*remove_device)(struct device *dev);
78 int (*device_group)(struct device *dev, unsigned int *groupid); 96 int (*device_group)(struct device *dev, unsigned int *groupid);
97 int (*domain_get_attr)(struct iommu_domain *domain,
98 enum iommu_attr attr, void *data);
99 int (*domain_set_attr)(struct iommu_domain *domain,
100 enum iommu_attr attr, void *data);
79 unsigned long pgsize_bitmap; 101 unsigned long pgsize_bitmap;
80}; 102};
81 103
104#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
105#define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
106#define IOMMU_GROUP_NOTIFY_BIND_DRIVER 3 /* Pre Driver bind */
107#define IOMMU_GROUP_NOTIFY_BOUND_DRIVER 4 /* Post Driver bind */
108#define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER 5 /* Pre Driver unbind */
109#define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */
110
82extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); 111extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops);
83extern bool iommu_present(struct bus_type *bus); 112extern bool iommu_present(struct bus_type *bus);
84extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); 113extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
@@ -97,7 +126,34 @@ extern int iommu_domain_has_cap(struct iommu_domain *domain,
97 unsigned long cap); 126 unsigned long cap);
98extern void iommu_set_fault_handler(struct iommu_domain *domain, 127extern void iommu_set_fault_handler(struct iommu_domain *domain,
99 iommu_fault_handler_t handler, void *token); 128 iommu_fault_handler_t handler, void *token);
100extern int iommu_device_group(struct device *dev, unsigned int *groupid); 129
130extern int iommu_attach_group(struct iommu_domain *domain,
131 struct iommu_group *group);
132extern void iommu_detach_group(struct iommu_domain *domain,
133 struct iommu_group *group);
134extern struct iommu_group *iommu_group_alloc(void);
135extern void *iommu_group_get_iommudata(struct iommu_group *group);
136extern void iommu_group_set_iommudata(struct iommu_group *group,
137 void *iommu_data,
138 void (*release)(void *iommu_data));
139extern int iommu_group_set_name(struct iommu_group *group, const char *name);
140extern int iommu_group_add_device(struct iommu_group *group,
141 struct device *dev);
142extern void iommu_group_remove_device(struct device *dev);
143extern int iommu_group_for_each_dev(struct iommu_group *group, void *data,
144 int (*fn)(struct device *, void *));
145extern struct iommu_group *iommu_group_get(struct device *dev);
146extern void iommu_group_put(struct iommu_group *group);
147extern int iommu_group_register_notifier(struct iommu_group *group,
148 struct notifier_block *nb);
149extern int iommu_group_unregister_notifier(struct iommu_group *group,
150 struct notifier_block *nb);
151extern int iommu_group_id(struct iommu_group *group);
152
153extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr,
154 void *data);
155extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
156 void *data);
101 157
102/** 158/**
103 * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework 159 * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework
@@ -142,6 +198,7 @@ static inline int report_iommu_fault(struct iommu_domain *domain,
142#else /* CONFIG_IOMMU_API */ 198#else /* CONFIG_IOMMU_API */
143 199
144struct iommu_ops {}; 200struct iommu_ops {};
201struct iommu_group {};
145 202
146static inline bool iommu_present(struct bus_type *bus) 203static inline bool iommu_present(struct bus_type *bus)
147{ 204{
@@ -197,11 +254,88 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain,
197{ 254{
198} 255}
199 256
200static inline int iommu_device_group(struct device *dev, unsigned int *groupid) 257int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group)
258{
259 return -ENODEV;
260}
261
262void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group)
263{
264}
265
266struct iommu_group *iommu_group_alloc(void)
267{
268 return ERR_PTR(-ENODEV);
269}
270
271void *iommu_group_get_iommudata(struct iommu_group *group)
272{
273 return NULL;
274}
275
276void iommu_group_set_iommudata(struct iommu_group *group, void *iommu_data,
277 void (*release)(void *iommu_data))
278{
279}
280
281int iommu_group_set_name(struct iommu_group *group, const char *name)
282{
283 return -ENODEV;
284}
285
286int iommu_group_add_device(struct iommu_group *group, struct device *dev)
287{
288 return -ENODEV;
289}
290
291void iommu_group_remove_device(struct device *dev)
292{
293}
294
295int iommu_group_for_each_dev(struct iommu_group *group, void *data,
296 int (*fn)(struct device *, void *))
297{
298 return -ENODEV;
299}
300
301struct iommu_group *iommu_group_get(struct device *dev)
302{
303 return NULL;
304}
305
306void iommu_group_put(struct iommu_group *group)
307{
308}
309
310int iommu_group_register_notifier(struct iommu_group *group,
311 struct notifier_block *nb)
201{ 312{
202 return -ENODEV; 313 return -ENODEV;
203} 314}
204 315
316int iommu_group_unregister_notifier(struct iommu_group *group,
317 struct notifier_block *nb)
318{
319 return 0;
320}
321
322int iommu_group_id(struct iommu_group *group)
323{
324 return -ENODEV;
325}
326
327static inline int iommu_domain_get_attr(struct iommu_domain *domain,
328 enum iommu_attr attr, void *data)
329{
330 return -EINVAL;
331}
332
333static inline int iommu_domain_set_attr(struct iommu_domain *domain,
334 enum iommu_attr attr, void *data)
335{
336 return -EINVAL;
337}
338
205#endif /* CONFIG_IOMMU_API */ 339#endif /* CONFIG_IOMMU_API */
206 340
207#endif /* __LINUX_IOMMU_H */ 341#endif /* __LINUX_IOMMU_H */