Skip to contentSkip to conversation

Initial SR-IOV validation

PATCH Superseded Lukasz Laguna 3 participants 14 messages Dec 4, 2023 – Dec 5, 2023

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Initial SR-IOV validation

Series introduces a basic SR-IOV test that validates VFs enabling in different scenarios together with VF DRM driver binding. Implemented library helpers rely on generic PCI device attributes defined in ABI.

Daniel Mrzyglod (1):
lib/igt_sriov_device: add helper for checking if VF DRM driver is
probed

Katarzyna Dec (4):
lib/igt_sriov_device: add core SR-IOV helpers lib/igt_sriov_device: add helper for opening VF device tests/sriov_basic: add basic tests for enabling SR-IOV VFs tests/sriov_basic: validate driver binding to VFs

Lukasz Laguna (3):
lib/igt_sriov_device: add helpers for operations in different VFs
scenarios
lib/igt_sriov_device: add helpers for VF DRM driver bind and unbind tests/sriov_basic: add more tests for VF driver binding

 lib/drmtest.c          |  22 ++-
 lib/drmtest.h          |   1 +
 lib/igt_sriov_device.c | 341 +++++++++++++++++++++++++++++++++++++++++
 lib/igt_sriov_device.h |  72 +++++++++
 lib/meson.build        |   1 +
 tests/meson.build      |   1 +
 tests/sriov_basic.c    | 262 +++++++++++++++++++++++++++++++
 7 files changed, 696 insertions(+), 4 deletions(-)
 create mode 100644 lib/igt_sriov_device.c
 create mode 100644 lib/igt_sriov_device.h
 create mode 100644 tests/sriov_basic.c
Signature · 1 line
2.40.0
#1 lore raw

PATCH v6 1/8 lib/igt_sriov_device: add core SR-IOV helpers

From: Katarzyna Dec <[email protected]>

Create lib for core SR-IOV (Single Root I/O Virtualization) helpers that allow to manage SR-IOV devices.

v2:
- change functions description (Michal)
v3:
- decipher SR-IOV shortcut in commit message (Kamil)
- add SR-IOV description in header file (Kamil)
- remove old r-b and add cc (Kamil)
- return bool result in functions prefixed with "__" (Kamil)
- add brief description in functions documentation (Michal)
- add asserts in helpers (Michal)
v4:
- remove unnecessary include (Kamil)

---
 lib/igt_sriov_device.c | 213 +++++++++++++++++++++++++++++++++++++++++
 lib/igt_sriov_device.h |  27 ++++++
 lib/meson.build        |   1 +
 3 files changed, 241 insertions(+)
 create mode 100644 lib/igt_sriov_device.c
 create mode 100644 lib/igt_sriov_device.h
