From patchwork Mon May 14 15:53:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 135740 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1952193lji; Mon, 14 May 2018 08:53:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrZ0Ycbte1UtnkIbSdIPtweHjlFlAzRDnCN+VHWAFBZgLo3DVRhdioD2YoKmr4IE6IQpQlJ X-Received: by 2002:a63:b647:: with SMTP id v7-v6mr6699619pgt.181.1526313191415; Mon, 14 May 2018 08:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526313191; cv=none; d=google.com; s=arc-20160816; b=CIVO8fOmL70t5o5HXFwAmxvU0okp94iV9jvyIC35Xv3FZJ1MAeURStXHMzOJkUpJvk GH6MqMtFgFmI0H53nMnilUdJLa7of6DrpGQ+wpU4phPxUSyV+WI9JM0o8cXtW4ulkOhx YLQaqaRvDrziqOK9BzF6v8rxDhHoYswubGzfcRD9j3RyGz1hnGwIRRNgQ5+pHAGwJfQi zC6H2e+1aLH+hYx3yrwHb7SNsEA/aINifxJHWpCNLJ8DlTmo826o+GkYvUg8vaayOTtC JMnIp93kl1pjMppK23S1I68n5JxE1Yq00QR/d575RMSVRlUVfhzUJs3lbDXquO52QUrt WobA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=DRRSnMOUQlPBs6alvaV1BDSUU6F3rYOTWVcRvJ8/D8Q=; b=WSTmHuvHxhztvjcNt4FAnZvMURk20K95Dma6P5DyXlZy04qK6ib4cd61Tc2qIngRVo p1f+SOLD1o599ZUw4Ml7WwRwMJmhLm7VFGjMPx07MHPM8b4NVbpXEGfKTNiBglz3/jRJ mThL8vfTu+BDL1P/UrCxlwSJFaGLtacYxYH0EJYLzLUyqsfe1VhZSr/lmpnaikWtmljU SgQZEn41Edvc40D5hc8FdWXBdDBEK5AkCmKyysSXlIGwZlrBomduhmjX3G9RuNXIVbRO yqI7cllUaYmoj6Q+ShdWhioZDl01EuTTmO6ZHcD33hCPnOTpmp1g448uTMkdzJT5VaUq 5m+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YiGgaEKk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f16-v6si9975581pfe.291.2018.05.14.08.53.11; Mon, 14 May 2018 08:53:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YiGgaEKk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752969AbeENPxJ (ORCPT + 29 others); Mon, 14 May 2018 11:53:09 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:46922 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752822AbeENPxG (ORCPT ); Mon, 14 May 2018 11:53:06 -0400 Received: by mail-qt0-f195.google.com with SMTP id m16-v6so16720929qtg.13 for ; Mon, 14 May 2018 08:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=DRRSnMOUQlPBs6alvaV1BDSUU6F3rYOTWVcRvJ8/D8Q=; b=YiGgaEKkPNyiWYnx1qmAoU6qx7kkEFqc6W+5KYfbdJV3PjJNTt/SABii+xZKshoJHH 8KiEvWesMNKBMdv0h/ubvvuN4GrXv+jJHF4Xl43UAcelI7BNv2s8WrC0AXbW5R/s6lKO wo8yJni+oPn72vxPFCUemg7aO1oq0pnetaEVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=DRRSnMOUQlPBs6alvaV1BDSUU6F3rYOTWVcRvJ8/D8Q=; b=HDy27Xt+RoflULJ5SNmx4YFeHhCgLTzVBQRRzInh9T6luZWEYRl8MNma0jmYZ86maN 2b+ueqoiUbygoFWJrPY4HGEqDPIsF7fjcqoOzGv/Q8MC2kP5JKR1AwApZVOxj1IriWn+ /rF7R7Q8KvaDX4PXcllRU5UazLnLXoVbxTdOXE6LYiTKML3bQLVxEFfnhTFoiHWgZz7X 8A78o7Bp51jN+iq913OOTgzc97O6EUo3p/m9T9hNGD9ODepW+x+IvSK+RPV1IEMc4LR4 /JQgEOvL2wVE6W2R8h39WovJwkOZmAYGap+ppTzOcadmum6pd6WY+SVOUp/j7TAuMMQM YvPw== X-Gm-Message-State: ALKqPwfYYiLYGW9Fdh5VRwS9qduYxvtAf/dfIU4q0WzpK32b0UE/lkXD 35cyNqBnT72odmz4PQ5ctYAL2A== X-Received: by 2002:ac8:1933:: with SMTP id t48-v6mr9536232qtj.371.1526313185852; Mon, 14 May 2018 08:53:05 -0700 (PDT) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id g47-v6sm8029129qtk.87.2018.05.14.08.53.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 08:53:04 -0700 (PDT) Date: Mon, 14 May 2018 11:53:04 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman , Jiri Slaby cc: linux-kernel@vger.kernel.org Subject: [PATCH] vt: Performsafe console erase only once Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index f97251f39c..1eb1a376a0 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) 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; @@ -1194,7 +1187,12 @@ static void csi_J(struct vc_data *vc, int vpar) 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; }