Skip to content

Commit a1b60c1

Browse files
committed
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>
1 parent 905d66c commit a1b60c1

5 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎arch/ia64/kvm/kvm-ia64.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/uaccess.h>
3434
#include <linux/iommu.h>
3535
#include <linux/intel-iommu.h>
36+
#include <linux/pci.h>
3637

3738
#include <asm/pgtable.h>
3839
#include <asm/gcc_intrin.h>
@@ -204,7 +205,7 @@ int kvm_dev_ioctl_check_extension(long ext)
204205
r = KVM_COALESCED_MMIO_PAGE_OFFSET;
205206
break;
206207
case KVM_CAP_IOMMU:
207-
r = iommu_found();
208+
r = iommu_present(&pci_bus_type);
208209
break;
209210
default:
210211
r = 0;

‎arch/x86/kvm/x86.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/perf_event.h>
4545
#include <linux/uaccess.h>
4646
#include <linux/hash.h>
47+
#include <linux/pci.h>
4748
#include <trace/events/kvm.h>
4849

4950
#define CREATE_TRACE_POINTS
@@ -2095,7 +2096,7 @@ int kvm_dev_ioctl_check_extension(long ext)
20952096
r = 0;
20962097
break;
20972098
case KVM_CAP_IOMMU:
2098-
r = iommu_found();
2099+
r = iommu_present(&pci_bus_type);
20992100
break;
21002101
case KVM_CAP_MCE:
21012102
r = KVM_MAX_MCE_BANKS;

‎drivers/iommu/iommu.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops)
6666
}
6767
EXPORT_SYMBOL_GPL(bus_set_iommu);
6868

69-
bool iommu_found(void)
69+
bool iommu_present(struct bus_type *bus)
7070
{
71-
return iommu_ops != NULL;
71+
if (bus->iommu_ops != NULL)
72+
return true;
73+
else
74+
return iommu_ops != NULL;
7275
}
73-
EXPORT_SYMBOL_GPL(iommu_found);
76+
EXPORT_SYMBOL_GPL(iommu_present);
7477

7578
struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
7679
{

‎include/linux/iommu.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct iommu_ops {
5656

5757
extern void register_iommu(struct iommu_ops *ops);
5858
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);
6060
extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
6161
extern void iommu_domain_free(struct iommu_domain *domain);
6262
extern int iommu_attach_device(struct iommu_domain *domain,
@@ -76,7 +76,7 @@ extern int iommu_domain_has_cap(struct iommu_domain *domain,
7676

7777
struct iommu_ops {};
7878

79-
static inline bool iommu_found(void)
79+
static inline bool iommu_present(struct bus_type *bus)
8080
{
8181
return false;
8282
}

‎virt/kvm/iommu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ int kvm_iommu_map_guest(struct kvm *kvm)
228228
{
229229
int r;
230230

231-
if (!iommu_found()) {
231+
if (!iommu_present(&pci_bus_type)) {
232232
printk(KERN_ERR "%s: iommu not found\n", __func__);
233233
return -ENODEV;
234234
}

0 commit comments

Comments
 (0)