From 76be0834849846f7d801b75fe30166047c09d9b2 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Thu, 2 Nov 2017 13:56:33 +0100 Subject: lib/igt_debugfs: Use fstat instead of open for testing CRC support. commit 8038e09be5a3ac06 ("drm/crc: Only open CRC on atomic drivers when the CRTC is active.") rejects opens on the CRC when the CRTC is not configured. Use fstat instead to check this file exists, so we don't accidentally rely on the legacy CRC path. Signed-off-by: Maarten Lankhorst Reviewed-by: Daniel Vetter #irc --- lib/igt_debugfs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/igt_debugfs.c') diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 8b33b478..a7f01d0e 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -584,9 +584,15 @@ void igt_require_pipe_crc(int fd) { const char *cmd = "pipe A none"; int ctl, written; + int dir, ret; + struct stat stat; + + dir = igt_debugfs_dir(fd); + igt_require_f(dir >= 0, "Could not open debugfs directory\n"); + ret = fstatat(dir, "crtc-0/crc/control", &stat, 0); + close(dir); - ctl = igt_debugfs_open(fd, "crtc-0/crc/control", O_RDONLY); - if (ctl < 0) { + if (ret < 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"); @@ -594,8 +600,8 @@ void igt_require_pipe_crc(int fd) written = write(ctl, cmd, strlen(cmd)); igt_require_f(written < 0, "CRCs not supported on this platform\n"); + close(ctl); } - close(ctl); } static void igt_hpd_storm_exit_handler(int sig) -- cgit v1.2.3