[PATCH v2 05/19] platform/x86/intel/tpmi: Keep the feature resources in intel_tpmi_info
From: Kuppuswamy Sathyanarayanan
Date: Thu Sep 24 2026 - 14:31:32 EST
The PFS walk and tpmi_create_devices() go back to the intel_vsec_device
for the MMIO resource array and its count, although the count is already
cached in intel_tpmi_info.
Cache the resource array as well and use it everywhere. The array
belongs to the enumerating device and outlives the TPMI instance, so
holding a pointer to it is safe. Fewer places need an intel_vsec_device,
which enumeration methods other than PCI VSEC do not have.
No functional change.
Co-developed-by: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
---
drivers/platform/x86/intel/vsec_tpmi.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/intel/vsec_tpmi.c b/drivers/platform/x86/intel/vsec_tpmi.c
index d254dc6a4d0d..b462fd0319e5 100644
--- a/drivers/platform/x86/intel/vsec_tpmi.c
+++ b/drivers/platform/x86/intel/vsec_tpmi.c
@@ -110,6 +110,7 @@ struct intel_tpmi_pm_feature {
* @plat_info: Stores platform info which can be used by the client drivers
* @tpmi_control_mem: Memory mapped IO for getting control information
* @dbgfs_dir: debugfs entry pointer
+ * @resource: Array of feature_count MMIO resources, one per PFS entry
*
* Stores the information for all TPMI devices enumerated from a single PCI device.
*/
@@ -121,6 +122,7 @@ struct intel_tpmi_info {
struct oobmsm_plat_info plat_info;
void __iomem *tpmi_control_mem;
struct dentry *dbgfs_dir;
+ struct resource *resource;
};
/**
@@ -656,10 +658,9 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info)
{
- struct intel_vsec_device *vsec_dev = tpmi_info->vsec_dev;
int ret, i;
- for (i = 0; i < vsec_dev->num_resources; i++) {
+ for (i = 0; i < tpmi_info->feature_count; i++) {
ret = tpmi_create_device(tpmi_info, &tpmi_info->tpmi_features[i],
tpmi_info->pfs_start);
/*
@@ -748,15 +749,16 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
tpmi_info->vsec_dev = vsec_dev;
tpmi_info->feature_count = vsec_dev->num_resources;
+ tpmi_info->resource = vsec_dev->resource;
tpmi_info->plat_info.bus_number = pci_dev->bus->number;
- tpmi_info->tpmi_features = devm_kcalloc(&auxdev->dev, vsec_dev->num_resources,
+ tpmi_info->tpmi_features = devm_kcalloc(&auxdev->dev, tpmi_info->feature_count,
sizeof(*tpmi_info->tpmi_features),
GFP_KERNEL);
if (!tpmi_info->tpmi_features)
return -ENOMEM;
- for (i = 0; i < vsec_dev->num_resources; i++) {
+ for (i = 0; i < tpmi_info->feature_count; i++) {
struct intel_tpmi_pm_feature *pfs;
struct resource *res;
u64 res_start;
@@ -764,7 +766,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
pfs = &tpmi_info->tpmi_features[i];
- res = &vsec_dev->resource[i];
+ res = &tpmi_info->resource[i];
if (!res)
continue;
--
2.43.0