From patchwork Wed Jan 9 03:54:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 155045 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp255629jaa; Tue, 8 Jan 2019 19:57:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN4XcZeHeJn3MkzfjuMYlHsBOtIYLtMwx7fW6nK79Znvo6kb/V+UbsurFrLJL9izQPMScGyn X-Received: by 2002:a63:6b05:: with SMTP id g5mr3854505pgc.15.1547006159564; Tue, 08 Jan 2019 19:55:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547006159; cv=none; d=google.com; s=arc-20160816; b=COfb4Y+lTPsWvest+iBZYmTK+AncGjZQpfbZf4X6mVD2k78qCUlMyVvuoZIcx/oHK7 21F8+skjwu6zOo5NO06v8qB2eE4mHWq6qcMa+wp7iDw+mgPtaq7pTW+Ci0y575Oey8v0 1KMmeHXZlY7ze8YD8R3NTqL88Ha+0S/vPZnHudt0G6m6f8ANklqs3iucA5x93w3hn7b7 A8E8EWclIy2geE8QmU4wFW6jILqGzNq6LWzBSSR22Bm5FcPWWNV7//KMzVhrV4C0AZ89 pVAtDi+nnGOKN/jKwulXIsWTxVF9RZHsKRMJ3zfqAb65JqxErZx6aNsCnVjpldYsHObN bwJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AmyLjgBBCj6oc3J9NLEQ15OP3X0xj6BVkHsydRd3U60=; b=bgBDL9WFcPO0YShoJaRRbAE/dG9S6FZea9GMFpmoh1hmZX+YYdQVvWJJ6vGQ7LxYYa dnuZIOH+5H294H+lCZJr/AsBZTEoUMZxqVgsHJBjJiKpvRJiYwC7ZZtPQ287wAbg/e5W zCpPDuIVK7HZ7tMdijWYBrG81xBsFCLJGxwvxWn9qCGV+EpxUVrqrwA0+zipKa1NC3iR oi97rMMS71oubI4TLfDm1iTEvpIIyyZ+e2oXV0ObzxYiGM510QUU2AyVWeQsL5rnaH3Y MoNLykaWSdxDqB+vNuPgPm+JiWE4h1Rrus8Qx9TRVqE5C550kjCQ+XOqh7ae/OmFNJmX 9Mqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=RoISlc7J; 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 m39si10551398plg.315.2019.01.08.19.55.59; Tue, 08 Jan 2019 19:55:59 -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=RoISlc7J; 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 S1729402AbfAIDzw (ORCPT + 31 others); Tue, 8 Jan 2019 22:55:52 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:56242 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbfAIDzt (ORCPT ); Tue, 8 Jan 2019 22:55:49 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 9390F119303; Tue, 8 Jan 2019 22:55:46 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=efjSLXWMsEa9kIKOsVZ02niDE Ro=; b=RoISlc7JQddGZ45MNYdE176p9Ar+pIL8qhRyTKO0eEmDr4WiYVv39CQOf 5jQp1V0CS/swp9JW/HN8f7pfKp88Cg/0Iw075poRKUPI6M2tliW/fMpGzPgUPR8m AsEyhYXYGKea+nn6bMyTR+XwHkrP2UajvkaTwUccc1USn01Jyk= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 892491192FF; Tue, 8 Jan 2019 22:55:46 -0500 (EST) 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 0CBEF1192FC; Tue, 8 Jan 2019 22:55:46 -0500 (EST) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 3069F2DA0419; Tue, 8 Jan 2019 22:55:45 -0500 (EST) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] vt: make vt_console_print() compatible with the unicode screen buffer Date: Tue, 8 Jan 2019 22:54:59 -0500 Message-Id: <20190109035504.8413-2-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190109035504.8413-1-nicolas.pitre@linaro.org> References: <20190109035504.8413-1-nicolas.pitre@linaro.org> MIME-Version: 1.0 X-Pobox-Relay-ID: 7186B80C-13C2-11E9-83F5-70EFDD2159A7-78420484!pb-smtp1.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kernel messages are printed to the console, they appear blank on the unicode screen. This is because vt_console_print() is lacking a call to vc_uniscr_putc(). However the later function assumes vc->vc_x is always up to date when called, which is not the case here as vt_console_print() uses it to mark the beginning of the display update. This patch reworks (and simplifies) vt_console_print() so that vc->vc_x is always valid and keeps the start of display update in a local variable instead, which finally allows for adding the missing vc_uniscr_putc() call. Signed-off-by: Nicolas Pitre Cc: stable@vger.kernel.org # v4.19+ --- drivers/tty/vt/vt.c | 47 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 32 deletions(-) -- 2.20.1 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 41ec8e5010..b9004bd087 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2884,8 +2884,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) unsigned char c; static DEFINE_SPINLOCK(printing_lock); const ushort *start; - ushort cnt = 0; - ushort myx; + ushort start_x, cnt; int kmsg_console; /* console busy or not yet initialized */ @@ -2898,10 +2897,6 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) if (kmsg_console && vc_cons_allocated(kmsg_console - 1)) vc = vc_cons[kmsg_console - 1].d; - /* read `x' only after setting currcons properly (otherwise - the `x' macro will read the x of the foreground console). */ - myx = vc->vc_x; - if (!vc_cons_allocated(fg_console)) { /* impossible */ /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */ @@ -2916,53 +2911,41 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) hide_cursor(vc); start = (ushort *)vc->vc_pos; - - /* Contrived structure to try to emulate original need_wrap behaviour - * Problems caused when we have need_wrap set on '\n' character */ + start_x = vc->vc_x; + cnt = 0; while (count--) { c = *b++; if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { - if (cnt > 0) { - if (con_is_visible(vc)) - vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); - vc->vc_x += cnt; - if (vc->vc_need_wrap) - vc->vc_x--; - cnt = 0; - } + if (cnt && con_is_visible(vc)) + vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, start_x); + cnt = 0; if (c == 8) { /* backspace */ bs(vc); start = (ushort *)vc->vc_pos; - myx = vc->vc_x; + start_x = vc->vc_x; continue; } if (c != 13) lf(vc); cr(vc); start = (ushort *)vc->vc_pos; - myx = vc->vc_x; + start_x = vc->vc_x; if (c == 10 || c == 13) continue; } + vc_uniscr_putc(vc, c); scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); notify_write(vc, c); cnt++; - if (myx == vc->vc_cols - 1) { - vc->vc_need_wrap = 1; - continue; - } - vc->vc_pos += 2; - myx++; - } - if (cnt > 0) { - if (con_is_visible(vc)) - vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); - vc->vc_x += cnt; - if (vc->vc_x == vc->vc_cols) { - vc->vc_x--; + if (vc->vc_x == vc->vc_cols - 1) { vc->vc_need_wrap = 1; + } else { + vc->vc_pos += 2; + vc->vc_x++; } } + if (cnt && con_is_visible(vc)) + vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, start_x); set_cursor(vc); notify_update(vc);