Skip to content

Commit 9803d4c

Browse files
committed
Merge PR#109 -- branch 'intel-pmt-enhancement-cwf' into intel-baseline-6.6-velinux
Backport PMT spec 3.0 support (Discovery driver and preparation for PMT AET). This PR adds PMT spec 3.0 support, which is critical for AET feature. Note, this PR depends on PR openvelinux#95, PR openvelinux#48 and PR openvelinux#108. commits 1-24 are from these PRs. Note, commit 35/50 in this PR fixes a boot crush introduced by commit b628352 ("sysfs: Introduce a mechanism to hide static attribute_groups") which is merged recently. Add new configs CONFIG_INTEL_PMT_DISCOVERY=m CONFIG_INTEL_PMT_KUNIT_TEST is not set Test: Tested on GNR/CWF. On CWF, pmt discovery driver is loaded with all available features dumped. On GNR, no regression is found. No regression found by lkvs testcases for PMT telemetry driver
2 parents ac0669b + 10151fe commit 9803d4c

24 files changed

Lines changed: 2085 additions & 197 deletions

File tree

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
What: /sys/class/intel_pmt/features-<PCI BDF>/
2+
Date: 2025-04-24
3+
KernelVersion: 6.16
4+
Contact: david.e.box@linux.intel.com
5+
Description:
6+
The `features-<PCI BDF>/` directory represents the "features"
7+
capability exposed by Intel PMT (Platform Monitoring Technology)
8+
for the given PCI device.
9+
10+
Each directory corresponds to a PMT feature and contains
11+
attributes describing the available telemetry, monitoring, or
12+
control functionalities.
13+
14+
Directory Structure:
15+
16+
/sys/class/intel_pmt/features-<PCI BDF>/
17+
├── accelerator_telemetry/ # Per-accelerator telemetry data
18+
├── crash_log/ # Contains system crash telemetry logs
19+
├── per_core_environment_telemetry/ # Environmental telemetry per core
20+
├── per_core_performance_telemetry/ # Performance telemetry per core
21+
├── per_rmid_energy_telemetry/ # Energy telemetry for RMIDs
22+
├── per_rmid_perf_telemetry/ # Performance telemetry for RMIDs
23+
├── tpmi_control/ # TPMI-related controls and telemetry
24+
├── tracing/ # PMT tracing features
25+
└── uncore_telemetry/ # Uncore telemetry data
26+
27+
Common Files (Present in all feature directories):
28+
29+
caps
30+
- Read-only
31+
- Lists available capabilities for this feature.
32+
33+
guids
34+
- Read-only
35+
- Lists GUIDs associated with this feature.
36+
37+
Additional Attributes (Conditional Presence):
38+
39+
max_command_size
40+
- Read-only
41+
- Present if the feature supports out-of-band MCTP access.
42+
- Maximum supported MCTP command size for out-of-band PMT access (bytes).
43+
44+
max_stream_size
45+
- Read-only
46+
- Present if the feature supports out-of-band MCTP access.
47+
- Maximum supported MCTP stream size (bytes).
48+
49+
min_watcher_period_ms
50+
- Read-only
51+
- Present if the feature supports the watcher API.
52+
The watcher API provides a writable control interface that allows user
53+
configuration of monitoring behavior, such as setting the sampling or
54+
reporting interval.
55+
- Minimum supported time period for the watcher interface (milliseconds).
56+
57+
num_rmids
58+
- Read-only
59+
- Present if the feature supports RMID (Resource Monitoring ID) telemetry.
60+
RMIDs are identifiers used by hardware to track and report resource usage,
61+
such as memory bandwidth or energy consumption, on a per-logical-entity
62+
basis (e.g., per core, thread, or process group).
63+
- Maximum number of RMIDs tracked simultaneously.
64+
65+
Example:
66+
For a device with PCI BDF `0000:00:03.1`, the directory tree could look like:
67+
68+
/sys/class/intel_pmt/features-0000:00:03.1/
69+
├── accelerator_telemetry/
70+
│ ├── caps
71+
│ ├── guids
72+
│ ├── max_command_size
73+
│ ├── max_stream_size
74+
│ ├── min_watcher_period_ms
75+
├── crash_log/
76+
│ ├── caps
77+
│ ├── guids
78+
│ ├── max_command_size
79+
│ ├── max_stream_size
80+
├── per_core_environment_telemetry/
81+
│ ├── caps
82+
│ ├── guids
83+
│ ├── max_command_size
84+
│ ├── max_stream_size
85+
│ ├── min_watcher_period_ms
86+
├── per_rmid_energy_telemetry/
87+
│ ├── caps
88+
│ ├── guids
89+
│ ├── max_command_size
90+
│ ├── max_stream_size
91+
│ ├── min_watcher_period_ms
92+
│ ├── num_rmids
93+
├── tpmi_control/
94+
│ ├── caps
95+
│ ├── guids
96+
├── tracing/
97+
│ ├── caps
98+
│ ├── guids
99+
├── uncore_telemetry/
100+
│ ├── caps
101+
│ ├── guids
102+
│ ├── max_command_size
103+
│ ├── max_stream_size
104+
│ ├── min_watcher_period_ms
105+
106+
Notes:
107+
- Some attributes are only present if the corresponding feature supports
108+
the capability (e.g., `max_command_size` for MCTP-capable features).
109+
- Features supporting RMIDs include `num_rmids`.
110+
- Features supporting the watcher API include `min_watcher_period_ms`.
111+
- The `caps` file provides additional information about the functionality
112+
of the feature.
113+
114+
Example 'caps' content for the 'tracing' feature:
115+
116+
/sys/class/intel_pmt/features-0000:00:03.1/
117+
├── tracing/
118+
│ ├── caps
119+
120+
telemetry Available: No
121+
watcher Available: Yes
122+
crashlog Available: No
123+
streaming Available: No
124+
threashold Available: No
125+
window Available: No
126+
config Available: Yes
127+
tracing Available: No
128+
inband Available: Yes
129+
oob Available: Yes
130+
secure_chan Available: No
131+
pmt_sp Available: Yes
132+
pmt_sp_policy Available: Yes
133+
mailbox Available: Yes
134+
bios_lock Available: Yes

MAINTAINERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10762,6 +10762,8 @@ F: include/linux/mfd/intel_soc_pmic*
1076210762
INTEL PMT DRIVERS
1076310763
M: David E. Box <david.e.box@linux.intel.com>
1076410764
S: Supported
10765+
F: Documentation/ABI/testing/sysfs-class-intel_pmt
10766+
F: Documentation/ABI/testing/sysfs-class-intel_pmt-features
1076510767
F: drivers/platform/x86/intel/pmt/
1076610768

1076710769
INTEL PRO/WIRELESS 2100, 2200BG, 2915ABG NETWORK CONNECTION SUPPORT
@@ -10870,7 +10872,8 @@ F: drivers/platform/x86/intel/uncore-frequency/
1087010872
INTEL VENDOR SPECIFIC EXTENDED CAPABILITIES DRIVER
1087110873
M: David E. Box <david.e.box@linux.intel.com>
1087210874
S: Supported
10873-
F: drivers/platform/x86/intel/vsec.*
10875+
F: drivers/platform/x86/intel/vsec.c
10876+
F: include/linux/intel_vsec.h
1087410877

1087510878
INTEL VIRTUAL BUTTON DRIVER
1087610879
M: AceLan Kao <acelan.kao@canonical.com>

config.x86_64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8169,6 +8169,7 @@ CONFIG_INTEL_IFS=m
81698169
CONFIG_INTEL_PMT_CLASS=m
81708170
CONFIG_INTEL_PMT_TELEMETRY=m
81718171
CONFIG_INTEL_PMT_CRASHLOG=m
8172+
CONFIG_INTEL_PMT_DISCOVERY=m
81728173

