From patchwork Wed May 30 21:27:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 137290 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp5816546lji; Wed, 30 May 2018 14:28:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKOfk/VuQ2KPTacNuC+joumYFL+iWvtxZ4bTfjc3tyHWGNXL/R3w8Vqr3JBW4mFCcD6b5ej X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr4430291pld.72.1527715709274; Wed, 30 May 2018 14:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527715709; cv=none; d=google.com; s=arc-20160816; b=O3rWpnw9Itj65veRqWxMp4cWw2Z+bwff1vFBk5uXQKCInaBXGswjObSoNLS1IHybLf HInittLch5yo8rYnde/FnVbrcxbOf/1Xzdf44pkoiOBTga+8UsKwIyEXlRstJ1NrtPIv u3+PKqNi7es4iH5P1fH98TSqx8VYYHNdZAyBEnu/vafKL5UB6hi1RkCQVJiTEOCcq82f tF8Ikz5vbPZcu+tEfe1fQqkcndiui7YEQBsHFCkNUxUoLsJUaDliX1ubuNiSrcq5ToUc AV0DGx74FWzLQjnu9wTsP1VWkx20usMknxYH6fhNyM83Mj9MyvxB0L4W+0WlhCd/TBib e84w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=KBVCz/A4/QKu+Ny7CChZ6mXS+SUXRx1oIzPCcCSIges=; b=PhXJiAqLh6ZQwMrMwseec0anZBf6v7K+WTjUwQPiVh52AtKY5tsg++mi54BWFZGSds ukHY1pFXDWN9RtOifogJgByWtaRrRfoBKReSWOg+5GH/tNNkA6evCd0KduNGphXcy5pf qzRkE2cFfgKgflFipkXZCJEySH3jbO4lEQ+sX1ZUEy16gvQIBp02qRU+0bFiRN0fgHsQ FriOV0ODfs48XcT36GUnhAhnqd333KyAvoFxvCRMoUvn1fv846lyIJdqK0ZnHdX3G/5M 8SKbN8IIEyM6y7aL/TKnSd0iZh6BHMVS/axe9hQJVYevmX6/97bX4MwXOMvnY4VROPhu RdIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=A408m1D6; 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=fail (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 5-v6si36237263plx.517.2018.05.30.14.28.29; Wed, 30 May 2018 14:28:29 -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=@pobox.com header.s=sasl header.b=A408m1D6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932563AbeE3V20 (ORCPT + 30 others); Wed, 30 May 2018 17:28:26 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:63592 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932382AbeE3V2V (ORCPT ); Wed, 30 May 2018 17:28:21 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 21F89F2C61; Wed, 30 May 2018 17:28:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=uxqV sKozu7t18hByTPZhHNi4yGc=; b=A408m1D6UZarsb02BnCgK77NChzAjkBfDZRD 2rTTg/TKSsKnY6mBkKa08UR8TKRyDcnBF/6vhmPZr+i0t2IIqvoD/ea9TFbo9hVi LI1cjM9YXbNriCPF3KIXTIVheuii8FnhwKYojIgHpYOh/lqb/4J/i2yg8DC1Ly3b fTShDII= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 1891EF2C5F; Wed, 30 May 2018 17:28:19 -0400 (EDT) Received: from yoda.home (unknown [70.82.104.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 9F7CEF2C5E; Wed, 30 May 2018 17:28:18 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id BBA492DA0513; Wed, 30 May 2018 17:28:17 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , Samuel Thibault , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] vt: perform safe console erase only once Date: Wed, 30 May 2018 17:27:41 -0400 Message-Id: <20180530212745.10997-2-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530212745.10997-1-nicolas.pitre@linaro.org> References: <20180530212745.10997-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: 5EE000B8-6450-11E8-8397-44CE1968708C-78420484!pb-smtp1.pobox.com 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 is called twice on the whole screen buffer. Let's reorganize the code so the same work is not performed twice. Signed-off-by: Nicolas Pitre --- drivers/tty/vt/vt.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.17.0 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; }