All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Riana Tauro <riana.tauro@intel.com>
Cc: <igt-dev@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
	<lucas.demarchi@intel.com>, <kamil.konieczny@intel.com>,
	<aravind.iddamsetty@linux.intel.com>, <louis.chauvet@bootlin.com>
Subject: Re: [PATCH i-g-t v3 5/5] tests/intel/xe_configfs: Add test to validate survivability mode
Date: Wed, 14 May 2025 10:24:21 -0400	[thread overview]
Message-ID: <aCSnlerlgHRzi6SU@intel.com> (raw)
In-Reply-To: <20250513142827.1129334-6-riana.tauro@intel.com>

On Tue, May 13, 2025 at 07:58:25PM +0530, Riana Tauro wrote:
> The test validates if survivability mode is enabled on supported
> platforms when configured using configfs attribute.
> 
> v2: make test platform specific
>     check for presence of file for survivability mode
>     use mode_t flags (Aravind)
> 
> Signed-off-by: Riana Tauro <riana.tauro@intel.com>
> ---
>  tests/intel/xe_configfs.c | 100 ++++++++++++++++++++++++++++++++++++++
>  tests/meson.build         |   1 +
>  2 files changed, 101 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..4d244321c
> --- /dev/null
> +++ b/tests/intel/xe_configfs.c
> @@ -0,0 +1,100 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +#include <limits.h>
> +
> +#include "igt.h"
> +#include "igt_configfs.h"
> +#include "igt_device.h"
> +#include "igt_fs.h"
> +#include "igt_kmod.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 void restore(int sig)
> +{
> +	/* Restore after survivability mode */
> +	igt_kmod_unbind("xe", bus_addr);
> +	igt_kmod_bind("xe", bus_addr);
> +}
> +
> +static void set_survivability_mode(int dir_fd, bool value)
> +{
> +	igt_kmod_unbind("xe", bus_addr);
> +	igt_sysfs_set_boolean(dir_fd, "survivability_mode", value);
> +	igt_kmod_bind("xe", bus_addr);
> +}
> +
> +/**
> + * SUBTEST: survivability-mode
> + * Description: Validate survivability mode by setting configfs
> + */
> +static void test_survivability_mode(int dir_fd)
> +{
> +	char path[PATH_MAX];
> +	int fd;
> +
> +	/* Enable survivability mode */
> +	set_survivability_mode(dir_fd, true);
> +
> +	/* check presence of survivability mode sysfs */
> +	snprintf(path, PATH_MAX, "/sys/bus/pci/devices/%s/survivability_mode", bus_addr);
> +
> +	fd = open(path, O_RDONLY);
> +	igt_assert_f(fd >= 0, "Survivability mode not set\n");
> +	close(fd);
> +}
> +
> +static int create_device_configfs(int configfs_fd, int fd)
> +{
> +	int dir_fd;
> +	struct pci_device *pci_dev;
> +	mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
> +
> +	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_fs_create_dir(configfs_fd, bus_addr, mode);
> +	igt_assert(dir_fd);
> +
> +	return dir_fd;
> +}

This could probably be in /lib/ (in the future)

Let's do this later whenever we have other cases, and then
think about the clean up with multiple users...

> +
> +igt_main
> +{
> +	int fd, configfs_fd, dir_fd;
> +
> +	igt_fixture {
> +		fd = drm_open_driver(DRIVER_XE);
> +		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_require(IS_BATTLEMAGE(intel_get_drm_devid(fd)));
> +		igt_install_exit_handler(restore);
> +		test_survivability_mode(dir_fd);

I believe the only thing confusing here is the name of this variable.
I was expecting that to be the config_fs and it was hard to follow

So, perhaps s/dir_fd/configfs_device_fd/g ?!

up to you:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> +	}
> +
> +	igt_fixture {
> +		igt_fs_remove_dir(configfs_fd, bus_addr);
> +		close(dir_fd);
> +		close(configfs_fd);
> +		close(fd);
> +	}
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 20ddddb89..55bcf57ec 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -279,6 +279,7 @@ intel_xe_progs = [
>  	'xe_compute',
>  	'xe_compute_preempt',
>  	'xe_copy_basic',
> +	'xe_configfs',
>  	'xe_dma_buf_sync',
>  	'xe_drm_fdinfo',
>  	'xe_eu_stall',
> -- 
> 2.47.1
> 

  reply	other threads:[~2025-05-14 14:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 14:28 [PATCH i-g-t v3 0/5] Add test to validate survivability mode Riana Tauro
2025-05-13 14:28 ` [PATCH i-g-t v3 1/5] lib/igt_aux: Move is_mountpoint() to igt_aux Riana Tauro
2025-05-13 14:28 ` [PATCH i-g-t v3 2/5] lib/igt_configfs: Add helper to mount configfs Riana Tauro
2025-05-13 14:28 ` [PATCH i-g-t v3 3/5] lib/igt_fs: Rename igt_io to igt_fs to add additional helpers Riana Tauro
2025-05-13 14:28 ` [PATCH i-g-t v3 4/5] lib/igt_fs: Add helper functions to create and remove directories Riana Tauro
2025-05-13 14:28 ` [PATCH i-g-t v3 5/5] tests/intel/xe_configfs: Add test to validate survivability mode Riana Tauro
2025-05-14 14:24   ` Rodrigo Vivi [this message]
2025-05-20  4:49     ` Riana Tauro
2025-05-14 14:46   ` Aravind Iddamsetty
2025-05-13 18:30 ` ✓ Xe.CI.BAT: success for Add test to validate survivability mode (rev3) Patchwork
2025-05-13 18:47 ` ✓ i915.CI.BAT: " Patchwork
2025-05-13 19:25 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-13 22:35 ` ✗ i915.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=aCSnlerlgHRzi6SU@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=aravind.iddamsetty@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@intel.com \
    --cc=louis.chauvet@bootlin.com \
    --cc=lucas.demarchi@intel.com \
    --cc=riana.tauro@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.