Convert sh scripts to C variants.
v3 cover Convert sh scripts to C variants.
This series adds some library support to help converting sh scripts to C version. Based on that I've converted drv_module_reload_basic and kms_sysfs_edid_timing. Other tests should follow. drv_module_reload requires the most boilerplate code.
The reason for so many changes is the fact that some code got moved so other users can use it. Secondly wrappers around libkmod and procps in igt_aux. Thirdly drv_module_reload has embedded tools/gem_info and tests/gem_exec_store in it, with minor modifications to allow running them as subtests. Finally, C is more verbose than sh.
Changes since v2:lib/igt_aux: Addressed comments from Chris Wilson tests/drv_module_reload: Passed incorrectly boolean instead of uint as flags to igt_kmod_unload().
Changes since v1:lib/igt_aux: Addressed comments from Chris Wilson tests/drv_module_reload: Addressed comments from Chris Wilson and Petri Latvala tests/kms_sysfs_edid_timing: Addressed comments from Chris Wilson (Hopefully): Addressed comments from Jani Nikula.
Marius Vlad (3):
lib/{igt_sysfs,igt_aux}: Make available to other users kick_fbcon()
(unbind_fbcon()), and added helpers to igt_aux
(module loading/unloading, pkill)
tests/drv_module_reload: Convert sh script to C version. tests/kms_sysfs_edid_timing: Convert sh to C version.
configure.ac | 2 + lib/Makefile.am | 2 + lib/igt_aux.c | 185 ++++++++++++++++ lib/igt_aux.h | 6 + lib/igt_gvt.c | 43 +--- lib/igt_sysfs.c | 54 +++++ lib/igt_sysfs.h | 2 + tests/Makefile.am | 1 - tests/Makefile.sources | 4 +- tests/drv_module_reload.c | 394 ++++++++++++++++++++++++++++++++++ tests/drv_module_reload_basic | 105 --------- tests/gem_alive.c | 35 --- tests/intel-ci/fast-feedback.testlist | 13 +- tests/kms_sysfs_edid_timing | 25 --- tests/kms_sysfs_edid_timing.c | 107 +++++++++ tools/Makefile.sources | 1 + tools/intel_gem_info.c | 35 +++ 17 files changed, 804 insertions(+), 210 deletions(-) create mode 100644 tests/drv_module_reload.c delete mode 100755 tests/drv_module_reload_basic delete mode 100644 tests/gem_alive.c delete mode 100755 tests/kms_sysfs_edid_timing create mode 100644 tests/kms_sysfs_edid_timing.c create mode 100644 tools/intel_gem_info.c
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 1/3 lib/{igt_sysfs, igt_aux}: Make available to other users kick_fbcon() (unbind_fbcon()), and added helpers to igt_aux.
Previously under unbind_fbcon(), to disable/enable framebuffer console.
lib/igt_aux: Added helpers to help convert sh scripts to C version. libkmod and procps interface.
v3:
- return -errno (igt_pkill()) in case of failure (Cris Wilson)
- return bool for igt_kmod_is_loaded(), replaced strncasecmp with strncmp (Chris Wilson)
- use igt_debug() instead of igt_info() for igt_kmod_load()/ igt_kmod_unload() and return -err directly from libkmod (Chris Wilson)
v2:
- Renamed libkmod helpers (Chris Wilson)
- Removed SIGTERM/SIGKILL case where we repeatedly tried to terminate the
process: just call kill(2) once (Chris Wilson)
- Removed redundant check in igt_kmod_unload(), igt_module_in_use() (Chris Wilson)
- Pass flags to igt_kmod_unload() from the caller (Chris Wilson)
- Removed useless function igt_kill() which acts just as kill(2) (Chris Wilson)
--- configure.ac | 2 + lib/Makefile.am | 2 + lib/igt_aux.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_aux.h | 6 ++ lib/igt_gvt.c | 43 +------------- lib/igt_sysfs.c | 54 +++++++++++++++++ lib/igt_sysfs.h | 2 + 7 files changed, 245 insertions(+), 41 deletions(-)
configure.ac +2 -0
@@ -121,6 +121,8 @@ AC_SUBST(ASSEMBLER_WARN_CFLAGS) PKG_CHECK_MODULES(DRM, [libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) +PKG_CHECK_MODULES(KMOD, [libkmod]) +PKG_CHECK_MODULES(PROCPS, [libprocps]) case "$target_cpu" in x86*|i?86)
lib/Makefile.am +2 -0
@@ -34,6 +34,8 @@ AM_CFLAGS += $(CAIRO_CFLAGS) libintel_tools_la_LIBADD = \ $(DRM_LIBS) \ $(PCIACCESS_LIBS) \ + $(PROCPS_LIBS) \ + $(KMOD_LIBS) \ $(CAIRO_LIBS) \ $(LIBUDEV_LIBS) \ $(LIBUNWIND_LIBS) \
lib/igt_aux.c +177 -0
189 lines not on this page · raw message
lib/igt_aux.h +6 -0
@@ -264,4 +264,10 @@ double igt_stop_siglatency(struct igt_mean *result);void igt_set_module_param (const char *name,const char *val);void igt_set_module_param_int (const char *name,int val); +int igt_pkill (int sig,const char *comm); + +bool igt_kmod_is_loaded (const char *mod_name); +int igt_kmod_load (const char *mod_name,const char *opts); +int igt_kmod_unload (const char *mod_name,unsigned int flags); +#endif /* IGT_AUX_H */
lib/igt_gvt.c +2 -41
57 lines not on this page · raw message
lib/igt_sysfs.c +54 -0
64 lines not on this page · raw message
lib/igt_sysfs.h +2 -0
@@ -43,4 +43,6 @@ bool igt_sysfs_set_u32(int dir, const char *attr, uint32_t value);bool igt_sysfs_get_boolean (int dir,const char *attr);bool igt_sysfs_set_boolean (int dir,const char *attr,bool value); +void kick_fbcon (bool enable); +#endif /* __IGT_SYSFS_H__ */
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 1/3 v3] lib/{igt_sysfs, igt_aux}: Make available to other users kick_fbcon() (unbind_fbcon()), and added helpers to igt_aux.
Quoted 13 lines · Marius Vlad
lib/igt_gvt.c +1
-0@@ -23,6 +23,7 @@#include "igt.h" #include "igt_gvt.h" +#include "igt_sysfs.h" #include <dirent.h> #include <unistd.h>
lib/igt_gvt.c static bool is_gvt_enabled(void) · line 53
Quoted 8 lines
lib/igt_gvt.c +1
-1@@ -46,49 +47,9 @@ static bool is_gvt_enabled(void)return enabled; }static void unload_i915 (void ) { -unbind_fbcon (); +kick_fbcon (false);/* pkill alsact */
Complete the conversion here to the new kmod helpers. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 2/3 tests/drv_module_reload: Convert sh script to C version.
In reply to Marius Vladv3:
- fix passing boolean value as flags to igt_kmod_unload().
v2:
- embedded gem_alive and gem_exec_store into test (Chris Wilson)
- int main() to igt_main (Chris Wilson)
- moved tests/gem_alive -> tools/gem_info (Chris Wilson)
- added to intel-ci/fast-feedback.testlist (Petri Latvala)
- added hda_dynamic_debug() (Petri Latvala)
- renamed from tests/drv_module_reload_basic to tests/drv_module_reload (all subtests are basic and have been added to fast-feedback.testlist)
Fix igt kmod unload
--- tests/Makefile.am | 1 - tests/Makefile.sources | 2 +- tests/drv_module_reload.c | 394 ++++++++++++++++++++++++++++++++++ tests/drv_module_reload_basic | 105 --------- tests/gem_alive.c | 35 --- tests/intel-ci/fast-feedback.testlist | 13 +- tools/Makefile.sources | 1 + tools/intel_gem_info.c | 35 +++ 8 files changed, 443 insertions(+), 143 deletions(-) create mode 100644 tests/drv_module_reload.c delete mode 100755 tests/drv_module_reload_basic delete mode 100644 tests/gem_alive.c create mode 100644 tools/intel_gem_info.c
tests/Makefile.am +0 -1
@@ -26,7 +26,6 @@ noinst_PROGRAMS = \ $(NULL) pkglibexec_PROGRAMS = \ - gem_alive \ gem_stress \ $(TESTS_progs) \ $(TESTS_progs_M) \
tests/Makefile.sources +1 -1
@@ -211,6 +211,7 @@ TESTS_progs = \ kms_pwrite_crc \ kms_sink_crc_basic \ prime_udl \ + drv_module_reload \ $(NULL) # IMPORTANT: The ZZ_ tests need to be run last!
@@ -221,7 +222,6 @@ TESTS_scripts_M = \ TESTS_scripts = \ debugfs_emon_crash \ drv_debugfs_reader \ - drv_module_reload_basic \ kms_sysfs_edid_timing \ sysfs_l3_parity \ test_rte_check \
tests/drv_module_reload.c new file +394 -0
394 lines not on this page · raw message
tests/drv_module_reload_basic deleted +0 -105
105 lines not on this page · raw message
tests/gem_alive.c deleted +0 -35
@@ -1,35 +0,0 @@ -#include "igt.h" -#include <sys/ioctl.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include <signal.h> -#include <i915_drm.h> - - -int main (void ) -{ -struct drm_i915_gem_sw_finish arg = {0 }; -int fd; - -signal (SIGALRM ,SIG_IGN ); - - fd =__drm_open_driver (DRIVER_INTEL ); -if (fd <0 ) -return IGT_EXIT_SKIP ; - -alarm (1 ); -if (ioctl (fd,DRM_IOCTL_I915_GEM_SW_FINISH , &arg) ==0 ) -return IGT_EXIT_SKIP ; - -switch (errno) { -case ENOENT : -return 0 ; -case EIO : -return 1 ; -case EINTR : -return 2 ; -default : -return 3 ; - } -}
tests/intel-ci/fast-feedback.testlist +12 -1
@@ -3,7 +3,18 @@ igt@core_prop_blob@basic igt@drv_getparams_basic@basic-eu-total igt@drv_getparams_basic@basic-subslice-total igt@drv_hangman@error-state-basic -igt@drv_module_reload_basic +igt@drv_module_reload@basic-reload +igt@drv_module_reload@basic-gem-info +igt@drv_module_reload@basic-exec-store-default +igt@drv_module_reload@basic-exec-store-render +igt@drv_module_reload@basic-exec-store-bsd +igt@drv_module_reload@basic-exec-store-bsd1 +igt@drv_module_reload@basic-exec-store-bsd2 +igt@drv_module_reload@basic-exec-store-blt +igt@drv_module_reload@basic-exec-store-vebox +igt@drv_module_reload@basic-exec-store-all +igt@drv_module_reload@basic-reload-inject +igt@drv_module_reload@basic-reload-final igt@gem_basic@bad-close igt@gem_basic@create-close igt@gem_basic@create-fd-close
tools/Makefile.sources +1 -0
@@ -29,6 +29,7 @@ tools_prog_lists = \ intel_residency \ intel_stepping \ intel_watermark \ + intel_gem_info \ $(NULL) dist_bin_SCRIPTS = intel_gpu_abrt
tools/intel_gem_info.c new file +35 -0
@@ -0,0 +1,35 @@ +#include "igt.h" +#include <sys/ioctl.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <signal.h> +#include <i915_drm.h> + + +int main (void ) +{ +struct drm_i915_gem_sw_finish arg = {0 }; +int fd; + +signal (SIGALRM ,SIG_IGN ); + + fd =__drm_open_driver (DRIVER_INTEL ); +if (fd <0 ) +return IGT_EXIT_SKIP ; + +alarm (1 ); +if (ioctl (fd,DRM_IOCTL_I915_GEM_SW_FINISH , &arg) ==0 ) +return IGT_EXIT_SKIP ; + +switch (errno) { +case ENOENT : +return 0 ; +case EIO : +return 1 ; +case EINTR : +return 2 ; +default : +return 3 ; + } +}
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/3 v3] tests/drv_module_reload: Convert sh script to C version.
Quoted 4 lines · Marius Vlad
tools/intel_gem_info.c new file +4
-0+int main (void ) +{ +struct drm_i915_gem_sw_finish arg = {0 }; +int fd;
tools/intel_gem_info.c line 23
Quoted 10 lines
tools/intel_gem_info.c new file +10
-0+ +signal (SIGALRM ,SIG_IGN ); + + fd =__drm_open_driver (DRIVER_INTEL ); +if (fd <0 ) +return IGT_EXIT_SKIP ; + +alarm (1 ); +if (ioctl (fd,DRM_IOCTL_I915_GEM_SW_FINISH , &arg) ==0 ) +return IGT_EXIT_SKIP ;
Hmm, good point. sw-finish work like this any more. The key was that we used to wait on the struct_mutex before doing the lookup (and so we could probe whether the driver was stuck on the reset, or just stuck).
Current candidate for replacement is the SET_CACHEING ioctl -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 3/3 tests/kms_sysfs_edid_timing: Convert sh to C version.
In reply to Marius Vladv2:
- don't read cached values (Chris Wilson)
- warn on per connector, and fail per mean (Chris Wilson)
These are synthetic: 5us per connector, and 600us for all (as threshold).
--- tests/Makefile.sources | 2 +- tests/kms_sysfs_edid_timing | 25 ---------- tests/kms_sysfs_edid_timing.c | 107 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 26 deletions(-) delete mode 100755 tests/kms_sysfs_edid_timing create mode 100644 tests/kms_sysfs_edid_timing.c
tests/Makefile.sources +1 -1
@@ -212,6 +212,7 @@ TESTS_progs = \ kms_sink_crc_basic \ prime_udl \ drv_module_reload \ + kms_sysfs_edid_timing \ $(NULL) # IMPORTANT: The ZZ_ tests need to be run last!
@@ -222,7 +223,6 @@ TESTS_scripts_M = \ TESTS_scripts = \ debugfs_emon_crash \ drv_debugfs_reader \ - kms_sysfs_edid_timing \ sysfs_l3_parity \ test_rte_check \ tools_test \
tests/kms_sysfs_edid_timing deleted +0 -25
@@ -1,25 +0,0 @@ -#!/bin/bash -# -# This check the time we take to read the content of all the possible connectors. -# Without the edid -ENXIO patch (http://permalink.gmane.org/gmane.comp.video.dri.devel/62083), -# we sometimes take a *really* long time. So let's just check for some reasonable timing here -# - -DRM_LIB_ALLOW_NO_MASTER=1 - -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )" -. $SOURCE_DIR/drm_lib.sh - -TIME1=$(date +%s%N) -cat $(find /sys/devices/|grep drm | grep /status) > /dev/null -TIME2=$(date +%s%N) - -# time in ms -RES=$(((TIME2 - TIME1) / 1000000)) - -if [ $RES -gt 600 ]; then - echo "Talking to outputs took ${RES}ms, something is wrong" - exit $IGT_EXIT_FAILURE -fi - -exit $IGT_EXIT_SUCCESS
tests/kms_sysfs_edid_timing.c new file +107 -0
107 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx