[PATCH 4/4] drm/xe/xe_debugfs: Exposure of Mods residency counter

Riana Tauro riana.tauro at intel.com
Wed May 14 11:10:58 UTC 2025


Hi Soham

On 5/14/2025 1:37 PM, Soham Purkait wrote:
> Add a debugfs node named mods_residency in order to obtain the ModS
> residency counter value.
> 
> Signed-off-by: Soham Purkait <soham.purkait at intel.com>
> ---
>   drivers/gpu/drm/xe/xe_debugfs.c | 34 +++++++++++++++++++++++++++++++++
>   drivers/gpu/drm/xe/xe_debugfs.h |  1 +
>   2 files changed, 35 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index 66eab5528b92..240cb73800ae 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> @@ -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),
> +				&reg_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

> +	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);
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.h b/drivers/gpu/drm/xe/xe_debugfs.h
> index 27fbb8d46471..55ef13662fec 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.h
> +++ b/drivers/gpu/drm/xe/xe_debugfs.h
> @@ -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);



More information about the Intel-xe mailing list