Skip to content

Commit a41e0ab

Browse files
tdzardbiesheuvel
authored andcommitted
sysfb: Replace screen_info with sysfb_primary_display
Replace the global screen_info with sysfb_primary_display of type struct sysfb_display_info. Adapt all users of screen_info. Instances of screen_info are defined for x86, loongarch and EFI, with only one instance compiled into a specific build. Replace all of them with sysfb_primary_display. All existing users of screen_info are updated by pointing them to sysfb_primary_display.screen instead. This introduces some churn to the code, but has no impact on functionality. Boot parameters and EFI config tables are unchanged. They transfer screen_info as before. The logic in EFI's alloc_screen_info() changes slightly, as it now returns the screen field of sysfb_primary_display. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/ Reviewed-by: Richard Lyu <richard.lyu@suse.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent b945922 commit a41e0ab

17 files changed

Lines changed: 68 additions & 55 deletions

File tree

arch/arm64/kernel/image-vars.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROVIDE(__efistub__end = _end);
3838
PROVIDE(__efistub___inittext_end = __inittext_end);
3939
PROVIDE(__efistub__edata = _edata);
4040
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
41-
PROVIDE(__efistub_screen_info = screen_info);
41+
PROVIDE(__efistub_sysfb_primary_display = sysfb_primary_display);
4242
#endif
4343
PROVIDE(__efistub__ctype = _ctype);
4444

arch/loongarch/kernel/efi.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <linux/kobject.h>
1919
#include <linux/memblock.h>
2020
#include <linux/reboot.h>
21-
#include <linux/screen_info.h>
21+
#include <linux/sysfb.h>
2222
#include <linux/uaccess.h>
2323

2424
#include <asm/early_ioremap.h>
@@ -75,11 +75,11 @@ bool efi_poweroff_required(void)
7575
unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
7676

7777
#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)
78-
struct screen_info screen_info __section(".data");
79-
EXPORT_SYMBOL_GPL(screen_info);
78+
struct sysfb_display_info sysfb_primary_display __section(".data");
79+
EXPORT_SYMBOL_GPL(sysfb_primary_display);
8080
#endif
8181

82-
static void __init init_screen_info(void)
82+
static void __init init_primary_display(void)
8383
{
8484
struct screen_info *si;
8585

@@ -91,11 +91,12 @@ static void __init init_screen_info(void)
9191
pr_err("Could not map screen_info config table\n");
9292
return;
9393
}
94-
screen_info = *si;
94+
sysfb_primary_display.screen = *si;
9595
memset(si, 0, sizeof(*si));
9696
early_memunmap(si, sizeof(*si));
9797

98-
memblock_reserve(__screen_info_lfb_base(&screen_info), screen_info.lfb_size);
98+
memblock_reserve(__screen_info_lfb_base(&sysfb_primary_display.screen),
99+
sysfb_primary_display.screen.lfb_size);
99100
}
100101

101102
void __init efi_init(void)
@@ -129,7 +130,7 @@ void __init efi_init(void)
129130
set_bit(EFI_CONFIG_TABLES, &efi.flags);
130131

131132
if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB))
132-
init_screen_info();
133+
init_primary_display();
133134

134135
if (boot_memmap == EFI_INVALID_TABLE_ADDR)
135136
return;

arch/loongarch/kernel/image-vars.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ __efistub_kernel_entry = kernel_entry;
1212
__efistub_kernel_asize = kernel_asize;
1313
__efistub_kernel_fsize = kernel_fsize;
1414
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
15-
__efistub_screen_info = screen_info;
15+
__efistub_sysfb_primary_display = sysfb_primary_display;
1616
#endif
1717

1818
#endif

arch/riscv/kernel/image-vars.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ __efistub__end = _end;
2929
__efistub__edata = _edata;
3030
__efistub___init_text_end = __init_text_end;
3131
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
32-
__efistub_screen_info = screen_info;
32+
__efistub_sysfb_primary_display = sysfb_primary_display;
3333
#endif
3434

3535
#endif

arch/x86/kernel/kexec-bzimage64.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/of_fdt.h>
2121
#include <linux/efi.h>
2222
#include <linux/random.h>
23+
#include <linux/sysfb.h>
2324

2425
#include <asm/bootparam.h>
2526
#include <asm/setup.h>
@@ -303,7 +304,8 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
303304
params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch;
304305

305306
/* Copying screen_info will do? */
306-
memcpy(&params->screen_info, &screen_info, sizeof(struct screen_info));
307+
memcpy(&params->screen_info, &sysfb_primary_display.screen,
308+
sizeof(sysfb_primary_display.screen));
307309

308310
/* Fill in memsize later */
309311
params->screen_info.ext_mem_k = 0;

arch/x86/kernel/setup.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/random.h>
2323
#include <linux/root_dev.h>
2424
#include <linux/static_call.h>
25+
#include <linux/sysfb.h>
2526
#include <linux/swiotlb.h>
2627
#include <linux/tboot.h>
2728
#include <linux/usb/xhci-dbgp.h>
@@ -211,8 +212,9 @@ arch_initcall(init_x86_sysctl);
211212
/*
212213
* Setup options
213214
*/
214-
struct screen_info screen_info;
215-
EXPORT_SYMBOL(screen_info);
215+
216+
struct sysfb_display_info sysfb_primary_display;
217+
EXPORT_SYMBOL(sysfb_primary_display);
216218
#if defined(CONFIG_FIRMWARE_EDID)
217219
struct edid_info edid_info;
218220
EXPORT_SYMBOL_GPL(edid_info);
@@ -526,7 +528,7 @@ static void __init parse_setup_data(void)
526528
static void __init parse_boot_params(void)
527529
{
528530
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
529-
screen_info = boot_params.screen_info;
531+
sysfb_primary_display.screen = boot_params.screen_info;
530532
#if defined(CONFIG_FIRMWARE_EDID)
531533
edid_info = boot_params.edid_info;
532534
#endif
@@ -1254,7 +1256,7 @@ void __init setup_arch(char **cmdline_p)
12541256
#ifdef CONFIG_VT
12551257
#if defined(CONFIG_VGA_CONSOLE)
12561258
if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
1257-
vgacon_register_screen(&screen_info);
1259+
vgacon_register_screen(&sysfb_primary_display.screen);
12581260
#endif
12591261
#endif
12601262
x86_init.oem.banner();

arch/x86/video/video-common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <linux/module.h>
1111
#include <linux/pci.h>
12-
#include <linux/screen_info.h>
12+
#include <linux/sysfb.h>
1313
#include <linux/vgaarb.h>
1414

1515
#include <asm/video.h>
@@ -29,7 +29,7 @@ EXPORT_SYMBOL(pgprot_framebuffer);
2929
bool video_is_primary_device(struct device *dev)
3030
{
3131
#ifdef CONFIG_SCREEN_INFO
32-
struct screen_info *si = &screen_info;
32+
struct screen_info *si = &sysfb_primary_display.screen;
3333
struct resource res[SCREEN_INFO_MAX_RESOURCES];
3434
ssize_t i, numres;
3535
#endif

drivers/firmware/efi/earlycon.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/io.h>
1010
#include <linux/kernel.h>
1111
#include <linux/serial_core.h>
12-
#include <linux/screen_info.h>
12+
#include <linux/sysfb.h>
1313
#include <linux/string.h>
1414

1515
#include <asm/early_ioremap.h>
@@ -32,7 +32,7 @@ static void *efi_fb;
3232
*/
3333
static int __init efi_earlycon_remap_fb(void)
3434
{
35-
const struct screen_info *si = &screen_info;
35+
const struct screen_info *si = &sysfb_primary_display.screen;
3636

3737
/* bail if there is no bootconsole or it was unregistered already */
3838
if (!earlycon_console || !console_is_registered(earlycon_console))
@@ -147,7 +147,7 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h,
147147
static void
148148
efi_earlycon_write(struct console *con, const char *str, unsigned int num)
149149
{
150-
const struct screen_info *si = &screen_info;
150+
const struct screen_info *si = &sysfb_primary_display.screen;
151151
u32 cur_efi_x = efi_x;
152152
unsigned int len;
153153
const char *s;
@@ -227,7 +227,7 @@ void __init efi_earlycon_reprobe(void)
227227
static int __init efi_earlycon_setup(struct earlycon_device *device,
228228
const char *opt)
229229
{
230-
const struct screen_info *si = &screen_info;
230+
const struct screen_info *si = &sysfb_primary_display.screen;
231231
u16 xres, yres;
232232
u32 i;
233233

drivers/firmware/efi/efi-init.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/of_address.h>
2020
#include <linux/of_fdt.h>
2121
#include <linux/platform_device.h>
22-
#include <linux/screen_info.h>
22+
#include <linux/sysfb.h>
2323

2424
#include <asm/efi.h>
2525

@@ -57,15 +57,15 @@ static phys_addr_t __init efi_to_phys(unsigned long addr)
5757
extern __weak const efi_config_table_type_t efi_arch_tables[];
5858

5959
/*
60-
* x86 defines its own screen_info and uses it even without EFI,
61-
* everything else can get it from here.
60+
* x86 defines its own instance of sysfb_primary_display and uses
61+
* it even without EFI, everything else can get them from here.
6262
*/
6363
#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON))
64-
struct screen_info screen_info __section(".data");
65-
EXPORT_SYMBOL_GPL(screen_info);
64+
struct sysfb_display_info sysfb_primary_display __section(".data");
65+
EXPORT_SYMBOL_GPL(sysfb_primary_display);
6666
#endif
6767

68-
static void __init init_screen_info(void)
68+
static void __init init_primary_display(void)
6969
{
7070
struct screen_info *si;
7171

@@ -75,13 +75,13 @@ static void __init init_screen_info(void)
7575
pr_err("Could not map screen_info config table\n");
7676
return;
7777
}
78-
screen_info = *si;
78+
sysfb_primary_display.screen = *si;
7979
memset(si, 0, sizeof(*si));
8080
early_memunmap(si, sizeof(*si));
8181

82-
if (memblock_is_map_memory(screen_info.lfb_base))
83-
memblock_mark_nomap(screen_info.lfb_base,
84-
screen_info.lfb_size);
82+
if (memblock_is_map_memory(sysfb_primary_display.screen.lfb_base))
83+
memblock_mark_nomap(sysfb_primary_display.screen.lfb_base,
84+
sysfb_primary_display.screen.lfb_size);
8585

8686
if (IS_ENABLED(CONFIG_EFI_EARLYCON))
8787
efi_earlycon_reprobe();
@@ -274,5 +274,5 @@ void __init efi_init(void)
274274
if (IS_ENABLED(CONFIG_X86) ||
275275
IS_ENABLED(CONFIG_SYSFB) ||
276276
IS_ENABLED(CONFIG_EFI_EARLYCON))
277-
init_screen_info();
277+
init_primary_display();
278278
}

drivers/firmware/efi/libstub/efi-stub-entry.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22

33
#include <linux/efi.h>
4-
#include <linux/screen_info.h>
4+
#include <linux/sysfb.h>
55

66
#include <asm/efi.h>
77

88
#include "efistub.h"
99

10-
static unsigned long screen_info_offset;
10+
static unsigned long kernel_image_offset;
11+
12+
static void *kernel_image_addr(void *addr)
13+
{
14+
return addr + kernel_image_offset;
15+
}
1116

1217
struct screen_info *alloc_screen_info(void)
1318
{
@@ -16,8 +21,11 @@ struct screen_info *alloc_screen_info(void)
1621

1722
if (IS_ENABLED(CONFIG_X86) ||
1823
IS_ENABLED(CONFIG_EFI_EARLYCON) ||
19-
IS_ENABLED(CONFIG_SYSFB))
20-
return (void *)&screen_info + screen_info_offset;
24+
IS_ENABLED(CONFIG_SYSFB)) {
25+
struct sysfb_display_info *dpy = kernel_image_addr(&sysfb_primary_display);
26+
27+
return &dpy->screen;
28+
}
2129

2230
return NULL;
2331
}
@@ -73,7 +81,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
7381
return status;
7482
}
7583

76-
screen_info_offset = image_addr - (unsigned long)image->image_base;
84+
kernel_image_offset = image_addr - (unsigned long)image->image_base;
7785

7886
status = efi_stub_common(handle, image, image_addr, cmdline_ptr);
7987

0 commit comments

Comments
 (0)