Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/core: Add bus_type parameter to iommu_domain_alloc

This is necessary to store a pointer to the bus-specific
iommu_ops in the iommu-domain structure. It will be used
later to call into bus-specific iommu-ops.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

+19 -5
+13 -1
drivers/iommu/iommu.c
··· 16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 */ 18 18 19 + #include <linux/device.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/bug.h> 21 22 #include <linux/types.h> ··· 72 71 } 73 72 EXPORT_SYMBOL_GPL(iommu_found); 74 73 75 - struct iommu_domain *iommu_domain_alloc(void) 74 + struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) 76 75 { 77 76 struct iommu_domain *domain; 77 + struct iommu_ops *ops; 78 78 int ret; 79 + 80 + if (bus->iommu_ops) 81 + ops = bus->iommu_ops; 82 + else 83 + ops = iommu_ops; 84 + 85 + if (ops == NULL) 86 + return NULL; 79 87 80 88 domain = kmalloc(sizeof(*domain), GFP_KERNEL); 81 89 if (!domain) 82 90 return NULL; 91 + 92 + domain->ops = ops; 83 93 84 94 ret = iommu_ops->domain_init(domain); 85 95 if (ret)
+1 -1
drivers/media/video/omap3isp/isp.c
··· 2141 2141 /* to be removed once iommu migration is complete */ 2142 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 2145 if (!isp->domain) { 2146 2146 dev_err(isp->dev, "can't alloc iommu domain\n"); 2147 2147 ret = -ENOMEM;
+4 -2
include/linux/iommu.h
··· 25 25 #define IOMMU_WRITE (2) 26 26 #define IOMMU_CACHE (4) /* DMA cache coherency */ 27 27 28 + struct iommu_ops; 28 29 struct bus_type; 29 30 struct device; 30 31 31 32 struct iommu_domain { 33 + struct iommu_ops *ops; 32 34 void *priv; 33 35 }; 34 36 ··· 57 55 extern void register_iommu(struct iommu_ops *ops); 58 56 extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); 59 57 extern bool iommu_found(void); 60 - extern struct iommu_domain *iommu_domain_alloc(void); 58 + extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); 61 59 extern void iommu_domain_free(struct iommu_domain *domain); 62 60 extern int iommu_attach_device(struct iommu_domain *domain, 63 61 struct device *dev); ··· 81 79 return false; 82 80 } 83 81 84 - static inline struct iommu_domain *iommu_domain_alloc(void) 82 + static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) 85 83 { 86 84 return NULL; 87 85 }
+1 -1
virt/kvm/iommu.c
··· 233 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 237 if (!kvm->arch.iommu_domain) 238 238 return -ENOMEM; 239 239