Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3016947ybl; Sun, 8 Dec 2019 05:36:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzcMGXXThl7QoW0LOIB9pHa+AgbILfbxFBgvM47YCq9D/ns/MAkTJa8PvuONhq09u2josLL X-Received: by 2002:a9d:12ef:: with SMTP id g102mr5811548otg.303.1575812188190; Sun, 08 Dec 2019 05:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575812188; cv=none; d=google.com; s=arc-20160816; b=GBmT+izdzeveWYjlEJERNBkGlns+enCds3p8LVWKqGR/HevVBEV7BeOmX1ya8gyf3y PmXxtA1HxUXOQJ38ncPICt5ZAuPOcV/hjcMMcUSNDHB/eUAwd8tJzJZnzqMtGA1L3qk4 eBzZditry29GO2oJdtBn+D87/b8Szz7J3jDI4jOvEXXrMHv5pbD7MoWr5HjK3AFJI/0y N384a6ZF6+OAQB4Mx0UUaihiCR1ivmgzLb19QKPoCi7fhbFhQsFY1nOdSDEFm5ByXY3H s1rrAtXFNycLCEutja+s91dYQ+0ZsWHn6zSC26h0G5yVjYs7FttqgJSFHbOccRTqoS9Z hmiQ== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=BPcD23TqDaPMSzg8PVyxwyBNNYrLsqSmIstYjB3wVYw=; b=J/M+rDx3KCGg5jCsIoNcPoi/8PfSGXV1EE0bz/+TP4eFGTlXvGp1bd9uxTapGUwlwK 3BDT9xX7IxdLAPW95BJlaSwFJ217Lat+AlbYKtE80yiqosGWwkEs0AjZ8rjU5hj3rObE yXSHM43ELKXfnpMcBVf0s5eB4jd1M070QDW4n+f9cyxsGKnL62E9KJQS9wMMaOyVXA+V 9auE9iSmNSKY6crMbi6wUiq/k0F30eGhqtMBFpAVrmCc/SkNRN/N719hfI4CcRLvYjjo xMMXOY0jljumYTQgarKVw1dChyDH+zF5iQ1iwy/3wRs6bD7pDnHF6LDeU4y5LG8xlfsB UTlw== ARC-Authentication-Results: i=1; mx.google.com; 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 x26si1972529oie.58.2019.12.08.05.35.37; Sun, 08 Dec 2019 05:36:28 -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; 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 S1726506AbfLHNdu (ORCPT + 99 others); Sun, 8 Dec 2019 08:33:50 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:36605 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfLHNdu (ORCPT ); Sun, 8 Dec 2019 08:33:50 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1idwgr-0007gM-6O; Sun, 08 Dec 2019 14:33:37 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 62C3D1C269D; Sun, 8 Dec 2019 14:33:33 +0100 (CET) Date: Sun, 08 Dec 2019 13:33:33 -0000 From: "tip-bot2 for Andy Shevchenko" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: efi/urgent] efi/earlycon: Remap entire framebuffer after page initialization Cc: Andy Shevchenko , Ard Biesheuvel , Arvind Sankar , Bhupesh Sharma , Masayoshi Mizuma , linux-efi@vger.kernel.org, Ingo Molnar , x86 , LKML In-Reply-To: <20191206165542.31469-7-ardb@kernel.org> References: <20191206165542.31469-7-ardb@kernel.org> MIME-Version: 1.0 Message-ID: <157581201321.21853.9033877797032028086.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the efi/urgent branch of tip: Commit-ID: b418d660bb9798d2249ac6a46c844389ef50b6a5 Gitweb: https://git.kernel.org/tip/b418d660bb9798d2249ac6a46c844389ef50b6a5 Author: Andy Shevchenko AuthorDate: Fri, 06 Dec 2019 16:55:42 Committer: Ingo Molnar CommitterDate: Sun, 08 Dec 2019 12:42:19 +01:00 efi/earlycon: Remap entire framebuffer after page initialization When commit: 69c1f396f25b ("efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation") moved the x86 specific EFI earlyprintk implementation to a shared location, it also tweaked the behaviour. In particular, it dropped a trick with full framebuffer remapping after page initialization, leading to two regressions: 1) very slow scrolling after page initialization, 2) kernel hang when the 'keep_bootcon' command line argument is passed. Putting the tweak back fixes #2 and mitigates #1, i.e., it limits the slow behavior to the early boot stages, presumably due to eliminating heavy map()/unmap() operations per each pixel line on the screen. [ ardb: ensure efifb is unmapped again unless keep_bootcon is in effect. ] [ mingo: speling fixes. ] Signed-off-by: Andy Shevchenko Signed-off-by: Ard Biesheuvel Cc: Arvind Sankar Cc: Bhupesh Sharma Cc: Masayoshi Mizuma Cc: linux-efi@vger.kernel.org Fixes: 69c1f396f25b ("efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation") Link: https://lkml.kernel.org/r/20191206165542.31469-7-ardb@kernel.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/earlycon.c | 40 ++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+) diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c index c9a0efc..d4077db 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -13,18 +13,57 @@ #include +static const struct console *earlycon_console __initdata; static const struct font_desc *font; static u32 efi_x, efi_y; static u64 fb_base; static pgprot_t fb_prot; +static void *efi_fb; + +/* + * EFI earlycon needs to use early_memremap() to map the framebuffer. + * But early_memremap() is not usable for 'earlycon=efifb keep_bootcon', + * memremap() should be used instead. memremap() will be available after + * paging_init() which is earlier than initcall callbacks. Thus adding this + * early initcall function early_efi_map_fb() to map the whole EFI framebuffer. + */ +static int __init efi_earlycon_remap_fb(void) +{ + /* bail if there is no bootconsole or it has been disabled already */ + if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED)) + return 0; + + if (pgprot_val(fb_prot) == pgprot_val(PAGE_KERNEL)) + efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WB); + else + efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WC); + + return efi_fb ? 0 : -ENOMEM; +} +early_initcall(efi_earlycon_remap_fb); + +static int __init efi_earlycon_unmap_fb(void) +{ + /* unmap the bootconsole fb unless keep_bootcon has left it enabled */ + if (efi_fb && !(earlycon_console->flags & CON_ENABLED)) + memunmap(efi_fb); + return 0; +} +late_initcall(efi_earlycon_unmap_fb); static __ref void *efi_earlycon_map(unsigned long start, unsigned long len) { + if (efi_fb) + return efi_fb + start; + return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot)); } static __ref void efi_earlycon_unmap(void *addr, unsigned long len) { + if (efi_fb) + return; + early_memunmap(addr, len); } @@ -201,6 +240,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device, efi_earlycon_scroll_up(); device->con->write = efi_earlycon_write; + earlycon_console = device->con; return 0; } EARLYCON_DECLARE(efifb, efi_earlycon_setup);