Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Teres Alexis, Alan Previn" <alan.previn.teres.alexis@intel.com>
To: "Dong, Zhanjun" <zhanjun.dong@intel.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v1 1/1] drm/xe/guc: Fix missing init value and add register order check
Date: Thu, 31 Oct 2024 22:38:54 +0000	[thread overview]
Message-ID: <ae2c5a7e6467859249c3c90cead887003ee70425.camel@intel.com> (raw)
In-Reply-To: <20241023192307.746525-1-zhanjun.dong@intel.com>

Thanks for the clarification this morning - as such, i should have reviewed sooner. 

On Wed, 2024-10-23 at 12:23 -0700, Zhanjun Dong wrote:
> Fix missing initial value for last_value.
> For GuC capture register definition, it is required to define 64bit
> register in a pair of 2 consecutive 32bit register entries, low first,
> then hi. Add code to check this order.
> 
> Fixes: 0f1fdf559225 ("drm/xe/guc: Save manual engine capture into capture list")
> 
alan:Should the fixes tag be applied to this instead? ->
ecb633646391 ("drm/xe/guc: Plumb GuC-capture into dev coredump")

> Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_guc_capture.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_capture.c b/drivers/gpu/drm/xe/xe_guc_capture.c
> index 8b6cb786a2aa..d7ff7dd60a1d 100644
> --- a/drivers/gpu/drm/xe/xe_guc_capture.c
> +++ b/drivers/gpu/drm/xe/xe_guc_capture.c
> @@ -102,6 +102,7 @@ struct __guc_capture_parsed_output {
>   *                   A 64 bit register define requires 2 consecutive entries,
>   *                   with low dword first and hi dword the second.
>   *     2. Register name: null for incompleted define
> + *     3. Incorrect order will trigger XE_WARN.
>   */
>  #define COMMON_XELP_BASE_GLOBAL \
>         { FORCEWAKE_GT,                 REG_32BIT,      0,      0,      "FORCEWAKE_GT"}
> @@ -1678,10 +1679,10 @@ snapshot_print_by_list_order(struct xe_hw_engine_snapshot *snapshot, struct drm_
>         struct xe_devcoredump *devcoredump = &xe->devcoredump;
>         struct xe_devcoredump_snapshot *devcore_snapshot = &devcoredump->snapshot;
>         struct gcap_reg_list_info *reginfo = NULL;
> -       u32 last_value, i;
> -       bool is_ext;
> +       u32 i, last_value = 0;
> +       bool is_ext, low32_ready = false;
>  
> -       if (!list || list->num_regs == 0)
> +       if (!list || !list->list || list->num_regs == 0)
>                 return;
>         XE_WARN_ON(!devcore_snapshot->matched_node);
>  
> @@ -1706,11 +1707,27 @@ snapshot_print_by_list_order(struct xe_hw_engine_snapshot *snapshot, struct drm_
>                 value = reg->value;
>                 if (reg_desc->data_type == REG_64BIT_LOW_DW) {
>                         last_value = value;
> +
> +                       /*
> +                        * A 64 bit register define requires 2 consecutive
> +                        * entries in register list, with low dword first
> +                        * and hi dword the second, like:
> +                        *  { XXX_REG_LO(0), REG_64BIT_LOW_DW, 0, 0, NULL},
> +                        *  { XXX_REG_HI(0), REG_64BIT_HI_DW,  0, 0, "XXX_REG"},
> +                        *
> +                        * Incorrect order will trigger XE_WARN.
> +                        */
> +                       XE_WARN_ON(low32_ready); /* Possible double low here */
> +                       low32_ready = true;
>                         /* Low 32 bit dword saved, continue for high 32 bit */
>                         continue;
>                 } else if (reg_desc->data_type == REG_64BIT_HI_DW) {
>                         u64 value_qw = ((u64)value << 32) | last_value;
alan: (just a comment) i see that we continue to print the values out irrespective
of ordering issue, but i think that's perfectly fine since an attempt to mitigate
could be completely wrong without knowing how the last developer incorrectly
modified the reglist. So this is fine.
>  
> +                       /* Incorrect 64bit register order. Possible missing low */
> +                       XE_WARN_ON(!low32_ready);
alan: perhaps we should catch errors in the opposite direction.
so perhaps we need something like the following before the first if(LOW_DW) check above?
                   if (low32_ready && reg_desc->data_type != REG_64BIT_HI_DW) {
                           /* Incorrect register order: higher-DW not following lower-DW */
                           XE_WARN_ON(!low32_ready);
                           low32_ready = false;
                   }

> +                       low32_ready = false;
> +
>                         drm_printf(p, "\t%s: 0x%016llx\n", reg_desc->regname, value_qw);
>                         continue;
>                 }
> @@ -1727,6 +1744,9 @@ snapshot_print_by_list_order(struct xe_hw_engine_snapshot *snapshot, struct drm_
>                         drm_printf(p, "\t%s: 0x%08x\n", reg_desc->regname, value);
>                 }
>         }
> +
> +       /* Incorrect 64bit register order. Possible missing high */
> +       XE_WARN_ON(low32_ready);
>  }
>  
>  /**


  parent reply	other threads:[~2024-10-31 22:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23 19:23 [PATCH v1 1/1] drm/xe/guc: Fix missing init value and add register order check Zhanjun Dong
2024-10-24 11:09 ` ✓ CI.Patch_applied: success for series starting with [v1,1/1] " Patchwork
2024-10-24 11:09 ` ✓ CI.checkpatch: " Patchwork
2024-10-24 11:10 ` ✓ CI.KUnit: " Patchwork
2024-10-24 11:22 ` ✓ CI.Build: " Patchwork
2024-10-24 11:24 ` ✓ CI.Hooks: " Patchwork
2024-10-24 11:26 ` ✓ CI.checksparse: " Patchwork
2024-10-24 11:27 ` [PATCH v1 1/1] " Nirmoy Das
2024-10-24 14:13   ` Dong, Zhanjun
2024-10-24 23:50     ` Teres Alexis, Alan Previn
2024-10-31 14:22       ` Dong, Zhanjun
2024-10-31 16:55         ` Dong, Zhanjun
2024-10-24 11:47 ` ✗ CI.BAT: failure for series starting with [v1,1/1] " Patchwork
2024-10-25  6:27 ` ✓ CI.FULL: success " Patchwork
2024-10-29  0:00 ` ✓ CI.Patch_applied: success for series starting with [v1,1/1] drm/xe/guc: Fix missing init value and add register order check (rev2) Patchwork
2024-10-29  0:01 ` ✓ CI.checkpatch: " Patchwork
2024-10-29  0:02 ` ✓ CI.KUnit: " Patchwork
2024-10-29  0:13 ` ✓ CI.Build: " Patchwork
2024-10-29  0:16 ` ✓ CI.Hooks: " Patchwork
2024-10-29  0:17 ` ✓ CI.checksparse: " Patchwork
2024-10-29  0:40 ` ✗ CI.BAT: failure " Patchwork
2024-10-29  1:39 ` ✗ CI.FULL: " Patchwork
2024-10-31 22:38 ` Teres Alexis, Alan Previn [this message]
2024-11-01 14:43   ` [PATCH v1 1/1] drm/xe/guc: Fix missing init value and add register order check Dong, Zhanjun

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=ae2c5a7e6467859249c3c90cead887003ee70425.camel@intel.com \
    --to=alan.previn.teres.alexis@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=zhanjun.dong@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