aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iommu.h
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2012-05-21 13:20:05 -0400
committerJoerg Roedel <joerg.roedel@amd.com>2012-05-22 12:08:08 -0400
commit77ca23323594589ac8cba1c8d59bfe7e85d3cb8b (patch)
tree7b2f6e2c95e799084043e36266cecdc0a6198e01 /include/linux/iommu.h
parent76e10d158efb6d4516018846f60c2ab5501900bc (diff)
iommu/core: pass a user-provided token to fault handlers
Sometimes a single IOMMU user may have to deal with several different IOMMU devices (e.g. remoteproc). When an IOMMU fault happens, such users have to regain their context in order to deal with the fault. Users can't use the private fields of neither the iommu_domain nor the IOMMU device, because those are already used by the IOMMU core and low level driver (respectively). This patch just simply allows users to pass a private token (most notably their own context pointer) to iommu_set_fault_handler(), and then makes sure it is provided back to the users whenever an IOMMU fault happens. The patch also adopts remoteproc to the new fault handling interface, but the real functionality using this (recovery of remote processors) will only be added later in a subsequent patch set. Cc: Fernando Guzman Lugo <fernando.lugo@ti.com> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'include/linux/iommu.h')
-rw-r--r--include/linux/iommu.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d937580417ba..450293f6d68b 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -35,12 +35,13 @@ struct iommu_domain;
35#define IOMMU_FAULT_WRITE 0x1 35#define IOMMU_FAULT_WRITE 0x1
36 36
37typedef int (*iommu_fault_handler_t)(struct iommu_domain *, 37typedef int (*iommu_fault_handler_t)(struct iommu_domain *,
38 struct device *, unsigned long, int); 38 struct device *, unsigned long, int, void *);
39 39
40struct iommu_domain { 40struct iommu_domain {
41 struct iommu_ops *ops; 41 struct iommu_ops *ops;
42 void *priv; 42 void *priv;
43 iommu_fault_handler_t handler; 43 iommu_fault_handler_t handler;
44 void *handler_token;
44}; 45};
45 46
46#define IOMMU_CAP_CACHE_COHERENCY 0x1 47#define IOMMU_CAP_CACHE_COHERENCY 0x1
@@ -95,7 +96,7 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
95extern int iommu_domain_has_cap(struct iommu_domain *domain, 96extern int iommu_domain_has_cap(struct iommu_domain *domain,
96 unsigned long cap); 97 unsigned long cap);
97extern void iommu_set_fault_handler(struct iommu_domain *domain, 98extern void iommu_set_fault_handler(struct iommu_domain *domain,
98 iommu_fault_handler_t handler); 99 iommu_fault_handler_t handler, void *token);
99extern int iommu_device_group(struct device *dev, unsigned int *groupid); 100extern int iommu_device_group(struct device *dev, unsigned int *groupid);
100 101
101/** 102/**
@@ -132,7 +133,8 @@ static inline int report_iommu_fault(struct iommu_domain *domain,
132 * invoke it. 133 * invoke it.
133 */ 134 */
134 if (domain->handler) 135 if (domain->handler)
135 ret = domain->handler(domain, dev, iova, flags); 136 ret = domain->handler(domain, dev, iova, flags,
137 domain->handler_token);
136 138
137 return ret; 139 return ret;
138} 140}
@@ -191,7 +193,7 @@ static inline int domain_has_cap(struct iommu_domain *domain,
191} 193}
192 194
193static inline void iommu_set_fault_handler(struct iommu_domain *domain, 195static inline void iommu_set_fault_handler(struct iommu_domain *domain,
194 iommu_fault_handler_t handler) 196 iommu_fault_handler_t handler, void *token)
195{ 197{
196} 198}
197 199