[PATCH V2 0/6] Support PCIe3 uncore PMU on Snow Ridge

From: kan . liang
Date: Wed Aug 05 2020 - 16:25:10 EST


From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>

Changes since V1:
- Drop the platform device solution
- A new uncore PCI sub driver solution is introduced which searches
the PCIe Root Port device via pci_get_device() and id table.
Register a PCI bus notifier for the remove notification. Once the
device is removed, the uncore driver can be notified to unregister
the corresponding PMU.
- Modify the parameters of uncore_pci_pmu_unregister() function.

The Snow Ridge integrated PCIe3 uncore performance monitoring unit (PMU)
can be used to collect the performance data, e.g., the utilization
between the PCIe devices and the components (in M2IOSF) which are
responsible for translating and managing the requests to/from the
device. The performance data is very useful for analyzing the
performance of the PCIe devices.

The PCIe3 uncore PMU was once supported in the Linux kernel, but it was
removed by the commit 2167f1625c2f ("perf/x86/intel/uncore: Remove
PCIe3 unit for SNR") due to the conflict between the PCIe Root Port
driver and the perf uncore driver. The counters of the PCIe3 uncore PMU
are located in the configuration space of the PCIe Root Port device,
which already has a bonded driver portdrv_pci. One device can only have
one bonded driver. The uncore driver is always failed to be loaded.

To re-enable the PCIe3 uncore PMU support in the uncore driver, a new
solution should be introduced, which has to meet the requirements as
below:
- must have a reliable way to find the PCIe Root Port device from the
uncore driver;
- must be able to access the uncore counters of the PCIe Root Port
device from the uncore driver;
- must support hotplug. When the PCIe Root Port device is removed, the
uncore driver has to be notified and unregisters the PCIe3 uncore
PMU.

In the v1 patch set, a new platform device solution is implemented to
address the issue, but it's rejected.
https://lkml.kernel.org/r/20200708183034.GA466341@bjorn-Precision-5520

A new uncore PCI sub driver solution is introduced from the V2 patch
set, which:
- searches the PCIe Root Port device via pci_get_device() and id table.
The matched pci_dev can be used to register a PMU for accessing the
counters in the PCIe Root Port device.
- register a PCI bus notifier. Once the device is removed, the uncore
driver can be notified to unregister the corresponding PMU.

Kan Liang (6):
perf/x86/intel/uncore: Factor out uncore_pci_get_dev_die_info()
perf/x86/intel/uncore: Factor out uncore_pci_find_dev_pmu()
perf/x86/intel/uncore: Factor out uncore_pci_pmu_register()
perf/x86/intel/uncore: Factor out uncore_pci_pmu_unregister()
perf/x86/intel/uncore: Generic support for the PCI sub driver
perf/x86/intel/uncore: Support PCIe3 unit on Snow Ridge

arch/x86/events/intel/uncore.c | 273 +++++++++++++++++++++++++++--------
arch/x86/events/intel/uncore.h | 1 +
arch/x86/events/intel/uncore_snbep.c | 53 +++++++
3 files changed, 265 insertions(+), 62 deletions(-)

--
2.7.4