[PATCH i-g-t 6/6] tests/intel/xe_sriov_flr: Implement clear-scratch-regs and clear-media-scratch-regs subchecks
Marcin Bernatowicz
marcin.bernatowicz at linux.intel.com
Wed Oct 9 11:30:18 UTC 2024
Add tests to verify clearing of scratch and media scratch registers in
Virtual Functions (VFs) after a Functional Level Reset (FLR).
This code is based on prior work of Lukasz Laguna.
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>
Cc: Adam Miszczak <adam.miszczak at linux.intel.com>
Cc: Jakub Kolakowski <jakub1.kolakowski at intel.com>
Cc: Lukasz Laguna <lukasz.laguna at intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko at intel.com>
Cc: Michał Winiarski <michal.winiarski at intel.com>
Cc: Narasimha C V <narasimha.c.v at intel.com>
Cc: Piotr Piórkowski <piotr.piorkowski at intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
Cc: Tomasz Lis <tomasz.lis at intel.com>
---
tests/intel/xe_sriov_flr.c | 130 ++++++++++++++++++++++++++++++++++++-
1 file changed, 129 insertions(+), 1 deletion(-)
diff --git a/tests/intel/xe_sriov_flr.c b/tests/intel/xe_sriov_flr.c
index 4c97c83a4..93e45c928 100644
--- a/tests/intel/xe_sriov_flr.c
+++ b/tests/intel/xe_sriov_flr.c
@@ -7,6 +7,7 @@
#include <sys/stat.h>
#include "drmtest.h"
#include "igt_core.h"
+#include "igt_device.h"
#include "igt_sriov_device.h"
#include "intel_chipset.h"
#include "linux_scaffold.h"
@@ -706,6 +707,103 @@ static void lmem_subcheck_cleanup(struct subcheck_data *data)
free(ldata->vf_lmem_size);
}
+#define SCRATCH_REG 0x190240
+#define SCRATCH_REG_COUNT 4
+#define MED_SCRATCH_REG 0x190310
+#define MED_SCRATCH_REG_COUNT 4
+
+struct regs_data {
+ struct subcheck_data base;
+ struct intel_mmio_data *mmio;
+ uint32_t reg_addr;
+ int reg_count;
+};
+
+static void regs_subcheck_init(struct subcheck_data *data)
+{
+ struct regs_data *rdata = (struct regs_data *)data;
+
+ if (!xe_has_media_gt(data->pf_fd) &&
+ rdata->reg_addr == MED_SCRATCH_REG) {
+ igt_assert_neq(asprintf(&data->stop_reason, "%s : No media GT",
+ SKIP_REASON), -1);
+ }
+}
+
+static void regs_subcheck_prepare_vf(int vf_id, struct subcheck_data *data)
+{
+ struct regs_data *rdata = (struct regs_data *)data;
+ uint32_t reg;
+ int i;
+
+ if (data->stop_reason)
+ return;
+
+ if (!is_intel_mmio_initialized(&rdata->mmio[vf_id - 1])) {
+ struct pci_device *pci_dev = __igt_device_get_pci_device(data->pf_fd, vf_id);
+
+ if (!pci_dev) {
+ igt_assert_neq(asprintf(&data->stop_reason,
+ "No PCI device found for VF%u\n",
+ vf_id), -1);
+ return;
+ }
+
+ if (intel_register_access_init(&rdata->mmio[vf_id - 1], pci_dev, false)) {
+ igt_assert_neq(asprintf(&data->stop_reason,
+ "Failed to get access to VF%u MMIO\n",
+ vf_id), -1);
+ return;
+ }
+ }
+
+ for (i = 0; i < rdata->reg_count; i++) {
+ reg = rdata->reg_addr + i * 4;
+
+ intel_register_write(&rdata->mmio[vf_id - 1], reg, vf_id);
+ if (intel_register_read(&rdata->mmio[vf_id - 1], reg) != vf_id) {
+ igt_assert_neq(asprintf(&data->stop_reason,
+ "Registers write/read check failed on VF%u\n",
+ vf_id),
+ -1);
+ return;
+ }
+ }
+}
+
+static void regs_subcheck_verify_vf(int vf_id, int flr_vf_id, struct subcheck_data *data)
+{
+ struct regs_data *rdata = (struct regs_data *)data;
+ uint32_t expected = (vf_id == flr_vf_id) ? 0 : vf_id;
+ uint32_t reg;
+ int i;
+
+ if (data->stop_reason)
+ return;
+
+ for (i = 0; i < rdata->reg_count; i++) {
+ reg = rdata->reg_addr + i * 4;
+
+ if (intel_register_read(&rdata->mmio[vf_id - 1], reg) != expected) {
+ igt_assert_neq(asprintf(&data->stop_reason,
+ "Registers check after VF%u FLR failed on VF%u\n",
+ flr_vf_id, vf_id), -1);
+ return;
+ }
+ }
+}
+
+static void regs_subcheck_cleanup(struct subcheck_data *data)
+{
+ struct regs_data *rdata = (struct regs_data *)data;
+ int i;
+
+ if (rdata->mmio)
+ for (i = 0; i < data->num_vfs; ++i)
+ if (is_intel_mmio_initialized(&rdata->mmio[i]))
+ intel_register_access_fini(&rdata->mmio[i]);
+}
+
static void clear_tests(int pf_fd, int num_vfs)
{
struct xe_mmio xemmio = { };
@@ -714,10 +812,25 @@ static void clear_tests(int pf_fd, int num_vfs)
struct lmem_data ldata = {
.base = { .pf_fd = pf_fd, .num_vfs = num_vfs }
};
- const unsigned int num_checks = num_gts + 1;
+ struct intel_mmio_data mmio[num_vfs];
+ struct regs_data scratch_data = {
+ .base = { .pf_fd = pf_fd, .num_vfs = num_vfs },
+ .mmio = mmio,
+ .reg_addr = SCRATCH_REG,
+ .reg_count = SCRATCH_REG_COUNT
+ };
+ struct regs_data media_scratch_data = {
+ .base = { .pf_fd = pf_fd, .num_vfs = num_vfs },
+ .mmio = mmio,
+ .reg_addr = MED_SCRATCH_REG,
+ .reg_count = MED_SCRATCH_REG_COUNT
+ };
+ const unsigned int num_checks = num_gts + 3;
struct subcheck checks[num_checks];
int i;
+ memset(mmio, 0, sizeof(mmio));
+
for (i = 0; i < num_gts; ++i) {
gdata[i] = (struct ggtt_data){
.base = { .pf_fd = pf_fd, .num_vfs = num_vfs, .gt = i },
@@ -739,6 +852,21 @@ static void clear_tests(int pf_fd, int num_vfs)
.prepare_vf = lmem_subcheck_prepare_vf,
.verify_vf = lmem_subcheck_verify_vf,
.cleanup = lmem_subcheck_cleanup };
+ checks[i++] = (struct subcheck) {
+ .data = (struct subcheck_data *)&scratch_data,
+ .name = "clear-scratch-regs",
+ .init = regs_subcheck_init,
+ .prepare_vf = regs_subcheck_prepare_vf,
+ .verify_vf = regs_subcheck_verify_vf,
+ .cleanup = regs_subcheck_cleanup };
+ checks[i++] = (struct subcheck) {
+ .data = (struct subcheck_data *)&media_scratch_data,
+ .name = "clear-media-scratch-regs",
+ .init = regs_subcheck_init,
+ .prepare_vf = regs_subcheck_prepare_vf,
+ .verify_vf = regs_subcheck_verify_vf,
+ .cleanup = regs_subcheck_cleanup
+ };
igt_assert_eq(i, num_checks);
verify_flr(pf_fd, num_vfs, checks, num_checks);
--
2.31.1
More information about the igt-dev
mailing list