Skip to content

Commit 4b4ecd9

Browse files
Nicolas Pitregregkh
authored andcommitted
vt: Perform safe console erase only once
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 339c7a8 commit 4b4ecd9

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/tty/vt/vt.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,23 +1178,21 @@ static void csi_J(struct vc_data *vc, int vpar)
11781178
count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
11791179
start = (unsigned short *)vc->vc_origin;
11801180
break;
1181-
case 3: /* erase scroll-back buffer (and whole display) */
1182-
scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
1183-
vc->vc_screenbuf_size);
1184-
flush_scrollback(vc);
1185-
set_origin(vc);
1186-
if (con_is_visible(vc))
1187-
update_screen(vc);
1188-
/* fall through */
11891181
case 2: /* erase whole display */
1182+
case 3: /* (and scrollback buffer later) */
11901183
count = vc->vc_cols * vc->vc_rows;
11911184
start = (unsigned short *)vc->vc_origin;
11921185
break;
11931186
default:
11941187
return;
11951188
}
11961189
scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1197-
if (con_should_update(vc))
1190+
if (vpar == 3) {
1191+
set_origin(vc);
1192+
flush_scrollback(vc);
1193+
if (con_is_visible(vc))
1194+
update_screen(vc);
1195+
} else if (con_should_update(vc))
11981196
do_update_region(vc, (unsigned long) start, count);
11991197
vc->vc_need_wrap = 0;
12001198
}

0 commit comments

Comments
 (0)