Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@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,
	riana.tauro@intel.com, jonathan.cavitt@intel.com
Cc: lucas.demarchi@intel.com, soham.purkait@intel.com,
	ashutosh.dixit@intel.com
Subject: Re: [PATCH v8 2/2] drm/xe/xe_debugfs: Exposure of G-State and pcie link state residency counters through debugfs
Date: Mon, 30 Jun 2025 12:05:08 +0300	[thread overview]
Message-ID: <8879e3469b8fd3c98040f7df5bc5889125ec9436@intel.com> (raw)
In-Reply-To: <20250627190041.238015-3-soham.purkait@intel.com>

On Sat, 28 Jun 2025, Soham Purkait <soham.purkait@intel.com> wrote:
> Add debug nodes, "dgfx_pkg_residencies" for G-states (G2, G6, G8, G10,
> ModS) and "dgfx_pcie_link_residencies" for PCIe link states(L0, L1, L1.2)
> residency counters.
>
> v1:
>  - Expose all G-State residency counter values under
>    dgfx_pkg_residencies. (Anshuman)
>  - Include runtime_get/put. (Riana)
> v2:
>  - Move "dgfx_pkg_residencies" from "gtidle". (Anshuman)
> v3:
>  - Include debugfs node "dgfx_pcie_link_residencies" for pcie link
>    residency counter values.  (Anshuman)
> v4:
>  - Include check for BMG for and add helper function for repetitive
>    code. (Riana)
>  - Use "drm_debugfs_create_files" to create debugfs. (Karthik)
> v5:
>  - Reorder commits to reflect the correct dependency hierarchy.  (Jonathan)
>  - Simplification of commit message and rectified register offset.(Karthik)
>  - Error handling and return before printing.                       (Riana)
> v6:
>  - Remove check for DGFX as BMG is discrete. (Karthik)
> v7:
>  - Add for loop and local struct to avoid repetition. (Riana)
>
> Signed-off-by: Soham Purkait <soham.purkait@intel.com>
> Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Reviewed-by: Karthik Poosa <karthik.poosa@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_debugfs.c | 87 +++++++++++++++++++++++++++++++++
>  1 file changed, 87 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index d83cd6ed3fa8..f086dba253a0 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"
> @@ -30,6 +33,23 @@
>  
>  DECLARE_FAULT_ATTR(gt_reset_failure);
>  
> +static void read_residency_counter(struct xe_device *xe, struct xe_mmio *mmio,
> +				   u32 offset, char *name, struct drm_printer *p)
> +{
> +	u64 residency = 0;
> +	int ret;
> +
> +	ret = xe_pmt_telem_read(to_pci_dev(xe->drm.dev),
> +				xe_mmio_read32(mmio, PUNIT_TELEMETRY_GUID),
> +				&residency, offset, sizeof(residency));
> +	if (ret != sizeof(residency)) {
> +		drm_warn(&xe->drm, "%s counter failed to read, ret %d\n", name, ret);
> +		return;
> +	}
> +
> +	drm_printf(p, "%s : %llu\n", name, residency);
> +}
> +
>  static struct xe_device *node_to_xe(struct drm_info_node *node)
>  {
>  	return to_xe_device(node->minor->dev);
> @@ -82,11 +102,73 @@ static int sriov_info(struct seq_file *m, void *data)
>  	return 0;
>  }
>  
> +static int dgfx_pkg_residencies_show(struct seq_file *m, void *data)
> +{
> +	struct xe_device *xe;
> +	struct xe_mmio *mmio;
> +	struct drm_printer p;
> +
> +	xe = node_to_xe(m->private);
> +	p = drm_seq_file_printer(m);
> +	xe_pm_runtime_get(xe);
> +	mmio = xe_root_tile_mmio(xe);
> +	struct {
> +		u32 offset;
> +		char *name;
> +	} residencies[] = {
> +		{BMG_G2_RESIDENCY_OFFSET, "Package G2"},
> +		{BMG_G6_RESIDENCY_OFFSET, "Package G6"},
> +		{BMG_G8_RESIDENCY_OFFSET, "Package G8"},
> +		{BMG_G10_RESIDENCY_OFFSET, "Package G10"},
> +		{BMG_MODS_RESIDENCY_OFFSET, "Package ModS"},
> +		{0, NULL}
> +	};

Drive-by comment, that's now unnecessarily mutable, and as const could
be placed in rodata.

BR,
Jani.

> +
> +	for (int i = 0; residencies[i].name; i++)
> +		read_residency_counter(xe, mmio, residencies[i].offset, residencies[i].name, &p);
> +
> +	xe_pm_runtime_put(xe);
> +	return 0;
> +}
> +
> +static int dgfx_pcie_link_residencies_show(struct seq_file *m, void *data)
> +{
> +	struct xe_device *xe;
> +	struct xe_mmio *mmio;
> +	struct drm_printer p;
> +
> +	xe = node_to_xe(m->private);
> +	p = drm_seq_file_printer(m);
> +	xe_pm_runtime_get(xe);
> +	mmio = xe_root_tile_mmio(xe);
> +
> +	struct {
> +		u32 offset;
> +		char *name;
> +	} residencies[] = {
> +		{BMG_PCIE_LINK_L0_RESIDENCY_OFFSET, "PCIE LINK L0 RESIDENCY"},
> +		{BMG_PCIE_LINK_L1_RESIDENCY_OFFSET, "PCIE LINK L1 RESIDENCY"},
> +		{BMG_PCIE_LINK_L1_2_RESIDENCY_OFFSET, "PCIE LINK L1.2 RESIDENCY"},
> +		{0, NULL}
> +	};
> +
> +	for (int i = 0; residencies[i].name; i++)
> +		read_residency_counter(xe, mmio, residencies[i].offset, residencies[i].name, &p);
> +
> +	xe_pm_runtime_put(xe);
> +	return 0;
> +}
> +
>  static const struct drm_info_list debugfs_list[] = {
>  	{"info", info, 0},
>  	{ .name = "sriov_info", .show = sriov_info, },
>  };
>  
> +static const struct drm_info_list debugfs_residencies[] = {
> +	{ .name = "dgfx_pkg_residencies", .show = dgfx_pkg_residencies_show, },
> +	{ .name = "dgfx_pcie_link_residencies", .show = dgfx_pcie_link_residencies_show, },
> +};
> +
>  static int forcewake_open(struct inode *inode, struct file *file)
>  {
>  	struct xe_device *xe = inode->i_private;
> @@ -240,6 +322,11 @@ void xe_debugfs_register(struct xe_device *xe)
>  				 ARRAY_SIZE(debugfs_list),
>  				 root, minor);
>  
> +	if (xe->info.platform == XE_BATTLEMAGE)
> +		drm_debugfs_create_files(debugfs_residencies,
> +					 ARRAY_SIZE(debugfs_residencies),
> +					 root, minor);
> +
>  	debugfs_create_file("forcewake_all", 0400, root, xe,
>  			    &forcewake_all_fops);

-- 
Jani Nikula, Intel

  parent reply	other threads:[~2025-06-30  9:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 19:00 [PATCH v8 0/2] Add debugfs node to expose G-state and pcie link state residency Soham Purkait
2025-06-27 19:00 ` [PATCH v8 1/2] drm/xe/regs/xe_pmt: Macros for G-State and pcie link state residency offset Soham Purkait
2025-06-30  6:42   ` Riana Tauro
2025-06-30 14:15     ` Lucas De Marchi
2025-06-27 19:00 ` [PATCH v8 2/2] drm/xe/xe_debugfs: Exposure of G-State and pcie link state residency counters through debugfs Soham Purkait
2025-06-30  6:41   ` Riana Tauro
2025-06-30  9:05   ` Jani Nikula [this message]
2025-06-30 19:38 ` ✓ CI.KUnit: success for Add debugfs node to expose G-state and pcie link state residency (rev6) Patchwork
2025-06-30 20:25 ` ✓ Xe.CI.BAT: " Patchwork
2025-07-02  0:44 ` ✗ Xe.CI.Full: failure " Patchwork

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=8879e3469b8fd3c98040f7df5bc5889125ec9436@intel.com \
    --to=jani.nikula@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=karthik.poosa@intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=riana.tauro@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox