[igt-dev] [PATCH i-g-t v2 2/4] lib: Convert igt_hotplug_detected to msec
José Roberto de Souza
jose.souza at intel.com
Fri Jun 28 21:40:07 UTC 2019
A future test will need a smaller timeout than 1sec for
igt_hotplug_detected().
Signed-off-by: José Roberto de Souza <jose.souza at 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
More information about the igt-dev
mailing list