From patchwork Tue Jun 27 10:53:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowki X-Patchwork-Id: 9811373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 238286020A for ; Tue, 27 Jun 2017 10:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 166A828548 for ; Tue, 27 Jun 2017 10:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0903D285E8; Tue, 27 Jun 2017 10:53:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53F83285EC for ; Tue, 27 Jun 2017 10:53:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B7F889FEA; Tue, 27 Jun 2017 10:53:25 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6072989FEA for ; Tue, 27 Jun 2017 10:53:24 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2017 03:53:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,399,1493708400"; d="scan'208";a="985661347" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 27 Jun 2017 03:53:23 -0700 Received: from workstation.fi.intel.com (workstation.fi.intel.com [10.237.68.144]) by linux.intel.com (Postfix) with ESMTP id 20FE1580351; Tue, 27 Jun 2017 03:53:21 -0700 (PDT) From: Paul Kocialkowski To: intel-gfx@lists.freedesktop.org Date: Tue, 27 Jun 2017 13:53:06 +0300 Message-Id: <20170627105311.28975-2-paul.kocialkowski@linux.intel.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170627105311.28975-1-paul.kocialkowski@linux.intel.com> References: <20170627105311.28975-1-paul.kocialkowski@linux.intel.com> Cc: Lyude Subject: [Intel-gfx] [PATCH i-g-t v2 2/7] chamelium: Add support for HPD toggle scheduling instead of async pulses X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This adds support for the newly-introduced ScheduleHpdToggle XMLRPC method of the Chamelium's interface and makes use of it instead of starting pulses with an asynchronous call, suspending and dealing with the result at resume. The XMLRPC library does not guarantee that the call will be made before caring for its outcome and this is in fact what was happening: the call was being delayed until resume time, as can be seen from the Chamelium's logs. The quite generous timeout for HPD event detection would then catch the toggle, that was sent after resume. This is especially useful for testing HPD during suspend/resume. Signed-off-by: Paul Kocialkowski --- lib/igt_chamelium.c | 78 ++++++++++------------------------------------------- lib/igt_chamelium.h | 7 +++-- tests/chamelium.c | 13 +++++---- 3 files changed, 23 insertions(+), 75 deletions(-) diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c index 4a2af796..225f98c3 100644 --- a/lib/igt_chamelium.c +++ b/lib/igt_chamelium.c @@ -447,76 +447,26 @@ void chamelium_fire_mixed_hpd_pulses(struct chamelium *chamelium, xmlrpc_DECREF(pulse_widths); } -static void async_rpc_handler(const char *server_url, const char *method_name, - xmlrpc_value *param_array, void *user_data, - xmlrpc_env *fault, xmlrpc_value *result) -{ - /* We don't care about the responses */ -} - /** - * chamelium_async_hpd_pulse_start: + * chamelium_schedule_hpd_toggle: * @chamelium: The Chamelium instance to use * @port: The port to fire the HPD pulses on - * @high: Whether to fire a high pulse (e.g. simulate a connect), or a low - * pulse (e.g. simulate a disconnect) - * @delay_secs: How long to wait before sending the HPD pulse. - * - * Instructs the chamelium to send an hpd pulse after @delay_secs seconds have - * passed, without waiting for the chamelium to finish. This is useful for - * testing things such as hpd after a suspend/resume cycle, since we can't tell - * the chamelium to send a hotplug at the same time that our system is - * suspended. - * - * It is required that the user eventually call - * #chamelium_async_hpd_pulse_finish, to clean up the leftover XML-RPC - * responses from the chamelium. - */ -void chamelium_async_hpd_pulse_start(struct chamelium *chamelium, - struct chamelium_port *port, - bool high, int delay_secs) -{ - xmlrpc_value *pulse_widths = xmlrpc_array_new(&chamelium->env), *width; - - /* TODO: Actually implement something in the chameleon server to allow - * for delayed actions such as hotplugs. This would work a bit better - * and allow us to test suspend/resume on ports without hpd like VGA - */ - - igt_debug("Sending HPD pulse (%s) on %s with %d second delay\n", - high ? "high->low" : "low->high", port->name, delay_secs); - - /* If we're starting at high, make the first pulse width 0 so we keep - * the port connected */ - if (high) { - width = xmlrpc_int_new(&chamelium->env, 0); - xmlrpc_array_append_item(&chamelium->env, pulse_widths, width); - xmlrpc_DECREF(width); - } - - width = xmlrpc_int_new(&chamelium->env, delay_secs * 1000); - xmlrpc_array_append_item(&chamelium->env, pulse_widths, width); - xmlrpc_DECREF(width); - - xmlrpc_client_start_rpcf(&chamelium->env, chamelium->client, - chamelium->url, - "FireMixedHpdPulses", async_rpc_handler, NULL, - "(iA)", port->id, pulse_widths); - xmlrpc_DECREF(pulse_widths); -} - -/** - * chamelium_async_hpd_pulse_finish: - * @chamelium: The Chamelium instance to use + * @delay_ms: Delay in milli-second before the toggle takes place + * @rising_edge: Whether the toggle should be a rising edge or a falling edge * - * Waits for any asynchronous RPC started by #chamelium_async_hpd_pulse_start - * to complete, and then cleans up any leftover responses from the chamelium. - * If all of the RPC calls have already completed, this function returns - * immediately. + * Instructs the chamelium to schedule an hpd toggle (either a rising edge or + * a falling edge, depending on @rising_edg) after @delay_ms have passed. + * This is useful for testing things such as hpd after a suspend/resume cycle. */ -void chamelium_async_hpd_pulse_finish(struct chamelium *chamelium) +void chamelium_schedule_hpd_toggle(struct chamelium *chamelium, + struct chamelium_port *port, int delay_ms, + bool rising_edge) { - xmlrpc_client_event_loop_finish(chamelium->client); + igt_debug("Scheduling HPD toggle on %s in %d ms\n", port->name, + delay_ms); + + xmlrpc_DECREF(chamelium_rpc(chamelium, NULL, "ScheduleHpdToggle", + "(iii)", port->id, delay_ms, rising_edge)); } /** diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h index 15f60246..81322ad2 100644 --- a/lib/igt_chamelium.h +++ b/lib/igt_chamelium.h @@ -61,10 +61,9 @@ void chamelium_fire_mixed_hpd_pulses(struct chamelium *chamelium, void chamelium_fire_hpd_pulses(struct chamelium *chamelium, struct chamelium_port *port, int width_msec, int count); -void chamelium_async_hpd_pulse_start(struct chamelium *chamelium, - struct chamelium_port *port, - bool high, int delay_secs); -void chamelium_async_hpd_pulse_finish(struct chamelium *chamelium); +void chamelium_schedule_hpd_toggle(struct chamelium *chamelium, + struct chamelium_port *port, int delay_ms, + bool rising_edge); int chamelium_new_edid(struct chamelium *chamelium, const unsigned char *edid); void chamelium_port_set_edid(struct chamelium *chamelium, struct chamelium_port *port, int edid_id); diff --git a/tests/chamelium.c b/tests/chamelium.c index f1addb0f..04e7e379 100644 --- a/tests/chamelium.c +++ b/tests/chamelium.c @@ -226,25 +226,24 @@ try_suspend_resume_hpd(data_t *data, struct chamelium_port *port, igt_flush_hotplugs(mon); if (port) { - chamelium_async_hpd_pulse_start(data->chamelium, port, - connected, - SUSPEND_RESUME_DELAY / 2); + chamelium_schedule_hpd_toggle(data->chamelium, port, + SUSPEND_RESUME_DELAY * 1000 / 2, + !connected); } else { for (p = 0; p < data->port_count; p++) { port = data->ports[p]; if (chamelium_port_get_type(port) == DRM_MODE_CONNECTOR_VGA) continue; - chamelium_async_hpd_pulse_start(data->chamelium, port, - connected, - SUSPEND_RESUME_DELAY / 2); + chamelium_schedule_hpd_toggle(data->chamelium, port, + SUSPEND_RESUME_DELAY * 1000 / 2, + !connected); } port = NULL; } igt_system_suspend_autoresume(state, test); - chamelium_async_hpd_pulse_finish(data->chamelium); igt_assert(igt_hotplug_detected(mon, HOTPLUG_TIMEOUT)); if (port) {