From 987f58240c7841abc090a84ce8fa7ebfe8fd4985 Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Sun, 4 Mar 2018 04:17:54 +0200 Subject: lib/sysfs: Fix fbcon unbind, again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ä Reviewed-by: Chris Wilson --- 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 f8aae9d5..3b830811 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: * -- cgit v1.2.3