diff options
-rw-r--r-- | arch/x86/events/amd/iommu.c | 17 | ||||
-rw-r--r-- | arch/x86/events/amd/iommu.h | 9 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_init.c | 34 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_proto.h | 2 |
4 files changed, 31 insertions, 31 deletions
diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c index d4375dadd4e9..10f67d39cac5 100644 --- a/arch/x86/events/amd/iommu.c +++ b/arch/x86/events/amd/iommu.c | |||
@@ -239,14 +239,6 @@ static int perf_iommu_event_init(struct perf_event *event) | |||
239 | return -EINVAL; | 239 | return -EINVAL; |
240 | } | 240 | } |
241 | 241 | ||
242 | /* integrate with iommu base devid (0000), assume one iommu */ | ||
243 | perf_iommu->max_banks = | ||
244 | amd_iommu_pc_get_max_banks(IOMMU_BASE_DEVID); | ||
245 | perf_iommu->max_counters = | ||
246 | amd_iommu_pc_get_max_counters(IOMMU_BASE_DEVID); | ||
247 | if ((perf_iommu->max_banks == 0) || (perf_iommu->max_counters == 0)) | ||
248 | return -EINVAL; | ||
249 | |||
250 | /* update the hw_perf_event struct with the iommu config data */ | 242 | /* update the hw_perf_event struct with the iommu config data */ |
251 | hwc->config = config; | 243 | hwc->config = config; |
252 | hwc->extra_reg.config = config1; | 244 | hwc->extra_reg.config = config1; |
@@ -448,6 +440,11 @@ static __init int _init_perf_amd_iommu( | |||
448 | return ret; | 440 | return ret; |
449 | } | 441 | } |
450 | 442 | ||
443 | perf_iommu->max_banks = amd_iommu_pc_get_max_banks(0); | ||
444 | perf_iommu->max_counters = amd_iommu_pc_get_max_counters(0); | ||
445 | if (!perf_iommu->max_banks || !perf_iommu->max_counters) | ||
446 | return -EINVAL; | ||
447 | |||
451 | perf_iommu->null_group = NULL; | 448 | perf_iommu->null_group = NULL; |
452 | perf_iommu->pmu.attr_groups = perf_iommu->attr_groups; | 449 | perf_iommu->pmu.attr_groups = perf_iommu->attr_groups; |
453 | 450 | ||
@@ -457,8 +454,8 @@ static __init int _init_perf_amd_iommu( | |||
457 | amd_iommu_pc_exit(); | 454 | amd_iommu_pc_exit(); |
458 | } else { | 455 | } else { |
459 | pr_info("Detected AMD IOMMU (%d banks, %d counters/bank).\n", | 456 | pr_info("Detected AMD IOMMU (%d banks, %d counters/bank).\n", |
460 | amd_iommu_pc_get_max_banks(IOMMU_BASE_DEVID), | 457 | amd_iommu_pc_get_max_banks(0), |
461 | amd_iommu_pc_get_max_counters(IOMMU_BASE_DEVID)); | 458 | amd_iommu_pc_get_max_counters(0)); |
462 | } | 459 | } |
463 | 460 | ||
464 | return ret; | 461 | return ret; |
diff --git a/arch/x86/events/amd/iommu.h b/arch/x86/events/amd/iommu.h index 5c5c9329e571..b775107c221e 100644 --- a/arch/x86/events/amd/iommu.h +++ b/arch/x86/events/amd/iommu.h | |||
@@ -24,19 +24,18 @@ | |||
24 | #define PC_MAX_SPEC_BNKS 64 | 24 | #define PC_MAX_SPEC_BNKS 64 |
25 | #define PC_MAX_SPEC_CNTRS 16 | 25 | #define PC_MAX_SPEC_CNTRS 16 |
26 | 26 | ||
27 | /* iommu pc reg masks*/ | ||
28 | #define IOMMU_BASE_DEVID 0x0000 | ||
29 | |||
30 | /* amd_iommu_init.c external support functions */ | 27 | /* amd_iommu_init.c external support functions */ |
31 | extern int amd_iommu_get_num_iommus(void); | 28 | extern int amd_iommu_get_num_iommus(void); |
32 | 29 | ||
33 | extern bool amd_iommu_pc_supported(void); | 30 | extern bool amd_iommu_pc_supported(void); |
34 | 31 | ||
35 | extern u8 amd_iommu_pc_get_max_banks(u16 devid); | 32 | extern u8 amd_iommu_pc_get_max_banks(unsigned int idx); |
36 | 33 | ||
37 | extern u8 amd_iommu_pc_get_max_counters(u16 devid); | 34 | extern u8 amd_iommu_pc_get_max_counters(unsigned int idx); |
38 | 35 | ||
39 | extern int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, | 36 | extern int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, |
40 | u8 fxn, u64 *value, bool is_write); | 37 | u8 fxn, u64 *value, bool is_write); |
41 | 38 | ||
39 | extern struct amd_iommu *get_amd_iommu(int idx); | ||
40 | |||
42 | #endif /*_PERF_EVENT_AMD_IOMMU_H_*/ | 41 | #endif /*_PERF_EVENT_AMD_IOMMU_H_*/ |
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index d3ec9c32c446..8fdf109e6109 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
@@ -2718,6 +2718,18 @@ bool amd_iommu_v2_supported(void) | |||
2718 | } | 2718 | } |
2719 | EXPORT_SYMBOL(amd_iommu_v2_supported); | 2719 | EXPORT_SYMBOL(amd_iommu_v2_supported); |
2720 | 2720 | ||
2721 | struct amd_iommu *get_amd_iommu(unsigned int idx) | ||
2722 | { | ||
2723 | unsigned int i = 0; | ||
2724 | struct amd_iommu *iommu; | ||
2725 | |||
2726 | for_each_iommu(iommu) | ||
2727 | if (i++ == idx) | ||
2728 | return iommu; | ||
2729 | return NULL; | ||
2730 | } | ||
2731 | EXPORT_SYMBOL(get_amd_iommu); | ||
2732 | |||
2721 | /**************************************************************************** | 2733 | /**************************************************************************** |
2722 | * | 2734 | * |
2723 | * IOMMU EFR Performance Counter support functionality. This code allows | 2735 | * IOMMU EFR Performance Counter support functionality. This code allows |
@@ -2725,17 +2737,14 @@ EXPORT_SYMBOL(amd_iommu_v2_supported); | |||
2725 | * | 2737 | * |
2726 | ****************************************************************************/ | 2738 | ****************************************************************************/ |
2727 | 2739 | ||
2728 | u8 amd_iommu_pc_get_max_banks(u16 devid) | 2740 | u8 amd_iommu_pc_get_max_banks(unsigned int idx) |
2729 | { | 2741 | { |
2730 | struct amd_iommu *iommu; | 2742 | struct amd_iommu *iommu = get_amd_iommu(idx); |
2731 | u8 ret = 0; | ||
2732 | 2743 | ||
2733 | /* locate the iommu governing the devid */ | ||
2734 | iommu = amd_iommu_rlookup_table[devid]; | ||
2735 | if (iommu) | 2744 | if (iommu) |
2736 | ret = iommu->max_banks; | 2745 | return iommu->max_banks; |
2737 | 2746 | ||
2738 | return ret; | 2747 | return 0; |
2739 | } | 2748 | } |
2740 | EXPORT_SYMBOL(amd_iommu_pc_get_max_banks); | 2749 | EXPORT_SYMBOL(amd_iommu_pc_get_max_banks); |
2741 | 2750 | ||
@@ -2745,17 +2754,14 @@ bool amd_iommu_pc_supported(void) | |||
2745 | } | 2754 | } |
2746 | EXPORT_SYMBOL(amd_iommu_pc_supported); | 2755 | EXPORT_SYMBOL(amd_iommu_pc_supported); |
2747 | 2756 | ||
2748 | u8 amd_iommu_pc_get_max_counters(u16 devid) | 2757 | u8 amd_iommu_pc_get_max_counters(unsigned int idx) |
2749 | { | 2758 | { |
2750 | struct amd_iommu *iommu; | 2759 | struct amd_iommu *iommu = get_amd_iommu(idx); |
2751 | u8 ret = 0; | ||
2752 | 2760 | ||
2753 | /* locate the iommu governing the devid */ | ||
2754 | iommu = amd_iommu_rlookup_table[devid]; | ||
2755 | if (iommu) | 2761 | if (iommu) |
2756 | ret = iommu->max_counters; | 2762 | return iommu->max_counters; |
2757 | 2763 | ||
2758 | return ret; | 2764 | return 0; |
2759 | } | 2765 | } |
2760 | EXPORT_SYMBOL(amd_iommu_pc_get_max_counters); | 2766 | EXPORT_SYMBOL(amd_iommu_pc_get_max_counters); |
2761 | 2767 | ||
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index e8f0710aceb3..cd2257e20c3f 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h | |||
@@ -59,8 +59,6 @@ extern struct iommu_domain *amd_iommu_get_v2_domain(struct pci_dev *pdev); | |||
59 | 59 | ||
60 | /* IOMMU Performance Counter functions */ | 60 | /* IOMMU Performance Counter functions */ |
61 | extern bool amd_iommu_pc_supported(void); | 61 | extern bool amd_iommu_pc_supported(void); |
62 | extern u8 amd_iommu_pc_get_max_banks(u16 devid); | ||
63 | extern u8 amd_iommu_pc_get_max_counters(u16 devid); | ||
64 | extern int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, u8 fxn, | 62 | extern int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, u8 fxn, |
65 | u64 *value, bool is_write); | 63 | u64 *value, bool is_write); |
66 | 64 | ||