Skip to content

Commit

Permalink
efi/earlycon: Remap entire framebuffer after page initialization
Browse files Browse the repository at this point in the history
When commit:

  69c1f39 ("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 <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Cc: Arvind Sankar <[email protected]>
Cc: Bhupesh Sharma <[email protected]>
Cc: Masayoshi Mizuma <[email protected]>
Cc: [email protected]
Fixes: 69c1f39 ("efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation")
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
andy-shev authored and Ingo Molnar committed Dec 8, 2019
1 parent 9fa76ca commit b418d66
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions drivers/firmware/efi/earlycon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);

0 comments on commit b418d66

Please sign in to comment.