[igt-dev] [PATCH i-g-t] lib/chamelium: Ping the chamelium before use

Chris Wilson chris at chris-wilson.co.uk
Sat Jul 28 09:30:17 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 | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index b8418e13e..15f9b870c 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1520,6 +1520,23 @@ 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_va(&chamelium->env, chamelium->client,
+				chamelium->url, "Reset", "()", &res);
+	xmlrpc_DECREF(res);
+
+	return !chamelium->env.fault_occurred;
+}
+
 /**
  * chamelium_reset:
  * @chamelium: The Chamelium instance to use
@@ -1530,7 +1547,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 +1599,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