lib/igt_sriov_device.c new file +213 -0
new file mode 100644
index 000000000..c5c594c2c
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2023 Intel Corporation. All rights reserved.
+ */
+
+#include <errno.h>
+
+#include "igt_core.h"
+#include "igt_sriov_device.h"
+#include "igt_sysfs.h"
+
+/**
+ * igt_sriov_is_pf - Check if device is PF
+ * @device: device file descriptor
+ *
+ * Determine if device is PF by checking existence of sriov_totalvfs file.
+ *
+ * Return:
+ * True if device is PF, false otherwise.
+ */
+bool igt_sriov_is_pf(int device)
+{
+	int sysfs;
+	bool ret;
+
+	sysfs = igt_sysfs_open(device);
+	igt_assert_fd(sysfs);
+
+	ret = igt_sysfs_has_attr(sysfs, "device/sriov_totalvfs");
+	close(sysfs);
+
+	return ret;
+}
+
+static bool __pf_attr_get_u32(int pf, const char *attr, uint32_t *value)
+{
+	int sysfs;
+	bool ret;
+
+	igt_assert(igt_sriov_is_pf(pf));
+
+	sysfs = igt_sysfs_open(pf);
+	igt_assert_fd(sysfs);
+
+	ret = __igt_sysfs_get_u32(sysfs, attr, value);
+	close(sysfs);
+
+	return ret;
+}
+
+static uint32_t pf_attr_get_u32(int pf, const char *attr)
+{
+	uint32_t value;
+
+	igt_assert_f(__pf_attr_get_u32(pf, attr, &value),
+		     "Failed to read %s attribute (%s)\n", attr, strerror(errno));
+
+	return value;
+}
+
+static bool __pf_attr_set_u32(int pf, const char *attr, uint32_t value)
+{
+	int sysfs;
+	bool ret;
+
+	igt_assert(igt_sriov_is_pf(pf));
+
+	sysfs = igt_sysfs_open(pf);
+	igt_assert_fd(sysfs);
+
+	ret = __igt_sysfs_set_u32(sysfs, attr, value);
+	close(sysfs);
+
+	return ret;
+}
+
+static void pf_attr_set_u32(int pf, const char *attr, uint32_t value)
+{
+	igt_assert_f(__pf_attr_set_u32(pf, attr, value),
+		     "Failed to write %u to %s attribute (%s)\n", value, attr, strerror(errno));
+}
+
+/**
+ * igt_sriov_vfs_supported - Check if VFs are supported
+ * @pf: PF device file descriptor
+ *
+ * Determine VFs support by checking if value of sriov_totalvfs attribute
+ * corresponding to @pf device is bigger than 0.
+ *
+ * Return:
+ * True if VFs are supported, false otherwise.
+ */
+bool igt_sriov_vfs_supported(int pf)
+{
+	uint32_t totalvfs;
+
+	if (!__pf_attr_get_u32(pf, "device/sriov_totalvfs", &totalvfs))
+		return false;
+
+	return totalvfs > 0;
+}
+
+/**
+ * igt_sriov_get_totalvfs - Get maximum number of VFs that can be enabled
+ * @pf: PF device file descriptor
+ *
+ * Maximum number of VFs that can be enabled is checked by reading
+ * sriov_totalvfs attribute corresponding to @pf device.
+ *
+ * It asserts on failure.
+ *
+ * Return:
+ * Maximum number of VFs that can be associated with given PF.
+ */
+unsigned int igt_sriov_get_total_vfs(int pf)
+{
+	return pf_attr_get_u32(pf, "device/sriov_totalvfs");
+}
+
+/**
+ * igt_sriov_get_numvfs - Get number of enabled VFs
+ * @pf: PF device file descriptor
+ *
+ * Number of enabled VFs is checked by reading sriov_numvfs attribute
+ * corresponding to @pf device.
+ *
+ * It asserts on failure.
+ *
+ * Return:
+ * Number of VFs enabled by given PF.
+ */
+unsigned int igt_sriov_get_enabled_vfs(int pf)
+{
+	return pf_attr_get_u32(pf, "device/sriov_numvfs");
+}
+
+/**
+ * igt_sriov_enable_vfs - Enable VFs
+ * @pf: PF device file descriptor
+ * @num_vfs: Number of virtual functions to be enabled
+ *
+ * Enable VFs by writing @num_vfs to sriov_numvfs attribute corresponding to
+ * @pf device.
+ * It asserts on failure.
+ */
+void igt_sriov_enable_vfs(int pf, unsigned int num_vfs)
+{
+	igt_assert(num_vfs > 0);
+
+	igt_debug("Enabling %u VFs\n", num_vfs);
+	pf_attr_set_u32(pf, "device/sriov_numvfs", num_vfs);
+}
+
+/**
+ * igt_sriov_disable_vfs - Disable VFs
+ * @pf: PF device file descriptor
+ *
+ * Disable VFs by writing 0 to sriov_numvfs attribute corresponding to @pf
+ * device.
+ * It asserts on failure.
+ */
+void igt_sriov_disable_vfs(int pf)
+{
+	pf_attr_set_u32(pf, "device/sriov_numvfs", 0);
+}
+
+/**
+ * igt_sriov_is_driver_autoprobe_enabled - Get VF driver autoprobe setting
+ * @pf: PF device file descriptor
+ *
+ * Get current VF driver autoprobe setting by reading sriov_drivers_autoprobe
+ * attribute corresponding to @pf device.
+ *
+ * It asserts on failure.
+ *
+ * Return:
+ * True if autoprobe is enabled, false otherwise.
+ */
+bool igt_sriov_is_driver_autoprobe_enabled(int pf)
+{
+	return pf_attr_get_u32(pf, "device/sriov_drivers_autoprobe");
+}
+
+/**
+ * igt_sriov_enable_driver_autoprobe - Enable VF driver autoprobe
+ * @pf: PF device file descriptor
+ *
+ * Enable VF driver autoprobe setting by writing 1 to sriov_drivers_autoprobe
+ * attribute corresponding to @pf device.
+ *
+ * If successful, kernel will automatically bind VFs to a compatible driver
+ * immediately after they are enabled.
+ * It asserts on failure.
+ */
+void igt_sriov_enable_driver_autoprobe(int pf)
+{
+	pf_attr_set_u32(pf,  "device/sriov_drivers_autoprobe", true);
+}
+
+/**
+ * igt_sriov_disable_driver_autoprobe - Disable VF driver autoprobe
+ * @pf: PF device file descriptor
+ *
+ * Disable VF driver autoprobe setting by writing 0 to sriov_drivers_autoprobe
+ * attribute corresponding to @pf device.
+ *
+ * During VFs enabling driver won't be bound to VFs.
+ * It asserts on failure.
+ */
+void igt_sriov_disable_driver_autoprobe(int pf)
+{
+	pf_attr_set_u32(pf,  "device/sriov_drivers_autoprobe", false);
+}
lib/igt_sriov_device.h new file +27 -0
new file mode 100644
index 000000000..63359d57c
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2023 Intel Corporation. All rights reserved.
+ */
+
+#ifndef __IGT_SRIOV_DEVICE_H__
+#define __IGT_SRIOV_DEVICE_H__
+
+/* Library for managing SR-IOV (Single Root I/O Virtualization)
+ * devices.
+ *
+ * SR-IOV is a specification that allows a single PCIe physical
+ * device to appear as a physical function (PF) and multiple virtual
+ * functions (VFs) to the operating system.
+ */
+
+bool igt_sriov_is_pf(int device);
+bool igt_sriov_vfs_supported(int pf);
+unsigned int igt_sriov_get_total_vfs(int pf);
+unsigned int igt_sriov_get_enabled_vfs(int pf);
+void igt_sriov_enable_vfs(int pf, unsigned int num_vfs);
+void igt_sriov_disable_vfs(int pf);
+bool igt_sriov_is_driver_autoprobe_enabled(int pf);
+void igt_sriov_enable_driver_autoprobe(int pf);
+void igt_sriov_disable_driver_autoprobe(int pf);
+
+#endif /* __IGT_SRIOV_DEVICE_H__ */
lib/meson.build +1 -0
index 48466a2e9..0fc11b26c 100644
@@ -38,6 +38,7 @@ lib_sources = [
 	'igt_primes.c',
 	'igt_pci.c',
 	'igt_rand.c',
+	'igt_sriov_device.c',
 	'igt_stats.c',
 	'igt_syncobj.c',
 	'igt_sysfs.c',
Signature · 1 line
2.40.0
#2 lore raw

PATCH v6 2/8 lib/igt_sriov_device: add helper for opening VF device

In reply to Lukasz Laguna

From: Katarzyna Dec <[email protected]>

Helper opens DRM device node and returns its file descriptor.

v2:
- s/drm_open_device/__drm_open_device (Kamil)
- combine string with one go (Kamil)
v3:
- change description of __drm_open_device() (Kamil)
v4:
- return error on wrong input (!vf_num) instead of assert (Kamil)

---
 lib/drmtest.c          | 22 ++++++++++++++++----
 lib/drmtest.h          |  1 +
 lib/igt_sriov_device.c | 47 ++++++++++++++++++++++++++++++++++++++++++
 lib/igt_sriov_device.h |  1 +
 4 files changed, 67 insertions(+), 4 deletions(-)
lib/drmtest.c +18 -4
index f0b97e362..c98754798 100644
@@ -245,7 +245,21 @@ static void log_opened_device_path(const char *device_path)
 	igt_info("Opened device: %s\n", item->path);
 }
 
