public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: clinton.a.taylor@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH v2 i-g-t] tests/kms: increase max threshold time for edid read
Date: Wed,  9 Aug 2017 15:04:22 -0700	[thread overview]
Message-ID: <1502316262-7586-1-git-send-email-clinton.a.taylor@intel.com> (raw)
In-Reply-To: <20170807162026.37wa7j4mcjqxpytx@phenom.ffwll.local>

From: Clint Taylor <clinton.a.taylor@intel.com>

Current 50ms max threshold timing for an EDID read is very close to the
actual time for a 2 block HDMI EDID read. Adjust the timings base on
connector type as DP reads are at 1 MBit and HDMI at 100K bit. If an LSPcon
is connected to device under test the -l option should be passed to update
the threshold timing to allow the LSPcon to read the EDID at the HDMI
timing. The -l option should be used when LSPcon is on the motherboard or
if a USB_C->HDMI converter is present

V2: Adjust timings based on connector type, EDID size, and Add an option to
specify if an LSPcon is present.

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Marta Lofstedt <marta.lofstedt@intel.com>
Signed-off-by: Clint Taylor <clinton.a.taylor@intel.com>
---
 tests/kms_sysfs_edid_timing.c | 76 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 62 insertions(+), 14 deletions(-)

diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 1201388..441dfee 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -26,21 +26,46 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 
-#define THRESHOLD_PER_CONNECTOR	10
-#define THRESHOLD_TOTAL		50
-#define CHECK_TIMES		15
+#define THRESHOLD_FOR_EMPTY_CONNECTOR	10
+#define THRESHOLD_PER_EDID_BLOCK		5
+#define HDMI_THRESHOLD_MULTIPLIER		10
+#define CHECK_TIMES				10
 
 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");
+		     "we sometimes take a *really* long time. So let's check "
+		     "an approximate time per edid block based on connector "
+		     "type. The -l option adjusts DP timing to reflect HDMI read "
+		     "timings from LSPcon.");
+
+/* The -l option has been added to correctly handle timings when an LSPcon is
+ * present. This could be on the platform itself or in a USB_C->HDMI converter.
+ * With LSPCon EDID read timing will need to change from the 1 Mbit AUX
+ * bus speed to the 100 Kbit HDMI DDC bus speed
+ */
+bool lspcon_present;
 
+static int opt_handler(int opt, int opt_index, void *data)
+{
+	if (opt == 'l') {
+		lspcon_present = true;
+		igt_info("set LSPcon present on DP ports\n");
+	}
 
-igt_simple_main
+	return 0;
+}
+
+int main(int argc, char **argv)
 {
 	DIR *dirp;
 	struct dirent *de;
+	lspcon_present = false;
+
+	igt_simple_init_parse_opts(&argc, argv, "l", NULL, NULL,
+				      opt_handler, NULL);
+
+	igt_skip_on_simulation();
 
 	dirp = opendir("/sys/class/drm");
 	igt_assert(dirp != NULL);
@@ -49,17 +74,36 @@ igt_simple_main
 		struct igt_mean mean = {};
 		struct stat st;
 		char path[PATH_MAX];
-		int i;
+		char edid_path[PATH_MAX];
+		char edid[512]; /* enough for 4 block edid */
+		unsigned long edid_size = 0;
+		int i, fd_edid;
+		unsigned int threshold = 0;
 
 		if (*de->d_name == '.')
 			continue;;
 
 		snprintf(path, sizeof(path), "/sys/class/drm/%s/status",
 				de->d_name);
+		snprintf(edid_path, sizeof(edid_path), "/sys/class/drm/%s/edid",
+				de->d_name);
 
 		if (stat(path, &st))
 			continue;
 
+		fd_edid = open(edid_path, O_RDONLY);
+		if (fd_edid == -1) {
+			igt_warn("Read Error EDID\n");
+			continue;
+		}
+
+		edid_size = read(fd_edid, edid, 512);
+		threshold = THRESHOLD_PER_EDID_BLOCK * (edid_size / 128);
+		if (lspcon_present || (edid_size > 128 &&
+		    !strncmp(de->d_name, "card0-HDMI", 10))) {
+			threshold *= HDMI_THRESHOLD_MULTIPLIER;
+		}
+
 		igt_mean_init(&mean);
 		for (i = 0; i < CHECK_TIMES; i++) {
 			struct timespec ts = {};
@@ -76,22 +120,26 @@ igt_simple_main
 		}
 
 		igt_debug("%s: mean.max %.2fns, %.2fus, %.2fms, "
-			  "mean.avg %.2fns, %.2fus, %.2fms\n",
+			  "mean.avg %.2fns, %.2fus, %.2fms, "
+			  "edid_size %lu, threshold %d\n",
 			  de->d_name,
 			  mean.max, mean.max / 1e3, mean.max / 1e6,
-			  mean.mean, mean.mean / 1e3, mean.mean / 1e6);
+			  mean.mean, mean.mean / 1e3, mean.mean / 1e6,
+			  edid_size, threshold);
 
