From 7bf350ecb240c9db63031e3a1b6c99acd73c90ed Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Sat, 1 Apr 2023 01:51:49 -0700 Subject: [PATCH] drm/xe/reg_sr: Save errors for kunit integration 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 Reviewed-by: Matt Roper Link: https://lore.kernel.org/r/20230401085151.1786204-6-lucas.demarchi@intel.com Signed-off-by: Rodrigo Vivi --- 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 37ae8412cb006..f97673be2e62e 100644 --- a/drivers/gpu/drm/xe/xe_reg_sr.c +++ b/drivers/gpu/drm/xe/xe_reg_sr.c @@ -82,6 +82,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) { @@ -119,6 +126,7 @@ fail: 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 3d22578910051..91469784fd907 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.30.2