Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Thomas Zimmermann and committed by
Ard Biesheuvel
a41e0ab3 b9459226

+68 -55
+1 -1
arch/arm64/kernel/image-vars.h
··· 38 38 PROVIDE(__efistub___inittext_end = __inittext_end); 39 39 PROVIDE(__efistub__edata = _edata); 40 40 #if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) 41 - PROVIDE(__efistub_screen_info = screen_info); 41 + PROVIDE(__efistub_sysfb_primary_display = sysfb_primary_display); 42 42 #endif 43 43 PROVIDE(__efistub__ctype = _ctype); 44 44
+8 -7
arch/loongarch/kernel/efi.c
··· 18 18 #include <linux/kobject.h> 19 19 #include <linux/memblock.h> 20 20 #include <linux/reboot.h> 21 - #include <linux/screen_info.h> 21 + #include <linux/sysfb.h> 22 22 #include <linux/uaccess.h> 23 23 24 24 #include <asm/early_ioremap.h> ··· 75 75 unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR; 76 76 77 77 #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); 80 80 #endif 81 81 82 - static void __init init_screen_info(void) 82 + static void __init init_primary_display(void) 83 83 { 84 84 struct screen_info *si; 85 85 ··· 91 91 pr_err("Could not map screen_info config table\n"); 92 92 return; 93 93 } 94 - screen_info = *si; 94 + sysfb_primary_display.screen = *si; 95 95 memset(si, 0, sizeof(*si)); 96 96 early_memunmap(si, sizeof(*si)); 97 97 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); 99 100 } 100 101 101 102 void __init efi_init(void) ··· 130 129 set_bit(EFI_CONFIG_TABLES, &efi.flags); 131 130 132 131 if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) 133 - init_screen_info(); 132 + init_primary_display(); 134 133 135 134 if (boot_memmap == EFI_INVALID_TABLE_ADDR) 136 135 return;
+1 -1
arch/loongarch/kernel/image-vars.h
··· 12 12 __efistub_kernel_asize = kernel_asize; 13 13 __efistub_kernel_fsize = kernel_fsize; 14 14 #if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) 15 - __efistub_screen_info = screen_info; 15 + __efistub_sysfb_primary_display = sysfb_primary_display; 16 16 #endif 17 17 18 18 #endif
+1 -1
arch/riscv/kernel/image-vars.h
··· 29 29 __efistub__edata = _edata; 30 30 __efistub___init_text_end = __init_text_end; 31 31 #if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) 32 - __efistub_screen_info = screen_info; 32 + __efistub_sysfb_primary_display = sysfb_primary_display; 33 33 #endif 34 34 35 35 #endif
+3 -1
arch/x86/kernel/kexec-bzimage64.c
··· 20 20 #include <linux/of_fdt.h> 21 21 #include <linux/efi.h> 22 22 #include <linux/random.h> 23 + #include <linux/sysfb.h> 23 24 24 25 #include <asm/bootparam.h> 25 26 #include <asm/setup.h> ··· 304 303 params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch; 305 304 306 305 /* Copying screen_info will do? */ 307 - memcpy(&params->screen_info, &screen_info, sizeof(struct screen_info)); 306 + memcpy(&params->screen_info, &sysfb_primary_display.screen, 307 + sizeof(sysfb_primary_display.screen)); 308 308 309 309 /* Fill in memsize later */ 310 310 params->screen_info.ext_mem_k = 0;
+6 -4
arch/x86/kernel/setup.c
··· 22 22 #include <linux/random.h> 23 23 #include <linux/root_dev.h> 24 24 #include <linux/static_call.h> 25 + #include <linux/sysfb.h> 25 26 #include <linux/swiotlb.h> 26 27 #include <linux/tboot.h> 27 28 #include <linux/usb/xhci-dbgp.h> ··· 212 211 /* 213 212 * Setup options 214 213 */ 215 - struct screen_info screen_info; 216 - EXPORT_SYMBOL(screen_info); 214 + 215 + struct sysfb_display_info sysfb_primary_display; 216 + EXPORT_SYMBOL(sysfb_primary_display); 217 217 #if defined(CONFIG_FIRMWARE_EDID) 218 218 struct edid_info edid_info; 219 219 EXPORT_SYMBOL_GPL(edid_info); ··· 528 526 static void __init parse_boot_params(void) 529 527 { 530 528 ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev); 531 - screen_info = boot_params.screen_info; 529 + sysfb_primary_display.screen = boot_params.screen_info; 532 530 #if defined(CONFIG_FIRMWARE_EDID) 533 531 edid_info = boot_params.edid_info; 534 532 #endif ··· 1256 1254 #ifdef CONFIG_VT 1257 1255 #if defined(CONFIG_VGA_CONSOLE) 1258 1256 if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) 1259 - vgacon_register_screen(&screen_info); 1257 + vgacon_register_screen(&sysfb_primary_display.screen); 1260 1258 #endif 1261 1259 #endif 1262 1260 x86_init.oem.banner();
+2 -2
arch/x86/video/video-common.c
··· 9 9 10 10 #include <linux/module.h> 11 11 #include <linux/pci.h> 12 - #include <linux/screen_info.h> 12 + #include <linux/sysfb.h> 13 13 #include <linux/vgaarb.h> 14 14 15 15 #include <asm/video.h> ··· 29 29 bool video_is_primary_device(struct device *dev) 30 30 { 31 31 #ifdef CONFIG_SCREEN_INFO 32 - struct screen_info *si = &screen_info; 32 + struct screen_info *si = &sysfb_primary_display.screen; 33 33 struct resource res[SCREEN_INFO_MAX_RESOURCES]; 34 34 ssize_t i, numres; 35 35 #endif
+4 -4
drivers/firmware/efi/earlycon.c
··· 9 9 #include <linux/io.h> 10 10 #include <linux/kernel.h> 11 11 #include <linux/serial_core.h> 12 - #include <linux/screen_info.h> 12 + #include <linux/sysfb.h> 13 13 #include <linux/string.h> 14 14 15 15 #include <asm/early_ioremap.h> ··· 32 32 */ 33 33 static int __init efi_earlycon_remap_fb(void) 34 34 { 35 - const struct screen_info *si = &screen_info; 35 + const struct screen_info *si = &sysfb_primary_display.screen; 36 36 37 37 /* bail if there is no bootconsole or it was unregistered already */ 38 38 if (!earlycon_console || !console_is_registered(earlycon_console)) ··· 147 147 static void 148 148 efi_earlycon_write(struct console *con, const char *str, unsigned int num) 149 149 { 150 - const struct screen_info *si = &screen_info; 150 + const struct screen_info *si = &sysfb_primary_display.screen; 151 151 u32 cur_efi_x = efi_x; 152 152 unsigned int len; 153 153 const char *s; ··· 227 227 static int __init efi_earlycon_setup(struct earlycon_device *device, 228 228 const char *opt) 229 229 { 230 - const struct screen_info *si = &screen_info; 230 + const struct screen_info *si = &sysfb_primary_display.screen; 231 231 u16 xres, yres; 232 232 u32 i; 233 233
+11 -11
drivers/firmware/efi/efi-init.c
··· 19 19 #include <linux/of_address.h> 20 20 #include <linux/of_fdt.h> 21 21 #include <linux/platform_device.h> 22 - #include <linux/screen_info.h> 22 + #include <linux/sysfb.h> 23 23 24 24 #include <asm/efi.h> 25 25 ··· 57 57 extern __weak const efi_config_table_type_t efi_arch_tables[]; 58 58 59 59 /* 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. 62 62 */ 63 63 #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); 66 66 #endif 67 67 68 - static void __init init_screen_info(void) 68 + static void __init init_primary_display(void) 69 69 { 70 70 struct screen_info *si; 71 71 ··· 75 75 pr_err("Could not map screen_info config table\n"); 76 76 return; 77 77 } 78 - screen_info = *si; 78 + sysfb_primary_display.screen = *si; 79 79 memset(si, 0, sizeof(*si)); 80 80 early_memunmap(si, sizeof(*si)); 81 81 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); 85 85 86 86 if (IS_ENABLED(CONFIG_EFI_EARLYCON)) 87 87 efi_earlycon_reprobe(); ··· 274 274 if (IS_ENABLED(CONFIG_X86) || 275 275 IS_ENABLED(CONFIG_SYSFB) || 276 276 IS_ENABLED(CONFIG_EFI_EARLYCON)) 277 - init_screen_info(); 277 + init_primary_display(); 278 278 }
+13 -5
drivers/firmware/efi/libstub/efi-stub-entry.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 3 3 #include <linux/efi.h> 4 - #include <linux/screen_info.h> 4 + #include <linux/sysfb.h> 5 5 6 6 #include <asm/efi.h> 7 7 8 8 #include "efistub.h" 9 9 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 + } 11 16 12 17 struct screen_info *alloc_screen_info(void) 13 18 { ··· 21 16 22 17 if (IS_ENABLED(CONFIG_X86) || 23 18 IS_ENABLED(CONFIG_EFI_EARLYCON) || 24 - IS_ENABLED(CONFIG_SYSFB)) 25 - return (void *)&screen_info + screen_info_offset; 19 + IS_ENABLED(CONFIG_SYSFB)) { 20 + struct sysfb_display_info *dpy = kernel_image_addr(&sysfb_primary_display); 21 + 22 + return &dpy->screen; 23 + } 26 24 27 25 return NULL; 28 26 } ··· 81 73 return status; 82 74 } 83 75 84 - screen_info_offset = image_addr - (unsigned long)image->image_base; 76 + kernel_image_offset = image_addr - (unsigned long)image->image_base; 85 77 86 78 status = efi_stub_common(handle, image, image_addr, cmdline_ptr); 87 79
+4 -4
drivers/firmware/efi/sysfb_efi.c
··· 176 176 177 177 static int __init efifb_set_system_callback(const struct dmi_system_id *id) 178 178 { 179 - return efifb_set_system(&screen_info, id); 179 + return efifb_set_system(&sysfb_primary_display.screen, id); 180 180 } 181 181 182 182 #define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \ ··· 237 237 238 238 static int __init efifb_swap_width_height(const struct dmi_system_id *id) 239 239 { 240 - struct screen_info *si = &screen_info; 240 + struct screen_info *si = &sysfb_primary_display.screen; 241 241 u32 bpp = __screen_info_lfb_bits_per_pixel(si); 242 242 243 243 swap(si->lfb_width, si->lfb_height); ··· 256 256 efifb_check_and_swap_width_height(const struct dmi_system_id *id) 257 257 { 258 258 const struct efifb_mode_fixup *data = id->driver_data; 259 - struct screen_info *si = &screen_info; 259 + struct screen_info *si = &sysfb_primary_display.screen; 260 260 261 261 if (data->width == si->lfb_width && data->height == si->lfb_height) { 262 262 swap(si->lfb_width, si->lfb_height); ··· 379 379 } 380 380 381 381 for_each_of_pci_range(&parser, &range) 382 - if (efifb_overlaps_pci_range(&screen_info, &range)) 382 + if (efifb_overlaps_pci_range(&sysfb_primary_display.screen, &range)) 383 383 return np; 384 384 } 385 385 return NULL;
+3 -3
drivers/firmware/sysfb.c
··· 66 66 */ 67 67 void sysfb_disable(struct device *dev) 68 68 { 69 - struct screen_info *si = &screen_info; 69 + struct screen_info *si = &sysfb_primary_display.screen; 70 70 struct device *parent; 71 71 72 72 mutex_lock(&disable_lock); ··· 92 92 */ 93 93 bool sysfb_handles_screen_info(void) 94 94 { 95 - const struct screen_info *si = &screen_info; 95 + const struct screen_info *si = &sysfb_primary_display.screen; 96 96 97 97 return !!screen_info_video_type(si); 98 98 } ··· 141 141 142 142 static __init int sysfb_init(void) 143 143 { 144 - struct screen_info *si = &screen_info; 144 + struct screen_info *si = &sysfb_primary_display.screen; 145 145 struct device *parent; 146 146 unsigned int type; 147 147 struct simplefb_platform_data mode;
+3 -3
drivers/hv/vmbus_drv.c
··· 29 29 #include <linux/delay.h> 30 30 #include <linux/panic_notifier.h> 31 31 #include <linux/ptrace.h> 32 - #include <linux/screen_info.h> 32 + #include <linux/sysfb.h> 33 33 #include <linux/efi.h> 34 34 #include <linux/random.h> 35 35 #include <linux/kernel.h> ··· 2340 2340 if (efi_enabled(EFI_BOOT)) { 2341 2341 /* Gen2 VM: get FB base from EFI framebuffer */ 2342 2342 if (IS_ENABLED(CONFIG_SYSFB)) { 2343 - start = screen_info.lfb_base; 2344 - size = max_t(__u32, screen_info.lfb_size, 0x800000); 2343 + start = sysfb_primary_display.screen.lfb_base; 2344 + size = max_t(__u32, sysfb_primary_display.screen.lfb_size, 0x800000); 2345 2345 } 2346 2346 } else { 2347 2347 /* Gen1 VM: get FB base from PCI */
+2 -2
drivers/pci/vgaarb.c
··· 26 26 #include <linux/poll.h> 27 27 #include <linux/miscdevice.h> 28 28 #include <linux/slab.h> 29 - #include <linux/screen_info.h> 29 + #include <linux/sysfb.h> 30 30 #include <linux/vt.h> 31 31 #include <linux/console.h> 32 32 #include <linux/acpi.h> ··· 557 557 static bool vga_is_firmware_default(struct pci_dev *pdev) 558 558 { 559 559 #if defined CONFIG_X86 560 - return pdev == screen_info_pci_dev(&screen_info); 560 + return pdev == screen_info_pci_dev(&sysfb_primary_display.screen); 561 561 #else 562 562 return false; 563 563 #endif
+3 -2
drivers/video/screen_info_pci.c
··· 4 4 #include <linux/printk.h> 5 5 #include <linux/screen_info.h> 6 6 #include <linux/string.h> 7 + #include <linux/sysfb.h> 7 8 8 9 static struct pci_dev *screen_info_lfb_pdev; 9 10 static size_t screen_info_lfb_bar; ··· 27 26 28 27 void screen_info_apply_fixups(void) 29 28 { 30 - struct screen_info *si = &screen_info; 29 + struct screen_info *si = &sysfb_primary_display.screen; 31 30 32 31 if (screen_info_lfb_pdev) { 33 32 struct resource *pr = &screen_info_lfb_pdev->resource[screen_info_lfb_bar]; ··· 76 75 .flags = IORESOURCE_MEM, 77 76 }; 78 77 const struct resource *pr; 79 - const struct screen_info *si = &screen_info; 78 + const struct screen_info *si = &sysfb_primary_display.screen; 80 79 81 80 if (screen_info_lfb_pdev) 82 81 return; // already found
-2
include/linux/screen_info.h
··· 151 151 } 152 152 #endif 153 153 154 - extern struct screen_info screen_info; 155 - 156 154 #endif /* _SCREEN_INFO_H */
+3 -2
include/linux/sysfb.h
··· 8 8 */ 9 9 10 10 #include <linux/err.h> 11 + #include <linux/platform_data/simplefb.h> 11 12 #include <linux/screen_info.h> 12 13 #include <linux/types.h> 13 - 14 - #include <linux/platform_data/simplefb.h> 15 14 16 15 struct device; 17 16 struct platform_device; ··· 63 64 struct sysfb_display_info { 64 65 struct screen_info screen; 65 66 }; 67 + 68 + extern struct sysfb_display_info sysfb_primary_display; 66 69 67 70 #ifdef CONFIG_SYSFB 68 71