diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2011-09-06 10:44:29 -0400 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2011-10-21 08:37:21 -0400 |
commit | e5aa7f00776f2d73f410ede5c1f68246cdc83de1 (patch) | |
tree | 121c1084903a87bbebddb952470ae9c36e121a33 /drivers | |
parent | a1b60c1cd913c5ccfb38c717ba0bd22622425fa7 (diff) |
iommu/core: Use bus->iommu_ops in the iommu-api
Use the per-bus iommu-ops in the functions of the iommu-api
instead of the global iommu_ops.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/iommu/iommu.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ad8ce1addb4d..1575aaa36c94 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c | |||
@@ -110,34 +110,48 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc); | |||
110 | 110 | ||
111 | void iommu_domain_free(struct iommu_domain *domain) | 111 | void iommu_domain_free(struct iommu_domain *domain) |
112 | { | 112 | { |
113 | iommu_ops->domain_destroy(domain); | 113 | if (likely(domain->ops->domain_destroy != NULL)) |
114 | domain->ops->domain_destroy(domain); | ||
115 | |||
114 | kfree(domain); | 116 | kfree(domain); |
115 | } | 117 | } |
116 | EXPORT_SYMBOL_GPL(iommu_domain_free); | 118 | EXPORT_SYMBOL_GPL(iommu_domain_free); |
117 | 119 | ||
118 | int iommu_attach_device(struct iommu_domain *domain, struct device *dev) | 120 | int iommu_attach_device(struct iommu_domain *domain, struct device *dev) |
119 | { | 121 | { |
120 | return iommu_ops->attach_dev(domain, dev); | 122 | if (unlikely(domain->ops->attach_dev == NULL)) |
123 | return -ENODEV; | ||
124 | |||
125 | return domain->ops->attach_dev(domain, dev); | ||
121 | } | 126 | } |
122 | EXPORT_SYMBOL_GPL(iommu_attach_device); | 127 | EXPORT_SYMBOL_GPL(iommu_attach_device); |
123 | 128 | ||
124 | void iommu_detach_device(struct iommu_domain *domain, struct device *dev) | 129 | void iommu_detach_device(struct iommu_domain *domain, struct device *dev) |
125 | { | 130 | { |
126 | iommu_ops->detach_dev(domain, dev); | 131 | if (unlikely(domain->ops->detach_dev == NULL)) |
132 | return; | ||
133 | |||
134 | domain->ops->detach_dev(domain, dev); | ||
127 | } | 135 | } |
128 | EXPORT_SYMBOL_GPL(iommu_detach_device); | 136 | EXPORT_SYMBOL_GPL(iommu_detach_device); |
129 | 137 | ||
130 | phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, | 138 | phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, |
131 | unsigned long iova) | 139 | unsigned long iova) |
132 | { | 140 | { |
133 | return iommu_ops->iova_to_phys(domain, iova); | 141 | if (unlikely(domain->ops->iova_to_phys == NULL)) |
142 | return 0; | ||
143 | |||
144 | return domain->ops->iova_to_phys(domain, iova); | ||
134 | } | 145 | } |
135 | EXPORT_SYMBOL_GPL(iommu_iova_to_phys); | 146 | EXPORT_SYMBOL_GPL(iommu_iova_to_phys); |
136 | 147 | ||
137 | int iommu_domain_has_cap(struct iommu_domain *domain, | 148 | int iommu_domain_has_cap(struct iommu_domain *domain, |
138 | unsigned long cap) | 149 | unsigned long cap) |
139 | { | 150 | { |
140 | return iommu_ops->domain_has_cap(domain, cap); | 151 | if (unlikely(domain->ops->domain_has_cap == NULL)) |
152 | return 0; | ||
153 | |||
154 | return domain->ops->domain_has_cap(domain, cap); | ||
141 | } | 155 | } |
142 | EXPORT_SYMBOL_GPL(iommu_domain_has_cap); | 156 | EXPORT_SYMBOL_GPL(iommu_domain_has_cap); |
143 | 157 | ||
@@ -146,11 +160,14 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, | |||
146 | { | 160 | { |
147 | size_t size; | 161 | size_t size; |
148 | 162 | ||
163 | if (unlikely(domain->ops->map == NULL)) | ||
164 | return -ENODEV; | ||
165 | |||
149 | size = PAGE_SIZE << gfp_order; | 166 | size = PAGE_SIZE << gfp_order; |
150 | 167 | ||
151 | BUG_ON(!IS_ALIGNED(iova | paddr, size)); | 168 | BUG_ON(!IS_ALIGNED(iova | paddr, size)); |
152 | 169 | ||
153 | return iommu_ops->map(domain, iova, paddr, gfp_order, prot); | 170 | return domain->ops->map(domain, iova, paddr, gfp_order, prot); |
154 | } | 171 | } |
155 | EXPORT_SYMBOL_GPL(iommu_map); | 172 | EXPORT_SYMBOL_GPL(iommu_map); |
156 | 173 | ||
@@ -158,10 +175,13 @@ int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) | |||
158 | { | 175 | { |
159 | size_t size; | 176 | size_t size; |
160 | 177 | ||
178 | if (unlikely(domain->ops->unmap == NULL)) | ||
179 | return -ENODEV; | ||
180 | |||
161 | size = PAGE_SIZE << gfp_order; | 181 | size = PAGE_SIZE << gfp_order; |
162 | 182 | ||
163 | BUG_ON(!IS_ALIGNED(iova, size)); | 183 | BUG_ON(!IS_ALIGNED(iova, size)); |
164 | 184 | ||
165 | return iommu_ops->unmap(domain, iova, gfp_order); | 185 | return domain->ops->unmap(domain, iova, gfp_order); |
166 | } | 186 | } |
167 | EXPORT_SYMBOL_GPL(iommu_unmap); | 187 | EXPORT_SYMBOL_GPL(iommu_unmap); |