From patchwork Mon Jan 21 04:22:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 10773343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C8BA14E5 for ; Mon, 21 Jan 2019 08:29:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCDB2984F for ; Mon, 21 Jan 2019 08:29:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FDA829961; Mon, 21 Jan 2019 08:29:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F35B32984F for ; Mon, 21 Jan 2019 08:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbfAUI3c (ORCPT ); Mon, 21 Jan 2019 03:29:32 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:38709 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728239AbfAUI3c (ORCPT ); Mon, 21 Jan 2019 03:29:32 -0500 Received: by mail-qk1-f195.google.com with SMTP id m17so4353301qki.5 for ; Mon, 21 Jan 2019 00:29:31 -0800 (PST) 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=CpPMpjhb3lB7s2KZRGykFLTqswu/y32QmJo5HrnL5As=; b=KCjAlSqBfUlpr6/bNNZ+/b91cOD0xLSe3kXpnY5Yk9HPexVMeUzNhyfH6ktzaK1MAp EtfDpkT/HtwBVjuWcJzqENGd+VjLy7AVtVNCWQm5BuTr7++iEfgVEbB+q/3fIaU7OzUV 7FVPLoGOeO68HM16Ks9S5KudqpEfUmzaZbe0I= 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=CpPMpjhb3lB7s2KZRGykFLTqswu/y32QmJo5HrnL5As=; b=qVZf9TncG8AboNX2a+vBjSr++QMYgYz/BDTGcqlOyeBW/hAtFt50wk2ivfUt2Ixsh0 XEX76+xRNwSdw8JgIb4RXx9VDibI1z5LPocoob3wPoLaNega+q/9ti+Vghq1Kd2+AlGv 9wZI5AoCxkJ+M6MojqRN3bGRS6TtOPlKZByu2ogrY1Z8j3VhAH1TWzHURnOtmHHLLcr2 mfZyiICeEtNQZ3JlHVSF17DaSP/7gZEcI6Xsao1My4llOChwHbx6PLNiDD24LH1tg5HX pDVPO2IS7/PN/P+OIR8q31t6B0phtjJlzBLFcsTszK7f8MUQZh8mQz+ik5l5mhxGHsHw 3xkw== X-Gm-Message-State: AJcUukfJHQkj6MZxq20Vhs1+5uFs/FTRnSjegmOues0LUrHGxwKnpjuC XYlsCuxJh/Y6ee65CY3MHwfp55omWKo= X-Google-Smtp-Source: ALg8bN6R2/QyUJi0/wNJRBZmF/ZpIUgEZ/+Gx0loI9iAU3lObbZbx53pVBlhpwNcy1RrK9yk+hJYHA== X-Received: by 2002:a37:4b44:: with SMTP id y65mr22477595qka.316.1548044538138; Sun, 20 Jan 2019 20:22:18 -0800 (PST) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id c48sm67891799qtd.9.2019.01.20.20.22.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Jan 2019 20:22:17 -0800 (PST) Date: Sun, 20 Jan 2019 23:22:11 -0500 (EST) From: Nicolas Pitre To: Bartlomiej Zolnierkiewicz cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] vgacon: unconfuse vc_origin when using soft scrollback Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When CONFIG_VGACON_SOFT_SCROLLBACK is selected, the VGA display memory index and vc_visible_origin don't change when scrollback is activated. The actual screen content is saved away and the scrollbackdata is copied over it. However the vt code, and /dev/vcs devices in particular, still expect vc_origin to always point at the actual screen content not the displayed scrollback content. So adjust vc_origin to point at the saved screen content when scrollback is active and set it back to vc_visible_origin when restoring the screen. This fixes /dev/vcsa that return scrollback content when they shouldn't (onli /dev/vcsa without a number should), and also fixes /dev/vcsu that should return scrollback content when scrollback is active but currently doesn't. An unnecessary call to vga_set_mem_top() is also removed. Signed-off-by: Nicolas Pitre Cc: stable@vger.kernel.org # v4.19+ --- I tagged it for stable starting with v4.19 as this is the kernel that introduced /dev/vcsu* which is directly affected. Users of earlier kernels most likely won't care. diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 09731b2f68..c6b3bdbbdb 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -271,6 +271,7 @@ static void vgacon_scrollback_update(struct vc_data *c, int t, int count) static void vgacon_restore_screen(struct vc_data *c) { + c->vc_origin = c->vc_visible_origin; vgacon_scrollback_cur->save = 0; if (!vga_is_gfx && !vgacon_scrollback_cur->restore) { @@ -287,8 +288,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) int start, end, count, soff; if (!lines) { - c->vc_visible_origin = c->vc_origin; - vga_set_mem_top(c); + vgacon_restore_screen(c); return; } @@ -298,6 +298,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) if (!vgacon_scrollback_cur->save) { vgacon_cursor(c, CM_ERASE); vgacon_save_screen(c); + c->vc_origin = (unsigned long)c->vc_screenbuf; vgacon_scrollback_cur->save = 1; } @@ -335,7 +336,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) int copysize; int diff = c->vc_rows - count; - void *d = (void *) c->vc_origin; + void *d = (void *) c->vc_visible_origin; void *s = (void *) c->vc_screenbuf; count *= c->vc_size_row;