linux/arch/x86/events
Suravee Suthikulpanit f05c74e104 x86/events/amd/iommu: Fix invalid Perf result due to IOMMU PMC power-gating
commit e10de314287c2c14b0e6f0e3e961975ce2f4a83d upstream.

On certain AMD platforms, when the IOMMU performance counter source
(csource) field is zero, power-gating for the counter is enabled, which
prevents write access and returns zero for read access.

This can cause invalid perf result especially when event multiplexing
is needed (i.e. more number of events than available counters) since
the current logic keeps track of the previously read counter value,
and subsequently re-program the counter to continue counting the event.
With power-gating enabled, we cannot gurantee successful re-programming
of the counter.

Workaround this issue by :

1. Modifying the ordering of setting/reading counters and enabing/
   disabling csources to only access the counter when the csource
   is set to non-zero.

2. Since AMD IOMMU PMU does not support interrupt mode, the logic
   can be simplified to always start counting with value zero,
   and accumulate the counter value when stopping without the need
   to keep track and reprogram the counter with the previously read
   counter value.

This has been tested on systems with and without power-gating.

Fixes: 994d6608efe4 ("iommu/amd: Remove performance counter pre-initialization test")
Suggested-by: Alexander Monakov <amonakov@ispras.ru>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210504065236.4415-1-suravee.suthikulpanit@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-12 08:56:41 +02:00
..
amd x86/events/amd/iommu: Fix invalid Perf result due to IOMMU PMC power-gating 2021-09-12 08:56:41 +02:00
intel perf/x86/intel/pt: Fix mask of num_address_ranges 2021-09-12 08:56:39 +02:00
Kconfig perf/x86/rapl: Move RAPL support to common x86 code 2020-07-16 08:16:32 +02:00
Makefile perf/x86/rapl: Fix RAPL config variable bug 2020-07-16 08:16:32 +02:00
core.c
msr.c perf/x86/msr: Add Tremont support 2020-03-05 16:43:38 +01:00
perf_event.h perf/x86/amd: Don't touch the AMD64_EVENTSEL_HOSTONLY bit inside the guest 2021-08-12 13:21:04 +02:00
probe.c
probe.h
rapl.c perf/x86: fix sysfs type mismatches 2020-12-02 08:49:49 +01:00