intel-gpu-tools: Add support for the Chamelium
v2 cover intel-gpu-tools: Add support for the Chamelium
This is the next version of the patchset for adding Chamelium support into intel-gpu-tools. The major changes (described in more details in the actual patches):
- Connector mappings are specified in a configuration file, no more guessing
- Some fixes for tests that were throwing false negatives
- Cleanups
- Split into slightly smaller patches
As well, it was suggested that we use libsoup for the XMLRPC interactions with the Chamelium since we already include glib in igt's build deps, however I decided against it because (at least this seems to be the case on Fedora) libsoup is actually packaged seperately from glib, so using it would still require adding another dependency anyway. If I'm wrong here, feel free to let me know.
As a final note: a few of the DisplayPort tests can prove to be unreliable on some hardware, and the dp-display test will only work once by default. This is due to a couple of bugs with chameleond's handling of the chamelium's DP receiver. These problems can mostly be alleviated by using the patches I've got here
https://github.com/Lyude/chameleond/tree/wip/chameleon-fixes
All of which I'll be sending to Google at some point (whenever I get their strange depot-tools setup). As well, all of the display tests won't work on non-intel hardware due to a couple of errorneous intel-hardware specific assumptions made in igt_kms.c, which I should have fixed soon.
Lyude (5):
igt_aux: Add igt_skip_without_suspend_support()
igt_aux: Add igt_set_autoresume_delay()
igt_aux: Add some list helpers from wayland
igt_kms: Add helpers for watching for sysfs hotplug events Add support for hotplug testing with the Chamelium
configure.ac | 13 + lib/Makefile.am | 10 +- lib/igt.h | 3 + lib/igt_aux.c | 94 +++++++ lib/igt_aux.h | 41 +++ lib/igt_chamelium.c | 689 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_chamelium.h | 69 +++++ lib/igt_kms.c | 109 ++++++++ lib/igt_kms.h | 6 + scripts/run-tests.sh | 4 +- tests/Makefile.am | 5 +- tests/Makefile.sources | 1 + tests/chamelium.c | 407 +++++++++++++++++++++++++++++ 13 files changed, 1447 insertions(+), 4 deletions(-) create mode 100644 lib/igt_chamelium.c create mode 100644 lib/igt_chamelium.h create mode 100644 tests/chamelium.c
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v2 1/5 igt_aux: Add igt_skip_without_suspend_support()
Since all of the chamelium calls are blocking, we need to be able to make suspend/resume tests with it multi-threaded. As such, it's not the best idea to rely on igt_system_suspend_autoresume() for skipping tests on systems without suspend/resume support since we could accidentally leave the thread controlling the chamelium running after the test gets skipped.
--- lib/igt_aux.c | 21 +++++++++++++++++++++ lib/igt_aux.h | 2 ++ 2 files changed, 23 insertions(+)
lib/igt_aux.c +21 -0
@@ -743,6 +743,27 @@ static uint32_t get_supported_suspend_states(int power_dir) }/** +* igt_skip_without_suspend_state: +* @state: an #igt_suspend_state to check for +* +* Check whether or not the system supports the given @state, and skip the +* current test if it doesn't. Useful for tests we want to skip before +* attempting to call #igt_system_suspend_autoresume. +*/ +void igt_skip_without_suspend_support (enum igt_suspend_state state, +enum igt_suspend_test test) +{ +int power_dir; + +igt_require ((power_dir =open ("/sys/power" ,O_RDONLY )) >=0 ); +igt_require (get_supported_suspend_states (power_dir) & (1 << state)); +igt_require (test ==SUSPEND_TEST_NONE || +faccessat (power_dir,"pm_test" ,R_OK |W_OK ,0 ) ==0 ); + +close (power_dir); +} + +/** * igt_system_suspend_autoresume: * @state: an #igt_suspend_state, the target suspend state * @test: an #igt_suspend_test, test point at which to complete the suspend
lib/igt_aux.h +2 -0
@@ -170,6 +170,8 @@ enum igt_suspend_test { SUSPEND_TEST_NUM, }; +void igt_skip_without_suspend_support (enum igt_suspend_state state, +enum igt_suspend_test test);void igt_system_suspend_autoresume (enum igt_suspend_state state,enum igt_suspend_test test);
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v2 2/5 igt_aux: Add igt_set_autoresume_delay()
In reply to LyudeThe default autoresume delay is about 5 seconds. It's possible on a system that's not very fast this might not be a long enough time, since an asynchronous hotplug event we scheduled on the chamelium that was intended to happen during suspend could happen before we actually manage to suspend. So, add a function that allows us to increase the autoresume time to ensure this never happens during suspend/resume tests with the chamelium.
Changes since v1:
- Use igt_require, not assert
--- lib/igt_aux.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_aux.h | 1 + 2 files changed, 47 insertions(+)
lib/igt_aux.c +46 -0
@@ -812,6 +812,52 @@ void igt_system_suspend_autoresume(enum igt_suspend_state state,close (power_dir); } +static int original_autoresume_delay; + +static void igt_restore_autoresume_delay (int sig) +{ +int delay_fd; +char delay_str[10 ]; + +igt_require ((delay_fd =open ("/sys/module/suspend/parameters/pm_test_delay" , +O_WRONLY )) >=0 ); + +snprintf (delay_str,sizeof (delay_str),"%d" , original_autoresume_delay); +igt_require (write (delay_fd, delay_str,strlen (delay_str))); + +close (delay_fd); +} + +/** +* igt_set_autoresume_delay: +* @delay_secs: The delay in seconds before resuming the system +* +* Sets how long we wait to resume the system after suspending it, using the +* suspend.pm_test_delay variable. On exit, the original delay value is +* restored. +*/ +void igt_set_autoresume_delay (int delay_secs) +{ +int delay_fd; +char delay_str[10 ]; + +igt_skip_on_simulation (); + +igt_require ((delay_fd =open ("/sys/module/suspend/parameters/pm_test_delay" , +O_RDWR )) >=0 ); + +if (!original_autoresume_delay) { +igt_require (read (delay_fd, delay_str,sizeof (delay_str))); + original_autoresume_delay =atoi (delay_str); +igt_install_exit_handler (igt_restore_autoresume_delay); + } + +snprintf (delay_str,sizeof (delay_str),"%d" , delay_secs); +igt_require (write (delay_fd, delay_str,strlen (delay_str))); + +close (delay_fd); +} +/** * igt_drop_root: *
lib/igt_aux.h +1 -0
@@ -174,6 +174,7 @@ void igt_skip_without_suspend_support(enum igt_suspend_state state, enum igt_suspend_test test);void igt_system_suspend_autoresume (enum igt_suspend_state state,enum igt_suspend_test test); +void igt_set_autoresume_delay (int delay_secs);/* dropping priviledges */ void igt_drop_root (void );
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v2 3/5 igt_aux: Add some list helpers from wayland
In reply to LyudeSince we're going to be using lists for keeping track of EDIDs we've allocated on the chamelium, add some generic list helpers from the wayland project.
Changes since v1:
- Rename list helpers to be more like those from the Linux kernel
--- lib/igt_aux.c | 27 +++++++++++++++++++++++++++ lib/igt_aux.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+)
lib/igt_aux.c +27 -0
@@ -1343,3 +1343,30 @@ double igt_stop_siglatency(struct igt_mean *result)return mean; } + +void igt_list_init (struct igt_list *igt_list) +{ + igt_list->prev = igt_list; + igt_list->next = igt_list; +} + +void igt_list_add (struct igt_list *igt_list,struct igt_list *elm) +{ + elm->prev = igt_list; + elm->next = igt_list->next; + igt_list->next = elm; + elm->next->prev = elm; +} + +void igt_list_del (struct igt_list *elm) +{ + elm->prev->next = elm->next; + elm->next->prev = elm->prev; + elm->next =NULL ; + elm->prev =NULL ; +} + +bool igt_list_empty (const struct igt_list *igt_list) +{ +return igt_list->next == igt_list; +}
lib/igt_aux.h +38 -0
@@ -267,4 +267,42 @@ 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); +/* +* This list data structure is a verbatim copy from wayland-util.h from the +* Wayland project; except that wl_ prefix has been removed. +*/ + +struct igt_list { +struct igt_list *prev; +struct igt_list *next; +}; + +void igt_list_init (struct igt_list *list); +void igt_list_add (struct igt_list *list,struct igt_list *elm); +void igt_list_del (struct igt_list *elm); +bool igt_list_empty (const struct igt_list *list); + +#ifdef __GNUC__ +#define container_of (ptr, sample, member) \ + (__typeof__(sample))((char *)(ptr) - \ + ((char *)&(sample)->member - (char *)(sample))) +#else +#define container_of (ptr, sample, member) \ + (void *)((char *)(ptr) - \ + ((char *)&(sample)->member - (char *)(sample))) +#endif + +#define igt_list_for_each (pos, head, member) \ + for (pos = 0, pos = container_of((head)->next, pos, member); \ + &pos->member != (head); \ + pos = container_of(pos->member.next, pos, member)) + +#define igt_list_for_each_safe (pos, tmp, head, member) \ + for (pos = 0, tmp = 0, \ + pos = container_of((head)->next, pos, member), \ + tmp = container_of((pos)->member.next, tmp, member); \ + &pos->member != (head); \ + pos = tmp, \ + tmp = container_of(pos->member.next, tmp, member)) +#endif /* IGT_AUX_H */
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v2 4/5 igt_kms: Add helpers for watching for sysfs hotplug events
In reply to LyudeThis adds some basic helpers for connecting to udev and watching for sysfs hotplug events.
--- lib/igt_kms.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 6 ++++ 2 files changed, 115 insertions(+)
lib/igt_kms.c +109 -0
@@ -38,6 +38,10 @@#elif HAVE_SYS_KD_H #include <sys/kd.h> #endif +#ifdef HAVE_UDEV +#include <libudev.h> +#include <poll.h> +#endif #include <errno.h> #include <time.h>
@@ -2760,6 +2764,111 @@ void igt_reset_connectors(void) "detect"); } +#ifdef HAVE_UDEV +static struct udev_monitor *hotplug_mon; + +/** +* igt_watch_hotplug: +* +* Begin monitoring udev for hotplug events. +*/ +void igt_watch_hotplug (void ) +{ +struct udev *udev; +int ret, flags, fd; + +if (hotplug_mon) +igt_cleanup_hotplug (); + + udev =udev_new (); +igt_assert (udev !=NULL ); + + hotplug_mon =udev_monitor_new_from_netlink (udev,"udev" ); +igt_assert (hotplug_mon !=NULL ); + + ret =udev_monitor_filter_add_match_subsystem_devtype (hotplug_mon, +"drm" , +"drm_minor" ); +igt_assert_eq (ret,0 ); + ret =udev_monitor_filter_update (hotplug_mon); +igt_assert_eq (ret,0 ); + ret =udev_monitor_enable_receiving (hotplug_mon); +igt_assert_eq (ret,0 ); + +/* Set the fd for udev as non blocking */ + fd =udev_monitor_get_fd (hotplug_mon); + flags =fcntl (fd,F_GETFL ,0 ); +igt_assert (flags); + + flags |=O_NONBLOCK ; +igt_assert_neq (fcntl (fd,F_SETFL , flags),-1 ); +} + +/** +* igt_hotplug_detected: +* @timeout_secs: How long to wait for a hotplug event to occur. +* +* Assert that a hotplug event was received since we last checked the monitor. +* +* Returns: true if a sysfs hotplug event was received, false if we timed out +*/ +bool igt_hotplug_detected (int timeout_secs) +{ +struct udev_device *dev; +const char *hotplug_val; +struct pollfd fd = { + .fd =udev_monitor_get_fd (hotplug_mon), + .events =POLLIN + }; +bool hotplug_received = false; + +/* Go through all of the events pending on the udev monitor. Once we +* receive a hotplug, we continue going through the rest of the events +* so that redundant hotplug events don't change the results of future +* checks +*/ +while (!hotplug_received &&poll (&fd,1 , timeout_secs *1000 )) { + dev =udev_monitor_receive_device (hotplug_mon); + + hotplug_val =udev_device_get_property_value (dev,"HOTPLUG" ); +if (hotplug_val &&atoi (hotplug_val) ==1 ) + hotplug_received = true; + +udev_device_unref (dev); + } + +return hotplug_received; +} + +/** +* igt_flush_hotplugs: +* @mon: A udev monitor created by #igt_watch_hotplug +* +* Get rid of any pending hotplug events waiting on the udev monitor +*/ +void igt_flush_hotplugs (void ) +{ +struct udev_device *dev; + +while ((dev =udev_monitor_receive_device (hotplug_mon))) +udev_device_unref (dev); +} + +/** +* igt_cleanup_hotplug: +* +* Cleanup the resources allocated by #igt_watch_hotplug +*/ +void igt_cleanup_hotplug (void ) +{ +struct udev *udev =udev_monitor_get_udev (hotplug_mon); + +udev_monitor_unref (hotplug_mon); + hotplug_mon =NULL ; +udev_unref (udev); +} +#endif +/** * kmstest_get_vbl_flag: * @pipe_id: Pipe to convert to flag representation.
lib/igt_kms.h +6 -0
@@ -479,5 +479,11 @@ uint32_t kmstest_get_vbl_flag(uint32_t pipe_id);const unsigned char *igt_kms_get_base_edid (void );const unsigned char *igt_kms_get_alt_edid (void ); +#ifdef HAVE_UDEV +void igt_watch_hotplug (void ); +bool igt_hotplug_detected (int timeout_secs); +void igt_flush_hotplugs (void ); +void igt_cleanup_hotplug (void ); +#endif #endif /* __IGT_KMS_H__ */
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v2 5/5 Add support for hotplug testing with the Chamelium
In reply to LyudeFor the purpose of testing things such as hotplugging and bad monitors, the ChromeOS team ended up designing a neat little device known as the Chamelium. More information on this can be found here:
https://www.chromium.org/chromium-os/testing/chamelium
This adds support for a couple of things to intel-gpu-tools:
- igt library functions for connecting to udev and monitoring it for hotplug events, loosely based off of the unfinished hotplugging implementation in testdisplay
- Library functions for controlling the chamelium in tests using xmlrpc. A couple of RPC calls were ommitted here, mainly because they didn't seem very useful for our needs or because they're just plain broken
- A set of basic tests using the chamelium.
Because there's no sure fire way to figure out the mappings between chamelium connectors and the DRM connectors on the machine, we rely on the user specifying these mappings manually in the Chamelium configuration file.
Running these tests requires (of course) a working Chamelium, along with the RPC URL for the chamelium being specified in the environment variable CHAMELIUM_HOST. If no URL is specified, the tests will just skip on their own. As well, tests for connectors which are not actually present on the system or the chamelium will skip on their own as well.
Changes since v1:
- Don't try to guess connector mappings, have the user specify them manually using a configuration file
- Open DRM fd using DRIVER_ANY, not DRIVER_INTEL
- Lower the hotplug timeout a little bit, since 30 seconds was leftover from debugging these tests anyway
- Don't try to keep track of the original state of the chamelium ports, and just leave them plugged in after each run. This makes more sense to me, since I'd imagine in automated testing setups using chameliums that all of the extra monitors will probably be provided by the Chamelium to begin with, so keeping them plugged in would make sure tests running afterwards that require >1 monitor don't get skipped.
- Add wait_for_connector() to the chamelium tests. After some more testing, I found that depending on the system some tests would throw false negatives due to us not waiting long enough for the system to detect that we connected something to it. This mainly happened with VGA connectors, since their lack of HPD makes them take significantly longer for the hardware to notice. wait_for_connector() fixes this by continually reprobing the status of the desired connector (without relying on a hpd event happening, since that might never come) until we get what we want, or we time out and fail.
- Use kmstest_get_property() for retrieving EDIDs instead of doing it by hand
- Don't hardcode PIPE_A for bringing up the display, use kmstest to find an appropriate CRTC to use.
--- configure.ac | 13 + lib/Makefile.am | 10 +- lib/igt.h | 3 + lib/igt_chamelium.c | 689 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_chamelium.h | 69 +++++ scripts/run-tests.sh | 4 +- tests/Makefile.am | 5 +- tests/Makefile.sources | 1 + tests/chamelium.c | 407 +++++++++++++++++++++++++++++ 9 files changed, 1197 insertions(+), 4 deletions(-) create mode 100644 lib/igt_chamelium.c create mode 100644 lib/igt_chamelium.h create mode 100644 tests/chamelium.c
configure.ac +13 -0
@@ -262,6 +262,18 @@ if test "x$with_libunwind" = xyes; then AC_MSG_ERROR([libunwind not found. Use --without-libunwind to disable libunwind support.])) fi +# enable support for using the chamelium +AC_ARG_ENABLE(chamelium, + AS_HELP_STRING([--without-chamelium], + [Build tests without chamelium support]), + [], [with_chamelium=yes]) + +AM_CONDITIONAL(HAVE_CHAMELIUM, [test "x$with_chamelium" = xyes]) +if test "x$with_chamelium" = xyes; then + AC_DEFINE(HAVE_CHAMELIUM, 1, [chamelium suport]) + PKG_CHECK_MODULES(XMLRPC, xmlrpc_client) +fi + # enable debug symbols AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug],
@@ -359,6 +371,7 @@ echo " Assembler : ${enable_assembler}" echo " Debugger : ${enable_debugger}" echo " Overlay : X: ${enable_overlay_xlib}, Xv: ${enable_overlay_xvlib}" echo " x86-specific tools : ${build_x86}" +echo " Chamelium support : ${with_chamelium}" echo "" echo " • API-Documentation : ${enable_gtk_doc}" echo " • Fail on warnings : ${enable_werror}"
lib/Makefile.am +9 -1
@@ -22,8 +22,14 @@ if !HAVE_LIBDRM_INTEL stubs/drm/intel_bufmgr.h endif +if HAVE_CHAMELIUM + libintel_tools_la_SOURCES += \ + igt_chamelium.c \ + igt_chamelium.h +endif + AM_CPPFLAGS = -I$(top_srcdir) -AM_CFLAGS = $(CWARNFLAGS) $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(LIBUNWIND_CFLAGS) $(DEBUG_CFLAGS) \ +AM_CFLAGS = $(CWARNFLAGS) $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(LIBUNWIND_CFLAGS) $(DEBUG_CFLAGS) $(XMLRPC_CFLAGS) $(UDEV_CFLAGS) \ -DIGT_SRCDIR=\""$(abs_top_srcdir)/tests"\" \ -DIGT_DATADIR=\""$(pkgdatadir)"\" \ -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \
@@ -38,5 +44,7 @@ libintel_tools_la_LIBADD = \ $(LIBUDEV_LIBS) \ $(LIBUNWIND_LIBS) \ $(TIMER_LIBS) \ + $(XMLRPC_LIBS) \ + $(UDEV_LIBS) \ -lm
lib/igt.h +3 -0
@@ -30,6 +30,9 @@#include "igt_aux.h" #include "igt_core.h" #include "igt_core.h" +#ifdef HAVE_CHAMELIUM +#include "igt_chamelium.h" +#endif #include "igt_debugfs.h" #include "igt_draw.h" #include "igt_fb.h"
lib/igt_chamelium.c new file +689 -0
689 lines not on this page · raw message
lib/igt_chamelium.h new file +69 -0
69 lines not on this page · raw message
scripts/run-tests.sh +2 -2
@@ -122,10 +122,10 @@ if [ ! -x "$PIGLIT" ]; then fi if [ "x$RESUME" != "x" ]; then - sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" resume "$RESULTS" $NORETRY + sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" CHAMELIUM_HOST="$CHAMELIUM_HOST" "$PIGLIT" resume "$RESULTS" $NORETRY else mkdir -p "$RESULTS" - sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" run igt -o "$RESULTS" -s $VERBOSE $EXCLUDE $FILTER + sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" CHAMELIUM_HOST="$CHAMELIUM_HOST" "$PIGLIT" run igt -o "$RESULTS" -s $VERBOSE $EXCLUDE $FILTER fi if [ "$SUMMARY" == "html" ]; then
tests/Makefile.am +4 -1
@@ -63,7 +63,7 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\ $(LIBUNWIND_CFLAGS) $(WERROR_CFLAGS) \ $(NULL) -LDADD = ../lib/libintel_tools.la $(GLIB_LIBS) +LDADD = ../lib/libintel_tools.la $(GLIB_LIBS) $(XMLRPC_LIBS) AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) AM_LDFLAGS = -Wl,--as-needed
@@ -119,5 +119,8 @@ vc4_wait_bo_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS) vc4_wait_bo_LDADD = $(LDADD) $(DRM_VC4_LIBS) vc4_wait_seqno_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS) vc4_wait_seqno_LDADD = $(LDADD) $(DRM_VC4_LIBS) + +chamelium_CFLAGS = $(AM_CFLAGS) $(XMLRPC_CFLAGS) $(UDEV_CFLAGS) +chamelium_LDADD = $(LDADD) $(XMLRPC_LIBS) $(UDEV_LIBS) endif
tests/Makefile.sources +1 -0
@@ -134,6 +134,7 @@ TESTS_progs_M = \ template \ vgem_basic \ vgem_slow \ + chamelium \ $(NULL) TESTS_progs_XM = \
tests/chamelium.c new file +407 -0
407 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