From: Matthew Brost <matthew.brost@intel.com>
To: Matt Roper <matthew.d.roper@intel.com>
Cc: intel-xe@lists.freedesktop.org,
"José Roberto de Souza" <jose.souza@intel.com>
Subject: Re: [PATCH 1/2] drm/xe: Add debugfs to dump GuC's hwconfig
Date: Fri, 16 Aug 2024 02:18:00 +0000 [thread overview]
Message-ID: <Zr622GVl0utsp1ui@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240815213837.GJ5774@mdroper-desk1.amr.corp.intel.com>
On Thu, Aug 15, 2024 at 02:38:37PM -0700, Matt Roper wrote:
> On Thu, Aug 15, 2024 at 08:08:45PM +0000, Matthew Brost wrote:
> > On Thu, Aug 15, 2024 at 10:26:03AM -0700, Matt Roper wrote:
> > > Although the query uapi is the official way to get at the GuC's hwconfig
> > > table contents, it's still useful to have a quick debugfs interface to
> > > dump the table in a human-readable format while debugging the driver.
> > >
> >
> > Patch itself makes sense. Question though, would this be useful to
> > include devcoredump? If so we should code this with the snap semantics
> > for decoredump. See guc_exec_queue_print() for an example of this.
>
> You mean include the contents of the hwconfig within the devcoredump
> report? I don't really have a feel for whether anyone would find that
Yes, exactly - include hwconfig within the devcoredump report.
Don't want to hold up the patch as I said it LGTM but just something to
consider and if Jose (or someone on the KMD) indicates this could be
useful it is easy enough to change to use snap semantics and wire into
devcoredump too.
Matt
> useful or not. My personal use case is just being able to sit down at
> an unfamiliar machine and 'cat' the debugfs to see what the hwconfig
> characteristics of the GPU are before I start doing experiments.
>
> +Cc Jose for a UMD perspective on whether or not it would also be useful
> to capture the hwconfig contents in the devcoredump for userspace
> debugging.
>
>
> Matt
>
> >
> > Matt
> >
> > > Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> > > ---
> > > drivers/gpu/drm/xe/xe_gt_debugfs.c | 11 ++++++
> > > drivers/gpu/drm/xe/xe_guc_hwconfig.c | 57 ++++++++++++++++++++++++++++
> > > drivers/gpu/drm/xe/xe_guc_hwconfig.h | 2 +
> > > 3 files changed, 70 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> > > index 5125d76ccfac..8f95d3a5949b 100644
> > > --- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
> > > +++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
> > > @@ -19,6 +19,7 @@
> > > #include "xe_gt_sriov_vf_debugfs.h"
> > > #include "xe_gt_stats.h"
> > > #include "xe_gt_topology.h"
> > > +#include "xe_guc_hwconfig.h"
> > > #include "xe_hw_engine.h"
> > > #include "xe_lrc.h"
> > > #include "xe_macros.h"
> > > @@ -270,6 +271,15 @@ static int vecs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
> > > return 0;
> > > }
> > >
> > > +static int hwconfig(struct xe_gt *gt, struct drm_printer *p)
> > > +{
> > > + xe_pm_runtime_get(gt_to_xe(gt));
> > > + xe_guc_hwconfig_dump(>->uc.guc, p);
> > > + xe_pm_runtime_put(gt_to_xe(gt));
> > > +
> > > + return 0;
> > > +}
> > > +
> > > static const struct drm_info_list debugfs_list[] = {
> > > {"hw_engines", .show = xe_gt_debugfs_simple_show, .data = hw_engines},
> > > {"force_reset", .show = xe_gt_debugfs_simple_show, .data = force_reset},
> > > @@ -288,6 +298,7 @@ static const struct drm_info_list debugfs_list[] = {
> > > {"default_lrc_vcs", .show = xe_gt_debugfs_simple_show, .data = vcs_default_lrc},
> > > {"default_lrc_vecs", .show = xe_gt_debugfs_simple_show, .data = vecs_default_lrc},
> > > {"stats", .show = xe_gt_debugfs_simple_show, .data = xe_gt_stats_print_info},
> > > + {"hwconfig", .show = xe_gt_debugfs_simple_show, .data = hwconfig},
> > > };
> > >
> > > void xe_gt_debugfs_register(struct xe_gt *gt)
> > > diff --git a/drivers/gpu/drm/xe/xe_guc_hwconfig.c b/drivers/gpu/drm/xe/xe_guc_hwconfig.c
> > > index d9b570a154a2..025bad701556 100644
> > > --- a/drivers/gpu/drm/xe/xe_guc_hwconfig.c
> > > +++ b/drivers/gpu/drm/xe/xe_guc_hwconfig.c
> > > @@ -6,6 +6,7 @@
> > > #include "xe_guc_hwconfig.h"
> > >
> > > #include <drm/drm_managed.h>
> > > +#include <drm/drm_print.h>
> > >
> > > #include "abi/guc_actions_abi.h"
> > > #include "xe_bo.h"
> > > @@ -103,3 +104,59 @@ void xe_guc_hwconfig_copy(struct xe_guc *guc, void *dst)
> > > xe_map_memcpy_from(xe, dst, &guc->hwconfig.bo->vmap, 0,
> > > guc->hwconfig.size);
> > > }
> > > +
> > > +void xe_guc_hwconfig_dump(struct xe_guc *guc, struct drm_printer *p)
> > > +{
> > > + size_t size = xe_guc_hwconfig_size(guc);
> > > + u32 *hwconfig;
> > > + u64 num_dw;
> > > + u32 extra_bytes;
> > > + int i = 0;
> > > +
> > > + if (size == 0) {
> > > + drm_printf(p, "No hwconfig available\n");
> > > + return;
> > > + }
> > > +
> > > + num_dw = div_u64_rem(size, sizeof(u32), &extra_bytes);
> > > +
> > > + hwconfig = kzalloc(size, GFP_KERNEL);
> > > + if (!hwconfig) {
> > > + drm_printf(p, "Error: could not allocate hwconfig memory\n");
> > > + return;
> > > + }
> > > +
> > > + xe_guc_hwconfig_copy(guc, hwconfig);
> > > +
> > > + /* An entry requires at least three dwords for key, length, value */
> > > + while (i + 3 <= num_dw) {
> > > + u32 attribute = hwconfig[i++];
> > > + u32 len_dw = hwconfig[i++];
> > > +
> > > + if (i + len_dw > num_dw) {
> > > + drm_printf(p, "Error: Attribute %u is %u dwords, but only %llu remain\n",
> > > + attribute, len_dw, num_dw - i);
> > > + len_dw = num_dw - i;
> > > + }
> > > +
> > > + /*
> > > + * If it's a single dword (as most hwconfig attributes are),
> > > + * then it's probably a number that makes sense to display
> > > + * in decimal form. In the rare cases where it's more than
> > > + * one dword, just print it in hex form and let the user
> > > + * figure out how to interpret it.
> > > + */
> > > + if (len_dw == 1)
> > > + drm_printf(p, "[%2u] = %u\n", attribute, hwconfig[i]);
> > > + else
> > > + drm_printf(p, "[%2u] = { %*ph }\n", attribute,
> > > + (int)(len_dw * sizeof(u32)), &hwconfig[i]);
> > > + i += len_dw;
> > > + }
> > > +
> > > + if (i < num_dw || extra_bytes)
> > > + drm_printf(p, "Error: %llu extra bytes at end of hwconfig\n",
> > > + (num_dw - i) * sizeof(u32) + extra_bytes);
> > > +
> > > + kfree(hwconfig);
> > > +}
> > > diff --git a/drivers/gpu/drm/xe/xe_guc_hwconfig.h b/drivers/gpu/drm/xe/xe_guc_hwconfig.h
> > > index b5794d641900..7df315900e1c 100644
> > > --- a/drivers/gpu/drm/xe/xe_guc_hwconfig.h
> > > +++ b/drivers/gpu/drm/xe/xe_guc_hwconfig.h
> > > @@ -8,10 +8,12 @@
> > >
> > > #include <linux/types.h>
> > >
> > > +struct drm_printer;
> > > struct xe_guc;
> > >
> > > int xe_guc_hwconfig_init(struct xe_guc *guc);
> > > u32 xe_guc_hwconfig_size(struct xe_guc *guc);
> > > void xe_guc_hwconfig_copy(struct xe_guc *guc, void *dst);
> > > +void xe_guc_hwconfig_dump(struct xe_guc *guc, struct drm_printer *p);
> > >
> > > #endif
> > > --
> > > 2.45.2
> > >
>
> --
> Matt Roper
> Graphics Software Engineer
> Linux GPU Platform Enablement
> Intel Corporation
next prev parent reply other threads:[~2024-08-16 2:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 17:26 [PATCH 1/2] drm/xe: Add debugfs to dump GuC's hwconfig Matt Roper
2024-08-15 17:26 ` [PATCH 2/2] drm/xe/mcr: Try to derive dss_per_grp from hwconfig attributes Matt Roper
2024-08-15 18:27 ` Cavitt, Jonathan
2024-08-15 18:18 ` [PATCH 1/2] drm/xe: Add debugfs to dump GuC's hwconfig Cavitt, Jonathan
2024-08-15 19:03 ` Randhawa, Jagmeet
2024-08-15 19:40 ` ✓ CI.Patch_applied: success for series starting with [1/2] " Patchwork
2024-08-15 19:40 ` ✓ CI.checkpatch: " Patchwork
2024-08-15 19:41 ` ✓ CI.KUnit: " Patchwork
2024-08-15 19:53 ` ✓ CI.Build: " Patchwork
2024-08-15 19:55 ` ✓ CI.Hooks: " Patchwork
2024-08-15 19:57 ` ✓ CI.checksparse: " Patchwork
2024-08-15 20:08 ` [PATCH 1/2] " Matthew Brost
2024-08-15 21:38 ` Matt Roper
2024-08-16 2:18 ` Matthew Brost [this message]
2024-08-16 13:28 ` Souza, Jose
2024-08-16 18:10 ` Matt Roper
2024-08-15 20:40 ` ✓ CI.BAT: success for series starting with [1/2] " Patchwork
2024-08-16 0:13 ` ✗ 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=Zr622GVl0utsp1ui@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jose.souza@intel.com \
--cc=matthew.d.roper@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