-static int open_device(const char *name, unsigned int chipset)
+/**
+ * __drm_open_device:
+ * @name: DRM node name
+ * @chipset: OR'd flags for chipset to be opened
+ *
+ * Open a drm legacy device node with given @name and compatible with given
+ * @chipset flag.
+ *
+ * A special case is the use of the IGT_FORCE_DRIVER environment variable. In
+ * such case, even if opened device is compatible with given @chipset flag, the
+ * function returns error if forced driver is not compatible with @chipset.
+ *
+ * Returns: DRM file descriptor or -1 on error
+ */
+int __drm_open_device(const char *name, unsigned int chipset)
 {
 	const char *forced;
 	char dev_name[16] = "";
@@ -350,7 +364,7 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,
 		if (_is_already_opened(name, as_idx))
 			continue;
 
-		fd = open_device(name, chipset);
+		fd = __drm_open_device(name, chipset);
 		if (fd != -1)
 			return fd;
 	}
@@ -392,13 +406,13 @@ static int __open_driver_exact(const char *name, unsigned int chipset)
 {
 	int fd;
 
-	fd = open_device(name, chipset);
+	fd = __drm_open_device(name, chipset);
 	if (fd != -1)
 		return fd;
 
 	drm_load_module(chipset);
 
-	return open_device(name, chipset);
+	return __drm_open_device(name, chipset);
 }
 
 /*
lib/drmtest.h +1 -0
index 909a0c12c..271a93e8b 100644
@@ -98,6 +98,7 @@ void __set_forced_driver(const char *name);
  */
 #define ALIGN_DOWN(x, a)	ALIGN((x) - ((a) - 1), (a))
 
+int __drm_open_device(const char *name, unsigned int chipset);
 void drm_load_module(unsigned int chipset);
 int drm_open_driver(int chipset);
 int drm_open_driver_master(int chipset);
lib/igt_sriov_device.c +47 -0

58 lines not on this page · raw message

lib/igt_sriov_device.h +1 -0
index 63359d57c..2baf183fb 100644
@@ -23,5 +23,6 @@ void igt_sriov_disable_vfs(int pf);
 bool igt_sriov_is_driver_autoprobe_enabled(int pf);
 void igt_sriov_enable_driver_autoprobe(int pf);
 void igt_sriov_disable_driver_autoprobe(int pf);
+int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num);
 
 #endif /* __IGT_SRIOV_DEVICE_H__ */
Signature · 1 line
2.40.0
#3 lore raw

PATCH v6 3/8 lib/igt_sriov_device: add helper for checking if VF DRM driver is probed

In reply to Lukasz Laguna

From: Daniel Mrzyglod <[email protected]>

Probe check is based on existence of the DRM subsystem attribute in sysfs.

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 lib/igt_sriov_device.c | 29 +++++++++++++++++++++++++++++
 lib/igt_sriov_device.h |  1 +
 2 files changed, 30 insertions(+)
lib/igt_sriov_device.c +29 -0
index 36116058a..c643f47d1 100644
@@ -258,3 +258,32 @@ int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num)
 
 	return __drm_open_device(dev_name, DRIVER_ANY);
 }
+
+/**
+ * igt_sriov_is_vf_drm_driver_probed - Check if VF DRM driver is probed
+ * @pf: PF device file descriptor
+ * @vf_num: VF number (1-based to identify single VF)
+ *
+ * Verify if DRM driver is bound to VF device. Probe check is based on
+ * existence of the DRM subsystem attribute in sysfs.
+ *
+ * Returns:
+ * True if VF has DRM driver loaded, false if not.
+ */
+bool igt_sriov_is_vf_drm_driver_probed(int pf, unsigned int vf_num)
+{
+	char path[PATH_MAX];
+	int sysfs;
+	bool ret;
+
+	igt_assert(vf_num > 0);
+
+	sysfs = igt_sysfs_open(pf);
+	igt_assert_fd(sysfs);
+	/* vf_num is 1-based, but virtfn is 0-based */
+	snprintf(path, sizeof(path), "device/virtfn%u/drm", vf_num - 1);
+	ret = igt_sysfs_has_attr(sysfs, path);
+	close(sysfs);
+
+	return ret;
+}
lib/igt_sriov_device.h +1 -0
index 2baf183fb..ddbda6cd6 100644
@@ -24,5 +24,6 @@ bool igt_sriov_is_driver_autoprobe_enabled(int pf);
 void igt_sriov_enable_driver_autoprobe(int pf);
 void igt_sriov_disable_driver_autoprobe(int pf);
 int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num);
+bool igt_sriov_is_vf_drm_driver_probed(int pf, unsigned int vf_num);
 
 #endif /* __IGT_SRIOV_DEVICE_H__ */
Signature · 1 line
2.40.0
#4 lore raw

PATCH v6 4/8 lib/igt_sriov_device: add helpers for operations in different VFs scenarios

In reply to Lukasz Laguna

Added helpers:
- for_each_vf and for_each_num_vfs
- for_random_vf and for_random_num_vfs
- for_last_vf and for_max_num_vfs

v2:
- document helpers (Michal)
v3:
- add "_sriov_" in helpers name (Kamil)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 lib/igt_sriov_device.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
lib/igt_sriov_device.h +41 -0
index ddbda6cd6..c442c41a7 100644
@@ -26,4 +26,45 @@ void igt_sriov_disable_driver_autoprobe(int pf);
 int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num);
 bool igt_sriov_is_vf_drm_driver_probed(int pf, unsigned int vf_num);
 
+/**
+ * for_each_sriov_vf - Helper for running code on each VF
+ * @__pf_fd: PF device file descriptor
+ * @__vf_num: VFs iterator
+ *
+ * For loop that iterates over all VFs associated with given PF @__pf_fd.
+ */
+#define for_each_sriov_vf(__pf_fd, __vf_num) \
+	for (unsigned int __vf_num = 1, __total_vfs = igt_sriov_get_total_vfs(__pf_fd); \
+	     __vf_num <= __total_vfs; \
+	     ++__vf_num)
+#define for_each_sriov_num_vfs for_each_sriov_vf
+
+/**
+ * for_random_sriov_vf - Helper for running code on random VF
+ * @__pf_fd: PF device file descriptor
+ * @__vf_num: stores random VF
+ *
+ * Helper allows to run code using random VF number (stored in @__vf_num)
+ * picked from the range of all VFs associated with given PF @__pf_fd.
+ */
+#define for_random_sriov_vf(__pf_fd, __vf_num) \
+	for (unsigned int __vf_num = 1 + random() % igt_sriov_get_total_vfs(__pf_fd), __tmp = 0; \
+	     __tmp < 1; \
+	     ++__tmp)
+#define for_random_sriov_num_vfs for_random_sriov_vf
+
+/**
+ * for_last_sriov_vf - Helper for running code on last VF
+ * @__pf_fd: PF device file descriptor
+ * @__vf_num: stores last VF number
+ *
+ * Helper allows to run code using last VF number (stored in @__vf_num)
+ * associated with given PF @__pf_fd.
+ */
+#define for_last_sriov_vf(__pf_fd, __vf_num) \
+	for (unsigned int __vf_num = igt_sriov_get_total_vfs(__pf_fd), __tmp = 0; \
+	     __tmp < 1; \
+	     ++__tmp)
+#define for_max_sriov_num_vfs for_last_sriov_vf
+
 #endif /* __IGT_SRIOV_DEVICE_H__ */