-		if (mean.max > (THRESHOLD_PER_CONNECTOR * 1e6)) {
+		if (edid_size == 0 &&
+		   (mean.max > (THRESHOLD_FOR_EMPTY_CONNECTOR * 1e6))) {
 			igt_warn("%s: probe time exceed 10ms, "
 				 "max=%.2fms, avg=%.2fms\n", de->d_name,
 				 mean.max / 1e6, mean.mean / 1e6);
 		}
-		igt_assert_f(mean.mean < (THRESHOLD_TOTAL * 1e6),
-			     "%s: average probe time exceeded 50ms, "
-			     "max=%.2fms, avg=%.2fms\n", de->d_name,
+		if (edid_size > 0)
+			igt_assert_f(mean.mean < (threshold * 1e6),
+			     "%s: average probe time exceeded %dms, "
+			     "max=%.2fms, avg=%.2fms\n", de->d_name, threshold,
 			     mean.max / 1e6, mean.mean / 1e6);
 
 	}
 	closedir(dirp);
-
+	igt_exit();
 }
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-08-09 22:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 18:23 [PATCH i-g-t] tests/kms: increase max threshold time for edid read clinton.a.taylor
2017-08-07 16:20 ` Daniel Vetter
2017-08-09 22:04   ` clinton.a.taylor [this message]
2017-08-09 22:51   ` [PATCH v3 " clinton.a.taylor
2017-08-10  6:40     ` Lofstedt, Marta
2017-08-10  7:00     ` Lofstedt, Marta
2017-08-10 16:29       ` Clint Taylor
2017-08-10 17:50       ` [PATCH v4 " clinton.a.taylor
2017-08-11  7:49         ` Lofstedt, Marta
2017-08-11 16:36           ` Clint Taylor
2017-08-14  5:47             ` Lofstedt, Marta
2017-08-14  8:43             ` Jani Nikula
2017-08-14 14:36               ` Daniel Vetter
2017-08-14 15:30                 ` Jani Nikula
2017-08-14 15:36                   ` Daniel Vetter
2017-08-14 16:05                     ` Jani Nikula
2017-08-14 14:40         ` Daniel Vetter
2017-08-14 17:21           ` Clint Taylor
2017-08-15  7:58             ` Daniel Vetter
2017-08-15 18:04               ` Clint Taylor
2017-08-18  7:59                 ` Daniel Vetter
2017-10-09  7:05                   ` Lofstedt, Marta
2017-08-09 23:21   ` [PATCH " Chris Wilson
2017-08-08  7:51 ` Lofstedt, Marta
2017-08-09  0:15   ` Clint Taylor
2017-08-09 22:29 ` ✓ Fi.CI.BAT: success for tests/kms: increase max threshold time for edid read (rev2) Patchwork
2017-08-09 23:15 ` ✓ Fi.CI.BAT: success for tests/kms: increase max threshold time for edid read (rev3) Patchwork
2017-08-11 12:18 ` ✓ Fi.CI.BAT: success for tests/kms: increase max threshold time for edid read (rev5) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502316262-7586-1-git-send-email-clinton.a.taylor@intel.com \
    --to=clinton.a.taylor@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox