lib/igt_debugfs: Remove support for legacy CRC api.
PATCH 1/1 lib/igt_debugfs: Remove support for legacy CRC api.
In kernel v4.10 the legacy crc api has been replaced by a generic drm crc API. While at it, fix igt_require_pipe_crc, the file cannot be opened any more when the crtc is not active after kernel commit 8038e09be5a3 ("drm/crc: Only open CRC on atomic drivers when the CRTC is active."). Statting the file should be enough for testing it's supported.
--- lib/igt_debugfs.c | 231 +++++++----------------------------------------------- 1 file changed, 28 insertions(+), 203 deletions(-)
lib/igt_debugfs.c +28 -203
@@ -416,16 +416,12 @@ char *igt_crc_to_string(igt_crc_t *crc)#define MAX_CRC_ENTRIES 10#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1) -/* (6 fields, 8 chars each, space separated (5) + '\n') */ -#define LEGACY_LINE_LEN (6 * 8 + 5 + 1) -struct _igt_pipe_crc {int fd;int dir;int ctl_fd;int crc_fd;int flags; -bool is_legacy;enum pipe pipe;enum intel_pipe_crc_source source;
@@ -449,130 +445,6 @@ static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)return pipe_crc_sources[source]; } -static bool igt_pipe_crc_do_start (igt_pipe_crc_t *pipe_crc) -{ -char buf[64 ]; - -/* Stop first just to make sure we don't have lingering state left. */ -igt_pipe_crc_stop (pipe_crc); - -if (pipe_crc->is_legacy) -sprintf (buf,"pipe %s %s" ,kmstest_pipe_name (pipe_crc->pipe), -pipe_crc_source_name (pipe_crc->source)); -else -sprintf (buf,"%s" ,pipe_crc_source_name (pipe_crc->source)); - -igt_assert_eq (write (pipe_crc->ctl_fd, buf,strlen (buf)),strlen (buf)); - -if (!pipe_crc->is_legacy) { -int err; - -sprintf (buf,"crtc-%d/crc/data" , pipe_crc->pipe); - err =0 ; - - pipe_crc->crc_fd =openat (pipe_crc->dir, buf, pipe_crc->flags); -if (pipe_crc->crc_fd <0 ) - err = -errno; - -if (err == -EINVAL ) -return false; - -igt_assert_eq (err,0 ); - } - - errno =0 ; -return true; -} - -static void igt_pipe_crc_pipe_off (int fd,enum pipe pipe) -{ -char buf[32 ]; - -sprintf (buf,"pipe %s none" ,kmstest_pipe_name (pipe)); -igt_assert_eq (write (fd, buf,strlen (buf)),strlen (buf)); -} - -static void igt_pipe_crc_reset (int drm_fd) -{ -struct dirent *dirent; -const char *cmd ="none" ; -bool done = false; -DIR *dir; -int fdir; -int fd; - - fdir =igt_debugfs_dir (drm_fd); -if (fdir <0 ) -return ; - - dir =fdopendir (fdir); -if (!dir) { -close (fdir); -return ; - } - -while ((dirent =readdir (dir))) { -char buf[PATH_MAX ]; - -if (strcmp (dirent->d_name,"crtc-" ) !=0 ) -continue ; - -sprintf (buf,"%s/crc/control" , dirent->d_name); - fd =openat (fdir, buf,O_WRONLY ); -if (fd <0 ) -continue ; - -igt_assert_eq (write (fd, cmd,strlen (cmd)),strlen (cmd)); -close (fd); - - done = true; - } -closedir (dir); - -if (!done) { - fd =openat (fdir,"i915_display_crtc_ctl" ,O_WRONLY ); -if (fd !=-1 ) { -igt_pipe_crc_pipe_off (fd,PIPE_A ); -igt_pipe_crc_pipe_off (fd,PIPE_B ); -igt_pipe_crc_pipe_off (fd,PIPE_C ); - -close (fd); - } - } - -close (fdir); -} - -static void pipe_crc_exit_handler (int sig) -{ -struct dirent *dirent; -char buf[PATH_MAX ]; -DIR *dir; -int fd; - - dir =opendir ("/dev/dri" ); -if (!dir) -return ; - -/* -* Try to reset CRC capture for all DRM devices, this is only needed -* for the legacy CRC ABI and can be completely removed once the -* legacy codepaths are removed. -*/ -while ((dirent =readdir (dir))) { -if (strncmp (dirent->d_name,"card" ,4 ) !=0 ) -continue ; - -sprintf (buf,"/dev/dri/%s" , dirent->d_name); - fd =open (buf,O_WRONLY ); - -igt_pipe_crc_reset (fd); - -close (fd); - } -closedir (dir); -} -/** * igt_require_pipe_crc: *
@@ -582,20 +454,15 @@ static void pipe_crc_exit_handler(int sig)*/ void igt_require_pipe_crc (int fd) { -const char *cmd ="pipe A none" ; -int ctl, written; - - ctl =igt_debugfs_open (fd,"crtc-0/crc/control" ,O_RDONLY ); -if (ctl <0 ) { - ctl =igt_debugfs_open (fd,"i915_display_crc_ctl" ,O_WRONLY ); -igt_require_f (ctl, -"No display_crc_ctl found, kernel too old\n" ); - - written =write (ctl, cmd,strlen (cmd)); -igt_require_f (written <0 , -"CRCs not supported on this platform\n" ); - } -close (ctl); +int dir; +struct stat stat; + + dir =igt_debugfs_dir (fd); +igt_require_f (dir >=0 ,"Could not open debugfs directory\n" ); +igt_require_f (fstatat (dir,"crtc-0/crc/control" , &stat,0 ) ==0 , +"CRCs not supported on this platform\n" ); + +close (dir); }static void igt_hpd_storm_exit_handler (int sig)
@@ -729,29 +596,13 @@ pipe_crc_new(int fd, enum pipe pipe, enum intel_pipe_crc_source source, int flag debugfs =igt_debugfs_dir (fd);igt_assert (debugfs !=-1 ); -igt_install_exit_handler (pipe_crc_exit_handler); - pipe_crc =calloc (1 ,sizeof (struct _igt_pipe_crc ));sprintf (buf,"crtc-%d/crc/control" , pipe); pipe_crc->ctl_fd =openat (debugfs, buf,O_WRONLY ); -if (pipe_crc->ctl_fd ==-1 ) { - pipe_crc->ctl_fd =openat (debugfs, -"i915_display_crc_ctl" ,O_WRONLY ); -igt_assert (pipe_crc->ctl_fd !=-1 ); - pipe_crc->is_legacy = true; - } - -if (pipe_crc->is_legacy) { -sprintf (buf,"i915_pipe_%s_crc" ,kmstest_pipe_name (pipe)); - pipe_crc->crc_fd =openat (debugfs, buf, flags); -igt_assert (pipe_crc->crc_fd !=-1 ); -igt_debug ("Using legacy frame CRC ABI\n" ); - }else { - pipe_crc->crc_fd =-1 ; -igt_debug ("Using generic frame CRC ABI\n" ); - } +igt_assert (pipe_crc->ctl_fd !=-1 ); + pipe_crc->crc_fd =-1 ; pipe_crc->fd = fd; pipe_crc->dir = debugfs; pipe_crc->pipe = pipe;
@@ -817,18 +668,9 @@ void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)static bool pipe_crc_init_from_string (igt_pipe_crc_t *pipe_crc,igt_crc_t *crc,const char *line) { -int n, i; +int i;const char *buf; -if (pipe_crc->is_legacy) { - crc->has_valid_frame = true; - crc->n_words =5 ; - n =sscanf (line,"%8u %8x %8x %8x %8x %8x" , &crc->frame, - &crc->crc[0 ], &crc->crc[1 ], &crc->crc[2 ], - &crc->crc[3 ], &crc->crc[4 ]); -return n ==6 ; - } -if (strncmp (line,"XXXXXXXXXX" ,10 ) ==0 ) crc->has_valid_frame = false;else {
@@ -849,15 +691,9 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out) {ssize_t bytes_read;char buf[MAX_LINE_LEN +1 ]; -size_t read_len; - -if (pipe_crc->is_legacy) - read_len =LEGACY_LINE_LEN ; -else - read_len =MAX_LINE_LEN ;igt_set_timeout (5 ,"CRC reading" ); - bytes_read =read (pipe_crc->crc_fd, &buf, read_len); + bytes_read =read (pipe_crc->crc_fd, &buf,MAX_LINE_LEN );igt_reset_timeout ();if (bytes_read <0 && errno ==EAGAIN )
@@ -888,22 +724,19 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)*/ void igt_pipe_crc_start (igt_pipe_crc_t *pipe_crc) { -igt_crc_t crc; - -igt_assert (igt_pipe_crc_do_start (pipe_crc)); - -if (pipe_crc->is_legacy) { -/* -* For some no yet identified reason, the first CRC is -* bonkers. So let's just wait for the next vblank and read -* out the buggy result. -* -* On CHV sometimes the second CRC is bonkers as well, so -* don't trust that one either. -*/ -read_one_crc (pipe_crc, &crc); -read_one_crc (pipe_crc, &crc); - } +const char *src =pipe_crc_source_name (pipe_crc->source); +char buf[32 ]; + +/* Stop first just to make sure we don't have lingering state left. */ +igt_pipe_crc_stop (pipe_crc); + +igt_assert_eq (write (pipe_crc->ctl_fd, src,strlen (src)),strlen (src)); + +sprintf (buf,"crtc-%d/crc/data" , pipe_crc->pipe); + + pipe_crc->crc_fd =openat (pipe_crc->dir, buf, pipe_crc->flags); +igt_assert (pipe_crc->crc_fd !=-1 ); + errno =0 ; }/**
@@ -914,16 +747,8 @@ void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)*/ void igt_pipe_crc_stop (igt_pipe_crc_t *pipe_crc) { -char buf[32 ]; - -if (pipe_crc->is_legacy) { -sprintf (buf,"pipe %s none" ,kmstest_pipe_name (pipe_crc->pipe)); -igt_assert_eq (write (pipe_crc->ctl_fd, buf,strlen (buf)), -strlen (buf)); - }else { -close (pipe_crc->crc_fd); - pipe_crc->crc_fd =-1 ; - } +close (pipe_crc->crc_fd); + pipe_crc->crc_fd =-1 ; }/**
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for lib/igt_debugfs: Remove support for legacy CRC api.
== Series Details ==
== Series Details ==
Series: lib/igt_debugfs: Remove support for legacy CRC api.
URL : https://patchwork.freedesktop.org/series/32689/
State : failure
== Summary ==
IGT patchset tested on top of latest successful build 1fc4de1ca390adec9be8bd7cc0c36cab07465959 igt/gem_exec_latency: Wire up an interloper for preemption
with latest DRM-Tip kernel build CI_DRM_3286df3033b17405 drm-tip: 2017y-10m-26d-11h-03m-59s UTC integration manifest
No testlist changes.
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-b:
pass -> INCOMPLETE (fi-cnl-y)
Subgroup read-crc-pipe-b-frame-sequence:
skip -> PASS (fi-hsw-4770r) fdo#102332
Subgroup suspend-read-crc-pipe-b:
pass -> DMESG-WARN (fi-byt-j1900) fdo#101705fdo#102332 https://bugs.freedesktop.org/show_bug.cgi?id=102332
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:444s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:454s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:374s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:528s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:264s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:500s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:502s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:502s fi-byt-n2820 total:289 pass:249 dwarn:1 dfail:0 fail:0 skip:39 time:484s fi-cfl-s total:289 pass:253 dwarn:4 dfail:0 fail:0 skip:32 time:561s fi-cnl-y total:231 pass:206 dwarn:0 dfail:0 fail:0 skip:24 fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:416s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:250s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:578s fi-glk-dsi total:289 pass:258 dwarn:0 dfail:0 fail:1 skip:30 time:487s fi-hsw-4770 total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:430s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:430s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:437s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:497s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:467s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:489s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:585s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:475s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:586s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:550s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:457s fi-skl-6600u total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:589s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:645s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:518s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:510s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:461s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:564s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:429s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_427/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for lib/igt_debugfs: Remove support for legacy CRC api.
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: lib/igt_debugfs: Remove support for legacy CRC api.
URL : https://patchwork.freedesktop.org/series/32689/
State : success
== Summary ==
Test kms_busy:
Subgroup extended-modeset-hang-oldfb-with-reset-render-B:
dmesg-warn -> PASS (shard-hsw) fdo#102249
Test kms_plane:
Subgroup plane-panning-bottom-right-suspend-pipe-A-planes:
skip -> PASS (shard-hsw)
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-hsw) fdo#99912fdo#102249 https://bugs.freedesktop.org/show_bug.cgi?id=102249
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
shard-hsw total:2539 pass:1433 dwarn:0 dfail:0 fail:9 skip:1097 time:9221s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_427/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 5 lines · Maarten Lankhorst
In kernel v4.10 the legacy crc api has been replaced by a generic drm crc API. While at it, fix
igt_require_pipe_crc, the file cannot be opened any more when the crtc is not active after kernel commit8038e09be5a3("drm/crc: Only open CRC on atomic drivers when the CRTC is active."). Statting the file should be enough for testing it's supported.
What's the impact of this change on devices running older kernels - such as KBL ChromeOS on 4.4?
Quoted 322 lines
Cc Tomi Sarvela <[email protected]>Cc Petri Latvala <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_debugfs.c | 231 +++++++----------------------------------------------- 1 file changed, 28 insertions(+), 203 deletions(-)lib/igt_debugfs.c +28
-203@@ -416,16 +416,12 @@ char *igt_crc_to_string(igt_crc_t *crc)#define MAX_CRC_ENTRIES 10#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1) -/* (6 fields, 8 chars each, space separated (5) + '\n') */ -#define LEGACY_LINE_LEN (6 * 8 + 5 + 1) -struct _igt_pipe_crc {int fd;int dir;int ctl_fd;int crc_fd;int flags; -bool is_legacy;enum pipe pipe;enum intel_pipe_crc_source source;@@ -449,130 +445,6 @@ static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)return pipe_crc_sources[source]; } -static bool igt_pipe_crc_do_start (igt_pipe_crc_t *pipe_crc) -{ -char buf[64 ]; - -/* Stop first just to make sure we don't have lingering state left. */ -igt_pipe_crc_stop (pipe_crc); - -if (pipe_crc->is_legacy) -sprintf (buf,"pipe %s %s" ,kmstest_pipe_name (pipe_crc->pipe), -pipe_crc_source_name (pipe_crc->source)); -else -sprintf (buf,"%s" ,pipe_crc_source_name (pipe_crc->source)); - -igt_assert_eq (write (pipe_crc->ctl_fd, buf,strlen (buf)),strlen (buf)); - -if (!pipe_crc->is_legacy) { -int err; - -sprintf (buf,"crtc-%d/crc/data" , pipe_crc->pipe); - err =0 ; - - pipe_crc->crc_fd =openat (pipe_crc->dir, buf, pipe_crc->flags); -if (pipe_crc->crc_fd <0 ) - err = -errno; - -if (err == -EINVAL ) -return false; - -igt_assert_eq (err,0 ); - } - - errno =0 ; -return true; -} - -static void igt_pipe_crc_pipe_off (int fd,enum pipe pipe) -{ -char buf[32 ]; - -sprintf (buf,"pipe %s none" ,kmstest_pipe_name (pipe)); -igt_assert_eq (write (fd, buf,strlen (buf)),strlen (buf)); -} - -static void igt_pipe_crc_reset (int drm_fd) -{ -struct dirent *dirent; -const char *cmd ="none" ; -bool done = false; -DIR *dir; -int fdir; -int fd; - - fdir =igt_debugfs_dir (drm_fd); -if (fdir <0 ) -return ; - - dir =fdopendir (fdir); -if (!dir) { -close (fdir); -return ; - } - -while ((dirent =readdir (dir))) { -char buf[PATH_MAX ]; - -if (strcmp (dirent->d_name,"crtc-" ) !=0 ) -continue ; - -sprintf (buf,"%s/crc/control" , dirent->d_name); - fd =openat (fdir, buf,O_WRONLY ); -if (fd <0 ) -continue ; - -igt_assert_eq (write (fd, cmd,strlen (cmd)),strlen (cmd)); -close (fd); - - done = true; - } -closedir (dir); - -if (!done) { - fd =openat (fdir,"i915_display_crtc_ctl" ,O_WRONLY ); -if (fd !=-1 ) { -igt_pipe_crc_pipe_off (fd,PIPE_A ); -igt_pipe_crc_pipe_off (fd,PIPE_B ); -igt_pipe_crc_pipe_off (fd,PIPE_C ); - -close (fd); - } - } - -close (fdir); -} - -static void pipe_crc_exit_handler (int sig) -{ -struct dirent *dirent; -char buf[PATH_MAX ]; -DIR *dir; -int fd; - - dir =opendir ("/dev/dri" ); -if (!dir) -return ; - -/* -* Try to reset CRC capture for all DRM devices, this is only needed -* for the legacy CRC ABI and can be completely removed once the -* legacy codepaths are removed. -*/ -while ((dirent =readdir (dir))) { -if (strncmp (dirent->d_name,"card" ,4 ) !=0 ) -continue ; - -sprintf (buf,"/dev/dri/%s" , dirent->d_name); - fd =open (buf,O_WRONLY ); - -igt_pipe_crc_reset (fd); - -close (fd); - } -closedir (dir); -} -/** * igt_require_pipe_crc: * @@ -582,20 +454,15 @@ static void pipe_crc_exit_handler(int sig)*/ void igt_require_pipe_crc (int fd) { -const char *cmd ="pipe A none" ; -int ctl, written; - - ctl =igt_debugfs_open (fd,"crtc-0/crc/control" ,O_RDONLY ); -if (ctl <0 ) { - ctl =igt_debugfs_open (fd,"i915_display_crc_ctl" ,O_WRONLY ); -igt_require_f (ctl, -"No display_crc_ctl found, kernel too old\n" ); - - written =write (ctl, cmd,strlen (cmd)); -igt_require_f (written <0 , -"CRCs not supported on this platform\n" ); - } -close (ctl); +int dir; +struct stat stat; + + dir =igt_debugfs_dir (fd); +igt_require_f (dir >=0 ,"Could not open debugfs directory\n" ); +igt_require_f (fstatat (dir,"crtc-0/crc/control" , &stat,0 ) ==0 , +"CRCs not supported on this platform\n" ); + +close (dir); }static void igt_hpd_storm_exit_handler (int sig)@@ -729,29 +596,13 @@ pipe_crc_new(int fd, enum pipe pipe, enum intel_pipe_crc_source source, int flag debugfs =igt_debugfs_dir (fd);igt_assert (debugfs !=-1 ); -igt_install_exit_handler (pipe_crc_exit_handler); - pipe_crc =calloc (1 ,sizeof (struct _igt_pipe_crc ));sprintf (buf,"crtc-%d/crc/control" , pipe); pipe_crc->ctl_fd =openat (debugfs, buf,O_WRONLY ); -if (pipe_crc->ctl_fd ==-1 ) { - pipe_crc->ctl_fd =openat (debugfs, -"i915_display_crc_ctl" ,O_WRONLY ); -igt_assert (pipe_crc->ctl_fd !=-1 ); - pipe_crc->is_legacy = true; - } - -if (pipe_crc->is_legacy) { -sprintf (buf,"i915_pipe_%s_crc" ,kmstest_pipe_name (pipe)); - pipe_crc->crc_fd =openat (debugfs, buf, flags); -igt_assert (pipe_crc->crc_fd !=-1 ); -igt_debug ("Using legacy frame CRC ABI\n" ); - }else { - pipe_crc->crc_fd =-1 ; -igt_debug ("Using generic frame CRC ABI\n" ); - } +igt_assert (pipe_crc->ctl_fd !=-1 ); + pipe_crc->crc_fd =-1 ; pipe_crc->fd = fd; pipe_crc->dir = debugfs; pipe_crc->pipe = pipe;@@ -817,18 +668,9 @@ void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)static bool pipe_crc_init_from_string (igt_pipe_crc_t *pipe_crc,igt_crc_t *crc,const char *line) { -int n, i; +int i;const char *buf; -if (pipe_crc->is_legacy) { - crc->has_valid_frame = true; - crc->n_words =5 ; - n =sscanf (line,"%8u %8x %8x %8x %8x %8x" , &crc->frame, - &crc->crc[0 ], &crc->crc[1 ], &crc->crc[2 ], - &crc->crc[3 ], &crc->crc[4 ]); -return n ==6 ; - } -if (strncmp (line,"XXXXXXXXXX" ,10 ) ==0 ) crc->has_valid_frame = false;else {@@ -849,15 +691,9 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out) {ssize_t bytes_read;char buf[MAX_LINE_LEN +1 ]; -size_t read_len; - -if (pipe_crc->is_legacy) - read_len =LEGACY_LINE_LEN ; -else - read_len =MAX_LINE_LEN ;igt_set_timeout (5 ,"CRC reading" ); - bytes_read =read (pipe_crc->crc_fd, &buf, read_len); + bytes_read =read (pipe_crc->crc_fd, &buf,MAX_LINE_LEN );igt_reset_timeout ();if (bytes_read <0 && errno ==EAGAIN )@@ -888,22 +724,19 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)*/ void igt_pipe_crc_start (igt_pipe_crc_t *pipe_crc) { -igt_crc_t crc; - -igt_assert (igt_pipe_crc_do_start (pipe_crc)); - -if (pipe_crc->is_legacy) { -/* -* For some no yet identified reason, the first CRC is -* bonkers. So let's just wait for the next vblank and read -* out the buggy result. -* -* On CHV sometimes the second CRC is bonkers as well, so -* don't trust that one either. -*/ -read_one_crc (pipe_crc, &crc); -read_one_crc (pipe_crc, &crc); - } +const char *src =pipe_crc_source_name (pipe_crc->source); +char buf[32 ]; + +/* Stop first just to make sure we don't have lingering state left. */ +igt_pipe_crc_stop (pipe_crc); + +igt_assert_eq (write (pipe_crc->ctl_fd, src,strlen (src)),strlen (src)); + +sprintf (buf,"crtc-%d/crc/data" , pipe_crc->pipe); + + pipe_crc->crc_fd =openat (pipe_crc->dir, buf, pipe_crc->flags); +igt_assert (pipe_crc->crc_fd !=-1 ); + errno =0 ; }/** @@ -914,16 +747,8 @@ void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)*/ void igt_pipe_crc_stop (igt_pipe_crc_t *pipe_crc) { -char buf[32 ]; - -if (pipe_crc->is_legacy) { -sprintf (buf,"pipe %s none" ,kmstest_pipe_name (pipe_crc->pipe)); -igt_assert_eq (write (pipe_crc->ctl_fd, buf,strlen (buf)), -strlen (buf)); - }else { -close (pipe_crc->crc_fd); - pipe_crc->crc_fd =-1 ; - } +close (pipe_crc->crc_fd); + pipe_crc->crc_fd =-1 ; }/** Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · James Ausmus
Quoted 5 lines · Maarten Lankhorst
In kernel v4.10 the legacy crc api has been replaced by a generic drm crc API. While at it, fix
igt_require_pipe_crc, the file cannot be opened any more when the crtc is not active after kernel commit8038e09be5a3("drm/crc: Only open CRC on atomic drivers when the CRTC is active."). Statting the file should be enough for testing it's supported.What's the impact of this change on devices running older kernels - such as KBL ChromeOS on 4.4?
If you backport kernel features, you either also backport the new kernel CRC API, or forward port the igt support for the legacy debugfs if you want to use latest upstream igt?
BR,
Jani.
Quoted 323 lines
Quoted 323 lines
Cc Tomi Sarvela <[email protected]>Cc Petri Latvala <[email protected]>Cc Jani Nikula <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- lib/igt_debugfs.c | 231 +++++++----------------------------------------------- 1 file changed, 28 insertions(+), 203 deletions(-)lib/igt_debugfs.c +28
-203@@ -416,16 +416,12 @@ char *igt_crc_to_string(igt_crc_t *crc)#define MAX_CRC_ENTRIES 10#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1) -/* (6 fields, 8 chars each, space separated (5) + '\n') */ -#define LEGACY_LINE_LEN (6 * 8 + 5 + 1) -struct _igt_pipe_crc {int fd;int dir;int ctl_fd;int crc_fd;int flags; -bool is_legacy;enum pipe pipe;enum intel_pipe_crc_source source;@@ -449,130 +445,6 @@ static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)return pipe_crc_sources[source]; } -static bool igt_pipe_crc_do_start (igt_pipe_crc_t *pipe_crc) -{ -char buf[64 ]; - -/* Stop first just to make sure we don't have lingering state left. */ -igt_pipe_crc_stop (pipe_crc); - -if (pipe_crc->is_legacy) -sprintf (buf,"pipe %s %s" ,kmstest_pipe_name (pipe_crc->pipe), -pipe_crc_source_name (pipe_crc->source)); -else -sprintf (buf,"%s" ,pipe_crc_source_name (pipe_crc->source)); - -igt_assert_eq (write (pipe_crc->ctl_fd, buf,strlen (buf)),strlen (buf)); - -if (!pipe_crc->is_legacy) { -int err; - -sprintf (buf,"crtc-%d/crc/data" , pipe_crc->pipe); - err =0 ; - - pipe_crc->crc_fd =openat (pipe_crc->dir, buf, pipe_crc->flags); -if (pipe_crc->crc_fd <0 ) - err = -errno; - -if (err == -EINVAL ) -return false; - -igt_assert_eq (err,0 ); - } - - errno =0 ; -return true; -} - -static void igt_pipe_crc_pipe_off (int fd,enum pipe pipe) -{ -char buf[32 ]; - -sprintf (buf,"pipe %s none" ,kmstest_pipe_name (pipe)); -igt_assert_eq (write (fd, buf,strlen (buf)),strlen (buf)); -} - -static void igt_pipe_crc_reset (int drm_fd) -{ -struct dirent *dirent; -const char *cmd ="none" ; -bool done = false; -DIR *dir; -int fdir; -int fd; - - fdir =igt_debugfs_dir (drm_fd); -if (fdir <0 ) -return ; - - dir =fdopendir (fdir); -if (!dir) { -close (fdir); -return ; - } - -while ((dirent =readdir (dir))) { -char buf[PATH_MAX ]; - -if (strcmp (dirent->d_name,"crtc-" ) !=0 ) -continue ; - -sprintf (buf,"%s/crc/control" , dirent->d_name); - fd =openat (fdir, buf,O_WRONLY ); -if (fd <0 ) -continue ; - -igt_assert_eq (write (fd, cmd,strlen (cmd)),strlen (cmd)); -close (fd); - - done = true; - } -closedir (dir); - -if (!done) { - fd =openat (fdir,"i915_display_crtc_ctl" ,O_WRONLY ); -if (fd !=-1 ) { -igt_pipe_crc_pipe_off (fd,PIPE_A ); -igt_pipe_crc_pipe_off (fd,PIPE_B ); -igt_pipe_crc_pipe_off (fd,PIPE_C ); - -close (fd); - } - } - -close (fdir); -} - -static void pipe_crc_exit_handler (int sig) -{ -struct dirent *dirent; -char buf[PATH_MAX ]; -DIR *dir; -int fd; - - dir =opendir ("/dev/dri" ); -if (!dir) -return ; - -/* -* Try to reset CRC capture for all DRM devices, this is only needed -* for the legacy CRC ABI and can be completely removed once the -* legacy codepaths are removed. -*/ -while ((dirent =readdir (dir))) { -if (strncmp (dirent->d_name,"card" ,4 ) !=0 ) -continue ; - -sprintf (buf,"/dev/dri/%s" , dirent->d_name); - fd =open (buf,O_WRONLY ); - -igt_pipe_crc_reset (fd); - -close (fd); - } -closedir (dir); -} -/** * igt_require_pipe_crc: * @@ -582,20 +454,15 @@ static void pipe_crc_exit_handler(int sig)*/ void igt_require_pipe_crc (int fd) { -const char *cmd ="pipe A none" ; -int ctl, written; - - ctl =igt_debugfs_open (fd,"crtc-0/crc/control" ,O_RDONLY ); -if (ctl <0 ) { - ctl =igt_debugfs_open (fd,"i915_display_crc_ctl" ,O_WRONLY ); -igt_require_f (ctl, -"No display_crc_ctl found, kernel too old\n" ); - - written =write (ctl, cmd,strlen (cmd)); -igt_require_f (written <0 , -"CRCs not supported on this platform\n" ); - } -close (ctl); +int dir; +struct stat stat; + + dir =igt_debugfs_dir (fd); +igt_require_f (dir >=0 ,"Could not open debugfs directory\n" ); +igt_require_f (fstatat (dir,"crtc-0/crc/control" , &stat,0 ) ==0 , +"CRCs not supported on this platform\n" ); + +close (dir); }static void igt_hpd_storm_exit_handler (int sig)@@ -729,29 +596,13 @@ pipe_crc_new(int fd, enum pipe pipe, enum intel_pipe_crc_source source, int flag debugfs =igt_debugfs_dir (fd);igt_assert (debugfs !=-1 ); -igt_install_exit_handler (pipe_crc_exit_handler); - pipe_crc =calloc (1 ,sizeof (struct _igt_pipe_crc ));sprintf (buf,"crtc-%d/crc/control" , pipe); pipe_crc->ctl_fd =openat (debugfs, buf,O_WRONLY ); -if (pipe_crc->ctl_fd ==-1 ) { - pipe_crc->ctl_fd =openat (debugfs, -"i915_display_crc_ctl" ,O_WRONLY ); -igt_assert (pipe_crc->ctl_fd !=-1 ); - pipe_crc->is_legacy = true; - } - -if (pipe_crc->is_legacy) { -sprintf (buf,"i915_pipe_%s_crc" ,kmstest_pipe_name (pipe)); - pipe_crc->crc_fd =openat (debugfs, buf, flags); -igt_assert (pipe_crc->crc_fd !=-1 ); -igt_debug ("Using legacy frame CRC ABI\n" ); - }else { - pipe_crc->crc_fd =-1 ; -igt_debug ("Using generic frame CRC ABI\n" ); - } +igt_assert (pipe_crc->ctl_fd !=-1 ); + pipe_crc->crc_fd =-1 ; pipe_crc->fd = fd; pipe_crc->dir = debugfs; pipe_crc->pipe = pipe;@@ -817,18 +668,9 @@ void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)static bool pipe_crc_init_from_string (igt_pipe_crc_t *pipe_crc,igt_crc_t *crc,const char *line) { -int n, i; +int i;const char *buf; -if (pipe_crc->is_legacy) { - crc->has_valid_frame = true; - crc->n_words =5 ; - n =sscanf (line,"%8u %8x %8x %8x %8x %8x" , &crc->frame, - &crc->crc[0 ], &crc->crc[1 ], &crc->crc[2 ], - &crc->crc[3 ], &crc->crc[4 ]); -return n ==6 ; - } -if (strncmp (line,"XXXXXXXXXX" ,10 ) ==0 ) crc->has_valid_frame = false;else {@@ -849,15 +691,9 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out) {ssize_t bytes_read;char buf[MAX_LINE_LEN +1 ]; -size_t read_len; - -if (pipe_crc->is_legacy) - read_len =LEGACY_LINE_LEN ; -else - read_len =MAX_LINE_LEN ;igt_set_timeout (5 ,"CRC reading" ); - bytes_read =read (pipe_crc->crc_fd, &buf, read_len); + bytes_read =read (pipe_crc->crc_fd, &buf,MAX_LINE_LEN );igt_reset_timeout ();if (bytes_read <0 && errno ==EAGAIN )@@ -888,22 +724,19 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)*/ void igt_pipe_crc_start (igt_pipe_crc_t *pipe_crc) { -igt_crc_t crc; - -igt_assert (igt_pipe_crc_do_start (pipe_crc)); - -if (pipe_crc->is_legacy) { -/* -* For some no yet identified reason, the first CRC is -* bonkers. So let's just wait for the next vblank and read -* out the buggy result. -* -* On CHV sometimes the second CRC is bonkers as well, so -* don't trust that one either. -*/ -read_one_crc (pipe_crc, &crc); -read_one_crc (pipe_crc, &crc); - } +const char *src =pipe_crc_source_name (pipe_crc->source); +char buf[32 ]; + +/* Stop first just to make sure we don't have lingering state left. */ +igt_pipe_crc_stop (pipe_crc); + +igt_assert_eq (write (pipe_crc->ctl_fd, src,strlen (src)),strlen (src)); + +sprintf (buf,"crtc-%d/crc/data" , pipe_crc->pipe); + + pipe_crc->crc_fd =openat (pipe_crc->dir, buf, pipe_crc->flags); +igt_assert (pipe_crc->crc_fd !=-1 ); + errno =0 ; }/** @@ -914,16 +747,8 @@ void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)*/ void igt_pipe_crc_stop (igt_pipe_crc_t *pipe_crc) { -char buf[32 ]; - -if (pipe_crc->is_legacy) { -sprintf (buf,"pipe %s none" ,kmstest_pipe_name (pipe_crc->pipe)); -igt_assert_eq (write (pipe_crc->ctl_fd, buf,strlen (buf)), -strlen (buf)); - }else { -close (pipe_crc->crc_fd); - pipe_crc->crc_fd =-1 ; - } +close (pipe_crc->crc_fd); + pipe_crc->crc_fd =-1 ; }/** Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 27-10-17 om 09:39 schreef Jani Nikula:
Quoted 7 lines · James Ausmus
Quoted 6 lines · Maarten Lankhorst
Quoted 5 lines
In kernel v4.10 the legacy crc api has been replaced by a generic drm crc API. While at it, fix
igt_require_pipe_crc, the file cannot be opened any more when the crtc is not active after kernel commit8038e09be5a3("drm/crc: Only open CRC on atomic drivers when the CRTC is active."). Statting the file should be enough for testing it's supported.
Quoted 5 lines
Quoted 2 lines
What's the impact of this change on devices running older kernels - such as KBL ChromeOS on 4.4?
If you backport kernel features, you either also backport the new kernel CRC API, or forward port the igt support for the legacy debugfs if you want to use latest upstream igt?
It's part of the DRM api. Either you're using the old v4.4 kernel in which case a lot of tests in IGT would have already failed, or when you backport you backport the drm module too. Too much has changed between v4.4 and drm-tip, there's no way you can just grab a current snapshot of the driver and expect it to work in v4.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Petri Latvala
Acked-byQuoted 14 lines · Maarten Lankhorst
Op 27-10-17 om 09:39 schreef Jani Nikula:
Quoted 7 lines · James Ausmus
Quoted 6 lines · Maarten Lankhorst
Quoted 5 lines
In kernel v4.10 the legacy crc api has been replaced by a generic drm crc API. While at it, fix
igt_require_pipe_crc, the file cannot be opened any more when the crtc is not active after kernel commit8038e09be5a3("drm/crc: Only open CRC on atomic drivers when the CRTC is active."). Statting the file should be enough for testing it's supported.Quoted 5 lines
Quoted 2 lines
What's the impact of this change on devices running older kernels - such as KBL ChromeOS on 4.4?
If you backport kernel features, you either also backport the new kernel CRC API, or forward port the igt support for the legacy debugfs if you want to use latest upstream igt?
Quoted 5 lines
It's part of the DRM api. Either you're using the old v4.4 kernel in which case a lot of tests in IGT would have already failed, or when you backport you backport the drm module too. Too much has changed between v4.4 and drm-tip, there's no way you can just grab a current snapshot of the driver and expect it to work in v4.4
Fair enough.
This is
but someone(tm) should volunteer to review the actual changes.
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 27-10-17 om 14:25 schreef Petri Latvala:
Quoted 20 lines · Maarten Lankhorst
Quoted 10 lines
Op 27-10-17 om 09:39 schreef Jani Nikula:
Quoted 9 lines · James Ausmus
Quoted 8 lines · Maarten Lankhorst
Quoted 5 lines
In kernel v4.10 the legacy crc api has been replaced by a generic drm crc API. While at it, fix
igt_require_pipe_crc, the file cannot be opened any more when the crtc is not active after kernel commit8038e09be5a3("drm/crc: Only open CRC on atomic drivers when the CRTC is active."). Statting the file should be enough for testing it's supported.What's the impact of this change on devices running older kernels - such as KBL ChromeOS on 4.4?
Quoted 8 lines
Quoted 3 lines
If you backport kernel features, you either also backport the new kernel CRC API, or forward port the igt support for the legacy debugfs if you want to use latest upstream igt?
It's part of the DRM api. Either you're using the old v4.4 kernel in which case a lot of tests in IGT would have already failed, or when you backport you backport the drm module too. Too much has changed between v4.4 and drm-tip, there's no way you can just grab a current snapshot of the driver and expect it to work in v4.4
Quoted 6 lines
Fair enough.
This is
Acked-by Petri Latvala <[email protected]>but someone(tm) should volunteer to review the actual changes.
Pushed, thanks for review. :)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx