From: Lucas De Marchi <lucas.demarchi@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>, maarten.lankhorst@intel.com
Subject: [Intel-xe] [PATCH 7/7] drm/xe: Add test for GT workarounds and tunings
Date: Tue, 21 Mar 2023 15:05:27 -0700 [thread overview]
Message-ID: <20230321220527.595462-8-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20230321220527.595462-1-lucas.demarchi@intel.com>
In order to avoid mistakes when populating the workarounds, it's good to
be able to test if the entries added are all compatible for a certain
platform. The platform itself is not needed as long as we create fake
devices with enough configuration for the RTP helpers to process the
tables. Common mistakes that can be avoided:
- Entries clashing the bitfields being updated
- Register type being mixed (MCR vs regular / masked vs regular)
- Unexpected errors while adding the reg_sr entry
To test, inject a duplicate entry in gt_was, but with platform == tigerlake
rather than the currenct graphics version check:
{ XE_RTP_NAME("14011059788"),
XE_RTP_RULES(PLATFORM(TIGERLAKE)),
XE_RTP_ACTIONS(SET(GEN10_DFR_RATIO_EN_AND_CHICKEN, DFR_DISABLE))
},
This produces the following result:
$ ./tools/testing/kunit/kunit.py run \
--kunitconfig drivers/gpu/drm/xe/.kunitconfig xe_wa
[14:18:02] Starting KUnit Kernel (1/1)...
[14:18:02] ============================================================
[14:18:02] ==================== xe_wa (1 subtest) =====================
[14:18:02] ======================== xe_wa_gt =========================
[14:18:02] [drm:xe_reg_sr_add] *ERROR* Discarding save-restore reg 9550 (clear: 00000200, set: 00000200, masked: no): ret=-22
[14:18:02] # xe_wa_gt: ASSERTION FAILED at drivers/gpu/drm/xe/tests/xe_wa_test.c:116
[14:18:02] Expected gt->reg_sr.errors == 0, but
[14:18:02] gt->reg_sr.errors == 1 (0x1)
[14:18:02] [FAILED] TIGERLAKE (B0)
[14:18:02] [PASSED] DG1 (A0)
[14:18:02] [PASSED] DG1 (B0)
...
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
drivers/gpu/drm/xe/tests/Makefile | 3 +-
drivers/gpu/drm/xe/tests/xe_wa_test.c | 136 ++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_reg_sr.c | 1 +
drivers/gpu/drm/xe/xe_tuning.c | 1 +
drivers/gpu/drm/xe/xe_wa.c | 1 +
5 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/xe/tests/xe_wa_test.c
diff --git a/drivers/gpu/drm/xe/tests/Makefile b/drivers/gpu/drm/xe/tests/Makefile
index c5c2f108d017..56919abb3f2a 100644
--- a/drivers/gpu/drm/xe/tests/Makefile
+++ b/drivers/gpu/drm/xe/tests/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_DRM_XE_KUNIT_TEST) += \
xe_bo_test.o \
xe_dma_buf_test.o \
xe_migrate_test.o \
- xe_rtp_test.o
+ xe_rtp_test.o \
+ xe_wa_test.o
diff --git a/drivers/gpu/drm/xe/tests/xe_wa_test.c b/drivers/gpu/drm/xe/tests/xe_wa_test.c
new file mode 100644
index 000000000000..7f0dc821535b
--- /dev/null
+++ b/drivers/gpu/drm/xe/tests/xe_wa_test.c
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <drm/drm_drv.h>
+#include <drm/drm_kunit_helpers.h>
+
+#include <kunit/test.h>
+
+#include "xe_device.h"
+#include "xe_pci_test.h"
+#include "xe_reg_sr.h"
+#include "xe_tuning.h"
+#include "xe_wa.h"
+
+struct platform_test_case {
+ const char *name;
+ enum xe_platform platform;
+ enum xe_subplatform subplatform;
+ struct xe_step_info step;
+};
+
+#define PLATFORM_CASE(platform__, graphics_step__) \
+ { \
+ .name = #platform__ " (" #graphics_step__ ")", \
+ .platform = XE_ ## platform__, \
+ .subplatform = XE_SUBPLATFORM_NONE, \
+ .step = { .graphics = STEP_ ## graphics_step__ } \
+ }
+
+
+#define SUBPLATFORM_CASE(platform__, subplatform__, graphics_step__) \
+ { \
+ .name = #platform__ "_" #subplatform__ " (" #graphics_step__ ")", \
+ .platform = XE_ ## platform__, \
+ .subplatform = XE_SUBPLATFORM_ ## platform__ ## _ ## subplatform__, \
+ .step = { .graphics = STEP_ ## graphics_step__ } \
+ }
+
+static const struct platform_test_case cases[] = {
+ PLATFORM_CASE(TIGERLAKE, B0),
+ PLATFORM_CASE(DG1, A0),
+ PLATFORM_CASE(DG1, B0),
+ PLATFORM_CASE(ALDERLAKE_S, A0),
+ PLATFORM_CASE(ALDERLAKE_S, B0),
+ PLATFORM_CASE(ALDERLAKE_S, C0),
+ PLATFORM_CASE(ALDERLAKE_S, D0),
+ SUBPLATFORM_CASE(DG2, G10, A0),
+ SUBPLATFORM_CASE(DG2, G10, A1),
+ SUBPLATFORM_CASE(DG2, G10, B0),
+ SUBPLATFORM_CASE(DG2, G10, C0),
+ SUBPLATFORM_CASE(DG2, G11, A0),
+ SUBPLATFORM_CASE(DG2, G11, B0),
+ SUBPLATFORM_CASE(DG2, G11, B1),
+ SUBPLATFORM_CASE(DG2, G12, A0),
+ SUBPLATFORM_CASE(DG2, G12, A1),
+ PLATFORM_CASE(PVC, B0),
+ PLATFORM_CASE(PVC, B1),
+ PLATFORM_CASE(PVC, C0),
+};
+
+static void platform_desc(const struct platform_test_case *t, char *desc)
+{
+ strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE);
+}
+
+KUNIT_ARRAY_PARAM(platform, cases, platform_desc);
+
+static int xe_wa_test_init(struct kunit *test)
+{
+ const struct platform_test_case *param = test->param_value;
+ struct xe_device *xe;
+ struct device *dev;
+ int ret;
+
+ dev = drm_kunit_helper_alloc_device(test);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+ xe = drm_kunit_helper_alloc_drm_device(test, dev,
+ struct xe_device,
+ drm, DRIVER_GEM);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe);
+
+ ret = xe_pci_fake_device_init(xe, param->platform, param->subplatform);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ xe->info.step = param->step;
+
+ /* TODO: init hw engines for engine/LRC WAs */
+ xe->drm.dev = dev;
+ test->priv = xe;
+
+ return 0;
+}
+
+static void xe_wa_test_exit(struct kunit *test)
+{
+ struct xe_device *xe = test->priv;
+
+ drm_kunit_helper_free_device(test, xe->drm.dev);
+}
+
+static void xe_wa_gt(struct kunit *test)
+{
+ struct xe_device *xe = test->priv;
+ struct xe_gt *gt;
+ int id;
+
+ for_each_gt(gt, xe, id) {
+ xe_reg_sr_init(>->reg_sr, "GT", xe);
+
+ xe_wa_process_gt(gt);
+ xe_tuning_process_gt(gt);
+
+ KUNIT_ASSERT_EQ(test, gt->reg_sr.errors, 0);
+ }
+}
+
+static struct kunit_case xe_wa_tests[] = {
+ KUNIT_CASE_PARAM(xe_wa_gt, platform_gen_params),
+ {}
+};
+
+static struct kunit_suite xe_rtp_test_suite = {
+ .name = "xe_wa",
+ .init = xe_wa_test_init,
+ .exit = xe_wa_test_exit,
+ .test_cases = xe_wa_tests,
+};
+
+kunit_test_suite(xe_rtp_test_suite);
+
+MODULE_AUTHOR("Intel Corporation");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(XE_KUNIT);
diff --git a/drivers/gpu/drm/xe/xe_reg_sr.c b/drivers/gpu/drm/xe/xe_reg_sr.c
index 83f29aeb9250..b8939951bde7 100644
--- a/drivers/gpu/drm/xe/xe_reg_sr.c
+++ b/drivers/gpu/drm/xe/xe_reg_sr.c
@@ -44,6 +44,7 @@ int xe_reg_sr_init(struct xe_reg_sr *sr, const char *name, struct xe_device *xe)
return drmm_add_action_or_reset(&xe->drm, reg_sr_fini, sr);
}
+EXPORT_SYMBOL_NS_GPL(xe_reg_sr_init, XE_KUNIT);
static struct xe_reg_sr_entry *alloc_entry(struct xe_reg_sr *sr)
{
diff --git a/drivers/gpu/drm/xe/xe_tuning.c b/drivers/gpu/drm/xe/xe_tuning.c
index 7ff5eb762da5..31b163b971fb 100644
--- a/drivers/gpu/drm/xe/xe_tuning.c
+++ b/drivers/gpu/drm/xe/xe_tuning.c
@@ -62,6 +62,7 @@ void xe_tuning_process_gt(struct xe_gt *gt)
{
xe_rtp_process(gt_tunings, >->reg_sr, gt, NULL);
}
+EXPORT_SYMBOL_NS_GPL(xe_tuning_process_gt, XE_KUNIT);
/**
* xe_tuning_process_lrc - process lrc tunings
diff --git a/drivers/gpu/drm/xe/xe_wa.c b/drivers/gpu/drm/xe/xe_wa.c
index 59d2daab5929..282a25302e65 100644
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -628,6 +628,7 @@ void xe_wa_process_gt(struct xe_gt *gt)
{
xe_rtp_process(gt_was, >->reg_sr, gt, NULL);
}
+EXPORT_SYMBOL_NS_GPL(xe_wa_process_gt, XE_KUNIT);
/**
* xe_wa_process_engine - process engine workaround table
--
2.39.0
next prev parent reply other threads:[~2023-03-21 22:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 22:05 [Intel-xe] [PATCH 0/7] Unit tests for rtp and GT wa/tuning Lucas De Marchi
2023-03-21 22:05 ` [Intel-xe] [PATCH 1/7] drm/xe: Add basic unit tests for rtp Lucas De Marchi
2023-03-27 17:56 ` Michał Winiarski
2023-03-31 13:43 ` Lucas De Marchi
2023-04-01 8:59 ` Lucas De Marchi
2023-04-01 18:54 ` Michał Winiarski
2023-04-02 1:24 ` Lucas De Marchi
2023-04-02 10:51 ` Michal Wajdeczko
2023-03-31 14:34 ` Lucas De Marchi
2023-04-01 8:54 ` Lucas De Marchi
2023-04-01 18:26 ` Michał Winiarski
2023-04-02 1:34 ` Lucas De Marchi
2023-04-02 11:17 ` Michal Wajdeczko
2023-04-02 21:54 ` Lucas De Marchi
2023-04-03 7:38 ` Michal Wajdeczko
2023-04-03 13:02 ` Lucas De Marchi
2023-03-21 22:05 ` [Intel-xe] [PATCH 2/7] drm/xe: Extract function to initialize xe->info Lucas De Marchi
2023-03-21 22:05 ` [Intel-xe] [PATCH 3/7] drm/xe: Move test infra out of xe_pci.[ch] Lucas De Marchi
2023-03-21 22:05 ` [Intel-xe] [PATCH 4/7] drm/xe: Use XE_KUNIT for symbol namespace Lucas De Marchi
2023-03-21 22:05 ` [Intel-xe] [PATCH 5/7] drm/xe: Generalize fake device creation Lucas De Marchi
2023-03-21 22:05 ` [Intel-xe] [PATCH 6/7] drm/xe/reg_sr: Save errors for kunit integration Lucas De Marchi
2023-03-27 18:29 ` Michał Winiarski
2023-03-31 14:43 ` Lucas De Marchi
2023-03-21 22:05 ` Lucas De Marchi [this message]
2023-03-21 22:08 ` [Intel-xe] ✓ CI.Patch_applied: success for Unit tests for rtp and GT wa/tuning Patchwork
2023-03-31 15:14 ` Lucas De Marchi
2023-04-03 6:08 ` Mauro Carvalho Chehab
2023-03-21 22:09 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-03-21 22:13 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-03-21 22:25 ` [Intel-xe] ○ CI.BAT: info " 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=20230321220527.595462-8-lucas.demarchi@intel.com \
--to=lucas.demarchi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@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