lkml.org 
[lkml]   [2020]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] vt: Fix non-blinking cursor regression
On Wed, 22 Jan 2020, Lukas Wunner wrote:

> Since commit a6dbe4427559 ("vt: perform safe console erase in the right
> order"), when userspace clears both the scrollback buffer and the screen
> by writing "\e[3J" to an fbdev virtual console, the cursor stops blinking
> if that virtual console is not in the foreground. I'm witnessing this
> on every boot of Raspbian since updating to v4.19.37+ because agetty
> writes the sequence to /dev/tty6 while the console is still switched to
> /dev/tty1. Switching consoles once makes the cursor blink again.
>
> The commit added an invocation of ->con_switch() to flush_scrollback().
> Normally this is only invoked from switch_screen() to switch consoles.
> switch_screen() updates *vc->vc_display_fg to the new console and
> fbcon_switch() updates ops->currcon. Because the commit only invokes
> fbcon_switch() but doesn't update *vc->vc_display_fg, it performs an
> incomplete console switch.
>
> When fb_flashcursor() subsequently blinks the cursor, it retrieves the
> foreground console from ops->currcon. Because *vc->vc_display_fg wasn't
> updated, con_is_visible() incorrectly returns false and as a result,
> fb_flashcursor() bails out without blinking the cursor.
>
> The invocation of ->con_switch() appears to have been erroneous. After
> all, why should a console switch be performed when clearing the screen?
> The commit message doesn't provide a rationale either. So delete it.

The problem here is that only vgacon provides a con_flush_scrollback
method. When not provided, the only way to flush the scrollback buffer
is to invoke the switch method. If you remove it the scrollback buffer
of the foreground console won't be flushed in the fb case and possibly
others.

Originally the con_switch method was invoked via update_screen(). The
code rationalization in commit a6dbe4427559 failed to carry over a few
details though.

So I think the actual fix should instead be like this:

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 34aa39d1ae..93314a2f26 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -936,10 +936,13 @@ static void flush_scrollback(struct vc_data *vc)
WARN_CONSOLE_UNLOCKED();

set_origin(vc);
- if (vc->vc_sw->con_flush_scrollback)
+ if (vc->vc_sw->con_flush_scrollback) {
vc->vc_sw->con_flush_scrollback(vc);
- else
+ } else if (con_is_visible(vc)) {
+ hide_cursor(vc);
vc->vc_sw->con_switch(vc);
+ set_cursor(vc);
+ }
}

/*

Nicolas

\
 
 \ /
  Last update: 2020-01-22 17:41    [W:0.084 / U:1.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site