Signature · 1 line
2.40.0
#5 lore raw

PATCH v6 5/8 tests/sriov_basic: add basic tests for enabling SR-IOV VFs

In reply to Lukasz Laguna

From: Katarzyna Dec <[email protected]>

Add subtests that validate SR-IOV VFs enabling in two variants: with autoprobe disabled and enabled.

v2:
- rename function (Michal)
- remove checks that are outside the scope of the test (Michal)
v3:
- change run type of enable-vfs-autoprobe-on subtest (Michal)
- don't init random seed in test code (Michal)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 tests/meson.build   |   1 +
 tests/sriov_basic.c | 123 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 tests/sriov_basic.c
tests/meson.build +1 -0
index facf60ccf..a6673c511 100644
@@ -71,6 +71,7 @@ test_progs = [
 	'panfrost_submit',
 	'prime_udl',
 	'prime_vgem',
+	'sriov_basic',
 	'syncobj_basic',
 	'syncobj_eventfd',
 	'syncobj_wait',
tests/sriov_basic.c new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.40.0
#6 lore raw

Re: [igt-dev] [PATCH i-g-t v6 5/8] tests/sriov_basic: add basic tests for enabling SR-IOV VFs

Quoted 71 lines · Lukasz Laguna

From: Katarzyna Dec <[email protected]>

Add subtests that validate SR-IOV VFs enabling in two variants: with autoprobe disabled and enabled.

v2:
- rename function (Michal)
- remove checks that are outside the scope of the test (Michal)
v3:
- change run type of enable-vfs-autoprobe-on subtest (Michal)
- don't init random seed in test code (Michal)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 tests/meson.build   |   1 +
 tests/sriov_basic.c | 123 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 tests/sriov_basic.c
tests/meson.build +1 -0
index facf60ccf..a6673c511 100644
@@ -71,6 +71,7 @@ test_progs = [
 	'panfrost_submit',
 	'prime_udl',
 	'prime_vgem',
+	'sriov_basic',
 	'syncobj_basic',
 	'syncobj_eventfd',
 	'syncobj_wait',
tests/sriov_basic.c new file +31 -0
new file mode 100644
index 000000000..582e644f2
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2023 Intel Corporation. All rights reserved.
+ */
+
+#include "drmtest.h"
+#include "igt_core.h"
+#include "igt_sriov_device.h"
+
+IGT_TEST_DESCRIPTION("Basic tests for enabling SR-IOV Virtual Functions");
+
+/**
+ * TEST: sriov_basic
+ * Category: Software building block
+ * Mega feature: SR-IOV
+ * Sub-category: VFs enabling
+ * Description: Validate SR-IOV VFs enabling
+ */
+
+/**
+ * SUBTEST: enable-vfs-autoprobe-off
+ * Description:
+ *   Verify VFs enabling without probing VF driver
+ * Run type: BAT
+ */
+static void enable_vfs_autoprobe_off(int pf_fd, unsigned int num_vfs)
+{
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+	igt_sriov_disable_driver_autoprobe(pf_fd);

tests/sriov_basic.c line 41

Quoted 10 lines
tests/sriov_basic.c new file +10 -0
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_assert_eq(num_vfs, igt_sriov_get_enabled_vfs(pf_fd));
+	igt_sriov_disable_vfs(pf_fd);
+}
+
+/**
+ * SUBTEST: enable-vfs-autoprobe-on
+ * Description:
+ *   Verify VFs enabling and auto-probing VF driver
+ * Run type: FULL

can't we just have enable_vfs_bind_unbind_each() from 8/8 ?

this test as-is is still from STRESS category, that I'm not sure we use elsewhere, while enable_vfs_bind_unbind_each() will provide solid functional coverage that we are looking for

Quoted 82 lines
tests/sriov_basic.c new file +82 -0
+ */
+static void enable_vfs_autoprobe_on(int pf_fd, unsigned int num_vfs)
+{
+	bool err = false;
+
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_assert_eq(num_vfs, igt_sriov_get_enabled_vfs(pf_fd));
+	for (int vf_num = 1; vf_num <= num_vfs; ++vf_num) {
+		if (!igt_sriov_is_vf_drm_driver_probed(pf_fd, vf_num)) {
+			igt_debug("VF%u probe failed\n", vf_num);
+			err = true;
+		}
+	}
+	igt_sriov_disable_vfs(pf_fd);
+	igt_assert(!err);
+}
+
+igt_main
+{
+	int pf_fd;
+	bool autoprobe;
+
+	igt_fixture {
+		pf_fd = drm_open_driver(DRIVER_ANY);
+		igt_require(igt_sriov_is_pf(pf_fd));
+		igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+		autoprobe = igt_sriov_is_driver_autoprobe_enabled(pf_fd);
+	}
+
+	igt_describe("Verify VFs enabling without probing VF driver");
+	igt_subtest_with_dynamic("enable-vfs-autoprobe-off") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_autoprobe_off(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_autoprobe_off(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_autoprobe_off(pf_fd, num_vfs);
+			}
+		}
+	}
+
+	igt_describe("Verify VFs enabling and auto-probing VF driver");
+	igt_subtest_with_dynamic("enable-vfs-autoprobe-on") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_autoprobe_on(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_autoprobe_on(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_autoprobe_on(pf_fd, num_vfs);
+			}
+		}
+	}
+
+	igt_fixture {
+		igt_sriov_disable_vfs(pf_fd);
+		/* abort to avoid execution of next tests with enabled VFs */
+		igt_abort_on_f(igt_sriov_get_enabled_vfs(pf_fd) > 0, "Failed to disable VF(s)");
+		autoprobe ? igt_sriov_enable_driver_autoprobe(pf_fd) :
+			    igt_sriov_disable_driver_autoprobe(pf_fd);
+		igt_abort_on_f(autoprobe != igt_sriov_is_driver_autoprobe_enabled(pf_fd),
+			       "Failed to restore sriov_drivers_autoprobe value\n");
+		close(pf_fd);
+	}
+}
#7 lore raw

