aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iommu/iommu.c14
-rw-r--r--drivers/media/video/omap3isp/isp.c2
-rw-r--r--include/linux/iommu.h6
-rw-r--r--virt/kvm/iommu.c2
4 files changed, 19 insertions, 5 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3343264f5105..46e1c24f2f43 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 17 */
18 18
19#include <linux/device.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/bug.h> 21#include <linux/bug.h>
21#include <linux/types.h> 22#include <linux/types.h>
@@ -71,15 +72,26 @@ bool iommu_found(void)
71} 72}
72EXPORT_SYMBOL_GPL(iommu_found); 73EXPORT_SYMBOL_GPL(iommu_found);
73 74
74struct iommu_domain *iommu_domain_alloc(void) 75struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
75{ 76{
76 struct iommu_domain *domain; 77 struct iommu_domain *domain;
78 struct iommu_ops *ops;
77 int ret; 79 int ret;
78 80
81 if (bus->iommu_ops)
82 ops = bus->iommu_ops;
83 else
84 ops = iommu_ops;
85
86 if (ops == NULL)
87 return NULL;
88
79 domain = kmalloc(sizeof(*domain), GFP_KERNEL); 89 domain = kmalloc(sizeof(*domain), GFP_KERNEL);
80 if (!domain) 90 if (!domain)
81 return NULL; 91 return NULL;
82 92
93 domain->ops = ops;
94
83 ret = iommu_ops->domain_init(domain); 95 ret = iommu_ops->domain_init(domain);
84 if (ret) 96 if (ret)
85 goto out_free; 97 goto out_free;
diff --git a/drivers/media/video/omap3isp/isp.c b/drivers/media/video/omap3isp/isp.c
index a4baa6165c2c..a7ed98596883 100644
--- a/drivers/media/video/omap3isp/isp.c
+++ b/drivers/media/video/omap3isp/isp.c
@@ -2141,7 +2141,7 @@ static int isp_probe(struct platform_device *pdev)
2141 /* to be removed once iommu migration is complete */ 2141 /* to be removed once iommu migration is complete */
2142 isp->iommu = to_iommu(isp->iommu_dev); 2142 isp->iommu = to_iommu(isp->iommu_dev);
2143 2143
2144 isp->domain = iommu_domain_alloc(); 2144 isp->domain = iommu_domain_alloc(pdev->dev.bus);
2145 if (!isp->domain) { 2145 if (!isp->domain) {
2146 dev_err(isp->dev, "can't alloc iommu domain\n"); 2146 dev_err(isp->dev, "can't alloc iommu domain\n");
2147 ret = -ENOMEM; 2147 ret = -ENOMEM;
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index dca83d3405b1..c78d068930b7 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -25,10 +25,12 @@
25#define IOMMU_WRITE (2) 25#define IOMMU_WRITE (2)
26#define IOMMU_CACHE (4) /* DMA cache coherency */ 26#define IOMMU_CACHE (4) /* DMA cache coherency */
27 27
28struct iommu_ops;
28struct bus_type; 29struct bus_type;
29struct device; 30struct device;
30 31
31struct iommu_domain { 32struct iommu_domain {
33 struct iommu_ops *ops;
32 void *priv; 34 void *priv;
33}; 35};
34 36
@@ -55,7 +57,7 @@ struct iommu_ops {
55extern void register_iommu(struct iommu_ops *ops); 57extern void register_iommu(struct iommu_ops *ops);
56extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); 58extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops);
57extern bool iommu_found(void); 59extern bool iommu_found(void);
58extern struct iommu_domain *iommu_domain_alloc(void); 60extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
59extern void iommu_domain_free(struct iommu_domain *domain); 61extern void iommu_domain_free(struct iommu_domain *domain);
60extern int iommu_attach_device(struct iommu_domain *domain, 62extern int iommu_attach_device(struct iommu_domain *domain,
61 struct device *dev); 63 struct device *dev);
@@ -79,7 +81,7 @@ static inline bool iommu_found(void)
79 return false; 81 return false;
80} 82}
81 83
82static inline struct iommu_domain *iommu_domain_alloc(void) 84static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
83{ 85{
84 return NULL; 86 return NULL;
85} 87}
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index 78c80f67f535..20115b1aac6a 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -233,7 +233,7 @@ int kvm_iommu_map_guest(struct kvm *kvm)
233 return -ENODEV; 233 return -ENODEV;
234 } 234 }
235 235
236 kvm->arch.iommu_domain = iommu_domain_alloc(); 236 kvm->arch.iommu_domain = iommu_domain_alloc(&pci_bus_type);
237 if (!kvm->arch.iommu_domain) 237 if (!kvm->arch.iommu_domain)
238 return -ENOMEM; 238 return -ENOMEM;
239 239