From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
igt-dev@lists.freedesktop.org
Cc: adam.miszczak@linux.intel.com, jakub1.kolakowski@intel.com,
lukasz.laguna@intel.com, michal.winiarski@intel.com,
narasimha.c.v@intel.com, piotr.piorkowski@intel.com,
satyanarayana.k.v.p@intel.com, tomasz.lis@intel.com
Subject: Re: [PATCH v2 i-g-t 2/6] lib/igt_sriov_device: add helper for resetting SR-IOV device
Date: Tue, 22 Oct 2024 12:10:39 +0200 [thread overview]
Message-ID: <47c21095-f55b-4421-aec8-76ff5da86e29@intel.com> (raw)
In-Reply-To: <20241021200737.941384-3-marcin.bernatowicz@linux.intel.com>
On 21.10.2024 22:07, Marcin Bernatowicz wrote:
> Reset is initiated by writing 1 to device's sysfs reset attribute.
FLR is not SR-IOV only concept, FLR can be supported by any other PCI
device, it's just mandatory for the VFs, so maybe these SR-IOV helpers
should be built on top native helpers:
igt_trigger_reset(dir)
{
igt_sysfs_set(dir, "reset", "1")
}
igt_reset_device(fd)
{
dir = igt_get_device_dir(fd)
igt_trigger_reset(dir)
}
igt_sriov_get_vf_device_dir(fd, n)
{
igt_assert(n);
return ...("virtfn%u", n)
}
igt_sriov_reset_vf(fd, n)
{
dir = igt_sriov_get_vf_device_dir(fd, n)
igt_trigger_reset(dir)
}
>
> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> Reviewed-by: Adam Miszczak <adam.miszczak@linux.intel.com>
> Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
> Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
> Cc: Lukasz Laguna <lukasz.laguna@intel.com>
> Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Narasimha C V <narasimha.c.v@intel.com>
> Cc: Piotr Piórkowski <piotr.piorkowski@intel.com>
> Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> Cc: Tomasz Lis <tomasz.lis@intel.com>
> ---
> lib/igt_sriov_device.c | 51 ++++++++++++++++++++++++++++++++++++++++++
> lib/igt_sriov_device.h | 2 ++
> 2 files changed, 53 insertions(+)
>
> diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
> index d20c74823..2b83cd43c 100644
> --- a/lib/igt_sriov_device.c
> +++ b/lib/igt_sriov_device.c
> @@ -413,3 +413,54 @@ int igt_sriov_device_sysfs_open(int pf, unsigned int vf_num)
>
> return fd;
> }
> +
> +/**
> + * igt_sriov_device_reset_exists:
> + * @pf: PF device file descriptor
> + * @vf_num: VF number (1-based to identify single VF) or 0 for PF
> + *
> + * Check if reset attribute exists for a given SR-IOV device.
> + *
> + * Returns:
> + * True if reset attribute exists, false otherwise.
> + */
> +bool igt_sriov_device_reset_exists(int pf, unsigned int vf_num)
> +{
> + int sysfs;
> + bool reset_exists;
> +
> + sysfs = igt_sriov_device_sysfs_open(pf, vf_num);
> + if (sysfs < 0)
> + return false;
> +
> + reset_exists = igt_sysfs_has_attr(sysfs, "reset");
> + close(sysfs);
> +
> + return reset_exists;
> +}
> +
> +/**
> + * igt_sriov_device_reset:
> + * @pf: PF device file descriptor
> + * @vf_num: VF number (1-based to identify single VF) or 0 for PF
> + *
> + * Trigger FLR on a given VF.
> + *
> + * Returns:
> + * True on success, false on failure.
> + */
> +bool igt_sriov_device_reset(int pf, unsigned int vf_num)
> +{
> + int sysfs;
> + bool ret;
> +
> + sysfs = igt_sriov_device_sysfs_open(pf, vf_num);
> + if (sysfs < 0)
> + return false;
> +
> + igt_debug("Initiating FLR on VF%d\n", vf_num);
> + ret = igt_sysfs_set(sysfs, "reset", "1");
> + close(sysfs);
> +
> + return ret;
> +}
> diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h
> index dc95a4c78..4b63ceb22 100644
> --- a/lib/igt_sriov_device.h
> +++ b/lib/igt_sriov_device.h
> @@ -31,6 +31,8 @@ bool igt_sriov_is_vf_drm_driver_probed(int pf, unsigned int vf_num);
> void igt_sriov_bind_vf_drm_driver(int pf, unsigned int vf_num);
> void igt_sriov_unbind_vf_drm_driver(int pf, unsigned int vf_num);
> int igt_sriov_device_sysfs_open(int pf, unsigned int vf_num);
> +bool igt_sriov_device_reset_exists(int pf, unsigned int vf_num);
> +bool igt_sriov_device_reset(int pf, unsigned int vf_num);
>
> /**
> * for_each_sriov_vf - Helper for running code on each VF
next prev parent reply other threads:[~2024-10-22 10:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 20:07 [PATCH v2 i-g-t 0/6] Introduce xe_sriov_flr test Marcin Bernatowicz
2024-10-21 20:07 ` [PATCH v2 i-g-t 1/6] lib/igt_sriov_device: add helper for opening SR-IOV device sysfs Marcin Bernatowicz
2024-10-21 20:07 ` [PATCH v2 i-g-t 2/6] lib/igt_sriov_device: add helper for resetting SR-IOV device Marcin Bernatowicz
2024-10-22 10:10 ` Michal Wajdeczko [this message]
2024-10-23 14:23 ` Bernatowicz, Marcin
2024-10-21 20:07 ` [PATCH v2 i-g-t 3/6] tests/intel/xe_sriov_flr: Add skeleton for clear and isolation tests Marcin Bernatowicz
2024-10-21 20:07 ` [PATCH v2 i-g-t 4/6] tests/intel/xe_sriov_flr: Implement clear-ggtt subcheck Marcin Bernatowicz
2024-10-21 20:07 ` [PATCH v2 i-g-t 5/6] tests/intel/xe_sriov_flr: Implement clear-lmem subcheck Marcin Bernatowicz
2024-10-21 20:07 ` [PATCH v2 i-g-t 6/6] tests/intel/xe_sriov_flr: Implement clear-scratch-regs and clear-media-scratch-regs subchecks Marcin Bernatowicz
2024-10-21 21:41 ` ✓ Fi.CI.BAT: success for Introduce xe_sriov_flr test (rev2) Patchwork
2024-10-21 21:51 ` ✓ CI.xeBAT: " Patchwork
2024-10-22 3:56 ` ✗ CI.xeFULL: failure " Patchwork
2024-10-22 5:07 ` ✗ Fi.CI.IGT: " Patchwork
2024-10-28 14:29 ` [PATCH v2 i-g-t 0/6] Introduce xe_sriov_flr test Laguna, Lukasz
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=47c21095-f55b-4421-aec8-76ff5da86e29@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=adam.miszczak@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=marcin.bernatowicz@linux.intel.com \
--cc=michal.winiarski@intel.com \
--cc=narasimha.c.v@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=satyanarayana.k.v.p@intel.com \
--cc=tomasz.lis@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