All of lore.kernel.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: Soham Purkait <soham.purkait@intel.com>,
	<intel-xe@lists.freedesktop.org>,  <anshuman.gupta@intel.com>,
	<badal.nilawar@intel.com>, <karthik.poosa@intel.com>
Cc: <lucas.demarchi@intel.com>, <ashutosh.dixit@intel.com>,
	<jani.nikula@intel.com>
Subject: Re: [PATCH v3 1/2] drm/xe/xe_debugfs: Exposure of G-State and pcie link state residency counters through debugfs
Date: Thu, 5 Jun 2025 16:48:18 +0530	[thread overview]
Message-ID: <23fff9b4-a22b-4b8a-9d9c-45512ae96889@intel.com> (raw)
In-Reply-To: <20250603181205.1680363-2-soham.purkait@intel.com>

Hi Soham

On 6/3/2025 11:42 PM, Soham Purkait wrote:
>      Add two debugfs node named dgfx_pkg_residencies and dgfx_link_state_residencys
> in order to obtain the G-State residency counter values for G2, G6, G8, G10 &
> ModS and the pcie link state residency counter values for L0, L1 & L1.2
> respectively.
> 
> Signed-off-by: Soham Purkait <soham.purkait@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_debugfs.c | 99 +++++++++++++++++++++++++++++++++
>   1 file changed, 99 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index d83cd6ed3fa8..c339f05ce42e 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> @@ -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,6 +188,86 @@ 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));

What happens if this call fails? dst will be 0?

> +	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_pkg_residencies_show(struct file *f, char __user *ubuf,
> +					 size_t size, loff_t *pos)
> +{
> +	u64 g_states;

%s/g_states/residency

> +	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);
> +
> +	g_states = 0;
> +	read_residency_counter(xe, mmio, &g_states, BMG_G2_RESIDENCY_OFFSET, "G2");
> +	len = scnprintf(buf, sizeof(buf), "Package G2: %llu\n", g_states);
> +

There is no check for BMG. Is it applicable only for BMG?

> +	g_states = 0;
> +	read_residency_counter(xe, mmio, &g_states, BMG_G6_RESIDENCY_OFFSET, "G6");
> +	len += scnprintf(buf + len, sizeof(buf) - len, "Package G6: %llu\n", g_states);
> +
> +	g_states = 0;
> +	read_residency_counter(xe, mmio, &g_states, BMG_G8_RESIDENCY_OFFSET, "G8");
> +	len += scnprintf(buf + len, sizeof(buf) - len, "Package G8: %llu\n", g_states);
> +
> +	g_states = 0;
> +	read_residency_counter(xe, mmio, &g_states, BMG_G10_RESIDENCY_OFFSET, "G10");
> +	len += scnprintf(buf + len, sizeof(buf) - len, "Package G10: %llu\n", g_states);
> +
> +	g_states = 0;
> +	read_residency_counter(xe, mmio, &g_states, BMG_MODS_RESIDENCY_OFFSET, "ModS");
> +	len += scnprintf(buf + len, sizeof(buf) - len, "Package ModS: %llu\n", g_states);

Repeated code here. Use a helper

> +
> +	xe_pm_runtime_put(xe);
> +	return simple_read_from_buffer(ubuf, size, pos, buf, len);
> +}
> +
> +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);

Use a helper

> +
> +	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 +309,16 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = {
>   	.write = atomic_svm_timeslice_ms_set,
>   };
>   
> +static const struct file_operations dgfx_pkg_residencies_fops = {
> +	.owner = THIS_MODULE,
> +	.read = dgfx_pkg_residencies_show,
> +};
> +
> +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 +342,12 @@ 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_pkg_residencies", 0444, root, xe,
> +			    &dgfx_pkg_residencies_fops);
> +
> +	debugfs_create_file("dgfx_link_state_residencys", 0444, root, xe,
> +			    &dgfx_link_state_residencys_fops);
If these are for dgfx there needs to be dgfx check

Thanks
Riana


> +
>   	for (mem_type = XE_PL_VRAM0; mem_type <= XE_PL_VRAM1; ++mem_type) {
>   		man = ttm_manager_type(bdev, mem_type);
>   


  reply	other threads:[~2025-06-05 11:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03 18:12 [PATCH v3 0/2] Add debugfs node to expose G-state and pcie link state residency Soham Purkait
2025-06-03 18:12 ` [PATCH v3 1/2] drm/xe/xe_debugfs: Exposure of G-State and pcie link state residency counters through debugfs Soham Purkait
2025-06-05 11:18   ` Riana Tauro [this message]
2025-06-05 13:23   ` Poosa, Karthik
2025-06-03 18:12 ` [PATCH v3 2/2] drm/xe/regs/xe_pmt: Macros for G-State and pcie link state residency offset Soham Purkait
2025-06-05 10:00   ` Poosa, Karthik
2025-06-03 18:22 ` ✓ CI.Patch_applied: success for Add debugfs node to expose G-state and pcie link state residency Patchwork
2025-06-03 18:22 ` ✗ CI.checkpatch: warning " Patchwork
2025-06-03 18:23 ` ✗ CI.KUnit: failure " Patchwork
2025-06-05 10:02 ` [PATCH v3 0/2] " Poosa, Karthik
2025-06-05 10:15   ` Poosa, Karthik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23fff9b4-a22b-4b8a-9d9c-45512ae96889@intel.com \
    --to=riana.tauro@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=karthik.poosa@intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=soham.purkait@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.