From ea24aff99a8e41f716eb4b0607747cc2a208788b Mon Sep 17 00:00:00 2001 From: Joerg Roedel Date: Tue, 6 Sep 2011 18:46:34 +0200 Subject: 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 --- arch/ia64/kvm/kvm-ia64.c | 3 ++- arch/x86/kvm/x86.c | 3 ++- drivers/iommu/iommu.c | 9 ++++++--- include/linux/iommu.h | 4 ++-- virt/kvm/iommu.c | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 8213efe1998c..43f4c92816ef 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -204,7 +205,7 @@ int kvm_dev_ioctl_check_extension(long ext) r = KVM_COALESCED_MMIO_PAGE_OFFSET; break; case KVM_CAP_IOMMU: - r = iommu_found(); + r = iommu_present(&pci_bus_type); break; default: r = 0; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 84a28ea45fa4..73c6a4268bf4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS @@ -2095,7 +2096,7 @@ int kvm_dev_ioctl_check_extension(long ext) r = 0; break; case KVM_CAP_IOMMU: - r = iommu_found(); + r = iommu_present(&pci_bus_type); break; case KVM_CAP_MCE: r = KVM_MAX_MCE_BANKS; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ff3e3e7d575e..3529e34c131e 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -66,11 +66,14 @@ int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops) } EXPORT_SYMBOL_GPL(bus_set_iommu); -bool iommu_found(void) +bool iommu_present(struct bus_type *bus) { - return iommu_ops != NULL; + if (bus->iommu_ops != NULL) + return true; + else + return iommu_ops != NULL; } -EXPORT_SYMBOL_GPL(iommu_found); +EXPORT_SYMBOL_GPL(iommu_present); /** * iommu_set_fault_handler() - set a fault handler for an iommu domain diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 048653817af9..d96071674cce 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -65,7 +65,7 @@ struct iommu_ops { extern void register_iommu(struct iommu_ops *ops); extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); -extern bool iommu_found(void); +extern bool iommu_present(struct bus_type *bus); extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); extern void iommu_domain_free(struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain, @@ -126,7 +126,7 @@ static inline int report_iommu_fault(struct iommu_domain *domain, struct iommu_ops {}; -static inline bool iommu_found(void) +static inline bool iommu_present(struct bus_type *bus) { return false; } diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index 20115b1aac6a..d149940608da 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c @@ -228,7 +228,7 @@ int kvm_iommu_map_guest(struct kvm *kvm) { int r; - if (!iommu_found()) { + if (!iommu_present(&pci_bus_type)) { printk(KERN_ERR "%s: iommu not found\n", __func__); return -ENODEV; } -- cgit v1.2.3