efi: earlycon: Reduce number of references to global screen_info

Replace usage of global screen_info with local pointers. This will
later reduce churn when screen_info is being moved.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Richard Lyu <richard.lyu@suse.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Thomas Zimmermann
2025-11-26 17:03:18 +01:00
committed by Ard Biesheuvel
parent c7c7eb5ed5
commit b868070fbc

View File

@@ -32,12 +32,13 @@ static void *efi_fb;
*/
static int __init efi_earlycon_remap_fb(void)
{
const struct screen_info *si = &screen_info;
/* bail if there is no bootconsole or it was unregistered already */
if (!earlycon_console || !console_is_registered(earlycon_console))
return 0;
efi_fb = memremap(fb_base, screen_info.lfb_size,
fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
efi_fb = memremap(fb_base, si->lfb_size, fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
return efi_fb ? 0 : -ENOMEM;
}
@@ -71,12 +72,12 @@ static __ref void efi_earlycon_unmap(void *addr, unsigned long len)
early_memunmap(addr, len);
}
static void efi_earlycon_clear_scanline(unsigned int y)
static void efi_earlycon_clear_scanline(unsigned int y, const struct screen_info *si)
{
unsigned long *dst;
u16 len;
len = screen_info.lfb_linelength;
len = si->lfb_linelength;
dst = efi_earlycon_map(y*len, len);
if (!dst)
return;
@@ -85,7 +86,7 @@ static void efi_earlycon_clear_scanline(unsigned int y)
efi_earlycon_unmap(dst, len);
}
static void efi_earlycon_scroll_up(void)
static void efi_earlycon_scroll_up(const struct screen_info *si)
{
unsigned long *dst, *src;
u16 maxlen = 0;
@@ -99,8 +100,8 @@ static void efi_earlycon_scroll_up(void)
}
maxlen *= 4;
len = screen_info.lfb_linelength;
height = screen_info.lfb_height;
len = si->lfb_linelength;
height = si->lfb_height;
for (i = 0; i < height - font->height; i++) {
dst = efi_earlycon_map(i*len, len);
@@ -120,7 +121,8 @@ static void efi_earlycon_scroll_up(void)
}
}
static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h,
const struct screen_info *si)
{
const u32 color_black = 0x00000000;
const u32 color_white = 0x00ffffff;
@@ -145,13 +147,12 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
static void
efi_earlycon_write(struct console *con, const char *str, unsigned int num)
{
struct screen_info *si;
const struct screen_info *si = &screen_info;
u32 cur_efi_x = efi_x;
unsigned int len;
const char *s;
void *dst;
si = &screen_info;
len = si->lfb_linelength;
while (num) {
@@ -174,7 +175,7 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
x = efi_x;
while (n-- > 0) {
efi_earlycon_write_char(dst + x*4, *s, h);
efi_earlycon_write_char(dst + x * 4, *s, h, si);
x += font->width;
s++;
}
@@ -207,10 +208,10 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
cur_line_y = (cur_line_y + 1) % max_line_y;
efi_y -= font->height;
efi_earlycon_scroll_up();
efi_earlycon_scroll_up(si);
for (i = 0; i < font->height; i++)
efi_earlycon_clear_scanline(efi_y + i);
efi_earlycon_clear_scanline(efi_y + i, si);
}
}
}
@@ -226,22 +227,21 @@ void __init efi_earlycon_reprobe(void)
static int __init efi_earlycon_setup(struct earlycon_device *device,
const char *opt)
{
struct screen_info *si;
const struct screen_info *si = &screen_info;
u16 xres, yres;
u32 i;
fb_wb = opt && !strcmp(opt, "ram");
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) {
if (si->orig_video_isVGA != VIDEO_TYPE_EFI) {
fb_probed = true;
return -ENODEV;
}
fb_base = screen_info.lfb_base;
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
fb_base |= (u64)screen_info.ext_lfb_base << 32;
fb_base = si->lfb_base;
if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
fb_base |= (u64)si->ext_lfb_base << 32;
si = &screen_info;
xres = si->lfb_width;
yres = si->lfb_height;
@@ -266,7 +266,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
efi_y -= font->height;
for (i = 0; i < (yres - efi_y) / font->height; i++)
efi_earlycon_scroll_up();
efi_earlycon_scroll_up(si);
device->con->write = efi_earlycon_write;
earlycon_console = device->con;