All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH] drm/xe/debugfs: Move sa_info from gt to tile directory
Date: Tue, 2 Sep 2025 12:49:52 -0400	[thread overview]
Message-ID: <aLcgMFriYWNJ9aZz@intel.com> (raw)
In-Reply-To: <20250829201106.1263-1-michal.wajdeczko@intel.com>

On Fri, Aug 29, 2025 at 10:11:03PM +0200, Michal Wajdeczko wrote:
> Our drm-based suballocator is implemented per-tile so it is better
> to show its debug information also per-tile debugfs directory, not
> under per-gt directory as it is done today.
> 
> To allow adding more per-tile attributes, prepare necessary helper
> functions, like we already did for per-gt or per-uc attributes.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/xe/Makefile          |   1 +
>  drivers/gpu/drm/xe/xe_debugfs.c      |  20 +---
>  drivers/gpu/drm/xe/xe_gt_debugfs.c   |  13 ---
>  drivers/gpu/drm/xe/xe_tile_debugfs.c | 135 +++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_tile_debugfs.h |  13 +++
>  5 files changed, 151 insertions(+), 31 deletions(-)
>  create mode 100644 drivers/gpu/drm/xe/xe_tile_debugfs.c
>  create mode 100644 drivers/gpu/drm/xe/xe_tile_debugfs.h
> 
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index 987e4fe10538..95c0f0a9b403 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -325,6 +325,7 @@ ifeq ($(CONFIG_DEBUG_FS),y)
>  		xe_gt_stats.o \
>  		xe_guc_debugfs.o \
>  		xe_huc_debugfs.o \
> +		xe_tile_debugfs.o \
>  		xe_uc_debugfs.o
>  
>  	xe-$(CONFIG_PCI_IOV) += xe_gt_sriov_pf_debugfs.o
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index 8d6df6bd885e..4b71570529a6 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> @@ -25,6 +25,7 @@
>  #include "xe_sriov.h"
>  #include "xe_sriov_pf.h"
>  #include "xe_step.h"
> +#include "xe_tile_debugfs.h"
>  #include "xe_wa.h"
>  #include "xe_vsec.h"
>  
> @@ -329,23 +330,6 @@ static const struct file_operations atomic_svm_timeslice_ms_fops = {
>  	.write = atomic_svm_timeslice_ms_set,
>  };
>  
> -static void create_tile_debugfs(struct xe_tile *tile, struct dentry *root)
> -{
> -	char name[8];
> -
> -	snprintf(name, sizeof(name), "tile%u", tile->id);
> -	tile->debugfs = debugfs_create_dir(name, root);
> -	if (IS_ERR(tile->debugfs))
> -		return;
> -
> -	/*
> -	 * Store the xe_tile pointer as private data of the tile/ directory
> -	 * node so other tile specific attributes under that directory may
> -	 * refer to it by looking at its parent node private data.
> -	 */
> -	tile->debugfs->d_inode->i_private = tile;
> -}
> -
>  void xe_debugfs_register(struct xe_device *xe)
>  {
>  	struct ttm_device *bdev = &xe->ttm;
> @@ -398,7 +382,7 @@ void xe_debugfs_register(struct xe_device *xe)
>  		ttm_resource_manager_create_debugfs(man, root, "stolen_mm");
>  
>  	for_each_tile(tile, xe, tile_id)
> -		create_tile_debugfs(tile, root);
> +		xe_tile_debugfs_register(tile);
>  
>  	for_each_gt(gt, xe, id)
>  		xe_gt_debugfs_register(gt);
> diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> index bf3a67b5951c..f7a362ac8030 100644
> --- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> @@ -123,18 +123,6 @@ static int powergate_info(struct xe_gt *gt, struct drm_printer *p)
>  	return ret;
>  }
>  
> -static int sa_info(struct xe_gt *gt, struct drm_printer *p)
> -{
> -	struct xe_tile *tile = gt_to_tile(gt);
> -
> -	xe_pm_runtime_get(gt_to_xe(gt));
> -	drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,
> -				     xe_sa_manager_gpu_addr(tile->mem.kernel_bb_pool));
> -	xe_pm_runtime_put(gt_to_xe(gt));
> -
> -	return 0;
> -}
> -
>  static int sa_info_vf_ccs(struct xe_gt *gt, struct drm_printer *p)
>  {
>  	struct xe_tile *tile = gt_to_tile(gt);
> @@ -316,7 +304,6 @@ static int hwconfig(struct xe_gt *gt, struct drm_printer *p)
>   * - without access to the PF specific data
>   */
>  static const struct drm_info_list vf_safe_debugfs_list[] = {
> -	{"sa_info", .show = xe_gt_debugfs_simple_show, .data = sa_info},
>  	{"topology", .show = xe_gt_debugfs_simple_show, .data = topology},
>  	{"ggtt", .show = xe_gt_debugfs_simple_show, .data = ggtt},
>  	{"register-save-restore", .show = xe_gt_debugfs_simple_show, .data = register_save_restore},
> diff --git a/drivers/gpu/drm/xe/xe_tile_debugfs.c b/drivers/gpu/drm/xe/xe_tile_debugfs.c
> new file mode 100644
> index 000000000000..5523874cba7b
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_tile_debugfs.c
> @@ -0,0 +1,135 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#include <linux/debugfs.h>
> +#include <drm/drm_debugfs.h>
> +
> +#include "xe_pm.h"
> +#include "xe_sa.h"
> +#include "xe_tile_debugfs.h"
> +
> +static struct xe_tile *node_to_tile(struct drm_info_node *node)
> +{
> +	return node->dent->d_parent->d_inode->i_private;
> +}
> +
> +/**
> + * tile_debugfs_simple_show - A show callback for struct drm_info_list
> + * @m: the &seq_file
> + * @data: data used by the drm debugfs helpers
> + *
> + * This callback can be used in struct drm_info_list to describe debugfs
> + * files that are &xe_tile specific.
> + *
> + * It is assumed that those debugfs files will be created on directory entry
> + * which struct dentry d_inode->i_private points to &xe_tile.
> + *
> + *      /sys/kernel/debug/dri/0/
> + *      ├── tile0/		# tile = dentry->d_inode->i_private
> + *      │   │   ├── id		# tile = dentry->d_parent->d_inode->i_private
> + *
> + * This function assumes that &m->private will be set to the &struct
> + * drm_info_node corresponding to the instance of the info on a given &struct
> + * drm_minor (see struct drm_info_list.show for details).
> + *
> + * This function also assumes that struct drm_info_list.data will point to the
> + * function code that will actually print a file content::
> + *
> + *   int (*print)(struct xe_tile *, struct drm_printer *)
> + *
> + * Example::
> + *
> + *    int tile_id(struct xe_tile *tile, struct drm_printer *p)
> + *    {
> + *        drm_printf(p, "%u\n", tile->id);
> + *        return 0;
> + *    }
> + *
> + *    static const struct drm_info_list info[] = {
> + *        { name = "id", .show = tile_debugfs_simple_show, .data = tile_id },
> + *    };
> + *
> + *    dir = debugfs_create_dir("tile0", parent);
> + *    dir->d_inode->i_private = tile;
> + *    drm_debugfs_create_files(info, ARRAY_SIZE(info), dir, minor);
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +static int tile_debugfs_simple_show(struct seq_file *m, void *data)
> +{
> +	struct drm_printer p = drm_seq_file_printer(m);
> +	struct drm_info_node *node = m->private;
> +	struct xe_tile *tile = node_to_tile(node);
> +	int (*print)(struct xe_tile *, struct drm_printer *) = node->info_ent->data;
> +
> +	return print(tile, &p);
> +}
> +
> +/**
> + * tile_debugfs_show_with_rpm - A show callback for struct drm_info_list
> + * @m: the &seq_file
> + * @data: data used by the drm debugfs helpers
> + *
> + * Similar to tile_debugfs_simple_show() but implicitly takes a RPM ref.
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +static int tile_debugfs_show_with_rpm(struct seq_file *m, void *data)
> +{
> +	struct drm_info_node *node = m->private;
> +	struct xe_tile *tile = node_to_tile(node);
> +	struct xe_device *xe = tile_to_xe(tile);
> +	int ret;
> +
> +	xe_pm_runtime_get(xe);
> +	ret = tile_debugfs_simple_show(m, data);
> +	xe_pm_runtime_put(xe);
> +
> +	return ret;
> +}
> +
> +static int sa_info(struct xe_tile *tile, struct drm_printer *p)
> +{
> +	drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,
> +				     xe_sa_manager_gpu_addr(tile->mem.kernel_bb_pool));
> +
> +	return 0;
> +}
> +
> +/* only for debugfs files which can be safely used on the VF */
> +static const struct drm_info_list vf_safe_debugfs_list[] = {
> +	{ "sa_info", .show = tile_debugfs_show_with_rpm, .data = sa_info },
> +};
> +
> +/**
> + * xe_tile_debugfs_register - Register tile's debugfs attributes
> + * @tile: the &xe_tile to register
> + *
> + * Create debugfs sub-directory with a name that includes a tile ID and
> + * then creates set of debugfs files (attributes) specific to this tile.
> + */
> +void xe_tile_debugfs_register(struct xe_tile *tile)
> +{
> +	struct xe_device *xe = tile_to_xe(tile);
> +	struct drm_minor *minor = xe->drm.primary;
> +	struct dentry *root = minor->debugfs_root;
> +	char name[8];
> +
> +	snprintf(name, sizeof(name), "tile%u", tile->id);
> +	tile->debugfs = debugfs_create_dir(name, root);
> +	if (IS_ERR(tile->debugfs))
> +		return;
> +
> +	/*
> +	 * Store the xe_tile pointer as private data of the tile/ directory
> +	 * node so other tile specific attributes under that directory may
> +	 * refer to it by looking at its parent node private data.
> +	 */
> +	tile->debugfs->d_inode->i_private = tile;
> +
> +	drm_debugfs_create_files(vf_safe_debugfs_list,
> +				 ARRAY_SIZE(vf_safe_debugfs_list),
> +				 tile->debugfs, minor);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_tile_debugfs.h b/drivers/gpu/drm/xe/xe_tile_debugfs.h
> new file mode 100644
> index 000000000000..0e5f724de37f
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_tile_debugfs.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef _XE_TILE_DEBUGFS_H_
> +#define _XE_TILE_DEBUGFS_H_
> +
> +struct xe_tile;
> +
> +void xe_tile_debugfs_register(struct xe_tile *tile);
> +
> +#endif
> -- 
> 2.47.1
> 

      parent reply	other threads:[~2025-09-02 16:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 20:11 [PATCH] drm/xe/debugfs: Move sa_info from gt to tile directory Michal Wajdeczko
2025-08-29 21:41 ` ✗ CI.checkpatch: warning for " Patchwork
2025-08-29 21:43 ` ✓ CI.KUnit: success " Patchwork
2025-08-29 22:24 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-30 12:52 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-04 10:44   ` Michal Wajdeczko
2025-09-02 16:49 ` Rodrigo Vivi [this message]

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=aLcgMFriYWNJ9aZz@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@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.