Message ID | 20161020193649.11701-4-marius.c.vlad@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Oct 20, 2016 at 10:36:49PM +0300, Marius Vlad wrote: > While at it, make available time macros to other users. > > Signed-off-by: Marius Vlad <marius.c.vlad@intel.com> > --- > benchmarks/gem_syslatency.c | 4 --- > lib/igt_core.c | 3 -- > lib/igt_core.h | 3 ++ > tests/Makefile.sources | 2 +- > tests/drv_hangman.c | 1 - > tests/gem_wait.c | 4 --- > tests/kms_flip.c | 3 -- > tests/kms_sysfs_edid_timing | 25 ------------- > tests/kms_sysfs_edid_timing.c | 82 +++++++++++++++++++++++++++++++++++++++++++ > 9 files changed, 86 insertions(+), 41 deletions(-) > delete mode 100755 tests/kms_sysfs_edid_timing > create mode 100644 tests/kms_sysfs_edid_timing.c > > diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c > index 6cad3a0..83bfac7 100644 > --- a/benchmarks/gem_syslatency.c > +++ b/benchmarks/gem_syslatency.c > @@ -133,10 +133,6 @@ static void *gem_busyspin(void *arg) > return NULL; > } > > -#define MSEC_PER_SEC (1000) > -#define USEC_PER_SEC (1000 * MSEC_PER_SEC) > -#define NSEC_PER_SEC (1000 * USEC_PER_SEC) > - > static double elapsed(const struct timespec *a, const struct timespec *b) > { > return 1e9*(b->tv_sec - a->tv_sec) + (b->tv_nsec - a ->tv_nsec); > diff --git a/lib/igt_core.c b/lib/igt_core.c > index 9cd5f98..f64c809 100644 > --- a/lib/igt_core.c > +++ b/lib/igt_core.c > @@ -398,9 +398,6 @@ error: > return -errno; > } > > -#define MSEC_PER_SEC (1000) > -#define USEC_PER_SEC (1000*MSEC_PER_SEC) > -#define NSEC_PER_SEC (1000*USEC_PER_SEC) > uint64_t igt_nsec_elapsed(struct timespec *start) > { > struct timespec now; > diff --git a/lib/igt_core.h b/lib/igt_core.h > index 03be757..a45e334 100644 > --- a/lib/igt_core.h > +++ b/lib/igt_core.h > @@ -847,6 +847,9 @@ extern enum igt_log_level igt_log_level; > void igt_set_timeout(unsigned int seconds, > const char *op); > > +#define MSEC_PER_SEC (1000) > +#define USEC_PER_SEC (1000*MSEC_PER_SEC) > +#define NSEC_PER_SEC (1000*USEC_PER_SEC) > /** > * igt_nsec_elapsed: > * @start: measure from this point in time > diff --git a/tests/Makefile.sources b/tests/Makefile.sources > index c35ea11..969ef0b 100644 > --- a/tests/Makefile.sources > +++ b/tests/Makefile.sources > @@ -210,6 +210,7 @@ TESTS_progs = \ > kms_mmap_write_crc \ > kms_pwrite_crc \ > kms_sink_crc_basic \ > + kms_sysfs_edid_timing \ > prime_udl \ > drv_module_reload_basic \ > $(NULL) > @@ -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 \ > diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c > index 953a4c6..19d809c 100644 > --- a/tests/drv_hangman.c > +++ b/tests/drv_hangman.c > @@ -282,7 +282,6 @@ static void test_error_state_capture(unsigned ring_id, > * case and it takes a lot more time to wrap, so the acthd can potentially keep > * increasing for a long time > */ > -#define NSEC_PER_SEC 1000000000LL > static void hangcheck_unterminated(void) > { > int fd; > diff --git a/tests/gem_wait.c b/tests/gem_wait.c > index b4127de..db04958 100644 > --- a/tests/gem_wait.c > +++ b/tests/gem_wait.c > @@ -83,10 +83,6 @@ static void sigiter(int sig, siginfo_t *info, void *arg) > __sync_synchronize(); > } > > -#define MSEC_PER_SEC (1000) > -#define USEC_PER_SEC (1000 * MSEC_PER_SEC) > -#define NSEC_PER_SEC (1000 * USEC_PER_SEC) > - > #define BUSY 1 > #define HANG 2 > static void basic(int fd, unsigned engine, unsigned flags) > diff --git a/tests/kms_flip.c b/tests/kms_flip.c > index 7646aaf..842bc3a 100644 > --- a/tests/kms_flip.c > +++ b/tests/kms_flip.c > @@ -83,9 +83,6 @@ > #define DRM_CAP_TIMESTAMP_MONOTONIC 6 > #endif > > -#define USEC_PER_SEC 1000000L > -#define NSEC_PER_SEC 1000000000L > - > drmModeRes *resources; > int drm_fd; > static drm_intel_bufmgr *bufmgr; > diff --git a/tests/kms_sysfs_edid_timing b/tests/kms_sysfs_edid_timing > deleted file mode 100755 > index 46ea540..0000000 > --- a/tests/kms_sysfs_edid_timing > +++ /dev/null > @@ -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 > diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c > new file mode 100644 > index 0000000..8de4b78 > --- /dev/null > +++ b/tests/kms_sysfs_edid_timing.c > @@ -0,0 +1,82 @@ > +/* > + * Copyright © 2016 Intel Corporation > + * > + * 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. > + */ > +#include "igt.h" > +#include "igt_debugfs.h" > +#include "igt_sysfs.h" > +#include "igt_core.h" > + > +#include <dirent.h> > +#include <fcntl.h> > +#include <sys/stat.h> > +#include <time.h> > + > +#define MSEC_PER_SEC (1000) > +#define USEC_PER_SEC (1000*MSEC_PER_SEC) > +#define NSEC_PER_SEC (1000*USEC_PER_SEC) > + > +IGT_TEST_DESCRIPTION("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"); > + > +igt_simple_main > +{ > + int dir = igt_sysfs_open(-1, NULL); > + DIR *dirp = fdopendir(dir); > + struct dirent *de; > + > + int i, fd = 0; > + int fds[32]; > + uint64_t elapsed; > + > + struct stat st; > + struct timespec start = {}; > + > + memset(fds, -1, sizeof(fds)); > + while ((de = readdir(dirp))) { > + > + if (*de->d_name == '.') > + continue; > + > + if (fstatat(dir, de->d_name, &st, 0)) > + continue; > + > + if (S_ISDIR(st.st_mode) && > + strncmp(de->d_name, "card0-", 6) == 0) { Whilst you are here, you may as well generalise this to work on all outputs with an edid. > + int dfd = openat(dir, de->d_name, O_RDONLY); > + igt_assert(dfd > 0); > + fds[fd++] = dfd; > + } > + } > + closedir(dirp); > + > + elapsed = igt_nsec_elapsed(&start); > + for (i = 0; i < fd - 1; i++) { > + igt_assert(igt_sysfs_get(fds[i], "status") != NULL); This is reading the cached status. This no longer performs the original intentional. igt_sysfs_set(fd[i], "status", "detect"); > + close(fds[i]); > + } > + elapsed = igt_nsec_elapsed(&start); > + > + igt_fail_on(elapsed > 600 * USEC_PER_SEC); You should time each individually, and repeat a few times to identify outliers. (Warn if outlier > threshold, fail if mean > threshold). -Chris
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c index 6cad3a0..83bfac7 100644 --- a/benchmarks/gem_syslatency.c +++ b/benchmarks/gem_syslatency.c @@ -133,10 +133,6 @@ static void *gem_busyspin(void *arg) return NULL; } -#define MSEC_PER_SEC (1000) -#define USEC_PER_SEC (1000 * MSEC_PER_SEC) -#define NSEC_PER_SEC (1000 * USEC_PER_SEC) - static double elapsed(const struct timespec *a, const struct timespec *b) { return 1e9*(b->tv_sec - a->tv_sec) + (b->tv_nsec - a ->tv_nsec); diff --git a/lib/igt_core.c b/lib/igt_core.c index 9cd5f98..f64c809 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -398,9 +398,6 @@ error: return -errno; } -#define MSEC_PER_SEC (1000) -#define USEC_PER_SEC (1000*MSEC_PER_SEC) -#define NSEC_PER_SEC (1000*USEC_PER_SEC) uint64_t igt_nsec_elapsed(struct timespec *start) { struct timespec now; diff --git a/lib/igt_core.h b/lib/igt_core.h index 03be757..a45e334 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -847,6 +847,9 @@ extern enum igt_log_level igt_log_level; void igt_set_timeout(unsigned int seconds, const char *op); +#define MSEC_PER_SEC (1000) +#define USEC_PER_SEC (1000*MSEC_PER_SEC) +#define NSEC_PER_SEC (1000*USEC_PER_SEC) /** * igt_nsec_elapsed: * @start: measure from this point in time diff --git a/tests/Makefile.sources b/tests/Makefile.sources index c35ea11..969ef0b 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -210,6 +210,7 @@ TESTS_progs = \ kms_mmap_write_crc \ kms_pwrite_crc \ kms_sink_crc_basic \ + kms_sysfs_edid_timing \ prime_udl \ drv_module_reload_basic \ $(NULL) @@ -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 \ diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c index 953a4c6..19d809c 100644 --- a/tests/drv_hangman.c +++ b/tests/drv_hangman.c @@ -282,7 +282,6 @@ static void test_error_state_capture(unsigned ring_id, * case and it takes a lot more time to wrap, so the acthd can potentially keep * increasing for a long time */ -#define NSEC_PER_SEC 1000000000LL static void hangcheck_unterminated(void) { int fd; diff --git a/tests/gem_wait.c b/tests/gem_wait.c index b4127de..db04958 100644 --- a/tests/gem_wait.c +++ b/tests/gem_wait.c @@ -83,10 +83,6 @@ static void sigiter(int sig, siginfo_t *info, void *arg) __sync_synchronize(); } -#define MSEC_PER_SEC (1000) -#define USEC_PER_SEC (1000 * MSEC_PER_SEC) -#define NSEC_PER_SEC (1000 * USEC_PER_SEC) - #define BUSY 1 #define HANG 2 static void basic(int fd, unsigned engine, unsigned flags) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 7646aaf..842bc3a 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -83,9 +83,6 @@ #define DRM_CAP_TIMESTAMP_MONOTONIC 6 #endif -#define USEC_PER_SEC 1000000L -#define NSEC_PER_SEC 1000000000L - drmModeRes *resources; int drm_fd; static drm_intel_bufmgr *bufmgr; diff --git a/tests/kms_sysfs_edid_timing b/tests/kms_sysfs_edid_timing deleted file mode 100755 index 46ea540..0000000 --- a/tests/kms_sysfs_edid_timing +++ /dev/null @@ -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 diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c new file mode 100644 index 0000000..8de4b78 --- /dev/null +++ b/tests/kms_sysfs_edid_timing.c @@ -0,0 +1,82 @@ +/* + * Copyright © 2016 Intel Corporation + * + * 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. + */ +#include "igt.h" +#include "igt_debugfs.h" +#include "igt_sysfs.h" +#include "igt_core.h" + +#include <dirent.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <time.h> + +#define MSEC_PER_SEC (1000) +#define USEC_PER_SEC (1000*MSEC_PER_SEC) +#define NSEC_PER_SEC (1000*USEC_PER_SEC) + +IGT_TEST_DESCRIPTION("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"); + +igt_simple_main +{ + int dir = igt_sysfs_open(-1, NULL); + DIR *dirp = fdopendir(dir); + struct dirent *de; + + int i, fd = 0; + int fds[32]; + uint64_t elapsed; + + struct stat st; + struct timespec start = {}; + + memset(fds, -1, sizeof(fds)); + while ((de = readdir(dirp))) { + + if (*de->d_name == '.') + continue; + + if (fstatat(dir, de->d_name, &st, 0)) + continue; + + if (S_ISDIR(st.st_mode) && + strncmp(de->d_name, "card0-", 6) == 0) { + int dfd = openat(dir, de->d_name, O_RDONLY); + igt_assert(dfd > 0); + fds[fd++] = dfd; + } + } + closedir(dirp); + + elapsed = igt_nsec_elapsed(&start); + for (i = 0; i < fd - 1; i++) { + igt_assert(igt_sysfs_get(fds[i], "status") != NULL); + close(fds[i]); + } + elapsed = igt_nsec_elapsed(&start); + + igt_fail_on(elapsed > 600 * USEC_PER_SEC); +}
While at it, make available time macros to other users. Signed-off-by: Marius Vlad <marius.c.vlad@intel.com> --- benchmarks/gem_syslatency.c | 4 --- lib/igt_core.c | 3 -- lib/igt_core.h | 3 ++ tests/Makefile.sources | 2 +- tests/drv_hangman.c | 1 - tests/gem_wait.c | 4 --- tests/kms_flip.c | 3 -- tests/kms_sysfs_edid_timing | 25 ------------- tests/kms_sysfs_edid_timing.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 86 insertions(+), 41 deletions(-) delete mode 100755 tests/kms_sysfs_edid_timing create mode 100644 tests/kms_sysfs_edid_timing.c