diff options
-rw-r--r-- | drivers/iommu/amd_iommu_init.c | 15 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_proto.h | 3 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_types.h | 5 |
3 files changed, 23 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 2c25ae306e7c..d1e5067852d4 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/msi.h> | 26 | #include <linux/msi.h> |
27 | #include <linux/amd-iommu.h> | 27 | #include <linux/amd-iommu.h> |
28 | #include <linux/export.h> | ||
28 | #include <asm/pci-direct.h> | 29 | #include <asm/pci-direct.h> |
29 | #include <asm/iommu.h> | 30 | #include <asm/iommu.h> |
30 | #include <asm/gart.h> | 31 | #include <asm/gart.h> |
@@ -143,6 +144,8 @@ bool amd_iommu_iotlb_sup __read_mostly = true; | |||
143 | 144 | ||
144 | u32 amd_iommu_max_pasids __read_mostly = ~0; | 145 | u32 amd_iommu_max_pasids __read_mostly = ~0; |
145 | 146 | ||
147 | bool amd_iommu_v2_present __read_mostly; | ||
148 | |||
146 | /* | 149 | /* |
147 | * The ACPI table parsing functions set this variable on an error | 150 | * The ACPI table parsing functions set this variable on an error |
148 | */ | 151 | */ |
@@ -760,6 +763,12 @@ static void __init init_iommu_from_pci(struct amd_iommu *iommu) | |||
760 | amd_iommu_max_pasids = min(amd_iommu_max_pasids, pasids); | 763 | amd_iommu_max_pasids = min(amd_iommu_max_pasids, pasids); |
761 | } | 764 | } |
762 | 765 | ||
766 | if (iommu_feature(iommu, FEATURE_GT) && | ||
767 | iommu_feature(iommu, FEATURE_PPR)) { | ||
768 | iommu->is_iommu_v2 = true; | ||
769 | amd_iommu_v2_present = true; | ||
770 | } | ||
771 | |||
763 | if (!is_rd890_iommu(iommu->dev)) | 772 | if (!is_rd890_iommu(iommu->dev)) |
764 | return; | 773 | return; |
765 | 774 | ||
@@ -1645,3 +1654,9 @@ IOMMU_INIT_FINISH(amd_iommu_detect, | |||
1645 | gart_iommu_hole_init, | 1654 | gart_iommu_hole_init, |
1646 | 0, | 1655 | 0, |
1647 | 0); | 1656 | 0); |
1657 | |||
1658 | bool amd_iommu_v2_supported(void) | ||
1659 | { | ||
1660 | return amd_iommu_v2_present; | ||
1661 | } | ||
1662 | EXPORT_SYMBOL(amd_iommu_v2_supported); | ||
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index 7ffaa64410b0..3a46c300dffb 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h | |||
@@ -31,6 +31,9 @@ extern int amd_iommu_init_devices(void); | |||
31 | extern void amd_iommu_uninit_devices(void); | 31 | extern void amd_iommu_uninit_devices(void); |
32 | extern void amd_iommu_init_notifier(void); | 32 | extern void amd_iommu_init_notifier(void); |
33 | extern void amd_iommu_init_api(void); | 33 | extern void amd_iommu_init_api(void); |
34 | |||
35 | extern bool amd_iommu_v2_supported(void); | ||
36 | |||
34 | #ifndef CONFIG_AMD_IOMMU_STATS | 37 | #ifndef CONFIG_AMD_IOMMU_STATS |
35 | 38 | ||
36 | static inline void amd_iommu_stats_init(void) { } | 39 | static inline void amd_iommu_stats_init(void) { } |
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index a6e1dc616afe..7e81094ab73b 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
@@ -414,6 +414,9 @@ struct amd_iommu { | |||
414 | /* Extended features */ | 414 | /* Extended features */ |
415 | u64 features; | 415 | u64 features; |
416 | 416 | ||
417 | /* IOMMUv2 */ | ||
418 | bool is_iommu_v2; | ||
419 | |||
417 | /* | 420 | /* |
418 | * Capability pointer. There could be more than one IOMMU per PCI | 421 | * Capability pointer. There could be more than one IOMMU per PCI |
419 | * device function if there are more than one AMD IOMMU capability | 422 | * device function if there are more than one AMD IOMMU capability |
@@ -570,6 +573,8 @@ extern bool amd_iommu_unmap_flush; | |||
570 | /* Smallest number of PASIDs supported by any IOMMU in the system */ | 573 | /* Smallest number of PASIDs supported by any IOMMU in the system */ |
571 | extern u32 amd_iommu_max_pasids; | 574 | extern u32 amd_iommu_max_pasids; |
572 | 575 | ||
576 | extern bool amd_iommu_v2_present; | ||
577 | |||
573 | /* takes bus and device/function and returns the device id | 578 | /* takes bus and device/function and returns the device id |
574 | * FIXME: should that be in generic PCI code? */ | 579 | * FIXME: should that be in generic PCI code? */ |
575 | static inline u16 calc_devid(u8 bus, u8 devfn) | 580 | static inline u16 calc_devid(u8 bus, u8 devfn) |