Add debugfs to expose G8, G10 and ModS residency
Subsystems (2)
cover Add debugfs to expose G8, G10 and ModS residency
The changes in the first patch is taken from
https://patchwork.freedesktop.org/series/148926/
Thay are added only for compilation and does not require review.
This patch exposes G8, G10 and ModS residency counter value through
debugfs.
Soham Purkait (4):
[DO NOT REVIEW]: Utility function and macro for telemetry reading
drm/xe/xe_debugfs: Exposure of G8 residency counter through debugfs drm/xe/xe_debugfs: Exposure of G10 residency counter through debugfs. drm/xe/xe_debugfs: Exposure of Mods residency counter through debugfs.
drivers/gpu/drm/xe/regs/xe_pmt.h | 5 ++ drivers/gpu/drm/xe/xe_debugfs.c | 103 +++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 4 ++ drivers/gpu/drm/xe/xe_vsec.c | 2 +- drivers/gpu/drm/xe/xe_vsec.h | 5 ++ 5 files changed, 118 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH 1/4 Utility function and macro for telemetry reading
The changes in this patch is taken from
https://patchwork.freedesktop.org/series/148926/
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
Re: [PATCH 1/4] Utility function and macro for telemetry reading
Quoted 44 lines · Soham Purkait
The changes in this patch is taken from
https://patchwork.freedesktop.org/series/148926/
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 +0
-0
drivers/gpu/drm/xe/xe_vsec.h line 9
Quoted 6 lines
drivers/gpu/drm/xe/xe_vsec.h +3
-0@@ -4,8 +4,13 @@#ifndef _XE_VSEC_H_#define _XE_VSEC_H_ +#include "linux/types.h" +#include "linux/pci.h" +
Please address the reviews [1].
BR,
Jani.
Quoted 7 lines
drivers/gpu/drm/xe/xe_vsec.h +2
-0struct 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
Jani Nikula, Intel
Re: [PATCH 1/4] Utility function and macro for telemetry reading
Quoted 48 lines · Jani Nikula
Quoted 47 lines · Soham Purkait
The changes in this patch is taken from
https://patchwork.freedesktop.org/series/148926/
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 +0
-0@@ -4,8 +4,13 @@#ifndef _XE_VSEC_H_#define _XE_VSEC_H_
Quoted 7 lines
drivers/gpu/drm/xe/xe_vsec.h line 9
Quoted 3 lines
drivers/gpu/drm/xe/xe_vsec.h +3
-0+#include "linux/types.h" +#include "linux/pci.h" +Please address the reviews [1].
BR,
Jani.
These are addressed here Jani,
https://patchwork.freedesktop.org/patch/653146/?series=148926&rev=2
Quoted 13 lines
[1] https://lore.kernel.org/r/[email protected]
Quoted 7 lines
drivers/gpu/drm/xe/xe_vsec.h +2
-0struct 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
Re: [PATCH 1/4] Utility function and macro for telemetry reading
Quoted 54 lines · Karthik
Quoted 53 lines · Jani Nikula
Quoted 44 lines · Soham Purkait
The changes in this patch is taken from
https://patchwork.freedesktop.org/series/148926/
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 +0
-0drivers/gpu/drm/xe/xe_vsec.h line 9
Quoted 6 lines
drivers/gpu/drm/xe/xe_vsec.h +3
-0@@ -4,8 +4,13 @@#ifndef _XE_VSEC_H_#define _XE_VSEC_H_ +#include "linux/types.h" +#include "linux/pci.h" +Please address the reviews [1].
Quoted 6 lines
Quoted 2 lines
BR,
Jani.These are addressed here Jani,
https://patchwork.freedesktop.org/patch/653146/?series=148926&rev=2
Please sort this out between you and Soham. This is clearly conflicting stuff, sent *after* the above.
BR,
Jani.
Quoted 13 lines
Quoted 13 lines
[1] https://lore.kernel.org/r/[email protected]
Quoted 7 lines
drivers/gpu/drm/xe/xe_vsec.h +2
-0struct 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
Jani Nikula, Intel
PATCH 2/4 drm/xe/xe_debugfs: Exposure of G8 residency counter
In reply to Soham PurkaitAdd a debugfs node named g8_residency in order to obtain the G8 residency counter value.
--- drivers/gpu/drm/xe/xe_debugfs.c | 37 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 2 ++ 2 files changed, 39 insertions(+)
drivers/gpu/drm/xe/xe_debugfs.c +37 -0
@@ -11,16 +11,19 @@#include <drm/drm_debugfs.h> +#include "regs/xe_pmt.h" #include "xe_bo.h" #include "xe_device.h" #include "xe_force_wake.h" #include "xe_gt_debugfs.h" #include "xe_gt_printk.h" #include "xe_guc_ads.h" +#include "xe_mmio.h" #include "xe_pm.h" #include "xe_pxp_debugfs.h" #include "xe_sriov.h" #include "xe_step.h" +#include "xe_vsec.h" #ifdef CONFIG_DRM_XE_DEBUG #include "xe_bo_evict.h"
@@ -185,12 +188,43 @@ static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf,return size; } +static ssize_t g8_residency_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; + mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + ®_val, +BMG_G8_RESIDENCY_OFFSET , +sizeof (reg_val)); + +drm_warn (&xe->drm,"G8 Residency read from mbx 0x%016llx, ret %d\n" , + reg_val, ret); + + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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, .write = wedged_mode_set, }; +static const struct file_operations g8_residency_fops = { + .owner =THIS_MODULE , + .read = g8_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;
@@ -211,6 +245,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("wedged_mode" ,0600 , root, xe, &wedged_mode_fops); +debugfs_create_file ("g8_residency" ,0444 , root, xe, + &g8_residency_fops); +for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);
drivers/gpu/drm/xe/xe_debugfs.h +2 -0
@@ -8,6 +8,8 @@struct xe_device ; +#define BMG_G8_RESIDENCY_OFFSET (0x540) +#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);#else
Signature · 1 line
2.34.1
RE: [PATCH 2/4] drm/xe/xe_debugfs: Exposure of G8 residency counter
Quoted 13 lines
-----Original Message-----
From: Purkait, Soham <[email protected]>
Sent: Wednesday, May 14, 2025 1:37 PM
To: [email protected]; Gupta, Anshuman <[email protected]>; Nilawar, Badal <[email protected]>; Poosa, Karthik <[email protected]>
Cc: De Marchi, Lucas <[email protected]>; Purkait, Soham <[email protected]>; Dixit, Ashutosh <[email protected]>; Tauro, Riana <[email protected]>
Subject: [PATCH 2/4] drm/xe/xe_debugfs: Exposure of G8 residency counter
Quoted 2 lines
Add a debugfs node named
g8_residencyin order to obtain the G8 residency counter value.
IMO better to expose all such residencies under a debugfs called dgfx_pkgc_residencies CC @Vivi, Rodrigo for naming suggestion.
Context: This is similar to cpu PC8~PC10 residencies. i.e /sys/kernel/debug/pmc_core/package_cstate_show
Thanks,
Anshuman.
Quoted 104 lines
Signed-off-by Soham Purkait <[email protected]>--- drivers/gpu/drm/xe/xe_debugfs.c | 37 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 2 ++ 2 files changed, 39 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/xe/xe_debugfs.cindexd0503959a8ed..f9ab6a03af29100644drivers/gpu/drm/xe/xe_debugfs.c +37
-0@@ -11,16 +11,19 @@#include <drm/drm_debugfs.h> +#include "regs/xe_pmt.h" #include "xe_bo.h" #include "xe_device.h" #include "xe_force_wake.h" #include "xe_gt_debugfs.h" #include "xe_gt_printk.h" #include "xe_guc_ads.h" +#include "xe_mmio.h" #include "xe_pm.h" #include "xe_pxp_debugfs.h" #include "xe_sriov.h" #include "xe_step.h" +#include "xe_vsec.h" #ifdef CONFIG_DRM_XE_DEBUG #include "xe_bo_evict.h" @@ -185,12 +188,43 @@ static ssize_t wedged_mode_set(struct file *f,const char __user *ubuf, return size; } +static ssize_t g8_residency_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; + mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + ®_val, +BMG_G8_RESIDENCY_OFFSET , +sizeof (reg_val)); + + drm_warn(&xe->drm, "G8 Residency read from mbx 0x%016llx, ret %d\n", + reg_val, ret); + + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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, .write = wedged_mode_set, }; +static const struct file_operations g8_residency_fops = { + .owner =THIS_MODULE , + .read = g8_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;@@ -211,6 +245,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("wedged_mode" ,0600 , root, xe, &wedged_mode_fops); +debugfs_create_file ("g8_residency" ,0444 , root, xe, + &g8_residency_fops); +for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);(quoted diff) +0
-0
b/drivers/gpu/drm/xe/xe_debugfs.hindex17f4c2f1b5e4..86868a3cd379100644drivers/gpu/drm/xe/xe_debugfs.h +2
-1@@ -8,6 +8,8 @@struct xe_device ; +#define BMG_G8_RESIDENCY_OFFSET (0x540) +#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);#else --2.34.1
Rodrigo Vivi
maintainerRe: [PATCH 2/4] drm/xe/xe_debugfs: Exposure of G8 residency counter
Quoted 13 lines · Anshuman
Quoted 13 lines
-----Original Message-----
From: Purkait, Soham <[email protected]>
Sent: Wednesday, May 14, 2025 1:37 PM
To: [email protected]; Gupta, Anshuman <[email protected]>; Nilawar, Badal <[email protected]>; Poosa, Karthik <[email protected]>
Cc: De Marchi, Lucas <[email protected]>; Purkait, Soham <[email protected]>; Dixit, Ashutosh <[email protected]>; Tauro, Riana <[email protected]>
Subject: [PATCH 2/4] drm/xe/xe_debugfs: Exposure of G8 residency counter
Quoted 5 lines
Quoted 2 lines
Add a debugfs node named
g8_residencyin order to obtain the G8 residency counter value.IMO better to expose all such residencies under a debugfs called
dgfx_pkgc_residenciesCC @Vivi, Rodrigo for naming suggestion.
Context: This is similar to cpu PC8~PC10 residencies. i.e/sys/kernel/debug/pmc_core/package_cstate_show
I'm with Anshuman here. I'm bad with naming though.
Perhaps dgfx_package_cstate_show ?
And format something like this as well:
$ sudo cat /sys/kernel/debug/pmc_core/package_cstate_show Package C2 : 3250051350 Package C3 : 19056503 Package C6 : 929010443 Package C7 : 0 Package C8 : 2718 Package C9 : 0 Package C10 : 0
But of course, just adding the ones that are relevant to us.
And dgfx_pkgc_residencies also works for me... no preference to either one
Quoted 108 lines
Thanks,
Anshuman.Quoted 104 lines
Signed-off-by Soham Purkait <[email protected]>--- drivers/gpu/drm/xe/xe_debugfs.c | 37 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 2 ++ 2 files changed, 39 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/xe/xe_debugfs.cindexd0503959a8ed..f9ab6a03af29100644drivers/gpu/drm/xe/xe_debugfs.c +37
-0@@ -11,16 +11,19 @@#include <drm/drm_debugfs.h> +#include "regs/xe_pmt.h" #include "xe_bo.h" #include "xe_device.h" #include "xe_force_wake.h" #include "xe_gt_debugfs.h" #include "xe_gt_printk.h" #include "xe_guc_ads.h" +#include "xe_mmio.h" #include "xe_pm.h" #include "xe_pxp_debugfs.h" #include "xe_sriov.h" #include "xe_step.h" +#include "xe_vsec.h" #ifdef CONFIG_DRM_XE_DEBUG #include "xe_bo_evict.h" @@ -185,12 +188,43 @@ static ssize_t wedged_mode_set(struct file *f,const char __user *ubuf, return size; } +static ssize_t g8_residency_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; + mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + ®_val, +BMG_G8_RESIDENCY_OFFSET , +sizeof (reg_val)); + + drm_warn(&xe->drm, "G8 Residency read from mbx 0x%016llx, ret %d\n", + reg_val, ret); + + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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, .write = wedged_mode_set, }; +static const struct file_operations g8_residency_fops = { + .owner =THIS_MODULE , + .read = g8_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;@@ -211,6 +245,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("wedged_mode" ,0600 , root, xe, &wedged_mode_fops); +debugfs_create_file ("g8_residency" ,0444 , root, xe, + &g8_residency_fops); +for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);(quoted diff) +0
-0
b/drivers/gpu/drm/xe/xe_debugfs.hindex17f4c2f1b5e4..86868a3cd379100644drivers/gpu/drm/xe/xe_debugfs.h +2
-1@@ -8,6 +8,8 @@struct xe_device ; +#define BMG_G8_RESIDENCY_OFFSET (0x540) +#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);#else --2.34.1
Re: [PATCH 2/4] drm/xe/xe_debugfs: Exposure of G8 residency counter
In reply to Soham PurkaitHi Soham
Quoted 2 lines · Soham Purkait
Add a debugfs node named
g8_residencyin order to obtain the G8 residency counter value.
If this can be read by PMT, why a debugfs again?
Quoted 35 lines
Signed-off-by Soham Purkait <[email protected]>--- drivers/gpu/drm/xe/xe_debugfs.c | 37 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 2 ++ 2 files changed, 39 insertions(+)drivers/gpu/drm/xe/xe_debugfs.c +3
-0@@ -11,16 +11,19 @@#include <drm/drm_debugfs.h> +#include "regs/xe_pmt.h" #include "xe_bo.h" #include "xe_device.h" #include "xe_force_wake.h" #include "xe_gt_debugfs.h" #include "xe_gt_printk.h" #include "xe_guc_ads.h" +#include "xe_mmio.h" #include "xe_pm.h" #include "xe_pxp_debugfs.h" #include "xe_sriov.h" #include "xe_step.h" +#include "xe_vsec.h" #ifdef CONFIG_DRM_XE_DEBUG #include "xe_bo_evict.h" @@ -185,12 +188,43 @@ static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf,return size; } > +static ssize_t g8_residency_show(struct file *f, char __user *ubuf,
drivers/gpu/drm/xe/xe_debugfs.c static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf, · line 200
Quoted 10 lines
drivers/gpu/drm/xe/xe_debugfs.c +10
-0+ size_t size, loff_t *pos) +{ + u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private;
runtime_get/put missing
drivers/gpu/drm/xe/xe_debugfs.c static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf, · line 207
Quoted 6 lines
drivers/gpu/drm/xe/xe_debugfs.c +6
-0+ mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + ®_val, +BMG_G8_RESIDENCY_OFFSET , +sizeof (reg_val));
error needs to be handled?
drivers/gpu/drm/xe/xe_debugfs.c static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf, · line 210
Quoted 3 lines
drivers/gpu/drm/xe/xe_debugfs.c +3
-0+ +drm_warn (&xe->drm,"G8 Residency read from mbx 0x%016llx, ret %d\n" , + reg_val, ret);
warn gets flagged in CI. Remove this
Quoted 21 lines
drivers/gpu/drm/xe/xe_debugfs.c +11
-0+ + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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, .write = wedged_mode_set, }; +static const struct file_operations g8_residency_fops = { + .owner =THIS_MODULE , + .read = g8_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;
drivers/gpu/drm/xe/xe_debugfs.c void xe_debugfs_register(struct xe_device *xe) · line 249
Quoted 5 lines
drivers/gpu/drm/xe/xe_debugfs.c +2
-0@@ -211,6 +245,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("wedged_mode" ,0600 , root, xe, &wedged_mode_fops); +debugfs_create_file ("g8_residency" ,0444 , root, xe, + &g8_residency_fops);
Since there are multiple residency files they can be under one folder maybe (/sys/kernel/debug/gtidle/) similar to the sysfs
drivers/gpu/drm/xe/xe_debugfs.h line 11
Quoted 13 lines
drivers/gpu/drm/xe/xe_debugfs.c +1
-0+for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);drivers/gpu/drm/xe/xe_debugfs.h +1
-0@@ -8,6 +8,8 @@struct xe_device ; +#define BMG_G8_RESIDENCY_OFFSET (0x540)
These should be in same file as register
Thanks
Riana> +
Quoted 3 lines
drivers/gpu/drm/xe/xe_debugfs.h +0
-0#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);#else
PATCH 3/4 drm/xe/xe_debugfs: Exposure of G10 residency counter
In reply to Soham PurkaitAdd a debugfs node named g10_residency in order to obtain the G10 residency counter value.
--- drivers/gpu/drm/xe/xe_debugfs.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 1 + 2 files changed, 33 insertions(+)
drivers/gpu/drm/xe/xe_debugfs.c +32 -0
@@ -214,6 +214,30 @@ static ssize_t g8_residency_show(struct file *f, char __user *ubuf,return simple_read_from_buffer (ubuf, size, pos, buf, len); } +static ssize_t g10_residency_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; + mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), ®_val,BMG_G10_RESIDENCY_OFFSET , +sizeof (reg_val)); + +drm_warn (&xe->drm,"G10 Residency read from mbx 0x%016llx, ret %d\n" , + reg_val, ret); + + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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,
@@ -225,6 +249,11 @@ static const struct file_operations g8_residency_fops = { .read = g8_residency_show, }; +static const struct file_operations g10_residency_fops = { + .owner =THIS_MODULE , + .read = g10_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;
@@ -248,6 +277,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("g8_residency" ,0444 , root, xe, &g8_residency_fops); +debugfs_create_file ("g10_residency" ,0444 , root, xe, + &g10_residency_fops); +for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);
drivers/gpu/drm/xe/xe_debugfs.h +1 -0
@@ -9,6 +9,7 @@struct xe_device ;#define BMG_G8_RESIDENCY_OFFSET (0x540) +#define BMG_G10_RESIDENCY_OFFSET (0x548)#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);
Signature · 1 line
2.34.1
PATCH 4/4 drm/xe/xe_debugfs: Exposure of Mods residency counter
In reply to Soham PurkaitAdd a debugfs node named mods_residency in order to obtain the ModS residency counter value.
--- drivers/gpu/drm/xe/xe_debugfs.c | 34 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 1 + 2 files changed, 35 insertions(+)
drivers/gpu/drm/xe/xe_debugfs.c +34 -0
@@ -238,6 +238,32 @@ static ssize_t g10_residency_show(struct file *f, char __user *ubuf,return simple_read_from_buffer (ubuf, size, pos, buf, len); } +static ssize_t mods_residency_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe; +struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; + mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + ®_val, +BMG_MODS_RESIDENCY_OFFSET , +sizeof (reg_val)); + +drm_warn (&xe->drm,"ModS Residency read from mbx 0x%016llx, ret %d\n" , + reg_val, ret); + + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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,
@@ -254,6 +280,11 @@ static const struct file_operations g10_residency_fops = { .read = g10_residency_show, }; +static const struct file_operations mods_residency_fops = { + .owner =THIS_MODULE , + .read = mods_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;
@@ -279,6 +310,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("g10_residency" ,0444 , root, xe, &g10_residency_fops); + +debugfs_create_file ("mods_residency" ,0444 , root, xe, + &mods_residency_fops);for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);
drivers/gpu/drm/xe/xe_debugfs.h +1 -0
@@ -10,6 +10,7 @@ struct xe_device;#define BMG_G8_RESIDENCY_OFFSET (0x540)#define BMG_G10_RESIDENCY_OFFSET (0x548) +#define BMG_MODS_RESIDENCY_OFFSET (0x4D0)#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);
Signature · 1 line
2.34.1
Re: [PATCH 4/4] drm/xe/xe_debugfs: Exposure of Mods residency counter
Hi Soham
Quoted 25 lines · Soham Purkait
Add a debugfs node named
mods_residencyin order to obtain the ModS residency counter value.Signed-off-by Soham Purkait <[email protected]>--- drivers/gpu/drm/xe/xe_debugfs.c | 34 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_debugfs.h | 1 + 2 files changed, 35 insertions(+)drivers/gpu/drm/xe/xe_debugfs.c +8
-0@@ -238,6 +238,32 @@ static ssize_t g10_residency_show(struct file *f, char __user *ubuf,return simple_read_from_buffer (ubuf, size, pos, buf, len); } +static ssize_t mods_residency_show (struct file *f,char __user *ubuf, +size_t size,loff_t *pos) +{ +u64 reg_val; +char buf[32 ]; +int len =0 ; +int ret =0 ; +struct xe_device *xe;
drivers/gpu/drm/xe/xe_debugfs.c static ssize_t g10_residency_show(struct file *f, char __user *ubuf, · line 258
Quoted 10 lines
drivers/gpu/drm/xe/xe_debugfs.c +10
-0+struct xe_mmio *mmio; + + xe =file_inode (f)->i_private; + mmio =xe_root_tile_mmio (xe); + ret =xe_pmt_telem_read (to_pci_dev (xe->drm.dev), +xe_mmio_read32 (mmio,PUNIT_TELEMETRY_GUID ), + ®_val, +BMG_MODS_RESIDENCY_OFFSET , +sizeof (reg_val)); +
You can have a helper function since all three entries have similar code with offset as parameter. the patches can also be squashed
Thanks
Riana
Quoted 45 lines
drivers/gpu/drm/xe/xe_debugfs.c +16
-0+drm_warn (&xe->drm,"ModS Residency read from mbx 0x%016llx, ret %d\n" , + reg_val, ret); + + len =scnprintf (buf,sizeof (buf),"%llu\n" , reg_val); + +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,@@ -254,6 +280,11 @@ static const struct file_operations g10_residency_fops = { .read = g10_residency_show, }; +static const struct file_operations mods_residency_fops = { + .owner =THIS_MODULE , + .read = mods_residency_show, +}; +void xe_debugfs_register (struct xe_device *xe) {struct ttm_device *bdev = &xe->ttm;@@ -279,6 +310,9 @@ void xe_debugfs_register(struct xe_device *xe)debugfs_create_file ("g10_residency" ,0444 , root, xe, &g10_residency_fops); + +debugfs_create_file ("mods_residency" ,0444 , root, xe, + &mods_residency_fops);for (mem_type =XE_PL_VRAM0 ; mem_type <=XE_PL_VRAM1 ; ++mem_type) { man =ttm_manager_type (bdev, mem_type);drivers/gpu/drm/xe/xe_debugfs.h +1
-0@@ -10,6 +10,7 @@ struct xe_device;#define BMG_G8_RESIDENCY_OFFSET (0x540)#define BMG_G10_RESIDENCY_OFFSET (0x548) +#define BMG_MODS_RESIDENCY_OFFSET (0x4D0)#ifdef CONFIG_DEBUG_FS void xe_debugfs_register (struct xe_device *xe);
Patchwork
CI✗ CI.Patch_applied: failure for Add debugfs to expose G8, G10 and ModS residency
In reply to Soham Purkait== Series Details ==
== Series Details ==
Series: Add debugfs to expose G8, G10 and ModS residency
URL : https://patchwork.freedesktop.org/series/149001/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 3d6670fab64c drm-tip: 2025y-05m-14d-19h-28m-21s UTC integration manifest === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_debugfs.c:185
error: drivers/gpu/drm/xe/xe_debugfs.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: Utility function and macro for telemetry reading
Applying: drm/xe/xe_debugfs: Exposure of G8 residency counter
Patch failed at 0002 drm/xe/xe_debugfs: Exposure of G8 residency counter When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Patchwork
CI✗ CI.Patch_applied: failure for Add debugfs to expose G8, G10 and ModS residency
In reply to Soham Purkait== Series Details ==
== Series Details ==
Series: Add debugfs to expose G8, G10 and ModS residency
URL : https://patchwork.freedesktop.org/series/149001/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 3e019cc3eaff drm-tip: 2025y-05m-26d-14h-49m-23s UTC integration manifest === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_debugfs.c:185
error: drivers/gpu/drm/xe/xe_debugfs.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: Utility function and macro for telemetry reading
Applying: drm/xe/xe_debugfs: Exposure of G8 residency counter
Patch failed at 0002 drm/xe/xe_debugfs: Exposure of G8 residency counter When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".