summaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2018-05-14 11:53:04 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-25 12:01:16 -0400
commit4b4ecd9cb853c14913a3726cfcc60ccda1d2924a (patch)
tree21001a5011cdf3b6a1f066b290a22d1989708116 /drivers/tty/vt
parent339c7a875732a34b1ebd7f14e2357c28858cd2d0 (diff)
vt: Perform safe console erase only once
Commit f8df13e0a9 ("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>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/vt.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f97251f39c26..1eb1a376a041 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1178,15 +1178,8 @@ static void csi_J(struct vc_data *vc, int vpar)
1178 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; 1178 count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
1179 start = (unsigned short *)vc->vc_origin; 1179 start = (unsigned short *)vc->vc_origin;
1180 break; 1180 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 */
1189 case 2: /* erase whole display */ 1181 case 2: /* erase whole display */
1182 case 3: /* (and scrollback buffer later) */
1190 count = vc->vc_cols * vc->vc_rows; 1183 count = vc->vc_cols * vc->vc_rows;
1191 start = (unsigned short *)vc->vc_origin; 1184 start = (unsigned short *)vc->vc_origin;
1192 break; 1185 break;
@@ -1194,7 +1187,12 @@ static void csi_J(struct vc_data *vc, int vpar)
1194 return; 1187 return;
1195 } 1188 }
1196 scr_memsetw(start, vc->vc_video_erase_char, 2 * count); 1189 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))
1198 do_update_region(vc, (unsigned long) start, count); 1196 do_update_region(vc, (unsigned long) start, count);
1199 vc->vc_need_wrap = 0; 1197 vc->vc_need_wrap = 0;
1200} 1198}