From patchwork Tue Jan 10 21:28:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Manuel_Sch=C3=B6lling?= X-Patchwork-Id: 9508537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EAB2260231 for ; Tue, 10 Jan 2017 21:30:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8C43285C1 for ; Tue, 10 Jan 2017 21:30:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA5A8285C4; Tue, 10 Jan 2017 21:30:40 +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=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 485E7285BF for ; Tue, 10 Jan 2017 21:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753198AbdAJVaV (ORCPT ); Tue, 10 Jan 2017 16:30:21 -0500 Received: from mout.gmx.net ([212.227.17.20]:49615 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753123AbdAJVaS (ORCPT ); Tue, 10 Jan 2017 16:30:18 -0500 Received: from localhost.localdomain ([88.152.9.218]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0Luajs-1cZxyc0Gdk-00zrKx; Tue, 10 Jan 2017 22:29:06 +0100 From: =?UTF-8?q?Manuel=20Sch=C3=B6lling?= To: gregkh@linuxfoundation.org Cc: jslaby@suse.com, kilobyte@angband.pl, lkml14@scotdoyle.com, rdunlap@infradead.org, shorne@gmail.com, andrey_utkin@fastmail.com, akpm@linux-foundation.org, paul.burton@imgtec.com, daniel.vetter@ffwll.ch, tj@kernel.org, hdegoede@redhat.com, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, =?UTF-8?q?Manuel=20Sch=C3=B6lling?= Subject: [PATCH v9 2/4] console: Add callback to flush scrollback buffer to consw struct Date: Tue, 10 Jan 2017 22:28:36 +0100 Message-Id: <20170110212838.16175-3-manuel.schoelling@gmx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170110212838.16175-1-manuel.schoelling@gmx.de> References: <20170110212838.16175-1-manuel.schoelling@gmx.de> In-Reply-To: <4640722.jsFVORW8WM@amdc3058> References: <4640722.jsFVORW8WM@amdc3058> MIME-Version: 1.0 X-Provags-ID: V03:K0:sdsuZl28lqb1mZYq/QvU3gufnfiusWNKS3aCJae6W+oYR8UhvKo Z3FA/4TPmnDS6q2spAxqXtxzrSKXI1eUUQyXsTosDRdEN4LhhWVQFPBchH3xxiy+ml531W7 X5e6xdDfNhQtxffhw6/1lAa8LqH8rN1uI7AX39a+uP1432ypCTSGvof5MkIUvVaLdjWqjsF nTBJdUnsvy0vIi8Gak6CA== X-UI-Out-Filterresults: notjunk:1; V01:K0:w7OaiXoHlcQ=:+RefMomgOMmJagkzG2Ue3f aujRXf4vh1sUoDytregzWLkMxz7zJsD4mNA48aHo9Rq3yTARYRg3VrJBwm1eGEmB5ikN2amLp 29fsmPp/cOnVMmAAIclSlZhBh7PCwTa5te57wHeywvVrVnu4xn62HIwEZdS0XLLlci7cr9CTg ojgc8a3c8K1/ir4+aSCSSLw2e+n+4Vj0aPgeuFvUE/waBm/ebPEz9CE0C+2SEqHDrfw9UEeGX gb45fgZcjFX9fJ/52FtkhHYR4hUsK1+M7yEQi4KiDmDC+mLvGLhA1rUefKVz9WlbM09aZTlnn pqZ5DPoLzk/NigVsO6nRTfNpuxhtuIGYp5Gc8HYHYL5meCOp9AmaEx7aHnDlhLvl/DlUjT1S9 k7iKOctop2zWuabuCe+AU/814zIjzmWquzVdEUSrsxzVk0gCLTDXBe/vJa04riFfelG+cDRZB 3WwPsd2RTl37ugqejuq5RcS9t68xY2vntK406jbm0JrzlVyNyWsTu2wirLTeDud9eZJ0FO8gr R/55tI6A8OcB/13BTSBJCV6MHa/X3GMMpOMkPLV7uEM2pHw5T72R79eFF1bjm9iyZgCsZFV4Q Au/VDCX46NtMf3+ukJVuQQfMqJSb7P6a3qZns4R7IrKVMYgLgrSLc4ckImgxDukcV+Jrldbph 4A/zRIIFBKXhA1DTl662xy2DryUdnLZBeT9b98m8EWBydy6D88EKhV2TE3/6fYrB7RTQuK7Bj ag4u8j0t1tHzpTUXT32INLHzsXU7+ZomVAIcSMvY1S/6AcAIWn0cvM9yWNtwI+eQAiIHOGOV6 4Y7/yBM 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 This new callback is in preparation for persistent scrollback buffer support for VGA consoles. With a single scrollback buffer for all consoles, we could flush the buffer just by invocating consw->con_switch(). But when each VGA console has its own scrollback buffer, we need a new callback to tell the video console driver which buffer to flush. Signed-off-by: Manuel Schölling Reviewed-by: Andrey Utkin Tested-by: Andrey Utkin Tested-by: Adam Borowski --- drivers/tty/vt/vt.c | 9 +++++++++ drivers/video/console/vgacon.c | 24 +++++++++++++++++++++++- include/linux/console.h | 4 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 4c10a9df3b91..9d3ce505e7ab 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -625,6 +625,14 @@ static void save_screen(struct vc_data *vc) vc->vc_sw->con_save_screen(vc); } +static void flush_scrollback(struct vc_data *vc) +{ + WARN_CONSOLE_UNLOCKED(); + + if (vc->vc_sw->con_flush_scrollback) + vc->vc_sw->con_flush_scrollback(vc); +} + /* * Redrawing of screen */ @@ -1171,6 +1179,7 @@ static void csi_J(struct vc_data *vc, int vpar) 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); diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 48b97648d4af..9a7c2bbc5326 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -173,6 +173,16 @@ static struct vgacon_scrollback_info { int restore; } vgacon_scrollback; +static void vgacon_scrollback_reset(size_t reset_size) +{ + if (vgacon_scrollback.data && reset_size > 0) + memset(vgacon_scrollback.data, 0, reset_size); + + vgacon_scrollback.cnt = 0; + vgacon_scrollback.tail = 0; + vgacon_scrollback.cur = 0; +} + static void vgacon_scrollback_init(int pitch) { int rows = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024/pitch; @@ -305,6 +315,14 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) } else vgacon_cursor(c, CM_MOVE); } + +static void vgacon_flush_scrollback(struct vc_data *c) +{ + size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024; + + if (c->vc_num == fg_console) + vgacon_scrollback_reset(size); +} #else #define vgacon_scrollback_startup(...) do { } while (0) #define vgacon_scrollback_init(...) do { } while (0) @@ -322,6 +340,10 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) vga_vram_size); vga_set_mem_top(c); } + +static void vgacon_flush_scrollback(struct vc_data *c) +{ +} #endif /* CONFIG_VGACON_SOFT_SCROLLBACK */ static const char *vgacon_startup(void) @@ -1329,7 +1351,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, return true; } - /* * The console `switch' structure for the VGA based console */ @@ -1362,6 +1383,7 @@ const struct consw vga_con = { .con_save_screen = vgacon_save_screen, .con_build_attr = vgacon_build_attr, .con_invert_region = vgacon_invert_region, + .con_flush_scrollback = vgacon_flush_scrollback, }; EXPORT_SYMBOL(vga_con); diff --git a/include/linux/console.h b/include/linux/console.h index 9c26c6685587..5949d1855589 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -73,6 +73,10 @@ struct consw { u16 *(*con_screen_pos)(struct vc_data *, int); unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *); /* + * Flush the video console driver's scrollback buffer + */ + void (*con_flush_scrollback)(struct vc_data *); + /* * Prepare the console for the debugger. This includes, but is not * limited to, unblanking the console, loading an appropriate * palette, and allowing debugger generated output.