[Intel-xe] [PATCH v2 5/7] drm/xe/reg_sr: Save errors for kunit integration

Matt Roper matthew.d.roper at intel.com
Mon Apr 3 23:11:25 UTC 2023


On Sat, Apr 01, 2023 at 01:51:49AM -0700, Lucas De Marchi wrote:
> When there's an entry that is dropped when xe_reg_sr_add(), there's
> not much we can do other than reporting the error - it's for certain a
> driver issue or conflicting workarounds/tunings. Save the number of
> errors to be used later by kunit to report where it happens.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>

Does xe_reg_sr ever get allocated on the stack on with a non-zeroed
allocation?  I didn't think it did (it looks like they're always part of
the original xe_device allocation which was kzalloc'd), but I see
xe_reg_sr_init() explicitly zeroing the sr->pool substructure so it made
me second-guess myself.

Assuming I'm reading correctly that we never have an xe_reg_sr that
wasn't zeroed at allocation,

Reviewed-by: Matt Roper <matthew.d.roper at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_reg_sr.c       | 8 ++++++++
>  drivers/gpu/drm/xe/xe_reg_sr_types.h | 4 ++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_reg_sr.c b/drivers/gpu/drm/xe/xe_reg_sr.c
> index 9eaf1be27886..83f29aeb9250 100644
> --- a/drivers/gpu/drm/xe/xe_reg_sr.c
> +++ b/drivers/gpu/drm/xe/xe_reg_sr.c
> @@ -84,6 +84,13 @@ static bool compatible_entries(const struct xe_reg_sr_entry *e1,
>  	return true;
>  }
>  
> +static void reg_sr_inc_error(struct xe_reg_sr *sr)
> +{
> +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> +	sr->errors++;
> +#endif
> +}
> +
>  int xe_reg_sr_add(struct xe_reg_sr *sr, u32 reg,
>  		  const struct xe_reg_sr_entry *e)
>  {
> @@ -121,6 +128,7 @@ int xe_reg_sr_add(struct xe_reg_sr *sr, u32 reg,
>  	DRM_ERROR("Discarding save-restore reg %04lx (clear: %08x, set: %08x, masked: %s): ret=%d\n",
>  		  idx, e->clr_bits, e->set_bits,
>  		  str_yes_no(e->masked_reg), ret);
> +	reg_sr_inc_error(sr);
>  
>  	return ret;
>  }
> diff --git a/drivers/gpu/drm/xe/xe_reg_sr_types.h b/drivers/gpu/drm/xe/xe_reg_sr_types.h
> index 3d2257891005..91469784fd90 100644
> --- a/drivers/gpu/drm/xe/xe_reg_sr_types.h
> +++ b/drivers/gpu/drm/xe/xe_reg_sr_types.h
> @@ -32,6 +32,10 @@ struct xe_reg_sr {
>  	} pool;
>  	struct xarray xa;
>  	const char *name;
> +
> +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> +	unsigned int errors;
> +#endif
>  };
>  
>  #endif
> -- 
> 2.39.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the Intel-xe mailing list