Re: [igt-dev] [PATCH i-g-t v6 5/8] tests/sriov_basic: add basic tests for enabling SR-IOV VFs

Quoted 85 lines · Michal Wajdeczko
Quoted 71 lines · Lukasz Laguna

From: Katarzyna Dec <[email protected]>

Add subtests that validate SR-IOV VFs enabling in two variants: with autoprobe disabled and enabled.

v2:
- rename function (Michal)
- remove checks that are outside the scope of the test (Michal)
v3:
- change run type of enable-vfs-autoprobe-on subtest (Michal)
- don't init random seed in test code (Michal)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
  tests/meson.build   |   1 +
  tests/sriov_basic.c | 123 ++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 124 insertions(+)

create mode 100644 tests/sriov_basic.c

tests/meson.build +1 -0
index facf60ccf..a6673c511 100644
@@ -71,6 +71,7 @@ test_progs = [
  	'panfrost_submit',
  	'prime_udl',
  	'prime_vgem',
+	'sriov_basic',
  	'syncobj_basic',
  	'syncobj_eventfd',
  	'syncobj_wait',
tests/sriov_basic.c new file +31 -0
new file mode 100644
index 000000000..582e644f2
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2023 Intel Corporation. All rights reserved.
+ */
+
+#include "drmtest.h"
+#include "igt_core.h"
+#include "igt_sriov_device.h"
+
+IGT_TEST_DESCRIPTION("Basic tests for enabling SR-IOV Virtual Functions");
+
+/**
+ * TEST: sriov_basic
+ * Category: Software building block
+ * Mega feature: SR-IOV
+ * Sub-category: VFs enabling
+ * Description: Validate SR-IOV VFs enabling
+ */
+
+/**
+ * SUBTEST: enable-vfs-autoprobe-off
+ * Description:
+ *   Verify VFs enabling without probing VF driver
+ * Run type: BAT
+ */
+static void enable_vfs_autoprobe_off(int pf_fd, unsigned int num_vfs)
+{
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+	igt_sriov_disable_driver_autoprobe(pf_fd);

tests/sriov_basic.c line 41

Quoted 10 lines
tests/sriov_basic.c new file +10 -0
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_assert_eq(num_vfs, igt_sriov_get_enabled_vfs(pf_fd));
+	igt_sriov_disable_vfs(pf_fd);
+}
+
+/**
+ * SUBTEST: enable-vfs-autoprobe-on
+ * Description:
+ *   Verify VFs enabling and auto-probing VF driver
+ * Run type: FULL

can't we just have enable_vfs_bind_unbind_each() from 8/8 ?

Quoted 3 lines

this test as-is is still from STRESS category, that I'm not sure we use elsewhere, while enable_vfs_bind_unbind_each() will provide solid functional coverage that we are looking for

I'll remove enable_vfs_bind_unbind_each() as you sugested in 7/8, but I prefer to leave this one:
- enabling 1 or 2 VFs with autoprobe enabled is not that stress and it's common scenario
- if we remove this test we won't have any coverage where we try to probe VF driver while it's already probed on other VF
- it's good to know how it behaves in more stress cases

Quoted 82 lines
Quoted 82 lines
tests/sriov_basic.c new file +82 -0
+ */
+static void enable_vfs_autoprobe_on(int pf_fd, unsigned int num_vfs)
+{
+	bool err = false;
+
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_assert_eq(num_vfs, igt_sriov_get_enabled_vfs(pf_fd));
+	for (int vf_num = 1; vf_num <= num_vfs; ++vf_num) {
+		if (!igt_sriov_is_vf_drm_driver_probed(pf_fd, vf_num)) {
+			igt_debug("VF%u probe failed\n", vf_num);
+			err = true;
+		}
+	}
+	igt_sriov_disable_vfs(pf_fd);
+	igt_assert(!err);
+}
+
+igt_main
+{
+	int pf_fd;
+	bool autoprobe;
+
+	igt_fixture {
+		pf_fd = drm_open_driver(DRIVER_ANY);
+		igt_require(igt_sriov_is_pf(pf_fd));
+		igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+		autoprobe = igt_sriov_is_driver_autoprobe_enabled(pf_fd);
+	}
+
+	igt_describe("Verify VFs enabling without probing VF driver");
+	igt_subtest_with_dynamic("enable-vfs-autoprobe-off") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_autoprobe_off(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_autoprobe_off(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_autoprobe_off(pf_fd, num_vfs);
+			}
+		}
+	}
+
+	igt_describe("Verify VFs enabling and auto-probing VF driver");
+	igt_subtest_with_dynamic("enable-vfs-autoprobe-on") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_autoprobe_on(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_autoprobe_on(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_autoprobe_on(pf_fd, num_vfs);
+			}
+		}
+	}
+
+	igt_fixture {
+		igt_sriov_disable_vfs(pf_fd);
+		/* abort to avoid execution of next tests with enabled VFs */
+		igt_abort_on_f(igt_sriov_get_enabled_vfs(pf_fd) > 0, "Failed to disable VF(s)");
+		autoprobe ? igt_sriov_enable_driver_autoprobe(pf_fd) :
+			    igt_sriov_disable_driver_autoprobe(pf_fd);
+		igt_abort_on_f(autoprobe != igt_sriov_is_driver_autoprobe_enabled(pf_fd),
+			       "Failed to restore sriov_drivers_autoprobe value\n");
+		close(pf_fd);
+	}
+}
#8 lore raw

PATCH v6 6/8 lib/igt_sriov_device: add helpers for VF DRM driver bind and unbind

In reply to Lukasz Laguna

Helpers allow to bind and unbind a DRM driver for specified VF of a given PF device.

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 lib/igt_sriov_device.c | 52 ++++++++++++++++++++++++++++++++++++++++++
 lib/igt_sriov_device.h |  2 ++
 2 files changed, 54 insertions(+)