81738174
#
81748175
# Intel Speed Select Technology interface support

drivers/platform/x86/intel/intel_plr_tpmi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/err.h>
1515
#include <linux/gfp_types.h>
1616
#include <linux/intel_tpmi.h>
17+
#include <linux/intel_vsec.h>
1718
#include <linux/io.h>
1819
#include <linux/iopoll.h>
1920
#include <linux/kstrtox.h>
@@ -256,7 +257,7 @@ DEFINE_SHOW_STORE_ATTRIBUTE(plr_status);
256257

257258
static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id)
258259
{
259-
struct intel_tpmi_plat_info *plat_info;
260+
struct oobmsm_plat_info *plat_info;
260261
struct dentry *dentry;
261262
int i, num_resources;
262263
struct resource *res;

drivers/platform/x86/intel/pmt/Kconfig

Lines changed: 28 additions & 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
@@ -38,3 +39,30 @@ config INTEL_PMT_CRASHLOG
3839

3940
To compile this driver as a module, choose M here: the module
4041
will be called intel_pmt_crashlog.
42+
43+
config INTEL_PMT_DISCOVERY
44+
tristate "Intel Platform Monitoring Technology (PMT) Discovery driver"
45+
depends on INTEL_VSEC
46+
select INTEL_PMT_CLASS
47+
help
48+
The Intel Platform Monitoring Technology (PMT) discovery driver provides
49+
access to details about the various PMT features and feature specific
50+
attributes.
51+
52+
To compile this driver as a module, choose M here: the module
53+
will be called pmt_discovery.
54+
55+
config INTEL_PMT_KUNIT_TEST
56+
tristate "KUnit tests for Intel PMT driver"
57+
depends on INTEL_PMT_DISCOVERY
58+
depends on INTEL_PMT_TELEMETRY || !INTEL_PMT_TELEMETRY
59+
depends on KUNIT
60+
help
61+
Enable this option to compile and run a suite of KUnit tests for the Intel
62+
Platform Monitoring Technology (PMT) driver. These tests are designed to
63+
validate the driver's functionality, error handling, and overall stability,
64+
helping developers catch regressions and ensure code quality during changes.
65+
66+
This option is intended for development and testing environments. It is
67+
recommended to disable it in production builds. To compile this driver as a
68+
module, choose M here: the module will be called pmt-discovery-kunit.

drivers/platform/x86/intel/pmt/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ obj-$(CONFIG_INTEL_PMT_TELEMETRY) += pmt_telemetry.o
1010
pmt_telemetry-y := telemetry.o
1111
obj-$(CONFIG_INTEL_PMT_CRASHLOG) += pmt_crashlog.o
1212
pmt_crashlog-y := crashlog.o
13+
obj-$(CONFIG_INTEL_PMT_DISCOVERY) += pmt_discovery.o
14+
pmt_discovery-y := discovery.o features.o
15+
obj-$(CONFIG_INTEL_PMT_KUNIT_TEST) += pmt-discovery-kunit.o
16+
pmt-discovery-kunit-y := discovery-kunit.o

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

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

1111
#include <linux/kernel.h>
12+
#include <linux/log2.h>
13+
#include <linux/intel_vsec.h>
1214
#include <linux/io-64-nonatomic-lo-hi.h>
1315
#include <linux/module.h>
1416
#include <linux/mm.h>
1517
#include <linux/pci.h>
18+
#include <linux/sysfs.h>
1619

17-
#include "../vsec.h"
1820
#include "class.h"
1921

2022
#define PMT_XA_START 1
@@ -58,6 +60,24 @@ pmt_memcpy64_fromio(void *to, const u64 __iomem *from, size_t count)
5860
return count;
5961
}
6062

