[igt-dev] [PATCH i-g-t] lib/chamelium: Ping the chamelium before use
Chris Wilson
chris at chris-wilson.co.uk
Sat Jul 28 11:16:55 UTC 2018
Check we can talk to the device before hitting any asserts.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
lib/igt_chamelium.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index b8418e13e..fe5c4dac5 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1520,6 +1520,26 @@ static bool chamelium_read_config(struct chamelium *chamelium, int drm_fd)
return chamelium_read_port_mappings(chamelium, drm_fd);
}
+static bool __chamelium_reset(struct chamelium *chamelium)
+{
+ xmlrpc_value *res;
+
+ /* Cleanup the last error, if any */
+ if (chamelium->env.fault_occurred) {
+ xmlrpc_env_clean(&chamelium->env);
+ xmlrpc_env_init(&chamelium->env);
+ }
+
+ xmlrpc_client_call2f(&chamelium->env, chamelium->client,
+ chamelium->url, "Reset", "()", &res);
+
+ if (chamelium->env.fault_occurred)
+ return false;
+
+ xmlrpc_DECREF(res);
+ return true;
+}
+
/**
* chamelium_reset:
* @chamelium: The Chamelium instance to use
@@ -1530,7 +1550,7 @@ static bool chamelium_read_config(struct chamelium *chamelium, int drm_fd)
void chamelium_reset(struct chamelium *chamelium)
{
igt_debug("Resetting the chamelium\n");
- xmlrpc_DECREF(chamelium_rpc(chamelium, NULL, "Reset", "()"));
+ igt_assert(__chamelium_reset(chamelium));
}
static void chamelium_exit_handler(int sig)
@@ -1582,6 +1602,10 @@ struct chamelium *chamelium_init(int drm_fd)
goto error;
}
+ /* Ping the device before use and reset it to defaults */
+ if (!__chamelium_reset(chamelium))
+ goto error;
+
if (!chamelium_read_config(chamelium, drm_fd))
goto error;
--
2.18.0
More information about the igt-dev
mailing list