From: Louis Chauvet <louis.chauvet@bootlin.com>
To: Riana Tauro <riana.tauro@intel.com>, igt-dev@lists.freedesktop.org
Cc: anshuman.gupta@intel.com, lucas.demarchi@intel.com,
rodrigo.vivi@intel.com, kamil.konieczny@linux.intel.com,
katarzyna.piecielska@intel.com
Subject: Re: [PATCH i-g-t 2/2] tests/intel/xe_configfs: Add test to validate survivability mode
Date: Fri, 11 Apr 2025 09:53:52 +0200 [thread overview]
Message-ID: <4edbe1e1-b8d4-4598-bd9e-2a72cf18feaa@bootlin.com> (raw)
In-Reply-To: <20250410060727.1857299-3-riana.tauro@intel.com>
Le 10/04/2025 à 08:07, Riana Tauro a écrit :
> The test validates if survivability mode is enabled on supported
> platforms when configured using configfs attribute.
>
> Signed-off-by: Riana Tauro <riana.tauro@intel.com>
> ---
> tests/intel/xe_configfs.c | 138 ++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 2 files changed, 139 insertions(+)
> create mode 100644 tests/intel/xe_configfs.c
>
> diff --git a/tests/intel/xe_configfs.c b/tests/intel/xe_configfs.c
> new file mode 100644
> index 000000000..8954ed87c
> --- /dev/null
> +++ b/tests/intel/xe_configfs.c
> @@ -0,0 +1,138 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +#include <limits.h>
> +
> +#include "igt.h"
> +#include "igt_configfs.h"
> +#include "igt_device.h"
> +#include "igt_sysfs.h"
> +
> +/**
> + * TEST: Check configfs userspace API
> + * Category: Core
> + * Mega feature: General Core features
> + * Sub-category: uapi
> + * Functionality: configfs
> + * Description: validate configfs entries
> + * Test category: functionality test
> + */
> +
> +static char bus_addr[NAME_MAX];
> +static uint32_t dev_id;
> +
> +static int driver_fd(void)
> +{
> + int fd;
> +
> + fd = open("/sys/bus/pci/drivers/xe", O_RDONLY);
> + igt_assert_f(fd >= 0, "Can't open path\n");
> +
> + return fd;
> +}
> +
> +static void driver_bind(void)
> +{
> + int fd;
> +
> + fd = driver_fd();
> + igt_sysfs_write(fd, "bind", bus_addr, sizeof(bus_addr));
> + close(fd);
> +}
> +
> +static void driver_unbind(void)
> +{
> + int fd;
> +
> + fd = driver_fd();
> + igt_sysfs_write(fd, "unbind", bus_addr, sizeof(bus_addr));
> + close(fd);
> +}
Did you see the functions xe_sysfs_driver_do in igt_sysfs.c? It seems to
do the same thing as driver_bind/unbind here.
Thanks,
Louis Chauvet
> +
> +static void restore(int sig)
> +{
> + /* Restore after survivability mode */
> + driver_unbind();
> + driver_bind();
> +}
> +
> +static void set_survivability_mode(int dir_fd, bool value)
> +{
> + driver_unbind();
> + igt_sysfs_set_boolean(dir_fd, "survivability_mode", value);
> + driver_bind();
> +}
> +
> +static void check_survivability_mode(void)
> +{
> + char path[PATH_MAX], buf[4096];
> + int fd, len;
> +
> + snprintf(path, PATH_MAX, "/sys/bus/pci/devices/%s", bus_addr);
> + fd = open(path, O_RDONLY);
> + igt_assert_f(fd >= 0, "Cannot open %s\n", path);
> +
> + len = igt_sysfs_read(fd, "survivability_mode", buf, sizeof(buf) - 1);
> + if (len > 0) {
> + buf[len] = '\0';
> + igt_info("Survivability Mode:\n%s", buf);
> + }
> + close(fd);
> +
> + if (IS_BATTLEMAGE(dev_id))
> + igt_assert_f(len > 0, "Survivability mode not set\n");
> +}
> +
> +/**
> + * SUBTEST: survivability-mode
> + * Description: Validate survivability mode by setting configfs
> + */
> +static void test_survivability_mode(int dir_fd)
> +{
> + /* Enable survivability mode */
> + set_survivability_mode(dir_fd, true);
> +
> + check_survivability_mode();
> +}
> +
> +static int create_device_configfs(int configfs_fd, int fd)
> +{
> + int dir_fd;
> + struct pci_device *pci_dev;
> +
> + pci_dev = igt_device_get_pci_device(fd);
> + snprintf(bus_addr, sizeof(bus_addr), "%04x:%02x:%02x.%01x",
> + pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func);
> +
> + dir_fd = igt_configfs_create_directory(configfs_fd, bus_addr);
> + igt_assert(dir_fd);
> +
> + return dir_fd;
> +}
> +
> +igt_main
> +{
> + int fd, configfs_fd, dir_fd;
> +
> + igt_fixture {
> + fd = drm_open_driver(DRIVER_XE);
> + dev_id = intel_get_drm_devid(fd);
> + configfs_fd = igt_configfs_open("xe");
> + igt_require(configfs_fd != -1);
> + dir_fd = create_device_configfs(configfs_fd, fd);
> + }
> +
> + igt_describe("Validate survivability mode");
> + igt_subtest("survivability-mode") {
> + igt_install_exit_handler(restore);
> + test_survivability_mode(dir_fd);
> + }
> +
> + igt_fixture {
> + igt_configfs_remove_directory(configfs_fd, bus_addr);
> + close(dir_fd);
> + close(configfs_fd);
> + close(fd);
> + }
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 2a63d888f..74684ea35 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -279,6 +279,7 @@ intel_xe_progs = [
> 'xe_create',
> 'xe_compute',
> 'xe_compute_preempt',
> + 'xe_configfs',
> 'xe_copy_basic',
> 'xe_dma_buf_sync',
> 'xe_debugfs',
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-04-11 8:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 6:07 [PATCH i-g-t 0/2] Add test to validate survivability mode Riana Tauro
2025-04-10 6:07 ` [PATCH i-g-t 1/2] lib/igt_configfs: Add library for configfs Riana Tauro
2025-04-11 7:53 ` Louis Chauvet
2025-04-11 10:58 ` Riana Tauro
2025-04-13 17:56 ` José Expósito
2025-04-10 6:07 ` [PATCH i-g-t 2/2] tests/intel/xe_configfs: Add test to validate survivability mode Riana Tauro
2025-04-11 7:53 ` Louis Chauvet [this message]
2025-04-15 5:44 ` Riana Tauro
2025-04-10 6:55 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-04-10 7:53 ` ✗ Xe.CI.Full: failure " Patchwork
2025-04-10 8:55 ` ✗ i915.CI.BAT: " 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=4edbe1e1-b8d4-4598-bd9e-2a72cf18feaa@bootlin.com \
--to=louis.chauvet@bootlin.com \
--cc=anshuman.gupta@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=katarzyna.piecielska@intel.com \
--cc=lucas.demarchi@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@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