lib/igt_sriov_device.c +52 -0
index c643f47d1..354125974 100644
@@ -5,9 +5,11 @@
 
 #include <dirent.h>
 #include <errno.h>
+#include <pciaccess.h>
 
 #include "drmtest.h"
 #include "igt_core.h"
+#include "igt_device.h"
 #include "igt_sriov_device.h"
 #include "igt_sysfs.h"
 
@@ -287,3 +289,53 @@ bool igt_sriov_is_vf_drm_driver_probed(int pf, unsigned int vf_num)
 
 	return ret;
 }
+
+static bool __igt_sriov_bind_vf_drm_driver(int pf, unsigned int vf_num, bool bind)
+{
+	int sysfs, ret;
+	struct pci_device *pci_dev;
+	char pci_slot[14];
+
+	igt_assert(vf_num > 0);
+
+	pci_dev = __igt_device_get_pci_device(pf, vf_num);
+	igt_assert_f(pci_dev, "No PCI device for given VF number: %d\n", vf_num);
+	sprintf(pci_slot, "%04x:%02x:%02x.%x",
+		pci_dev->domain_16, pci_dev->bus, pci_dev->dev, pci_dev->func);
+
+	sysfs = igt_sysfs_open(pf);
+	igt_assert_fd(sysfs);
+
+	igt_debug("vf_num: %u, pci_slot: %s\n", vf_num, pci_slot);
+	ret = igt_sysfs_set(sysfs, bind ? "device/driver/bind" : "device/driver/unbind", pci_slot);
+
+	close(sysfs);
+
+	return ret;
+}
+
+/**
+ * igt_sriov_bind_vf_drm_driver - Bind DRM driver to VF
+ * @pf: PF device file descriptor
+ * @vf_num: VF number (1-based to identify single VF)
+ *
+ * Bind the DRM driver to given VF.
+ * It asserts on failure.
+ */
+void igt_sriov_bind_vf_drm_driver(int pf, unsigned int vf_num)
+{
+	igt_assert(__igt_sriov_bind_vf_drm_driver(pf, vf_num, true));
+}
+
+/**
+ * igt_sriov_unbind_vf_drm_driver - Unbind DRM driver from VF
+ * @pf: PF device file descriptor
+ * @vf_num: VF number (1-based to identify single VF)
+ *
+ * Unbind the DRM driver from given VF.
+ * It asserts on failure.
+ */
+void igt_sriov_unbind_vf_drm_driver(int pf, unsigned int vf_num)
+{
+	igt_assert(__igt_sriov_bind_vf_drm_driver(pf, vf_num, false));
+}
lib/igt_sriov_device.h +2 -0
index c442c41a7..a3a08f8e1 100644
@@ -25,6 +25,8 @@ void igt_sriov_enable_driver_autoprobe(int pf);
 void igt_sriov_disable_driver_autoprobe(int pf);
 int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num);
 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);
 
 /**
  * for_each_sriov_vf - Helper for running code on each VF
Signature · 1 line
2.40.0
#9 lore raw

PATCH v6 7/8 tests/sriov_basic: validate driver binding to VFs

In reply to Lukasz Laguna

From: Katarzyna Dec <[email protected]>

Test enables VFs in range <1..totalvfs>, bind driver to all of them and then unbind driver from all of them.

v2:
- remove checks that are outside the scope of the test (Michal)
- change subtest run type (Michal)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 tests/sriov_basic.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
tests/sriov_basic.c +49 -0
index 582e644f2..c2c8e5b6b 100644
@@ -60,6 +60,36 @@ static void enable_vfs_autoprobe_on(int pf_fd, unsigned int num_vfs)
 	igt_assert(!err);
 }
 
+/**
+ * SUBTEST: enable-vfs-bind-all-unbind-all
+ * Description:
+ *   Verify VFs enabling, binding the driver and then unbinding it from all of them
+ * Run type: FULL
+ */
+static void enable_vfs_bind_all_unbind_all(int pf_fd, unsigned int num_vfs)
+{
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+
+	for (int i = 1; i <= num_vfs; i++) {
+		igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+		igt_sriov_bind_vf_drm_driver(pf_fd, i);
+		igt_assert(igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+	}
+
+	for (int i = 1; i <= num_vfs; i++) {
+		igt_sriov_unbind_vf_drm_driver(pf_fd, i);
+		igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+	}
+
+	igt_sriov_disable_vfs(pf_fd);
+}
+
 igt_main
 {
 	int pf_fd;
@@ -110,6 +140,25 @@ igt_main
 		}
 	}
 
+	igt_describe("Verify VFs enabling, binding the driver and then unbinding it from all of them");
+	igt_subtest_with_dynamic("enable-vfs-bind-all-unbind-all") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_bind_all_unbind_all(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_bind_all_unbind_all(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_bind_all_unbind_all(pf_fd, num_vfs);
+			}
+		}
+	}
+
 	igt_fixture {
 		igt_sriov_disable_vfs(pf_fd);
 		/* abort to avoid execution of next tests with enabled VFs */
Signature · 1 line
2.40.0
#10 lore raw

Re: [igt-dev] [PATCH i-g-t v6 7/8] tests/sriov_basic: validate driver binding to VFs

Quoted 36 lines · Lukasz Laguna

From: Katarzyna Dec <[email protected]>

Test enables VFs in range <1..totalvfs>, bind driver to all of them and then unbind driver from all of them.

v2:
- remove checks that are outside the scope of the test (Michal)
- change subtest run type (Michal)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 tests/sriov_basic.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
tests/sriov_basic.c +11 -0
index 582e644f2..c2c8e5b6b 100644
@@ -60,6 +60,36 @@ static void enable_vfs_autoprobe_on(int pf_fd, unsigned int num_vfs)
 	igt_assert(!err);
 }
 
+/**
+ * SUBTEST: enable-vfs-bind-all-unbind-all
+ * Description:
+ *   Verify VFs enabling, binding the driver and then unbinding it from all of them
+ * Run type: FULL
+ */
+static void enable_vfs_bind_all_unbind_all(int pf_fd, unsigned int num_vfs)
+{
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);

tests/sriov_basic.c static void enable_vfs_autoprobe_on(int pf_fd, unsigned int num_vfs) · line 83

Quoted 10 lines
tests/sriov_basic.c +10 -0
+
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+
+	for (int i = 1; i <= num_vfs; i++) {
+		igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+		igt_sriov_bind_vf_drm_driver(pf_fd, i);
+		igt_assert(igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+	}

what's the point in keeping all VFs drivers loaded ? do we really want to stress the system ?
our goal should be to check that VF driver loads on each VF

IMO the enable_vfs_bind_unbind_each() from 8/8 provides sufficient coverage, while this one will just consume machine-test-hours

also this test duplicates enable_vfs_autoprobe_on() from 5/8 (just loads the all drivers manually instead of PCI-subsystem autoprobe)

Quoted 38 lines
tests/sriov_basic.c +28 -0
+
+	for (int i = 1; i <= num_vfs; i++) {
+		igt_sriov_unbind_vf_drm_driver(pf_fd, i);
+		igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+	}
+
+	igt_sriov_disable_vfs(pf_fd);
+}
+
 igt_main
 {
 	int pf_fd;
@@ -110,6 +140,25 @@ igt_main
 		}
 	}
 
+	igt_describe("Verify VFs enabling, binding the driver and then unbinding it from all of them");
+	igt_subtest_with_dynamic("enable-vfs-bind-all-unbind-all") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_bind_all_unbind_all(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_bind_all_unbind_all(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_bind_all_unbind_all(pf_fd, num_vfs);
+			}
+		}
+	}
+
 	igt_fixture {
 		igt_sriov_disable_vfs(pf_fd);
 		/* abort to avoid execution of next tests with enabled VFs */
#11 lore raw

PATCH v6 8/8 tests/sriov_basic: add more tests for VF driver binding

In reply to Lukasz Laguna

- bind-unbind-vf: validate driver binding and unbinding to specified VF
- enable-vfs-bind-unbind-each: validate driver binding and unbinding to VFs from specified range.

v2:
- remove checks that are outside the scope of the test (Michal)

Cc Marcin Bernatowicz <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 tests/sriov_basic.c | 90 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
tests/sriov_basic.c +90 -0
index c2c8e5b6b..f945f3948 100644
@@ -90,6 +90,58 @@ static void enable_vfs_bind_all_unbind_all(int pf_fd, unsigned int num_vfs)
 	igt_sriov_disable_vfs(pf_fd);
 }
 
+/**
+ * SUBTEST: enable-vfs-bind-unbind-each
+ * Description:
+ *   Verify VFs enabling with binding and unbinding the driver one be one to each of them
+ * Run type: BAT
+ */
+static void enable_vfs_bind_unbind_each(int pf_fd, unsigned int num_vfs)
+{
+	igt_debug("Testing %u VFs\n", num_vfs);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+
+	for (int i = 1; i <= num_vfs; i++) {
+		igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+		igt_sriov_bind_vf_drm_driver(pf_fd, i);
+		igt_assert(igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+		igt_sriov_unbind_vf_drm_driver(pf_fd, i);
+		igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, i));
+	}
+
+	igt_sriov_disable_vfs(pf_fd);
+}
+
+/**
+ * SUBTEST: bind-unbind-vf
+ * Description:
+ *   Verify binding and unbinding the driver to specific VF
+ * Run type: BAT
+ */
+static void bind_unbind_vf(int pf_fd, unsigned int vf_num)
+{
+	igt_debug("Testing VF%u\n", vf_num);
+
+	igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0);
+
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, vf_num);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+
+	igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, vf_num));
+	igt_sriov_bind_vf_drm_driver(pf_fd, vf_num);
+	igt_assert(igt_sriov_is_vf_drm_driver_probed(pf_fd, vf_num));
+	igt_sriov_unbind_vf_drm_driver(pf_fd, vf_num);
+	igt_assert(!igt_sriov_is_vf_drm_driver_probed(pf_fd, vf_num));
+
+	igt_sriov_disable_vfs(pf_fd);
+}
+
 igt_main
 {
 	int pf_fd;
@@ -159,6 +211,44 @@ igt_main
 		}
 	}
 
+	igt_describe("Verify VFs enabling with binding and unbinding the driver one be one to each of them");
+	igt_subtest_with_dynamic("enable-vfs-bind-unbind-each") {
+		for_each_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-%u", num_vfs) {
+				enable_vfs_bind_unbind_each(pf_fd, num_vfs);
+			}
+		}
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				enable_vfs_bind_unbind_each(pf_fd, num_vfs);
+			}
+		}
+		for_max_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-all") {
+				enable_vfs_bind_unbind_each(pf_fd, num_vfs);
+			}
+		}
+	}
+
+	igt_describe("Test binds and unbinds the driver to specific VF");
+	igt_subtest_with_dynamic("bind-unbind-vf") {
+		for_each_sriov_vf(pf_fd, vf) {
+			igt_dynamic_f("vf-%u", vf) {
+				bind_unbind_vf(pf_fd, vf);
+			}
+		}
+		for_random_sriov_vf(pf_fd, vf) {
+			igt_dynamic_f("vf-random") {
+				bind_unbind_vf(pf_fd, vf);
+			}
+		}
+		for_last_sriov_vf(pf_fd, vf) {
+			igt_dynamic_f("vf-last") {
+				bind_unbind_vf(pf_fd, vf);
+			}
+		}
+	}
+
 	igt_fixture {
 		igt_sriov_disable_vfs(pf_fd);
 		/* abort to avoid execution of next tests with enabled VFs */
Signature · 1 line
2.40.0
#12 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for Initial SR-IOV validation (rev7)

In reply to Lukasz Laguna
== Series Details ==

== Series Details ==

Series: Initial SR-IOV validation (rev7)
URL : https://patchwork.freedesktop.org/series/126034/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13972 -> IGTPW_10332
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_10332 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in IGTPW_10332, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/index.html

Participating hosts (35 -> 32)
------------------------------

Additional (2): bat-dg2-8 bat-mtlp-8
Missing (5): bat-kbl-2 bat-adlp-11 bat-dg2-9 fi-snb-2520m bat-jsl-1

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_10332:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@execlists:
- fi-bsw-nick: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13972/fi-bsw-nick/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/fi-bsw-nick/igt@i915_selftest@[email protected]

Known issues
------------

Here are the changes found in IGTPW_10332 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- bat-mtlp-8: NOTRUN -> [SKIP][3] ([i915#9318])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]

* igt@gem_exec_suspend@basic-s0@smem:
- bat-jsl-3: [PASS][4] -> [INCOMPLETE][5] ([i915#9275])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13972/bat-jsl-3/igt@gem_exec_suspend@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-jsl-3/igt@gem_exec_suspend@[email protected]

* igt@gem_lmem_swapping@verify-random:
- bat-mtlp-8: NOTRUN -> [SKIP][6] ([i915#4613]) +3 other tests skip
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]

* igt@gem_mmap@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][7] ([i915#4083])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][8] ([i915#4083])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@gem_mmap_gtt@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][9] ([i915#4077]) +2 other tests skip
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][10] ([i915#4077]) +2 other tests skip
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@gem_render_tiled_blits@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][11] ([i915#4079]) +1 other test skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]

* igt@gem_tiled_pread_basic:
- bat-dg2-8: NOTRUN -> [SKIP][12] ([i915#4079]) +1 other test skip
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@gem_tiled_pread_basic.html

* igt@i915_pm_rps@basic-api:
- bat-mtlp-8: NOTRUN -> [SKIP][13] ([i915#6621])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][14] ([i915#6621])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- bat-jsl-3: [PASS][15] -> [FAIL][16] ([fdo#103375])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13972/bat-jsl-3/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-jsl-3/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][17] ([i915#6645])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][18] ([i915#6645])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][19] ([i915#5190])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][20] ([i915#5190])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][21] ([i915#4212]) +8 other tests skip
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][22] ([i915#4215] / [i915#5190])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_addfb_basic@framebuffer-vs-set-tiling:
- bat-dg2-8: NOTRUN -> [SKIP][23] ([i915#4212]) +6 other tests skip
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_addfb_basic@tile-pitch-mismatch:
- bat-dg2-8: NOTRUN -> [SKIP][24] ([i915#4212] / [i915#5608])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][25] ([i915#4213]) +1 other test skip
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][26] ([i915#4103] / [i915#4213] / [i915#5608]) +1 other test skip
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- bat-mtlp-8: NOTRUN -> [SKIP][27] ([i915#3555] / [i915#3840] / [i915#9159])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-mtlp-8: NOTRUN -> [SKIP][28] ([fdo#109285])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][29] ([fdo#109285])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-mtlp-8: NOTRUN -> [SKIP][30] ([i915#5274])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][31] ([i915#5274])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@kms_setmode@basic-clone-single-crtc:
- bat-mtlp-8: NOTRUN -> [SKIP][32] ([i915#3555] / [i915#8809])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]
- bat-dg2-8: NOTRUN -> [SKIP][33] ([i915#3555])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- bat-dg2-8: NOTRUN -> [SKIP][34] ([i915#3708])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

* igt@prime_vgem@basic-fence-mmap:
- bat-dg2-8: NOTRUN -> [SKIP][35] ([i915#3708] / [i915#4077]) +1 other test skip
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]
- bat-mtlp-8: NOTRUN -> [SKIP][36] ([i915#3708] / [i915#4077]) +1 other test skip
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]

* igt@prime_vgem@basic-fence-read:
- bat-mtlp-8: NOTRUN -> [SKIP][37] ([i915#3708]) +2 other tests skip
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-mtlp-8/igt@[email protected]

* igt@prime_vgem@basic-write:
- bat-dg2-8: NOTRUN -> [SKIP][38] ([i915#3291] / [i915#3708]) +2 other tests skip
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-dg2-8/igt@[email protected]

#### Possible fixes ####

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [ABORT][39] ([i915#8668]) -> [PASS][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13972/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5608]: https://gitlab.freedesktop.org/drm/intel/issues/5608
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#8809]: https://gitlab.freedesktop.org/drm/intel/issues/8809
[i915#9159]: https://gitlab.freedesktop.org/drm/intel/issues/9159
[i915#9275]: https://gitlab.freedesktop.org/drm/intel/issues/9275
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
[i915#9673]: https://gitlab.freedesktop.org/drm/intel/issues/9673
[i915#9736]: https://gitlab.freedesktop.org/drm/intel/issues/9736

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_7617 -> IGTPW_10332

CI-20190529: 20190529
CI_DRM_13972: f76a66aa209bc55aab7be48e804217e0540ea673 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_10332: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/index.html
IGT_7617: 15eebc01e498c61f96928fa7fa3a0d53bdead193 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

Testlist changes
----------------

+igt@sriov_basic@bind-unbind-vf
+igt@sriov_basic@enable-vfs-autoprobe-off
+igt@sriov_basic@enable-vfs-autoprobe-on
+igt@sriov_basic@enable-vfs-bind-all-unbind-all
+igt@sriov_basic@enable-vfs-bind-unbind-each

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/index.html

#13 lore raw

[igt-dev] ✓ CI.xeBAT: success for Initial SR-IOV validation (rev7)

In reply to Lukasz Laguna
== Series Details ==

== Series Details ==

Series: Initial SR-IOV validation (rev7)
URL : https://patchwork.freedesktop.org/series/126034/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7617_BAT -> XEIGTPW_10332_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (4 -> 4)
------------------------------

No changes in participating hosts

Known issues
------------

Here are the changes found in XEIGTPW_10332_BAT that come from known issues:

### IGT changes ###

#### Possible fixes ####

* igt@kms_flip@basic-flip-vs-wf_vblank:
- bat-adlp-7: [FAIL][1] ([Intel XE#480]) -> [PASS][2] +1 other test pass
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7617/bat-adlp-7/igt@kms_flip@basic-flip-vs-wf_vblank.html
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10332/bat-adlp-7/igt@kms_flip@basic-flip-vs-wf_vblank.html

* igt@kms_flip@basic-flip-vs-wf_vblank@d-dp3:
- bat-dg2-oem2: [FAIL][3] ([Intel XE#480]) -> [PASS][4] +1 other test pass
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7617/bat-dg2-oem2/igt@kms_flip@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10332/bat-dg2-oem2/igt@kms_flip@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480
[Intel XE#524]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/524

Build changes
-------------

* IGT: IGT_7617 -> IGTPW_10332

IGTPW_10332: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10332/index.html
IGT_7617: 15eebc01e498c61f96928fa7fa3a0d53bdead193 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-547-3cf2df8b17f8be54008581a37361e6ec36dc3d87: 3cf2df8b17f8be54008581a37361e6ec36dc3d87

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10332/index.html