Skip to content

Commit d92b545

Browse files
nivedita76Ingo Molnar
authored andcommitted
efi/earlycon: Fix write-combine mapping on x86
On x86, until PAT is initialized, WC translates into UC-. Since we calculate and store pgprot_writecombine(PAGE_KERNEL) when earlycon is initialized, this means we actually use UC- mappings instead of WC mappings, which makes scrolling very slow. Instead store a boolean flag to indicate whether we want to use writeback or write-combine mappings, and recalculate the actual pgprot_t we need on every mapping. Once PAT is initialized, we will start using write-combine mappings, which speeds up the scrolling considerably. Signed-off-by: Arvind Sankar <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Cc: Hans de Goede <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[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]>
1 parent 46cf053 commit d92b545

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/firmware/efi/earlycon.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static const struct console *earlycon_console __initdata;
1717
static const struct font_desc *font;
1818
static u32 efi_x, efi_y;
1919
static u64 fb_base;
20-
static pgprot_t fb_prot;
20+
static bool fb_wb;
2121
static void *efi_fb;
2222

2323
/*
@@ -33,10 +33,8 @@ static int __init efi_earlycon_remap_fb(void)
3333
if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED))
3434
return 0;
3535

36-
if (pgprot_val(fb_prot) == pgprot_val(PAGE_KERNEL))
37-
efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WB);
38-
else
39-
efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WC);
36+
efi_fb = memremap(fb_base, screen_info.lfb_size,
37+
fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
4038

4139
return efi_fb ? 0 : -ENOMEM;
4240
}
@@ -53,9 +51,12 @@ late_initcall(efi_earlycon_unmap_fb);
5351

5452
static __ref void *efi_earlycon_map(unsigned long start, unsigned long len)
5553
{
54+
pgprot_t fb_prot;
55+
5656
if (efi_fb)
5757
return efi_fb + start;
5858

59+
fb_prot = fb_wb ? PAGE_KERNEL : pgprot_writecombine(PAGE_KERNEL);
5960
return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot));
6061
}
6162

@@ -215,10 +216,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
215216
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
216217
fb_base |= (u64)screen_info.ext_lfb_base << 32;
217218

218-
if (opt && !strcmp(opt, "ram"))
219-
fb_prot = PAGE_KERNEL;
220-
else
221-
fb_prot = pgprot_writecombine(PAGE_KERNEL);
219+
fb_wb = opt && !strcmp(opt, "ram");
222220

223221
si = &screen_info;
224222
xres = si->lfb_width;

0 commit comments

Comments
 (0)