63+
int pmt_telem_read_mmio(struct pci_dev *pdev, struct pmt_callbacks *cb, u32 guid, void *buf,
64+
void __iomem *addr, loff_t off, u32 count)
65+
{
66+
if (cb && cb->read_telem)
67+
return cb->read_telem(pdev, guid, buf, off, count);
68+
69+
addr += off;
70+
71+
if (guid == GUID_SPR_PUNIT)
72+
/* PUNIT on SPR only supports aligned 64-bit read */
73+
return pmt_memcpy64_fromio(buf, addr, count);
74+
75+
memcpy_fromio(buf, addr, count);
76+
77+
return count;
78+
}
79+
EXPORT_SYMBOL_NS_GPL(pmt_telem_read_mmio, INTEL_PMT);
80+
6181
/*
6282
* sysfs
6383
*/
@@ -79,11 +99,8 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
7999
if (count > entry->size - off)
80100
count = entry->size - off;
81101

82-
if (entry->guid == GUID_SPR_PUNIT)
83-
/* PUNIT on SPR only supports aligned 64-bit read */
84-
count = pmt_memcpy64_fromio(buf, entry->base + off, count);
85-
else
86-
memcpy_fromio(buf, entry->base + off, count);
102+
count = pmt_telem_read_mmio(entry->pcidev, entry->cb, entry->header.guid, buf,
103+
entry->base, off, count);
87104

88105
return count;
89106
}
@@ -151,12 +168,41 @@ static struct attribute *intel_pmt_attrs[] = {
151168
&dev_attr_offset.attr,
152169
NULL
153170
};
154-
ATTRIBUTE_GROUPS(intel_pmt);
155171

156-
static struct class intel_pmt_class = {
172+
static umode_t intel_pmt_attr_visible(struct kobject *kobj,
173+
struct attribute *attr, int n)
174+
{
175+
struct device *dev = container_of(kobj, struct device, kobj);
176+
struct auxiliary_device *auxdev = to_auxiliary_dev(dev->parent);
177+
struct intel_vsec_device *ivdev = auxdev_to_ivdev(auxdev);
178+
179+
/*
180+
* Place the discovery features folder in /sys/class/intel_pmt, but
181+
* exclude the common attributes as they are not applicable.
182+
*/
183+
if (ivdev->cap_id == ilog2(VSEC_CAP_DISCOVERY))
184+
return 0;
185+
186+
return attr->mode;
187+
}
188+
189+
static bool intel_pmt_group_visible(struct kobject *kobj)
190+
{
191+
return true;
192+
}
193+
DEFINE_SYSFS_GROUP_VISIBLE(intel_pmt);
194+
195+
static const struct attribute_group intel_pmt_group = {
196+
.attrs = intel_pmt_attrs,
197+
.is_visible = SYSFS_GROUP_VISIBLE(intel_pmt),
198+
};
199+
__ATTRIBUTE_GROUPS(intel_pmt);
200+
201+
struct class intel_pmt_class = {
157202
.name = "intel_pmt",
158203
.dev_groups = intel_pmt_groups,
159204
};
205+
EXPORT_SYMBOL_GPL(intel_pmt_class);
160206

161207
static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
162208
struct intel_vsec_device *ivdev,
@@ -237,8 +283,10 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
237283
return -EINVAL;
238284
}
239285

286+
entry->pcidev = pci_dev;
240287
entry->guid = header->guid;
241288
entry->size = header->size;
289+
entry->cb = ivdev->priv_data;
242290

243291
return 0;
244292
}
@@ -300,7 +348,7 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
300348
goto fail_ioremap;
301349

302350
if (ns->pmt_add_endpoint) {
303-
ret = ns->pmt_add_endpoint(entry, ivdev->pcidev);
351+
ret = ns->pmt_add_endpoint(ivdev, entry);
304352
if (ret)
305353
goto fail_add_endpoint;
306354
}

0 commit comments

Comments
 (0)