[PATCH v14 21/24] platform/x86/intel/pmt: Inform resctrl when MMIO maps are being removed
From: Tony Luck
Date: Mon Oct 19 2026 - 16:52:33 EST
resctrl obtains the virtual addresses of the telemetry MMIO regions from
intel_pmt_get_regions_by_feature() at mount time and reads event counters
from them until unmount.
When a telemetry device is unbound from the pmt_telemetry driver or
removed, the driver tears down those mappings. A subsequent read of a
telemetry event by resctrl faults on the stale address.
Before destroying the devices, tell resctrl that the mappings of the
device's package are about to be torn down and must not be used again.
Telemetry regions are organised per package, so the package ID identifies
the regions resctrl has to drop. This may be overly broad if there are
multiple telemetry devices on a package.
Notify resctrl while holding ep_lock so that the notification is ordered
against concurrent lookups of the regions. This is safe because ep_lock
is always taken before aet_lock.
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
v14:
Added commit comment on lock order.
New commit comment.
---
drivers/platform/x86/intel/pmt/telemetry.c | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
index 57eb2967a4d0..bd63653802d9 100644
--- a/drivers/platform/x86/intel/pmt/telemetry.c
+++ b/drivers/platform/x86/intel/pmt/telemetry.c
@@ -366,12 +366,42 @@ pmt_telem_find_and_register_endpoint(struct device *dev, u32 guid, u16 pos)
}
EXPORT_SYMBOL_NS_GPL(pmt_telem_find_and_register_endpoint, "INTEL_PMT_TELEMETRY");
+static int pmt_telem_get_package_id(struct pmt_telem_priv *priv)
+{
+ int i;
+
+ for (i = 0; i < priv->num_entries; i++) {
+ struct intel_pmt_entry *entry = &priv->entry[i];
+ struct pci_dev *pdev = to_pci_dev(entry->ep->dev);
+ struct oobmsm_plat_info *plat_info;
+
+ plat_info = intel_vsec_get_mapping(pdev);
+ if (!IS_ERR(plat_info)) {
+ /* All entries for a device have the same package ID */
+ return plat_info->package_id;
+ }
+ }
+
+ return -ENODEV;
+}
+
static void pmt_telem_remove(struct auxiliary_device *auxdev)
{
struct pmt_telem_priv *priv = auxiliary_get_drvdata(auxdev);
+ int package_id;
int i;
mutex_lock(&ep_lock);
+ package_id = pmt_telem_get_package_id(priv);
+ /*
+ * Tell resctrl/AET that virtual mappings for MMIO space in a CPU
+ * package are about to be torn down.
+ */
+ if (package_id < 0)
+ dev_dbg(&auxdev->dev, "Unable to determine package ID for removed device\n");
+ else
+ intel_aet_invalidate(package_id);
+
for (i = 0; i < priv->num_entries; i++) {
struct intel_pmt_entry *entry = &priv->entry[i];
--
2.56.0