Skip to content

Commit

Permalink
vt: Perform safe console erase only once
Browse files Browse the repository at this point in the history
Commit f8df13e ("tty: Clean console safely") added code to clear
both the scrollback buffer and the screen with "\e[3J", then execution
falls through into the code to simply clear the screen. This means
scr_memsetw() and the console driver update callback are called twice
on the whole screen buffer. Let's reorganize the code so the same work
is not performed twice needlessly.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Nicolas Pitre authored and Greg Kroah-Hartman committed May 25, 2018
1 parent 339c7a8 commit 4b4ecd9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions drivers/tty/vt/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,23 +1178,21 @@ static void csi_J(struct vc_data *vc, int vpar)
count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
start = (unsigned short *)vc->vc_origin;
break;
case 3: /* erase scroll-back buffer (and whole display) */
scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
vc->vc_screenbuf_size);
flush_scrollback(vc);
set_origin(vc);
if (con_is_visible(vc))
update_screen(vc);
/* fall through */
case 2: /* erase whole display */
case 3: /* (and scrollback buffer later) */
count = vc->vc_cols * vc->vc_rows;
start = (unsigned short *)vc->vc_origin;
break;
default:
return;
}
scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
if (con_should_update(vc))
if (vpar == 3) {
set_origin(vc);
flush_scrollback(vc);
if (con_is_visible(vc))
update_screen(vc);
} else if (con_should_update(vc))
do_update_region(vc, (unsigned long) start, count);
vc->vc_need_wrap = 0;
}
Expand Down

0 comments on commit 4b4ecd9

Please sign in to comment.