[RFC PATCH v5 4/7] platform/x86/intel/pmt: Register enumeration functions with resctrl

From: Tony Luck

Date: Fri Apr 10 2026 - 16:10:39 EST


INTEL_PMT_TELEMETRY is a loadable module, but resctrl is built-in and cannot
call PMT functions directly. Register the telemetry enumeration function
pointers at resctrl module init, and unregister them at module exit.

Add module_{get,put} calls to the PMT get/put functions to ensure that
INTEL_PMT_TELEMETRY cannot be unloaded while resctrl is mounted and
referencing the MMIO register space mapped by INTEL_PMT_TELEMETRY.

Note that checkpatch complains about the #include of <asm/resctrl.h>.
This is needed rather than <linux/resctrl.h> to get the function stub
definitions when CONFIG_X86_CPU_RESCTRL=n.

Suggested-by: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
drivers/platform/x86/intel/pmt/telemetry.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c
index a52803bfe124..e76927cabc97 100644
--- a/drivers/platform/x86/intel/pmt/telemetry.c
+++ b/drivers/platform/x86/intel/pmt/telemetry.c
@@ -25,6 +25,8 @@
#include <linux/uaccess.h>
#include <linux/xarray.h>

+#include <asm/resctrl.h>
+
#include "class.h"

#define TELEM_SIZE_OFFSET 0x0
@@ -283,6 +285,9 @@ struct pmt_feature_group *intel_pmt_get_regions_by_feature(enum pmt_feature_id i
region++;
}

+ if (!try_module_get(THIS_MODULE))
+ return ERR_PTR(-EINVAL);
+
kref_init(&feature_group->kref);

return no_free_ptr(feature_group);
@@ -292,6 +297,7 @@ EXPORT_SYMBOL(intel_pmt_get_regions_by_feature);
void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group)
{
kref_put(&feature_group->kref, pmt_feature_group_release);
+ module_put(THIS_MODULE);
}
EXPORT_SYMBOL(intel_pmt_put_feature_group);

@@ -404,6 +410,9 @@ static int pmt_telem_probe(struct auxiliary_device *auxdev, const struct auxilia
intel_pmt_get_features(entry);
}

+ intel_aet_register_enumeration(intel_pmt_get_regions_by_feature,
+ intel_pmt_put_feature_group);
+
return 0;
abort_probe:
pmt_telem_remove(auxdev);
@@ -432,6 +441,7 @@ static void __exit pmt_telem_exit(void)
{
auxiliary_driver_unregister(&pmt_telem_aux_driver);
xa_destroy(&telem_array);
+ intel_aet_unregister_enumeration();
}
module_exit(pmt_telem_exit);

--
2.53.0