Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5014561ybl; Wed, 22 Jan 2020 08:43:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxpmgxun0M9wJ7NYd4+KdgKx8YxyWq/E6DV5qTlPdUiuDkF+/eCTOvMgs8OT+wqOmtvLdAG X-Received: by 2002:a05:6830:1248:: with SMTP id s8mr7939284otp.202.1579711425990; Wed, 22 Jan 2020 08:43:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579711425; cv=none; d=google.com; s=arc-20160816; b=oqsOs5RDIjkrTsmcLcbJoi9HIcqCq9YypeGB2VK2UoiuZvg7i8UkXzR2N12NHRV7wI OxTo/bp8RoB0qVDGX8en5I6TVhJo7eqpGUQhfCgJUN1H5h3XZLlKCjnJFyQlUfJD60Ge aRD0ECQB5AyFpuvmO2M5qqvPGIeC9y0pA+GLVxYeha76hSqluId3xFruZyb1G1fti3BM WPfQhFCREljDRFgUprlkqzn/K097Tv+cC0uax+vt+zASApsNMfIiHuVrq6/SI9J4uVqM TR5/meciok3F+glgU/wF56Zk5rAWvnu7eC6zE87wu5zojo74gaO8kqsrrAlF2OEhdTXp Vxgg== 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:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=KRUzmwOA5vDOaV9XWFLzD+yg6biYcOOxSZqFvLiQqxU=; b=yVg6AjIlS6sAoT20WF8TYy20/toc8VnuLuo6A92rMmrsQ3Fd/wBBpJnkEhcV6igKl0 pU1qPQ4zYUnzsO3BEtoT/ULXQKMX7d1XPHwXOsSs6Q0gm+5ZO2w3BjGwqhkyfbaXNibg YPSM6aQhnasfQcu2CBvFf8VorbtRtAixpgYBNGMD5CkZ5dTCjlY+EpZU2QwBL7quvDxr zqx8n0Gdt4S9fDuOhtTElkt2GkFWymmMw7Xr6sF3INYHy3O8L36bxBBdmDjGmC8WZVlT 3dwEOL66g+p0JxlhtppQDq/P/teBSIVot/9qvgxHJTxDU+Z3ChcjHueC+lVeEXUZIY2f lZDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=Wknxobfb; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=tizz4lWi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l132si21300074oib.192.2020.01.22.08.43.32; Wed, 22 Jan 2020 08:43:45 -0800 (PST) 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=Wknxobfb; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=tizz4lWi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728855AbgAVQkp (ORCPT + 99 others); Wed, 22 Jan 2020 11:40:45 -0500 Received: from pb-smtp21.pobox.com ([173.228.157.53]:51435 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbgAVQkp (ORCPT ); Wed, 22 Jan 2020 11:40:45 -0500 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 48C2EAABAF; Wed, 22 Jan 2020 11:40:43 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=nm4+AllZt0xaKzJosnEhrST2Js8=; b=Wknxob fbY9/d9ilbkbi5SWP4zLtOZRg+xnQE+icEvid8r5yl7ZW3RyIb0/xZ4iyRYh1tCq k2yr2SD5jhl3g4ec7HjsWZ7HC+ddnEdxr/1jyTKsy+aqczATJQVsmG8Fr2diiTBC 9OS8QC3MoE9pepsExA4iJ9SBqLwbEfWO36j3g= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 4083CAABAE; Wed, 22 Jan 2020 11:40:43 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=htryAvkzPUayXcHLCDdZuj4Za0JJ4NkSs6AjxwfUoHc=; b=tizz4lWiNUT4myJCvvfT/5prD8HXoXbGd8rZHVOf+kAsTHNqnJZWeh9i7COEBa2CmxyjtXr4p8sdonfrmY392XBLjIlttj8gdpYv7QeD5VIPDvjy8Z8pZyDzmRAVs/yxSN1PtWOb4n4DDCcbfMlDSkUJ+VPhYUOTBqlDBDOsJ7A= Received: from yoda.home (unknown [24.203.50.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 3034BAABAD; Wed, 22 Jan 2020 11:40:40 -0500 (EST) (envelope-from nico@fluxnic.net) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 5EC3D2DA010B; Wed, 22 Jan 2020 11:40:38 -0500 (EST) Date: Wed, 22 Jan 2020 11:40:38 -0500 (EST) From: Nicolas Pitre To: Lukas Wunner cc: Greg Kroah-Hartman , Jiri Slaby , Mikulas Patocka , Matthew Whitehead , Daniel Vetter , Arvind Sankar , linux-kernel@vger.kernel.org Subject: Re: [PATCH] vt: Fix non-blinking cursor regression In-Reply-To: <575cb82102aa59a7a8e34248821b78e1dd844777.1579701673.git.lukas@wunner.de> Message-ID: References: <575cb82102aa59a7a8e34248821b78e1dd844777.1579701673.git.lukas@wunner.de> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: ECB65F08-3D35-11EA-869D-8D86F504CC47-78420484!pb-smtp21.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Jan 2020, Lukas Wunner wrote: > Since commit a6dbe4427559 ("vt: perform safe console erase in the right > order"), when userspace clears both the scrollback buffer and the screen > by writing "\e[3J" to an fbdev virtual console, the cursor stops blinking > if that virtual console is not in the foreground. I'm witnessing this > on every boot of Raspbian since updating to v4.19.37+ because agetty > writes the sequence to /dev/tty6 while the console is still switched to > /dev/tty1. Switching consoles once makes the cursor blink again. > > The commit added an invocation of ->con_switch() to flush_scrollback(). > Normally this is only invoked from switch_screen() to switch consoles. > switch_screen() updates *vc->vc_display_fg to the new console and > fbcon_switch() updates ops->currcon. Because the commit only invokes > fbcon_switch() but doesn't update *vc->vc_display_fg, it performs an > incomplete console switch. > > When fb_flashcursor() subsequently blinks the cursor, it retrieves the > foreground console from ops->currcon. Because *vc->vc_display_fg wasn't > updated, con_is_visible() incorrectly returns false and as a result, > fb_flashcursor() bails out without blinking the cursor. > > The invocation of ->con_switch() appears to have been erroneous. After > all, why should a console switch be performed when clearing the screen? > The commit message doesn't provide a rationale either. So delete it. The problem here is that only vgacon provides a con_flush_scrollback method. When not provided, the only way to flush the scrollback buffer is to invoke the switch method. If you remove it the scrollback buffer of the foreground console won't be flushed in the fb case and possibly others. Originally the con_switch method was invoked via update_screen(). The code rationalization in commit a6dbe4427559 failed to carry over a few details though. So I think the actual fix should instead be like this: diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 34aa39d1ae..93314a2f26 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -936,10 +936,13 @@ static void flush_scrollback(struct vc_data *vc) WARN_CONSOLE_UNLOCKED(); set_origin(vc); - if (vc->vc_sw->con_flush_scrollback) + if (vc->vc_sw->con_flush_scrollback) { vc->vc_sw->con_flush_scrollback(vc); - else + } else if (con_is_visible(vc)) { + hide_cursor(vc); vc->vc_sw->con_switch(vc); + set_cursor(vc); + } } /* Nicolas