public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "José Roberto de Souza" <jose.souza@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 2/4] lib: Convert igt_hotplug_detected to msec
Date: Fri, 28 Jun 2019 14:40:07 -0700	[thread overview]
Message-ID: <20190628214009.16962-2-jose.souza@intel.com> (raw)
In-Reply-To: <20190628214009.16962-1-jose.souza@intel.com>

A future test will need a smaller timeout than 1sec for
igt_hotplug_detected().

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
---
 lib/igt_chamelium.c   |  2 +-
 lib/igt_kms.c         | 12 ++++++------
 lib/igt_kms.h         |  4 ++--
 tests/kms_chamelium.c |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index b83ff395..d3ddba6a 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -247,7 +247,7 @@ static void *chamelium_fsm_mon(void *data)
 	 * Wait for the chamelium to try unplugging the connector, otherwise
 	 * the thread calling chamelium_rpc will kill us
 	 */
-	igt_hotplug_detected(args->mon, 60);
+	igt_hotplug_detected(args->mon, MSEC_PER_SEC * 60);
 
 	/*
 	 * Just in case the RPC call being executed returns before we complete
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index dc8992cb..f1b2f346 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -4274,7 +4274,7 @@ struct udev_monitor *igt_watch_hotplug(void)
 	return mon;
 }
 
-static bool event_detected(struct udev_monitor *mon, int timeout_secs,
+static bool event_detected(struct udev_monitor *mon, int timeout_msecs,
 			   const char *property)
 {
 	struct udev_device *dev;
@@ -4290,7 +4290,7 @@ static bool event_detected(struct udev_monitor *mon, int timeout_secs,
 	 * so that redundant hotplug events don't change the results of future
 	 * checks
 	 */
-	while (!hotplug_received && poll(&fd, 1, timeout_secs * 1000)) {
+	while (!hotplug_received && poll(&fd, 1, timeout_msecs)) {
 		dev = udev_monitor_receive_device(mon);
 
 		hotplug_val = udev_device_get_property_value(dev, property);
@@ -4306,15 +4306,15 @@ static bool event_detected(struct udev_monitor *mon, int timeout_secs,
 /**
  * igt_hotplug_detected:
  * @mon: A udev monitor initialized with #igt_watch_hotplug
- * @timeout_secs: How long to wait for a hotplug event to occur.
+ * @timeout_msecs: 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(struct udev_monitor *mon, int timeout_secs)
+bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_msecs)
 {
-	return event_detected(mon, timeout_secs, "HOTPLUG");
+	return event_detected(mon, timeout_msecs, "HOTPLUG");
 }
 
 /**
@@ -4328,7 +4328,7 @@ bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_secs)
  */
 bool igt_lease_change_detected(struct udev_monitor *mon, int timeout_secs)
 {
-	return event_detected(mon, timeout_secs, "LEASE");
+	return event_detected(mon, timeout_secs * MSEC_PER_SEC, "LEASE");
 }
 
 /**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a448a003..16c35ab9 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -767,9 +767,9 @@ const unsigned char *igt_kms_get_dp_audio_edid(void);
 
 struct udev_monitor *igt_watch_hotplug(void);
 bool igt_hotplug_detected(struct udev_monitor *mon,
-			  int timeout_secs);
+			  int timeout_msecs);
 bool igt_lease_change_detected(struct udev_monitor *mon,
-			       int timeout_secs);
+			       int timeout_msecs);
 void igt_flush_hotplugs(struct udev_monitor *mon);
 void igt_cleanup_hotplug(struct udev_monitor *mon);
 
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 7e0cd426..213686bf 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -54,9 +54,9 @@ typedef struct {
 	struct chamelium_edid *edids[TEST_EDID_COUNT];
 } data_t;
 
-#define HOTPLUG_TIMEOUT 20 /* 20 seconds */
+#define HOTPLUG_TIMEOUT (20 * MSEC_PER_SEC) /* 20 seconds */
 
-#define FAST_HOTPLUG_TIMEOUT (1) /* 1 second */
+#define FAST_HOTPLUG_TIMEOUT (MSEC_PER_SEC) /* 1 second */
 
 #define HPD_STORM_PULSE_INTERVAL_DP 100 /* ms */
 #define HPD_STORM_PULSE_INTERVAL_HDMI 200 /* ms */
@@ -2123,7 +2123,7 @@ test_hpd_storm_detect(data_t *data, struct chamelium_port *port, int width)
 	 * so we should only get at most 1 hotplug event
 	 */
 	igt_until_timeout(5)
-		count += igt_hotplug_detected(mon, 1);
+		count += igt_hotplug_detected(mon, FAST_HOTPLUG_TIMEOUT);
 	igt_assert_lt(count, 2);
 
 	igt_cleanup_hotplug(mon);
-- 
2.22.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-06-28 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 21:40 [igt-dev] [PATCH i-g-t v2 1/4] tests/chamelium: Add test for type-c hotplug workaround José Roberto de Souza
2019-06-28 21:40 ` José Roberto de Souza [this message]
2019-06-28 21:40 ` [igt-dev] [PATCH i-g-t v2 3/4] lib: Add new chamelium method: UnplugHPD José Roberto de Souza
2019-06-28 21:40 ` [igt-dev] [PATCH i-g-t v2 4/4] test/chamelium: Add HDMI slow unplug workaround José Roberto de Souza
2019-06-28 23:23 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/4] tests/chamelium: Add test for type-c hotplug workaround Patchwork
2019-06-29 11:31 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20190628214009.16962-2-jose.souza@intel.com \
    --to=jose.souza@intel.com \
    --cc=igt-dev@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