public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [igt-dev] [PATCH i-g-t 1/2] lib/igt_chamelium: Sleep when doing autodiscovery
Date: Wed, 6 May 2020 18:58:02 +0300	[thread overview]
Message-ID: <20200506155803.358220-1-arkadiusz.hiler@intel.com> (raw)

Autodiscovery was wrongly assuming that whenever we do chamelium_plug()
the connector state change is immediate.

It was working most of the time for native connectors, but may explain
some of the flip-flopping skips.

The problem got only more serious with the advent of LSPcons as USB-C,
where we have much things happening on the signal path, introducing
delays.

So for the sake of reliability this change introduces sleep(10) between
plug and reprobe. The number is about 2 * the_most_pathological_case_observed.

Also the discovery step is performed only if there is no static port
mapping set up. After the discovery is done, IGT prints the mapping
ready to be pasted into .igtrc.

Cc: Kunal Joshi <kunal1.joshi@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 lib/igt_chamelium.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index c704b84f..28be5248 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -82,6 +82,14 @@
  *
  */
 
+/*
+ * We cannot expect chamelium_plug() to take effect imediately.
+ *
+ * Especially with modern, more complex hardware where we may have LSPcons and
+ * USB controllers in the way.
+ */
+#define CHAMELIUM_HOTPLUG_DETECTION_DELAY 10
+
 struct chamelium_edid {
 	struct chamelium *chamelium;
 	struct edid *base;
@@ -2231,6 +2239,10 @@ static bool chamelium_autodiscover(struct chamelium *chamelium, int drm_fd)
 		chamelium_plug(chamelium, port);
 	}
 
+	igt_info("Sleeping %d seconds for the hotplug to take effect.\n",
+		 CHAMELIUM_HOTPLUG_DETECTION_DELAY);
+	sleep(CHAMELIUM_HOTPLUG_DETECTION_DELAY);
+
 	/* Reprobe connectors and build the mapping */
 	res = drmModeGetResources(drm_fd);
 	if (!res)
@@ -2448,8 +2460,20 @@ struct chamelium *chamelium_init(int drm_fd)
 	if (!chamelium_read_port_mappings(chamelium, drm_fd))
 		goto error;
 
-	if (!chamelium_autodiscover(chamelium, drm_fd))
-		goto error;
+	if (chamelium->port_count == 0) {
+		igt_info("Chamelium configured without port mapping, "
+			 "performing autodiscovery\n");
+
+		if (!chamelium_autodiscover(chamelium, drm_fd))
+			goto error;
+
+		if (chamelium->port_count != 0)
+			igt_info("\nConsider adding the following to your .igtrc:\n");
+		for (int i = 0; i < chamelium->port_count; ++i) {
+			igt_info("[Chamelium:%s]\n", chamelium->ports[i].name);
+			igt_info("ChameliumPortID=%d\n\n", chamelium->ports[i].id);
+		}
+	}
 
 	cleanup_instance = chamelium;
 	igt_install_exit_handler(chamelium_exit_handler);
-- 
2.25.2

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

             reply	other threads:[~2020-05-06 15:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 15:58 Arkadiusz Hiler [this message]
2020-05-06 15:58 ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_kms: Make igt_display_require() + chamelium more robust Arkadiusz Hiler
2020-05-07 19:53   ` Imre Deak
2020-05-07 20:16     ` Imre Deak
2020-05-08 10:25       ` Arkadiusz Hiler
2020-05-06 16:37 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/igt_chamelium: Sleep when doing autodiscovery Patchwork
2020-05-06 18:59 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2020-05-07 19:05 ` [igt-dev] [PATCH i-g-t 1/2] " Imre Deak

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=20200506155803.358220-1-arkadiusz.hiler@intel.com \
    --to=arkadiusz.hiler@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kunal1.joshi@intel.com \
    /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