linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Andy Shevchenko" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Arvind Sankar <nivedita@alum.mit.edu>,
	Bhupesh Sharma <bhsharma@redhat.com>,
	Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>,
	linux-efi@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	x86 <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [tip: efi/urgent] efi/earlycon: Remap entire framebuffer after page initialization
Date: Sun, 08 Dec 2019 13:33:33 -0000	[thread overview]
Message-ID: <157581201321.21853.9033877797032028086.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20191206165542.31469-7-ardb@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 <andriy.shevchenko@linux.intel.com>
AuthorDate:    Fri, 06 Dec 2019 16:55:42 
Committer:     Ingo Molnar <mingo@kernel.org>
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 <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Bhupesh Sharma <bhsharma@redhat.com>
Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
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 <mingo@kernel.org>
---
 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 <asm/early_ioremap.h>
 
+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);

  reply	other threads:[~2019-12-08 13:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 16:55 [GIT PULL 0/6] EFI fixes for v5.5 Ard Biesheuvel
2019-12-06 16:55 ` [PATCH 1/6] efi/memreserve: register reservations as 'reserved' in /proc/iomem Ard Biesheuvel
2019-12-08 13:33   ` [tip: efi/urgent] efi/memreserve: Register " tip-bot2 for Ard Biesheuvel
2019-12-06 16:55 ` [PATCH 2/6] efi/gop: Return EFI_NOT_FOUND if there are no usable GOPs Ard Biesheuvel
2019-12-08 13:33   ` [tip: efi/urgent] " tip-bot2 for Arvind Sankar
2019-12-06 16:55 ` [PATCH 3/6] efi/gop: Return EFI_SUCCESS if a usable GOP was found Ard Biesheuvel
2019-12-08 13:33   ` [tip: efi/urgent] " tip-bot2 for Arvind Sankar
2019-12-06 16:55 ` [PATCH 4/6] efi/gop: Fix memory leak from __gop_query32/64 Ard Biesheuvel
2019-12-08 13:33   ` [tip: efi/urgent] efi/gop: Fix memory leak in __gop_query32/64() tip-bot2 for Arvind Sankar
2019-12-06 16:55 ` [PATCH 5/6] efi: fix type of unload field in efi_loaded_image_t Ard Biesheuvel
2019-12-08 13:33   ` [tip: efi/urgent] efi: Fix efi_loaded_image_t::unload type tip-bot2 for Arvind Sankar
2019-12-06 16:55 ` [PATCH 6/6] efi/earlycon: Remap entire framebuffer after page initialization Ard Biesheuvel
2019-12-08 13:33   ` tip-bot2 for Andy Shevchenko [this message]
2019-12-09 19:12   ` Arvind Sankar
2019-12-09 19:24     ` Ard Biesheuvel
2019-12-10 20:05       ` Arvind Sankar
2019-12-11 11:26         ` Ard Biesheuvel
2019-12-11 15:55           ` Arvind Sankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=157581201321.21853.9033877797032028086.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ardb@kernel.org \
    --cc=bhsharma@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=m.mizuma@jp.fujitsu.com \
    --cc=mingo@kernel.org \
    --cc=nivedita@alum.mit.edu \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).