[igt-dev] [PATCH i-g-t 1/2] lib/sysfs: Fix fbcon unbind, again

Ville Syrjala ville.syrjala at linux.intel.com
Mon Mar 5 12:54:16 UTC 2018


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Looks like unbinding the dummy con doesn't work on all machines. Instead
we have to bind fbcon (which is what we used to do before commit
d18fca7f6cf3 ("lib/sysfs: Fix fbcon rebind")). Since some machines need
the bind and others need the unbind let's do both. The most obvious
difference I observed between two machines that behave differently
was the order in which the console drivers were listed in sysfs.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_sysfs.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index f8aae9d5c695..3b8308118432 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -503,14 +503,7 @@ bool igt_sysfs_set_boolean(int dir, const char *attr, bool value)
 	return igt_sysfs_printf(dir, attr, "%d", value) == 1;
 }
 
-/**
- * kick_fbcon:
- * @enable: boolean value
- *
- * This functions enables/disables the text console running on top of the
- * framebuffer device.
- */
-void kick_fbcon(bool enable)
+static void bind_con(const char *name, bool enable)
 {
 	const char *path = "/sys/class/vtconsole";
 	DIR *dir;
@@ -538,20 +531,39 @@ void kick_fbcon(bool enable)
 		if (len >= 0)
 			buf[len] = '\0';
 
-		if (!strstr(buf, enable ? "dummy device" :
-			    "frame buffer device"))
+		if (!strstr(buf, name))
 			continue;
 
 		sprintf(buf, "%s/%s/bind", path, de->d_name);
 		fd = open(buf, O_WRONLY);
 		if (fd != -1) {
-			igt_ignore_warn(write(fd, "0\n", 2));
+			igt_ignore_warn(write(fd, enable ? "1\n" : "0\n", 2));
 			close(fd);
 		}
+		break;
 	}
 	closedir(dir);
 }
 
+/**
+ * kick_fbcon:
+ * @enable: boolean value
+ *
+ * This functions enables/disables the text console running on top of the
+ * framebuffer device.
+ */
+void kick_fbcon(bool enable)
+{
+	/*
+	 * The vtcon bind interface seems somewhat broken. Possibly
+	 * depending on the order the console drivers have been
+	 * registered you either have to unbind the old driver,
+	 * or bind the new driver. Let's do both.
+	 */
+	bind_con("dummy device", !enable);
+	bind_con("frame buffer device", enable);
+}
+
 /**
  * kick_snd_hda_intel:
  *
-- 
2.16.1



More information about the igt-dev mailing list