Skip to content

Commit 86fc85c

Browse files
debox1ij-intel
authored andcommitted
platform/x86/intel/pmt/discovery: Get telemetry attributes
Add intel_pmt_get_features() in PMT Discovery to enable the PMT Telemetry driver to obtain attributes of the aggregated telemetry spaces it enumerates. The function gathers feature flags and associated data (like the number of RMIDs) from each PMT entry, laying the groundwork for a future kernel interface that will allow direct access to telemetry regions based on their capabilities. Signed-off-by: David E. Box <david.e.box@linux.intel.com> Link: https://lore.kernel.org/r/20250703022832.1302928-14-david.e.box@linux.intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent c969905 commit 86fc85c

5 files changed

Lines changed: 62 additions & 0 deletions

File tree

drivers/platform/x86/intel/pmt/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config INTEL_PMT_CLASS
1818
config INTEL_PMT_TELEMETRY
1919
tristate "Intel Platform Monitoring Technology (PMT) Telemetry driver"
2020
depends on INTEL_VSEC
21+
select INTEL_PMT_DISCOVERY
2122
select INTEL_PMT_CLASS
2223
help
2324
The Intel Platform Monitory Technology (PMT) Telemetry driver provides

drivers/platform/x86/intel/pmt/class.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct intel_pmt_entry {
4848
struct pmt_callbacks *cb;
4949
unsigned long base_addr;
5050
size_t size;
51+
u64 feature_flags;
5152
u32 guid;
5253
u32 num_rmids; /* Number of Resource Monitoring IDs */
5354
int devid;
@@ -71,4 +72,10 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry,
7172
struct intel_vsec_device *dev, int idx);
7273
void intel_pmt_dev_destroy(struct intel_pmt_entry *entry,
7374
struct intel_pmt_namespace *ns);
75+
#if IS_ENABLED(CONFIG_INTEL_PMT_DISCOVERY)
76+
void intel_pmt_get_features(struct intel_pmt_entry *entry);
77+
#else
78+
static inline void intel_pmt_get_features(struct intel_pmt_entry *entry) {}
79+
#endif
80+
7481
#endif

drivers/platform/x86/intel/pmt/discovery.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,39 @@ static int pmt_features_probe(struct auxiliary_device *auxdev, const struct auxi
583583
return ret;
584584
}
585585

586+
static void pmt_get_features(struct intel_pmt_entry *entry, struct feature *f)
587+
{
588+
int num_guids = f->table.header.num_guids;
589+
int i;
590+
591+
for (i = 0; i < num_guids; i++) {
592+
if (f->table.guids[i] != entry->guid)
593+
continue;
594+
595+
entry->feature_flags |= BIT(f->id);
596+
597+
if (feature_layout[f->id] == LAYOUT_RMID)
598+
entry->num_rmids = f->table.rmid.num_rmids;
599+
else
600+
entry->num_rmids = 0; /* entry is kzalloc but set anyway */
601+
}
602+
}
603+
604+
void intel_pmt_get_features(struct intel_pmt_entry *entry)
605+
{
606+
struct feature *feature;
607+
608+
mutex_lock(&feature_list_lock);
609+
list_for_each_entry(feature, &pmt_feature_list, list) {
610+
if (feature->priv->parent != &entry->ep->pcidev->dev)
611+
continue;
612+
613+
pmt_get_features(entry, feature);
614+
}
615+
mutex_unlock(&feature_list_lock);
616+
}
617+
EXPORT_SYMBOL_NS_GPL(intel_pmt_get_features, "INTEL_PMT");
618+
586619
static const struct auxiliary_device_id pmt_features_id_table[] = {
587620
{ .name = "intel_vsec.discovery" },
588621
{}

drivers/platform/x86/intel/pmt/telemetry.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
*/
1010

1111
#include <linux/auxiliary_bus.h>
12+
#include <linux/intel_pmt_features.h>
1213
#include <linux/intel_vsec.h>
1314
#include <linux/kernel.h>
15+
#include <linux/kref.h>
1416
#include <linux/module.h>
1517
#include <linux/pci.h>
1618
#include <linux/slab.h>
19+
#include <linux/types.h>
1720
#include <linux/uaccess.h>
1821
#include <linux/overflow.h>
1922

@@ -311,6 +314,8 @@ static int pmt_telem_probe(struct auxiliary_device *auxdev, const struct auxilia
311314
continue;
312315

313316
priv->num_entries++;
317+
318+
intel_pmt_get_features(entry);
314319
}
315320

316321
return 0;

include/linux/intel_vsec.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/auxiliary_bus.h>
66
#include <linux/bits.h>
7+
#include <linux/intel_pmt_features.h>
78

89
/*
910
* VSEC_CAP_UNUSED is reserved. It exists to prevent zero initialized
@@ -166,6 +167,21 @@ struct oobmsm_plat_info {
166167
u8 function_number;
167168
};
168169

170+
struct telemetry_region {
171+
struct oobmsm_plat_info plat_info;
172+
void __iomem *addr;
173+
size_t size;
174+
u32 guid;
175+
u32 num_rmids;
176+
};
177+
178+
struct pmt_feature_group {
179+
enum pmt_feature_id id;
180+
int count;
181+
struct kref kref;
182+
struct telemetry_region regions[];
183+
};
184+
169185
int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
170186
struct intel_vsec_device *intel_vsec_dev,
171187
const char *name);

0 commit comments

Comments
 (0)