From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Violet Monti <violet.monti@intel.com>, <intel-xe@lists.freedesktop.org>
Cc: Violet Monti <violet.monti@intel.com>
Subject: Re: [PATCH v5 2/4] drm/xe/rtp: Ensure gt_was doesn't evaluate rules with engine types
Date: Thu, 28 May 2026 17:52:03 -0300 [thread overview]
Message-ID: <87pl2f5kb0.fsf@intel.com> (raw)
In-Reply-To: <20260528163531.834721-8-violet.monti@intel.com>
Violet Monti <violet.monti@intel.com> writes:
> It is currently possible for a RTP rule, and subsequently a workaround,
> to expect contexts that may not be present when the workaround is
> applied. For example, the workarounds in the engine_was[] in drm/xe/xe_wa.c
> expect an engine entity to be active. Conversely, the gt_was[] is not
> depending on an engine entity to implement its workarounds. This kunit
> test addition checks the gt_was[] workaround list for any workarounds
> with XEP_RTP_ENGINE_CLASS() rules. If a workaround does have one of
> these rules, the workaround is then checked for the "FOREACH_ENGINE" flag,
> which ensures the workaround is implemented properly.
>
> The result of this test is an expectation failure if a workaround has an
> improper XE_RTP_ENGINE_CLASS() rule setup, and aims to prevent future
> issues of gt_was workarounds being applied without proper contexts.
>
> The gt_tunings[] RTP table has the same functional layout and
> requirements as gt_was[], so it shares the same kunit test function,
> minimizing excessive code.
>
> v5:
> - Remove unnecessary headers from xe_rtp_table_test.c
>
> v4:
> - No change
>
> v3:
> - Removed "VISIBLE_IF_KUNIT" keyword from xe_wa.h
> - Added gt_tunings[] for testing
> - Reworked KUNIT_EXPECT_TRUE() for easier parsing of errors
>
> v2:
> - Moved contents of xe_rtp_tables_test.h to .c and removed file
> - Renamed macro RTP_KUNIT_ARRAY_PARAM to RTP_TABLE_PARAM
> - Removed unnecessary functions and iterative components from
> generated _gen_params functions and implemented usage of table
> name and WA number as entry name
> - Condensed xe_rtp_table_gt_test() to use KUNIT_EXPECT_TRUE with no
> message statement
> - Removed xe_rtp_table_test_init() and xe_rtp_table_test_exit() as
> fake device initialization is not necessary
>
> Signed-off-by: Violet Monti <violet.monti@intel.com>
Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
> ---
> drivers/gpu/drm/xe/tests/Makefile | 1 +
> drivers/gpu/drm/xe/tests/xe_rtp_tables_test.c | 53 +++++++++++++++++++
> drivers/gpu/drm/xe/xe_tuning.c | 3 +-
> drivers/gpu/drm/xe/xe_tuning.h | 6 +++
> drivers/gpu/drm/xe/xe_wa.c | 3 +-
> drivers/gpu/drm/xe/xe_wa.h | 5 ++
> 6 files changed, 69 insertions(+), 2 deletions(-)
> create mode 100644 drivers/gpu/drm/xe/tests/xe_rtp_tables_test.c
>
> diff --git a/drivers/gpu/drm/xe/tests/Makefile b/drivers/gpu/drm/xe/tests/Makefile
> index 0e3408f4952c..f7aa47f11a36 100644
> --- a/drivers/gpu/drm/xe/tests/Makefile
> +++ b/drivers/gpu/drm/xe/tests/Makefile
> @@ -9,5 +9,6 @@ obj-$(CONFIG_DRM_XE_KUNIT_TEST) += xe_test.o
> xe_test-y = xe_test_mod.o \
> xe_args_test.o \
> xe_pci_test.o \
> + xe_rtp_tables_test.o \
> xe_rtp_test.o \
> xe_wa_test.o
> diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_tables_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_tables_test.c
> new file mode 100644
> index 000000000000..7dd77133bc42
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/tests/xe_rtp_tables_test.c
> @@ -0,0 +1,53 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#include <kunit/test.h>
> +
> +#include "xe_rtp_types.h"
> +#include "xe_tuning.h"
> +#include "xe_wa.h"
> +
> +#define RTP_TABLE_PARAM(table) \
> + static const void *table##_gen_params(struct kunit *test, \
> + const void *prev, char *desc) \
> + { \
> + typeof((table.entries)[0]) *__next = prev ? \
> + ((typeof(__next))prev) + 1 : (table.entries); \
> + if (__next - table.entries < table.n_entries) { \
> + scnprintf(desc, KUNIT_PARAM_DESC_SIZE, #table "/%s", __next->name); \
> + return __next; \
> + } \
> + return NULL; \
> + }
> +
> +static void xe_rtp_table_gt_test(struct kunit *test)
> +{
> + const struct xe_rtp_entry_sr *entry = test->param_value;
> +
> + for (int i = 0; i < entry->n_rules; i++) {
> + KUNIT_EXPECT_TRUE(test,
> + entry->rules[i].match_type != XE_RTP_MATCH_ENGINE_CLASS ||
> + entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE);
> + KUNIT_EXPECT_TRUE(test,
> + entry->rules[i].match_type != XE_RTP_MATCH_NOT_ENGINE_CLASS ||
> + entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE);
> + }
> +}
> +
> +RTP_TABLE_PARAM(gt_was);
> +RTP_TABLE_PARAM(gt_tunings);
> +
> +static struct kunit_case xe_rtp_table_tests[] = {
> + KUNIT_CASE_PARAM(xe_rtp_table_gt_test, gt_was_gen_params),
> + KUNIT_CASE_PARAM(xe_rtp_table_gt_test, gt_tunings_gen_params),
> + {}
> +};
> +
> +static struct kunit_suite xe_rtp_tables_test_suite = {
> + .name = "xe_rtp_tables_test",
> + .test_cases = xe_rtp_table_tests,
> +};
> +
> +kunit_test_suite(xe_rtp_tables_test_suite);
> diff --git a/drivers/gpu/drm/xe/xe_tuning.c b/drivers/gpu/drm/xe/xe_tuning.c
> index bf3fad9cdbef..bcec40ca2d35 100644
> --- a/drivers/gpu/drm/xe/xe_tuning.c
> +++ b/drivers/gpu/drm/xe/xe_tuning.c
> @@ -20,7 +20,7 @@
> #undef XE_REG_MCR
> #define XE_REG_MCR(...) XE_REG(__VA_ARGS__, .mcr = 1)
>
> -static const struct xe_rtp_table_sr gt_tunings = XE_RTP_TABLE_SR(
> +VISIBLE_IF_KUNIT const struct xe_rtp_table_sr gt_tunings = XE_RTP_TABLE_SR(
> { XE_RTP_NAME("Tuning: Blend Fill Caching Optimization Disable"),
> XE_RTP_RULES(PLATFORM(DG2)),
> XE_RTP_ACTIONS(SET(XEHP_L3SCQREG7, BLEND_FILL_CACHING_OPT_DIS))
> @@ -101,6 +101,7 @@ static const struct xe_rtp_table_sr gt_tunings = XE_RTP_TABLE_SR(
> BANK_HASH_4KB_MODE))
> },
> );
> +EXPORT_SYMBOL_IF_KUNIT(gt_tunings);
>
> static const struct xe_rtp_table_sr engine_tunings = XE_RTP_TABLE_SR(
> { XE_RTP_NAME("Tuning: L3 Hashing Mask"),
> diff --git a/drivers/gpu/drm/xe/xe_tuning.h b/drivers/gpu/drm/xe/xe_tuning.h
> index d18e187debf6..869564e3e992 100644
> --- a/drivers/gpu/drm/xe/xe_tuning.h
> +++ b/drivers/gpu/drm/xe/xe_tuning.h
> @@ -6,6 +6,8 @@
> #ifndef _XE_TUNING_H_
> #define _XE_TUNING_H_
>
> +#include <kunit/visibility.h>
> +
> struct drm_printer;
> struct xe_gt;
> struct xe_hw_engine;
> @@ -16,4 +18,8 @@ void xe_tuning_process_engine(struct xe_hw_engine *hwe);
> void xe_tuning_process_lrc(struct xe_hw_engine *hwe);
> int xe_tuning_dump(struct xe_gt *gt, struct drm_printer *p);
>
> +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> +extern const struct xe_rtp_table_sr gt_tunings;
> +#endif
> +
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
> index b9d9fe0801aa..1a1e04215f21 100644
> --- a/drivers/gpu/drm/xe/xe_wa.c
> +++ b/drivers/gpu/drm/xe/xe_wa.c
> @@ -130,7 +130,7 @@
> __diag_push();
> __diag_ignore_all("-Woverride-init", "Allow field overrides in table");
>
> -static const struct xe_rtp_table_sr gt_was = XE_RTP_TABLE_SR(
> +VISIBLE_IF_KUNIT const struct xe_rtp_table_sr gt_was = XE_RTP_TABLE_SR(
> /* Workarounds applying over a range of IPs */
>
> { XE_RTP_NAME("14011060649"),
> @@ -307,6 +307,7 @@ static const struct xe_rtp_table_sr gt_was = XE_RTP_TABLE_SR(
> XE_RTP_ACTIONS(SET(GUC_INTR_CHICKEN, DISABLE_SIGNALING_ENGINES))
> },
> );
> +EXPORT_SYMBOL_IF_KUNIT(gt_was);
>
> static const struct xe_rtp_table_sr engine_was = XE_RTP_TABLE_SR(
> /* Workarounds applying over a range of IPs */
> diff --git a/drivers/gpu/drm/xe/xe_wa.h b/drivers/gpu/drm/xe/xe_wa.h
> index a5f7d33c1b32..8784b491dde7 100644
> --- a/drivers/gpu/drm/xe/xe_wa.h
> +++ b/drivers/gpu/drm/xe/xe_wa.h
> @@ -6,6 +6,7 @@
> #ifndef _XE_WA_H_
> #define _XE_WA_H_
>
> +#include <kunit/visibility.h>
> #include "xe_assert.h"
>
> struct drm_printer;
> @@ -24,6 +25,10 @@ void xe_wa_apply_tile_workarounds(struct xe_tile *tile);
> void xe_wa_device_dump(struct xe_device *xe, struct drm_printer *p);
> int xe_wa_gt_dump(struct xe_gt *gt, struct drm_printer *p);
>
> +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> +extern const struct xe_rtp_table_sr gt_was;
> +#endif
> +
> /**
> * XE_GT_WA - Out-of-band GT workarounds, to be queried and called as needed.
> * @gt__: gt instance
> --
> 2.43.0
next prev parent reply other threads:[~2026-05-28 20:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 16:35 [PATCH v5 0/4] drm/xe/rtp: WA table context testing Violet Monti
2026-05-28 16:35 ` [PATCH v5 1/4] drm/xe/rtp: Add struct types for RTP tables Violet Monti
2026-05-28 17:12 ` Gustavo Sousa
2026-05-28 20:46 ` Gustavo Sousa
2026-06-01 16:29 ` Matt Roper
2026-06-01 16:34 ` Matt Roper
2026-05-28 16:35 ` [PATCH v5 2/4] drm/xe/rtp: Ensure gt_was doesn't evaluate rules with engine types Violet Monti
2026-05-28 20:52 ` Gustavo Sousa [this message]
2026-05-28 16:35 ` [PATCH v5 3/4] drm/xe/rtp: Ensure oob_was does not evaluate engine type rules Violet Monti
2026-05-28 16:35 ` [PATCH v5 4/4] drm/xe/rtp: Ensure device_oob_was only evaluates correct rules Violet Monti
2026-05-28 16:44 ` ✗ CI.checkpatch: warning for drm/xe/rtp: WA table context testing Patchwork
2026-05-28 16:45 ` ✓ CI.KUnit: success " Patchwork
2026-05-28 17:23 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-28 23:26 ` ✓ Xe.CI.FULL: " 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=87pl2f5kb0.fsf@intel.com \
--to=gustavo.sousa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=violet.monti@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.