aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2012-01-26 13:40:52 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2012-07-11 06:12:14 -0400
commit0cd76dd13bdd2f7f02a2dc931e808e92b191082f (patch)
tree210df4b7fda8f81121fd8fb1f89a57e3e358060e
parentbd0a521e88aa7a06ae7aabaed7ae196ed4ad867a (diff)
iommu: Add domain-attribute handlers
This patch introduces an extension to the iommu-api to get and set attributes for an iommu_domain. Two functions are introduced for this: * iommu_domain_get_attr() * iommu_domain_set_attr() These functions will be used to make the iommu-api suitable for GART-like IOMMUs and to implement hardware-specifc api-extensions. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
-rw-r--r--drivers/iommu/iommu.c20
-rw-r--r--include/linux/iommu.h28
2 files changed, 47 insertions, 1 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 8b9ded88e6f5..c39972d8ded3 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -344,3 +344,23 @@ int iommu_device_group(struct device *dev, unsigned int *groupid)
344 return -ENODEV; 344 return -ENODEV;
345} 345}
346EXPORT_SYMBOL_GPL(iommu_device_group); 346EXPORT_SYMBOL_GPL(iommu_device_group);
347
348int iommu_domain_get_attr(struct iommu_domain *domain,
349 enum iommu_attr attr, void *data)
350{
351 if (!domain->ops->domain_get_attr)
352 return -EINVAL;
353
354 return domain->ops->domain_get_attr(domain, attr, data);
355}
356EXPORT_SYMBOL_GPL(iommu_domain_get_attr);
357
358int iommu_domain_set_attr(struct iommu_domain *domain,
359 enum iommu_attr attr, void *data)
360{
361 if (!domain->ops->domain_set_attr)
362 return -EINVAL;
363
364 return domain->ops->domain_set_attr(domain, attr, data);
365}
366EXPORT_SYMBOL_GPL(iommu_domain_set_attr);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 450293f6d68b..0eef096183e8 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -47,6 +47,10 @@ struct iommu_domain {
47#define IOMMU_CAP_CACHE_COHERENCY 0x1 47#define IOMMU_CAP_CACHE_COHERENCY 0x1
48#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */ 48#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */
49 49
50enum iommu_attr {
51 DOMAIN_ATTR_MAX,
52};
53
50#ifdef CONFIG_IOMMU_API 54#ifdef CONFIG_IOMMU_API
51 55
52/** 56/**
@@ -59,7 +63,8 @@ struct iommu_domain {
59 * @unmap: unmap a physically contiguous memory region from an iommu domain 63 * @unmap: unmap a physically contiguous memory region from an iommu domain
60 * @iova_to_phys: translate iova to physical address 64 * @iova_to_phys: translate iova to physical address
61 * @domain_has_cap: domain capabilities query 65 * @domain_has_cap: domain capabilities query
62 * @commit: commit iommu domain 66 * @domain_get_attr: Query domain attributes
67 * @domain_set_attr: Change domain attributes
63 * @pgsize_bitmap: bitmap of supported page sizes 68 * @pgsize_bitmap: bitmap of supported page sizes
64 */ 69 */
65struct iommu_ops { 70struct iommu_ops {
@@ -76,6 +81,10 @@ struct iommu_ops {
76 int (*domain_has_cap)(struct iommu_domain *domain, 81 int (*domain_has_cap)(struct iommu_domain *domain,
77 unsigned long cap); 82 unsigned long cap);
78 int (*device_group)(struct device *dev, unsigned int *groupid); 83 int (*device_group)(struct device *dev, unsigned int *groupid);
84 int (*domain_get_attr)(struct iommu_domain *domain,
85 enum iommu_attr attr, void *data);
86 int (*domain_set_attr)(struct iommu_domain *domain,
87 enum iommu_attr attr, void *data);
79 unsigned long pgsize_bitmap; 88 unsigned long pgsize_bitmap;
80}; 89};
81 90
@@ -99,6 +108,11 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,
99 iommu_fault_handler_t handler, void *token); 108 iommu_fault_handler_t handler, void *token);
100extern int iommu_device_group(struct device *dev, unsigned int *groupid); 109extern int iommu_device_group(struct device *dev, unsigned int *groupid);
101 110
111extern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr,
112 void *data);
113extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
114 void *data);
115
102/** 116/**
103 * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework 117 * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework
104 * @domain: the iommu domain where the fault has happened 118 * @domain: the iommu domain where the fault has happened
@@ -202,6 +216,18 @@ static inline int iommu_device_group(struct device *dev, unsigned int *groupid)
202 return -ENODEV; 216 return -ENODEV;
203} 217}
204 218
219static inline int iommu_domain_get_attr(struct iommu_domain *domain,
220 enum iommu_attr attr, void *data)
221{
222 return -EINVAL;
223}
224
225static inline int iommu_domain_set_attr(struct iommu_domain *domain,
226 enum iommu_attr attr, void *data)
227{
228 return -EINVAL;
229}
230
205#endif /* CONFIG_IOMMU_API */ 231#endif /* CONFIG_IOMMU_API */
206 232
207#endif /* __LINUX_IOMMU_H */ 233#endif /* __LINUX_IOMMU_H */