@@ -14,19 +14,26 @@ Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1414
1515## Table of Contents
1616
17- - [ Overview] ( #overview )
18- - [ TPMI Drivers] ( #tpmi-drivers )
19- - [ Debugfs Interface] ( #debugfs-interface )
20- - [ TPMI Spec Files] ( #tpmi-spec-files )
21- - [ Spec File Loading] ( #spec-file-loading )
22- - [ Usage of ` pepc tpmi ` Command] ( #usage-of-pepc-tpmi-command )
23- - [ Examples] ( #examples )
24-
25- ## Overview
17+ - [ Introduction] ( #introduction )
18+ - [ TPMI Overview] ( #tpmi-overview )
19+ - [ TPMI Drivers] ( #tpmi-drivers )
20+ - [ Debugfs Interface] ( #debugfs-interface )
21+ - [ ` pepc ` TPMI Spec Files] ( #pepc-tpmi-spec-files )
22+ - [ Spec File Loading] ( #spec-file-loading )
23+ - [ ` pepc tpmi ` Usage] ( #pepc-tpmi-usage )
24+ - [ Live System Usage] ( #live-system-usage )
25+ - [ Examples] ( #examples )
26+ - [ TPMI debugfs Dump Decoding] ( #tpmi-debugfs-dump-decoding )
27+ - [ How To Construct VFM] ( #how-to-construct-vfm )
28+ - [ Examples] ( #examples-1 )
29+
30+ ## Introduction
2631
2732The ` pepc tpmi ` command groups operations related to TPMI. This document provides an overview of
2833the TPMI mechanism and explains how to use the ` pepc tpmi ` command.
2934
35+ ## TPMI Overview
36+
3037TPMI stands for Topology Aware Register and PM Capsule Interface. It provides a standardized way for
3138software to discover, configure, and control various PM (Power Management) features. Today, TPMI is
3239only available on server platforms starting from Granite Rapids and Sierra Forest Xeon.
@@ -84,7 +91,7 @@ TPMI devices
8491 └── Control registers (one copy per cluster)
8592```
8693
87- ## TPMI Drivers
94+ ### TPMI Drivers
8895
8996Different TPMI features may be managed by different Linux kernel drivers. For example, the UFS feature is
9097handled by the ` intel_uncore_freq_tpmi ` driver, and the SST feature is handled by the
@@ -94,7 +101,7 @@ The generic `intel_tpmi` driver is responsible for enumerating TPMI devices and
94101also exposes the entire TPMI device register space via 'debugfs' (typically mounted at
95102'/sys/kernel/debug'), allowing user-space tools to discover, read, and write to any TPMI register.
96103
97- ## Debugfs Interface
104+ ### Debugfs Interface
98105
99106Today, the 'tpmi' mechanism in ` pepc ` uses the TPMI debugfs interface to read and write TPMI
100107registers. Here is an example of TPMI debugfs layout on a Granite Rapids system:
@@ -144,7 +151,7 @@ TPMI Instance:4 offset:0x900040c0
144151The 'mem_write' file can be used to write to UFS registers. The writes are in the
145152'<instance >,<offset >,<value >' format.
146153
147- ## TPMI Spec Files
154+ ## ` pepc ` TPMI Spec Files
148155
149156The Linux kernel exposes raw TPMI registers via debugfs. However, to make sense of these registers,
150157` pepc ` needs to know the register layout, i.e., which register is at which offset, what each register
@@ -170,7 +177,7 @@ files using the `tpmi-spec-files-generator` tool, which is available in the `pep
170177** Note:** ` pepc ` git repository provides TPMI files only for some TPMI features, e.g., UFS and SST.
171178While the most important features are covered, not all TPMI features are supported.
172179
173- ## Spec File Loading
180+ ### Spec File Loading
174181
175182When running a ` pepc tpmi ` command, ` pepc ` first searches for TPMI spec files. Spec files are
176183installed along with ` pepc ` , so they are typically found in one of the standard locations.
@@ -188,7 +195,13 @@ $ export PEPC_TPMI_DATA_PATH=/home/user/tpmi-data
188195This overrides only the standard 'ufs.yml' file with your custom version. Other spec
189196files are not overridden, and ` pepc ` will use the standard spec files for other features.
190197
191- ## Usage of ` pepc tpmi ` Command
198+ ## ` pepc tpmi ` Usage
199+
200+ There are 2 ` pepc tpmi ` usage scenarios:
201+ 1 . Using ` pepc tpmi ` on a live system to read and write TPMI registers.
202+ 2 . Using ` pepc tpmi ` to decode TPMI debugfs dumps from other systems.
203+
204+ ### Live System Usage
192205
193206The general usage pattern of the ` pepc tpmi ` command is:
1942071 . Discover available TPMI features on the target system using ` pepc tpmi ls ` .
@@ -197,10 +210,10 @@ The general usage pattern of the `pepc tpmi` command is:
197210 - You may find the ` --yaml ` option useful.
1982112 . Read TPMI registers using ` pepc tpmi read ` , filtering by feature, package, instance, cluster,
199212 register, or bit field as needed.
200- 2 . Write to TPMI registers using ` pepc tpmi write ` , specifying the target feature, package,
213+ 3 . Write to TPMI registers using ` pepc tpmi write ` , specifying the target feature, package,
201214 instance, cluster, register, and bit field.
202215
203- ## Examples
216+ #### Examples
204217
205218** List Available TPMI Features**
206219
@@ -246,7 +259,7 @@ $ pepc tpmi ls --list-specs
246259TPMI spec directories information:
247260- /home/dedekind/git/pepc/pepcdata/tpmi
248261 Format version: 1.0
249- VFM: 1709
262+ VFM: 0x6AD
250263 Platform Name: Granite Rapids Xeon
251264 Spec Sub-directory Path: /home/dedekind/git/pepc/pepcdata/tpmi/gnr
252265TPMI spec files:
@@ -420,3 +433,120 @@ $ pepc tpmi read -F ufs --registers UFS_STATUS --packages 0 --instances 4 --no-b
420433 - Cluster: 0
421434 - UFS_STATUS: 0x279ff040ada88
422435```
436+
437+ ### TPMI debugfs Dump Decoding
438+
439+ ` pepc tpmi ` can decode TPMI debugfs dumps captured from other systems. The usage is similar to live
440+ system usage, with two key differences:
441+
442+ 1 . Use the ` --base ` option to specify the path to the debugfs dump directory instead of accessing
443+ the default '/sys/kernel/debug' path.
444+ 2 . Use the ` --vfm ` option to specify the VFM (Vendor, Family, Model) of the system from which the
445+ dump was captured. This ensures ` pepc ` uses the correct TPMI spec files for decoding. If ` --vfm `
446+ is not provided, ` pepc ` assumes Granite Rapids Xeon (VFM 0x6AD).
447+
448+ The debugfs dump directory structure must match the standard TPMI debugfs layout described in the
449+ [ Debugfs Interface] ( #debugfs-interface ) section.
450+
451+ All filtering options available for live systems (` --features ` , ` --packages ` , ` --instances ` ,
452+ ` --clusters ` , ` --registers ` , ` --bitfields ` ) work the same way with debugfs dumps.
453+
454+ #### How To Construct VFM
455+
456+ VFM (Vendor, Family, Model) is a 32-bit value that uniquely identifies a CPU model. The encoding is:
457+
458+ ```
459+ VFM = (vendor << 16) | (family << 8) | model
460+ ```
461+
462+ Where:
463+ - ** Vendor codes** : Intel = 0, AMD = 1
464+ - ** Family** and ** Model** : Obtained from ` /proc/cpuinfo `
465+
466+ ** Examples**
467+
468+ 1 . Intel CPU with family 6, model 0xAD (173 decimal):
469+ ```
470+ VFM = (6 << 8) | 0xAD = 0x600 | 0xAD = 0x6AD
471+ ```
472+ 2 . AMD CPU with family 19, model 0x1:
473+ ```
474+ VFM = (1 << 16) | (19 << 8) | 0x1 = 0x10000 | 0x1300 | 0x1 = 0x11301
475+ ```
476+
477+ #### Examples
478+
479+ Suppose you have a partial TPMI debugfs dump, that includes only few features:
480+
481+ ```
482+ $ tree /home/dedekind/tmp/debugfs-dump/
483+ /home/dedekind/tmp/debugfs-dump/
484+ ├── tpmi-0000:00:02.1
485+ │ ├── tpmi-id-00
486+ │ │ └── mem_dump
487+ │ ├── tpmi-id-02
488+ │ │ └── mem_dump
489+ │ ├── tpmi-id-81
490+ │ │ └── mem_dump
491+ │ └── tpmi-id-fe
492+ │ └── mem_dump
493+ └── tpmi-0001:00:02.1
494+ ├── tpmi-id-00
495+ │ └── mem_dump
496+ ├── tpmi-id-02
497+ │ └── mem_dump
498+ ├── tpmi-id-81
499+ │ └── mem_dump
500+ └── tpmi-id-fe
501+ └── mem_dump
502+ ```
503+
504+ *** Check TPMI Spec Files***
505+
506+ It is always handy to first verify that you have the correct TPMI spec files for the target system.
507+ Use the ` --list-specs ` option along with ` --base ` . Optionally, use ` --vfm ` to specify the target
508+ system VFM, but in this example, Granite Rapids Xeon TPMI spec files are OK for decoding.
509+
510+ ``` bash
511+ $ pepc tpmi ls --list-specs --base /home/dedekind/tmp/debugfs-dump/
512+ pepc: notice: No VFM provided, assuming VFM 0x6AD (Granite Rapids Xeon) for decoding TPMI debugfs dump
513+ TPMI spec directories information:
514+ - /home/dedekind/git/pepc/pepcdata/tpmi
515+ Format version: 1.0
516+ VFM: 0x6AD
517+ Platform Name: Granite Rapids Xeon
518+ Spec Sub-directory Path: /home/dedekind/git/pepc/pepcdata/tpmi/gnr
519+ TPMI spec files:
520+ - rapl (0): Running Average Power Limit (RAPL) reporting and control
521+ Spec file: /home/dedekind/git/pepc/pepcdata/tpmi/gnr/rapl.yml
522+ - ufs (2): Processor uncore (fabric) monitoring and control
523+ Spec file: /home/dedekind/git/pepc/pepcdata/tpmi/gnr/ufs.yml
524+ - sst (5): Intel Speed Select Technology (SST) control
525+ Spec file: /home/dedekind/git/pepc/pepcdata/tpmi/gnr/sst.yml
526+ - tpmi_info (129): TPMI Info Registers
527+ Spec file: /home/dedekind/git/pepc/pepcdata/tpmi/gnr/tpmi_info.yml
528+ ```
529+
530+ ** Read a TPMI Register from the Dump**
531+
532+ To read the 'UFS_STATUS' register of the UFS feature for package 0, instance 0 from the debugfs
533+ dump:
534+
535+ ``` bash
536+ $ pepc tpmi read -F ufs --registers UFS_STATUS --packages 0 --instances 0 --base /home/dedekind/tmp/debugfs-dump/
537+ pepc: notice: No VFM provided, assuming VFM 0x6AD (Granite Rapids Xeon) for decoding TPMI debugfs dump
538+ - TPMI feature: ufs
539+ - PCI address: 0000:00:02.1
540+ Package: 0
541+ - Instance: 0
542+ - Cluster: 0
543+ - UFS_STATUS: 0x18c7f14018c7f14
544+ CURRENT_RATIO[6:0]: 20
545+ CURRENT_VOLTAGE[22:7]: 6398
546+ AGENT_TYPE_CORE[23:23]: 1
547+ AGENT_TYPE_CACHE[24:24]: 1
548+ AGENT_TYPE_MEMORY[25:25]: 0
549+ AGENT_TYPE_IO[26:26]: 0
550+ RSVD[31:27]: 0
551+ THROTTLE_COUNTER[63:32]: 25984788
552+ ```
0 commit comments