Add debugfs node to expose pcie link state residency
Subsystems (2)
cover Add debugfs node to expose pcie link state residency
The changes in the first patch is taken from
https://patchwork.freedesktop.org/series/149026/
Thay are added only for compilation and does not
require review.
This patch exposes pcie link state residency counter values through
debugfs for L0, L1, L1.2.
Soham Purkait (3):
Utility function and macro for telemetry reading drm/xe/regs/xe_pmt: Macros for pcie link state residency offset drm/xe/xe_debugfs: Exposure of pcie link state residency counters
through debugfs
drivers/gpu/drm/xe/regs/xe_pmt.h | 9 ++++++ drivers/gpu/drm/xe/xe_debugfs.c | 49 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_vsec.c | 2 +- drivers/gpu/drm/xe/xe_vsec.h | 5 ++++ 4 files changed, 64 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH 1/3 Utility function and macro for telemetry reading
The changes in this patch is taken from
https://patchwork.freedesktop.org/series/149026/
Thay are added only for compilation and does not
require review.
--- drivers/gpu/drm/xe/regs/xe_pmt.h | 5 +++++ drivers/gpu/drm/xe/xe_vsec.c | 2 +- drivers/gpu/drm/xe/xe_vsec.h | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/regs/xe_pmt.h +5 -0
@@ -10,6 +10,11 @@#define BMG_PMT_BASE_OFFSET 0xDB000#define BMG_DISCOVERY_OFFSET (SOC_BASE + BMG_PMT_BASE_OFFSET) +#define PUNIT_TELEMETRY_GUID XE_REG(BMG_DISCOVERY_OFFSET + 0x4) +#define BMG_ENERGY_STATUS_PMT_OFFSET (0x30) +#define ENERGY_PKG REG_GENMASK64(31, 0) +#define ENERGY_CARD REG_GENMASK64(63, 32) +#define BMG_TELEMETRY_BASE_OFFSET 0xE0000#define BMG_TELEMETRY_OFFSET (SOC_BASE + BMG_TELEMETRY_BASE_OFFSET)
drivers/gpu/drm/xe/xe_vsec.c +1 -1
@@ -149,7 +149,7 @@ static int xe_guid_decode(u32 guid, int *index, u32 *offset)return 0 ; } -static int xe_pmt_telem_read (struct pci_dev *pdev,u32 guid,u64 *data,loff_t user_offset, +int xe_pmt_telem_read (struct pci_dev *pdev,u32 guid,u64 *data,loff_t user_offset,u32 count) {struct xe_device *xe =pdev_to_xe_device (pdev);
drivers/gpu/drm/xe/xe_vsec.h +5 -0
@@ -4,8 +4,13 @@#ifndef _XE_VSEC_H_#define _XE_VSEC_H_ +#include "linux/types.h" +#include "linux/pci.h" +struct xe_device ;void xe_vsec_init (struct xe_device *xe); +int xe_pmt_telem_read (struct pci_dev *pdev,u32 guid,u64 *data,loff_t user_offset, +u32 count);#endif
Signature · 1 line
2.34.1
PATCH 2/3 drm/xe/regs/xe_pmt: Macros for pcie link state residency offset
In reply to Soham PurkaitAdd pcie link state residency offset macros for L0, L1, L1.2
--- drivers/gpu/drm/xe/regs/xe_pmt.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/xe/regs/xe_pmt.h +4 -0
@@ -21,4 +21,8 @@#define SG_REMAP_INDEX1 XE_REG(SOC_BASE + 0x08)#define SG_REMAP_BITS REG_GENMASK(31, 24) +#define PCIE_LINK_L0_RESIDENCY_COUNTER (0x570) +#define PCIE_LINK_L1_RESIDENCY_COUNTER (0x578) +#define PCIE_LINK_L1_2_RESIDENCY_COUNTER (0x580) +#endif
Signature · 1 line
2.34.1
PATCH 3/3 drm/xe/xe_debugfs: Exposure of pcie link state residency counters through debugfs
In reply to Soham Purkait Add a debugfs node named dgfx_link_state_residencys in order to
obtain the pcie link state residency counter values for L0, L1, L1.2
--- drivers/gpu/drm/xe/xe_debugfs.c | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/gpu/drm/xe/xe_debugfs.c +49 -0
@@ -185,6 +185,47 @@ static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf,return size; } +static int read_residency_counter (struct xe_device *xe,struct xe_mmio *mmio, +u64 *dst,u32 offset,char *name) +{ +int ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + dst, offset,sizeof (u64)); +if (ret !=sizeof (u64)) { +drm_warn (&xe->drm,"%s residency counter failed to read, ret %d\n" , name, ret); + } +return 0 ; +} + +static ssize_t dgfx_link_state_residencys_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 link_res; +char buf[256 ]; +int len =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; +xe_pm_runtime_get (xe); + mmio =xe_root_tile_mmio (xe); + + link_res =0 ; +read_residency_counter (xe, mmio, &link_res,PCIE_LINK_L0_RESIDENCY_COUNTER ,"PCIE LINK L0" ); + len =scnprintf (buf,sizeof (buf),"PCIE LINK L0 RESIDENCY : %llu\n" , link_res); + + link_res =0 ; +read_residency_counter (xe, mmio, &link_res,PCIE_LINK_L1_RESIDENCY_COUNTER ,"PCIE LINK L1" ); + len +=scnprintf (buf + len,sizeof (buf) - len,"PCIE LINK L1 RESIDENCY : %llu\n" , link_res); + + link_res =0 ; +read_residency_counter (xe, mmio, &link_res,PCIE_LINK_L1_2_RESIDENCY_COUNTER ,"PCIE LINK L1.2" ); + len +=scnprintf (buf + len,sizeof (buf) - len,"PCIE LINK L1.2 RESIDENCY : %llu\n" , link_res); + +xe_pm_runtime_put (xe); +return simple_read_from_buffer (ubuf, size, pos, buf, len); +} +static const struct file_operations wedged_mode_fops = { .owner =THIS_MODULE , .read = wedged_mode_show,
@@ -226,6 +267,11 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = { .write = atomic_svm_timeslice_ms_set, }; +static const struct file_operations dgfx_link_state_residencys_fops = { + .owner =THIS_MODULE , + .read = dgfx_link_state_residencys_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;
@@ -249,6 +295,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("atomic_svm_timeslice_ms" ,0600 , root, xe, &atomic_svm_timeslice_ms_fops); +debugfs_create_file ("dgfx_link_state_residencys" ,0444 , root, xe, + &dgfx_link_state_residencys_fops); +for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);
Signature · 1 line
2.34.1
Patchwork
CI✓ CI.Patch_applied: success for Add debugfs node to expose pcie link state residency
In reply to Soham Purkait== Series Details ==
== Series Details ==
Series: Add debugfs node to expose pcie link state residency
URL : https://patchwork.freedesktop.org/series/149660/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 901190a06230 drm-tip: 2025y-05m-29d-16h-22m-38s UTC integration manifest === git am output follows ===
.git/rebase-apply/patch:15: trailing whitespace.
{
.git/rebase-apply/patch:36: trailing whitespace.
mmio = xe_root_tile_mmio(xe);
warning: 2 lines add whitespace errors.
Applying: Utility function and macro for telemetry reading
Applying: drm/xe/regs/xe_pmt: Macros for pcie link state residency offset
Applying: drm/xe/xe_debugfs: Exposure of pcie link state residency counters through debugfs
Patchwork
CI✗ CI.checkpatch: warning for Add debugfs node to expose pcie link state residency
In reply to Soham Purkait== Series Details ==
== Series Details ==
Series: Add debugfs node to expose pcie link state residency
URL : https://patchwork.freedesktop.org/series/149660/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 202708c00696422fd217223bb679a353a5936e23
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 236d658fd524e1b9f165113d20deefd6a407a7a3
Author: Soham Purkait <[email protected]> Date: Fri May 30 00:56:20 2025 +0530
drm/xe/xe_debugfs: Exposure of pcie link state residency counters through debugfs
Add a debugfs node named dgfx_link_state_residencys in order to obtain the pcie link state residency counter values for L0, L1, L1.2
+ /mt/dim checkpatch 901190a062301f01d432d9cf164a6b013df3e745 drm-intel 5db328d98d7c Utility function and macro for telemetry reading
-:37: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #37: FILE: drivers/gpu/drm/xe/xe_vsec.c:153:
+int xe_pmt_telem_read(struct pci_dev *pdev, u32 guid, u64 *data, loff_t user_offset,
u32 count)
-:57: ERROR:MISSING_SIGN_OFF: Missing Signed-off-by: line(s)
total: 1 errors, 0 warnings, 1 checks, 32 lines checkedce2dafadfd1b drm/xe/regs/xe_pmt: Macros for pcie link state residency offset 236d658fd524 drm/xe/xe_debugfs: Exposure of pcie link state residency counters through debugfs -:22: ERROR:CODE_INDENT: code indent should use tabs where possible
#22: FILE: drivers/gpu/drm/xe/xe_debugfs.c:189:
+ u64 *dst, u32 offset, char *name)$
-:22: WARNING:LEADING_SPACE: please, no spaces at the start of a line #22: FILE: drivers/gpu/drm/xe/xe_debugfs.c:189:
+ u64 *dst, u32 offset, char *name)$
-:23: ERROR:TRAILING_WHITESPACE: trailing whitespace #23: FILE: drivers/gpu/drm/xe/xe_debugfs.c:190:
+{^I$
-:27: WARNING:BRACES: braces {} are not necessary for single statement blocks #27: FILE: drivers/gpu/drm/xe/xe_debugfs.c:194:
+ if (ret != sizeof(u64)) {
+ drm_warn(&xe->drm, "%s residency counter failed to read, ret %d\n", name, ret);
+ }
-:34: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #34: FILE: drivers/gpu/drm/xe/xe_debugfs.c:201:
+static ssize_t dgfx_link_state_residencys_show(struct file *f, char __user *ubuf,
+ size_t size, loff_t *pos)
-:44: ERROR:TRAILING_WHITESPACE: trailing whitespace #44: FILE: drivers/gpu/drm/xe/xe_debugfs.c:211:
+^Immio = xe_root_tile_mmio(xe);^I$
-:56: WARNING:LONG_LINE: line length of 102 exceeds 100 columns #56: FILE: drivers/gpu/drm/xe/xe_debugfs.c:223:
+ len += scnprintf(buf + len, sizeof(buf) - len, "PCIE LINK L1.2 RESIDENCY : %llu\n", link_res);
total: 3 errors, 3 warnings, 1 checks, 67 lines checked
Patchwork
CI✗ CI.KUnit: failure for Add debugfs node to expose pcie link state residency
In reply to Soham Purkait== Series Details ==
== Series Details ==
Series: Add debugfs node to expose pcie link state residency
URL : https://patchwork.freedesktop.org/series/149660/
State : failure
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:../drivers/gpu/drm/xe/xe_debugfs.c: In function ‘read_residency_counter’:../drivers/gpu/drm/xe/xe_debugfs.c:191:19: error: implicit declaration of function ‘xe_pmt_telem_read’ [-Werror=implicit-function-declaration]
191 | int ret = xe_pmt_telem_read(to_pci_dev(xe->drm.dev),
| ^~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_debugfs.c:192:33: error: implicit declaration of function ‘xe_mmio_read32’; did you mean ‘xe_map_read32’? [-Werror=implicit-function-declaration]
192 | xe_mmio_read32(mmio, PUNIT_TELEMETRY_GUID),
| ^~~~~~~~~~~~~~
| xe_map_read32
../drivers/gpu/drm/xe/xe_debugfs.c:192:54: error: ‘PUNIT_TELEMETRY_GUID’ undeclared (first use in this function)
192 | xe_mmio_read32(mmio, PUNIT_TELEMETRY_GUID),
| ^~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_debugfs.c:192:54: note: each undeclared identifier is reported only once for each function it appears in
../drivers/gpu/drm/xe/xe_debugfs.c: In function ‘dgfx_link_state_residencys_show’:
../drivers/gpu/drm/xe/xe_debugfs.c:211:16: error: implicit declaration of function ‘xe_root_tile_mmio’ [-Werror=implicit-function-declaration]
211 | mmio = xe_root_tile_mmio(xe);
| ^~~~~~~~~~~~~~~~~../drivers/gpu/drm/xe/xe_debugfs.c:211:14: warning: assignment to ‘struct xe_mmio *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
211 | mmio = xe_root_tile_mmio(xe);
| ^../drivers/gpu/drm/xe/xe_debugfs.c:214:53: error: ‘PCIE_LINK_L0_RESIDENCY_COUNTER’ undeclared (first use in this function)
214 | read_residency_counter(xe, mmio, &link_res, PCIE_LINK_L0_RESIDENCY_COUNTER, "PCIE LINK L0");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_debugfs.c:218:53: error: ‘PCIE_LINK_L1_RESIDENCY_COUNTER’ undeclared (first use in this function)
218 | read_residency_counter(xe, mmio, &link_res, PCIE_LINK_L1_RESIDENCY_COUNTER, "PCIE LINK L1");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/xe_debugfs.c:222:53: error: ‘PCIE_LINK_L1_2_RESIDENCY_COUNTER’ undeclared (first use in this function)
222 | read_residency_counter(xe, mmio, &link_res, PCIE_LINK_L1_2_RESIDENCY_COUNTER, "PCIE LINK L1.2");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
make[7]: *** [../scripts/Makefile.build:203: drivers/gpu/drm/xe/xe_debugfs.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:461: drivers/gpu/drm/xe] Error 2 make[5]: *** [../scripts/Makefile.build:461: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:461: drivers/gpu] Error 2 make[3]: *** [../scripts/Makefile.build:461: drivers] Error 2
make[2]: *** [/kernel/Makefile:2003: .] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[20:31:07] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [20:31:11] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel