Add vkms configfs testing
Subsystems (2)
cover Add vkms configfs testing
With this series we add some basic tests for sanity checking the ConfigFS functionality into the vkms driver. This would allow to create and to customize dynamically the entire DRM pipeline.
This small series adds a new library (igt_vkms) for creating the entire pipeline, as well as enabling the device and set the connectors as connected or disconnected. Further more it adds some helpers (igt_configfs) to create the proper ConfigFS mount point.
The sub-tests in this series added are:
- a basic device test, that creates an entire pipeline with a primary plane
- an empty test, that doesn't create a primary plane and which should fail
- a test that creates multiple overlay and cursor planes
- a test that creates multiple pipelines
- a test similar to basic device test but that also disables the vkms device at the end
These kernel changes were written initially by Jim Shargo, and then were picked up by Brandon Pollack. As of today the latest version is at
https://patchwork.kernel.org/project/dri-devel/list/?series=780110
The i-g-t changes were also developed by Jim Shargo, and I've massaged them a bit doing some minor changes since their inception. These changes are:
- replaced all string strcat/strcpy with snprintfs
- renamed all _permit_ functions to _attach_
- added documentation for all public functions
- vkms_crtc_no_primary_test was fixed such that should it now fails as expected
- split the changes one more time, and group one of the patches with the introduction of igt_configfs
- fixed skipping the (sub)tests if vkms wasn't found loaded
I've kept the original author as Jim was the original person working on them.
For history purposes I've picked these up from
https://gitlab.freedesktop.org/jshargo/igt-gpu-tools/-/merge_requests/1.
Jim Shargo (4):
lib/drmtest: Add VKMS as a known driver type lib/confifs: Add helpers for mounting/unmounting configfs tests/vkms: Add a small library for VKMS testing tests/vkms: Add more tests for VKMS
lib/drmtest.c | 26 ++ lib/drmtest.h | 9 +- lib/igt.h | 3 +- lib/igt_aux.c | 25 ++ lib/igt_aux.h | 2 + lib/igt_configfs.c | 106 ++++++++ lib/igt_configfs.h | 36 +++ lib/igt_debugfs.c | 29 +-- lib/igt_vkms.c | 514 +++++++++++++++++++++++++++++++++++++ lib/igt_vkms.h | 66 +++++ lib/meson.build | 2 + tests/meson.build | 13 + tests/vkms/vkms_configfs.c | 194 ++++++++++++++ 13 files changed, 995 insertions(+), 30 deletions(-) create mode 100644 lib/igt_configfs.c create mode 100644 lib/igt_configfs.h create mode 100644 lib/igt_vkms.c create mode 100644 lib/igt_vkms.h create mode 100644 tests/vkms/vkms_configfs.c
Signature · 1 line
2.40.1
PATCH 1/5 lib/drmtest: Add VKMS as a known driver type
From: Jim Shargo <[email protected]>
--- lib/drmtest.c | 26 ++++++++++++++++++++++++++ lib/drmtest.h | 9 +++++++-- 2 files changed, 33 insertions(+), 2 deletions(-)
lib/drmtest.c +26 -0
@@ -161,6 +161,16 @@ enum intel_driver get_intel_driver(int fd)igt_assert_f (0 ,"Device is not handled by Intel driver\n" ); } +bool is_vkms_device (int fd) +{ +char name[64 ] ="" ; + +if (__get_drm_device_name (fd, name,sizeof (name) -1 )) +return false; + +return strncmp ("vkms" , name,strlen ("vkms" )) ==0 ; +} +static char _forced_driver[16 ] ="" ;/**
@@ -806,3 +816,19 @@ void igt_require_xe(int fd) {igt_require (is_xe_device (fd)); } + +void igt_require_vkms (void ) +{ +/* Since VKMS can create and destroy virtual drivers at will, instead +* look to make sure the driver is installed. */ +struct stat s = {}; +int ret; +const char *vkms_module_dir ="/sys/module/vkms" ; + + ret =stat (vkms_module_dir, &s); + +igt_require_f (ret ==0 ,"VKMS stat of %s returned %d (%s)\n" , + vkms_module_dir, ret,strerror (ret)); +igt_require_f (S_ISDIR (s.st_mode), +"VKMS stat of %s was not a directory\n" , vkms_module_dir); +}
lib/drmtest.h +7 -2
@@ -52,15 +52,18 @@#define DRIVER_PANFROST (1 << 5)#define DRIVER_MSM (1 << 6)#define DRIVER_XE (1 << 7) -#define DRIVER_VMWGFX (1 << 8) +#define DRIVER_VMWGFX (1 << 8) +#define DRIVER_VKMS (1 << 9)/* * Exclude DRVER_VGEM from DRIVER_ANY since if you run on a system * with vgem as well as a supported driver, you can end up with a * near-100% skip rate if you don't explicitly specify the device, * depending on device-load ordering. +* +* Exclude VKMS to prefer hardware drivers. */ -#define DRIVER_ANY ~(DRIVER_VGEM) +#define DRIVER_ANY ~(DRIVER_VGEM | DRIVER_VKMS)/* * Compile friendly enum for i915/xe.
@@ -115,6 +118,7 @@ void igt_require_i915(int fd);void igt_require_nouveau (int fd);void igt_require_vc4 (int fd);void igt_require_xe (int fd); +void igt_require_vkms (void );bool is_amdgpu_device (int fd);bool is_i915_device (int fd);
@@ -125,6 +129,7 @@ bool is_vc4_device(int fd);bool is_xe_device (int fd);bool is_intel_device (int fd);enum intel_driver get_intel_driver (int fd); +bool is_vkms_device (int fd);/** * do_or_die:
Signature · 1 line
2.40.1
PATCH 2/5 lib/confifs: Add helpers for mounting/unmounting configfs
In reply to Marius VladFrom: Jim Shargo <[email protected]>
This change supports the subsequent testing of ConfigFS-based VKMS features, which require their own mounting.
With this change, we also make is_mountpoint public renamaning to igt_is_mountpoint and we make use of it.
--- lib/igt.h | 2 +- lib/igt_aux.c | 25 +++++++++++ lib/igt_aux.h | 2 + lib/igt_configfs.c | 105 +++++++++++++++++++++++++++++++++++++++++++++ lib/igt_configfs.h | 36 ++++++++++++++++ lib/igt_debugfs.c | 29 +------------ lib/meson.build | 1 + 7 files changed, 172 insertions(+), 28 deletions(-) create mode 100644 lib/igt_configfs.c create mode 100644 lib/igt_configfs.h
lib/igt.h +1 -1
@@ -28,7 +28,7 @@#include "i915_3d.h" #include "igt_aux.h" #include "igt_core.h" -#include "igt_core.h" +#include "igt_configfs.h" #include "igt_debugfs.h" #include "igt_draw.h" #include "igt_dummyload.h"
lib/igt_aux.c +25 -0
@@ -2035,6 +2035,31 @@ bool igt_allow_unlimited_files(void)return setrlimit (RLIMIT_NOFILE , &rlim) ==0 ; } +bool igt_is_mountpoint (const char *path) +{ +char buf[strlen (path) +4 ]; +struct stat st; +dev_t dev; + +igt_assert_lt (snprintf (buf,sizeof (buf),"%s/." , path),sizeof (buf)); +if (stat (buf, &st)) +return false; + +if (!S_ISDIR (st.st_mode)) +return false; + + dev = st.st_dev; + +igt_assert_lt (snprintf (buf,sizeof (buf),"%s/.." , path),sizeof (buf)); +if (stat (buf, &st)) +return false; + +if (!S_ISDIR (st.st_mode)) +return false; + +return dev != st.st_dev; +} +/** * vfs_file_max: report maximum number of files *
lib/igt_aux.h +2 -0
@@ -311,6 +311,8 @@ double igt_stop_siglatency(struct igt_mean *result);bool igt_allow_unlimited_files (void ); +bool igt_is_mountpoint (const char *path); +int igt_is_process_running (const char *comm);int igt_terminate_process (int sig,const char *comm);void igt_lsof (const char *dpath);
lib/igt_configfs.c new file +105 -0
105 lines not on this page · raw message
lib/igt_configfs.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright 2023 Google LLC. +* Copyright 2023 Collabora, Ltd. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#ifndef __IGT_CONFIGFS_H__ +#define __IGT_CONFIGFS_H__ + +#define CONFIGFS_VKMS_DIR_SIZE 64 + +const char *igt_configfs_mount (void ); +const char *igt_configfs_vkms_mount (void ); + +int igt_configfs_dir (void ); + +#endif /* __IGT_CONFIGFS_H__ */
lib/igt_debugfs.c +2 -27
@@ -67,37 +67,12 @@* General debugfs helpers */ -static bool is_mountpoint (const char *path) -{ -char buf[strlen (path) +4 ]; -struct stat st; -dev_t dev; - -igt_assert_lt (snprintf (buf,sizeof (buf),"%s/." , path),sizeof (buf)); -if (stat (buf, &st)) -return false; - -if (!S_ISDIR (st.st_mode)) -return false; - - dev = st.st_dev; - -igt_assert_lt (snprintf (buf,sizeof (buf),"%s/.." , path),sizeof (buf)); -if (stat (buf, &st)) -return false; - -if (!S_ISDIR (st.st_mode)) -return false; - -return dev != st.st_dev; -} -static const char *__igt_debugfs_mount (void ) { -if (is_mountpoint ("/sys/kernel/debug" )) +if (igt_is_mountpoint ("/sys/kernel/debug" ))return "/sys/kernel/debug" ; -if (is_mountpoint ("/debug" )) +if (igt_is_mountpoint ("/debug" ))return "/debug" ;if (mount ("debug" ,"/sys/kernel/debug" ,"debugfs" ,0 ,0 ))
lib/meson.build +1 -0
@@ -19,6 +19,7 @@ lib_sources = [ 'igt_collection.c', 'igt_color_encoding.c', 'igt_crc.c', + 'igt_configfs.c', 'igt_debugfs.c', 'igt_device.c', 'igt_device_scan.c',
Signature · 1 line
2.40.1
PATCH 3/5 tests/vkms: Add a small library for VKMS testing
In reply to Marius VladFrom: Jim Shargo <[email protected]>
And with it, this adds a basic test that makes use of it, creating a device and with it a pipeline.
One should create a vkms device, add pipeline elements, like encoders, crtc, and connectors, compose the pipeline by attaching each element using the _attach_ functions, set the connector as connected and finally, enable the vkms device.
This works in-tandem with the vkms driver which requires to enable the device and set the connector as connected.
--- lib/igt.h | 1 + lib/igt_vkms.c | 532 +++++++++++++++++++++++++++++++++++++ lib/igt_vkms.h | 66 +++++ lib/meson.build | 1 + tests/meson.build | 13 + tests/vkms/vkms_configfs.c | 83 ++++++ 6 files changed, 696 insertions(+) create mode 100644 lib/igt_vkms.c create mode 100644 lib/igt_vkms.h create mode 100644 tests/vkms/vkms_configfs.c
lib/igt.h +1 -0
@@ -41,6 +41,7 @@#include "igt_pm.h" #include "igt_stats.h" #include "igt_dsc.h" +#include "igt_vkms.h" #ifdef HAVE_CHAMELIUM #include "igt_alsa.h" #include "igt_audio.h"
lib/igt_vkms.c new file +532 -0
532 lines not on this page · raw message
lib/igt_vkms.h new file +66 -0
66 lines not on this page · raw message
lib/meson.build +1 -0
@@ -20,6 +20,7 @@ lib_sources = [ 'igt_color_encoding.c', 'igt_crc.c', 'igt_configfs.c', + 'igt_vkms.c', 'igt_debugfs.c', 'igt_device.c', 'igt_device_scan.c',
tests/meson.build +13 -0
@@ -316,6 +316,10 @@ chamelium_progs = [ 'kms_chamelium_hpd', ] +vkms_progs = [ + 'vkms_configfs', +] + test_deps = [ igt_deps ] if libdrm_nouveau.found()
@@ -459,6 +463,15 @@ if chamelium.found() output : name + '.testlist') endif +foreach prog : vkms_progs + test_executables += executable(prog, join_paths('vkms', prog + '.c'), + dependencies : test_deps, + install_dir : libexecdir, + install_rpath : libexecdir_rpathdir, + install : true) + test_list += prog +endforeach + subdir('amdgpu') subdir('v3d')
tests/vkms/vkms_configfs.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH 4/5 tests/vkms: Add more tests for VKMS
In reply to Marius VladFrom: Jim Shargo <[email protected]>
This adds four more tests, one that should fail when no primary plane is created and added to the pipeline, one that creates a device with multiple overlay and cursor planes, another one that create two outputs, and tests that disable works.
--- lib/igt_vkms.c | 27 ++++++++ lib/igt_vkms.h | 1 + tests/vkms/vkms_configfs.c | 132 +++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+)
lib/igt_vkms.c +27 -0
@@ -440,6 +440,33 @@ void igt_vkms_enable(igt_vkms_t *device)igt_assert_eq (ret,0 ); } +/** +* igt_vkms_disable: +* @device: the vkms device in question +* +* This would disable the vkms device. +* +*/ +void igt_vkms_disable (igt_vkms_t *device) +{ +char enabled_file[VKMS_CARD_OBJECT_DIR_SIZE ]; +int fd, ret; + +memset (enabled_file,0x0 ,sizeof (enabled_file)); +snprintf (enabled_file,sizeof (enabled_file), +"%s/enabled" , device->device_dir); + + fd =open (enabled_file,O_WRONLY ); +igt_assert_f (fd >0 ,"Unable to open '%s'\n" , enabled_file); + + ret =write (fd,"0" ,1 ); +igt_assert_f (ret >=0 ,"Unable to write '%s'. Got errno=%d (%s)\n" , + enabled_file, errno,strerror (errno)); + + ret =close (fd); +igt_assert_eq (ret,0 ); +} +/** * igt_vkms_connector_connect: * @device: the vkms device in question
lib/igt_vkms.h +1 -0
@@ -59,6 +59,7 @@ void igt_vkms_device_attach_encoder_to_connector(igt_vkms_t *device, const char *encoder_name);void igt_vkms_enable (igt_vkms_t *device); +void igt_vkms_disable (igt_vkms_t *device);void igt_vkms_connector_connect (igt_vkms_t *device,const char *connector_name);void igt_vkms_connector_disconnect (igt_vkms_t *device,const char *connector_name);bool igt_vkms_is_enabled (igt_vkms_t *device);
tests/vkms/vkms_configfs.c +132 -0
144 lines not on this page · raw message
Signature · 1 line
2.40.1