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

iommu/core: Convert iommu_found to iommu_present

With per-bus iommu_ops the iommu_found function needs to
work on a bus_type too. This patch adds a bus_type parameter
to that function and converts all call-places.
The function is also renamed to iommu_present because the
function now checks if an iommu is present for a given bus
and does not check for a global iommu anymore.

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

+13 -8
+2 -1
arch/ia64/kvm/kvm-ia64.c
··· 33 33 #include <linux/uaccess.h> 34 34 #include <linux/iommu.h> 35 35 #include <linux/intel-iommu.h> 36 + #include <linux/pci.h> 36 37 37 38 #include <asm/pgtable.h> 38 39 #include <asm/gcc_intrin.h> ··· 205 204 r = KVM_COALESCED_MMIO_PAGE_OFFSET; 206 205 break; 207 206 case KVM_CAP_IOMMU: 208 - r = iommu_found(); 207 + r = iommu_present(&pci_bus_type); 209 208 break; 210 209 default: 211 210 r = 0;
+2 -1
arch/x86/kvm/x86.c
··· 44 44 #include <linux/perf_event.h> 45 45 #include <linux/uaccess.h> 46 46 #include <linux/hash.h> 47 + #include <linux/pci.h> 47 48 #include <trace/events/kvm.h> 48 49 49 50 #define CREATE_TRACE_POINTS ··· 2096 2095 r = 0; 2097 2096 break; 2098 2097 case KVM_CAP_IOMMU: 2099 - r = iommu_found(); 2098 + r = iommu_present(&pci_bus_type); 2100 2099 break; 2101 2100 case KVM_CAP_MCE: 2102 2101 r = KVM_MAX_MCE_BANKS;
+6 -3
drivers/iommu/iommu.c
··· 66 66 } 67 67 EXPORT_SYMBOL_GPL(bus_set_iommu); 68 68 69 - bool iommu_found(void) 69 + bool iommu_present(struct bus_type *bus) 70 70 { 71 - return iommu_ops != NULL; 71 + if (bus->iommu_ops != NULL) 72 + return true; 73 + else 74 + return iommu_ops != NULL; 72 75 } 73 - EXPORT_SYMBOL_GPL(iommu_found); 76 + EXPORT_SYMBOL_GPL(iommu_present); 74 77 75 78 struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) 76 79 {
+2 -2
include/linux/iommu.h
··· 56 56 57 57 extern void register_iommu(struct iommu_ops *ops); 58 58 extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); 59 - extern bool iommu_found(void); 59 + extern bool iommu_present(struct bus_type *bus); 60 60 extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); 61 61 extern void iommu_domain_free(struct iommu_domain *domain); 62 62 extern int iommu_attach_device(struct iommu_domain *domain, ··· 76 76 77 77 struct iommu_ops {}; 78 78 79 - static inline bool iommu_found(void) 79 + static inline bool iommu_present(struct bus_type *bus) 80 80 { 81 81 return false; 82 82 }
+1 -1
virt/kvm/iommu.c
··· 228 228 { 229 229 int r; 230 230 231 - if (!iommu_found()) { 231 + if (!iommu_present(&pci_bus_type)) { 232 232 printk(KERN_ERR "%s: iommu not found\n", __func__); 233 233 return -ENODEV; 234 234 }