diff options
| author | Thomas Zimmermann <tzimmermann@suse.de> | 2025-11-26 17:03:21 +0100 |
|---|---|---|
| committer | Ard Biesheuvel <ardb@kernel.org> | 2025-12-16 14:12:44 +0100 |
| commit | a41e0ab394e42c7c09ddd8155d2cc3ca17bdce55 (patch) | |
| tree | 3a374077b091def4f2e40b03a3fdd86abac2e2c7 /drivers | |
| parent | b945922619b77b95a48f254582ed86f33d24f560 (diff) | |
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>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/firmware/efi/earlycon.c | 8 | ||||
| -rw-r--r-- | drivers/firmware/efi/efi-init.c | 22 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efi-stub-entry.c | 18 | ||||
| -rw-r--r-- | drivers/firmware/efi/sysfb_efi.c | 8 | ||||
| -rw-r--r-- | drivers/firmware/sysfb.c | 6 | ||||
| -rw-r--r-- | drivers/hv/vmbus_drv.c | 6 | ||||
| -rw-r--r-- | drivers/pci/vgaarb.c | 4 | ||||
| -rw-r--r-- | drivers/video/screen_info_pci.c | 5 |
8 files changed, 43 insertions, 34 deletions
diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c index 42e3a173dac1..3d060d59968c 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -9,7 +9,7 @@ #include <linux/io.h> #include <linux/kernel.h> #include <linux/serial_core.h> -#include <linux/screen_info.h> +#include <linux/sysfb.h> #include <linux/string.h> #include <asm/early_ioremap.h> @@ -32,7 +32,7 @@ static void *efi_fb; */ static int __init efi_earlycon_remap_fb(void) { - const struct screen_info *si = &screen_info; + const struct screen_info *si = &sysfb_primary_display.screen; /* bail if there is no bootconsole or it was unregistered already */ 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, static void efi_earlycon_write(struct console *con, const char *str, unsigned int num) { - const struct screen_info *si = &screen_info; + const struct screen_info *si = &sysfb_primary_display.screen; u32 cur_efi_x = efi_x; unsigned int len; const char *s; @@ -227,7 +227,7 @@ void __init efi_earlycon_reprobe(void) static int __init efi_earlycon_setup(struct earlycon_device *device, const char *opt) { - const struct screen_info *si = &screen_info; + const struct screen_info *si = &sysfb_primary_display.screen; u16 xres, yres; u32 i; diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index a65c2d5b9e7b..d1d418a34407 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -19,7 +19,7 @@ #include <linux/of_address.h> #include <linux/of_fdt.h> #include <linux/platform_device.h> -#include <linux/screen_info.h> +#include <linux/sysfb.h> #include <asm/efi.h> @@ -57,15 +57,15 @@ static phys_addr_t __init efi_to_phys(unsigned long addr) extern __weak const efi_config_table_type_t efi_arch_tables[]; /* - * x86 defines its own screen_info and uses it even without EFI, - * everything else can get it from here. + * x86 defines its own instance of sysfb_primary_display and uses + * it even without EFI, everything else can get them from here. */ #if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)) -struct screen_info screen_info __section(".data"); -EXPORT_SYMBOL_GPL(screen_info); +struct sysfb_display_info sysfb_primary_display __section(".data"); +EXPORT_SYMBOL_GPL(sysfb_primary_display); #endif -static void __init init_screen_info(void) +static void __init init_primary_display(void) { struct screen_info *si; @@ -75,13 +75,13 @@ static void __init init_screen_info(void) pr_err("Could not map screen_info config table\n"); return; } - screen_info = *si; + sysfb_primary_display.screen = *si; memset(si, 0, sizeof(*si)); early_memunmap(si, sizeof(*si)); - if (memblock_is_map_memory(screen_info.lfb_base)) - memblock_mark_nomap(screen_info.lfb_base, - screen_info.lfb_size); + if (memblock_is_map_memory(sysfb_primary_display.screen.lfb_base)) + memblock_mark_nomap(sysfb_primary_display.screen.lfb_base, + sysfb_primary_display.screen.lfb_size); if (IS_ENABLED(CONFIG_EFI_EARLYCON)) efi_earlycon_reprobe(); @@ -274,5 +274,5 @@ void __init efi_init(void) if (IS_ENABLED(CONFIG_X86) || IS_ENABLED(CONFIG_SYSFB) || IS_ENABLED(CONFIG_EFI_EARLYCON)) - init_screen_info(); + init_primary_display(); } diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c index a6c049835190..401ecbbdf331 100644 --- a/drivers/firmware/efi/libstub/efi-stub-entry.c +++ b/drivers/firmware/efi/libstub/efi-stub-entry.c @@ -1,13 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only #include <linux/efi.h> -#include <linux/screen_info.h> +#include <linux/sysfb.h> #include <asm/efi.h> #include "efistub.h" -static unsigned long screen_info_offset; +static unsigned long kernel_image_offset; + +static void *kernel_image_addr(void *addr) +{ + return addr + kernel_image_offset; +} struct screen_info *alloc_screen_info(void) { @@ -16,8 +21,11 @@ struct screen_info *alloc_screen_info(void) if (IS_ENABLED(CONFIG_X86) || IS_ENABLED(CONFIG_EFI_EARLYCON) || - IS_ENABLED(CONFIG_SYSFB)) - return (void *)&screen_info + screen_info_offset; + IS_ENABLED(CONFIG_SYSFB)) { + struct sysfb_display_info *dpy = kernel_image_addr(&sysfb_primary_display); + + return &dpy->screen; + } return NULL; } @@ -73,7 +81,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, return status; } - screen_info_offset = image_addr - (unsigned long)image->image_base; + kernel_image_offset = image_addr - (unsigned long)image->image_base; status = efi_stub_common(handle, image, image_addr, cmdline_ptr); diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c index c074cbccd91b..4c3986ddcd54 100644 --- a/drivers/firmware/efi/sysfb_efi.c +++ b/drivers/firmware/efi/sysfb_efi.c @@ -176,7 +176,7 @@ static int __init efifb_set_system(struct screen_info *si, const struct dmi_syst static int __init efifb_set_system_callback(const struct dmi_system_id *id) { - return efifb_set_system(&screen_info, id); + return efifb_set_system(&sysfb_primary_display.screen, id); } #define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \ @@ -237,7 +237,7 @@ static const struct dmi_system_id efifb_dmi_system_table[] __initconst = { static int __init efifb_swap_width_height(const struct dmi_system_id *id) { - struct screen_info *si = &screen_info; + struct screen_info *si = &sysfb_primary_display.screen; u32 bpp = __screen_info_lfb_bits_per_pixel(si); swap(si->lfb_width, si->lfb_height); @@ -256,7 +256,7 @@ static int __init efifb_check_and_swap_width_height(const struct dmi_system_id *id) { const struct efifb_mode_fixup *data = id->driver_data; - struct screen_info *si = &screen_info; + struct screen_info *si = &sysfb_primary_display.screen; if (data->width == si->lfb_width && data->height == si->lfb_height) { swap(si->lfb_width, si->lfb_height); @@ -379,7 +379,7 @@ static struct device_node *find_pci_overlap_node(void) } for_each_of_pci_range(&parser, &range) - if (efifb_overlaps_pci_range(&screen_info, &range)) + if (efifb_overlaps_pci_range(&sysfb_primary_display.screen, &range)) return np; } return NULL; diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c index 916b28538a29..1f671f9219b0 100644 --- a/drivers/firmware/sysfb.c +++ b/drivers/firmware/sysfb.c @@ -66,7 +66,7 @@ static bool sysfb_unregister(void) */ void sysfb_disable(struct device *dev) { - struct screen_info *si = &screen_info; + struct screen_info *si = &sysfb_primary_display.screen; struct device *parent; mutex_lock(&disable_lock); @@ -92,7 +92,7 @@ EXPORT_SYMBOL_GPL(sysfb_disable); */ bool sysfb_handles_screen_info(void) { - const struct screen_info *si = &screen_info; + const struct screen_info *si = &sysfb_primary_display.screen; return !!screen_info_video_type(si); } @@ -141,7 +141,7 @@ static struct device *sysfb_parent_dev(const struct screen_info *si) static __init int sysfb_init(void) { - struct screen_info *si = &screen_info; + struct screen_info *si = &sysfb_primary_display.screen; struct device *parent; unsigned int type; struct simplefb_platform_data mode; diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index a53af6fe81a6..9c937190be81 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -29,7 +29,7 @@ #include <linux/delay.h> #include <linux/panic_notifier.h> #include <linux/ptrace.h> -#include <linux/screen_info.h> +#include <linux/sysfb.h> #include <linux/efi.h> #include <linux/random.h> #include <linux/kernel.h> @@ -2340,8 +2340,8 @@ static void __maybe_unused vmbus_reserve_fb(void) if (efi_enabled(EFI_BOOT)) { /* Gen2 VM: get FB base from EFI framebuffer */ if (IS_ENABLED(CONFIG_SYSFB)) { - start = screen_info.lfb_base; - size = max_t(__u32, screen_info.lfb_size, 0x800000); + start = sysfb_primary_display.screen.lfb_base; + size = max_t(__u32, sysfb_primary_display.screen.lfb_size, 0x800000); } } else { /* Gen1 VM: get FB base from PCI */ diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 436fa7f4c387..805be9ea4a34 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -26,7 +26,7 @@ #include <linux/poll.h> #include <linux/miscdevice.h> #include <linux/slab.h> -#include <linux/screen_info.h> +#include <linux/sysfb.h> #include <linux/vt.h> #include <linux/console.h> #include <linux/acpi.h> @@ -557,7 +557,7 @@ EXPORT_SYMBOL(vga_put); static bool vga_is_firmware_default(struct pci_dev *pdev) { #if defined CONFIG_X86 - return pdev == screen_info_pci_dev(&screen_info); + return pdev == screen_info_pci_dev(&sysfb_primary_display.screen); #else return false; #endif diff --git a/drivers/video/screen_info_pci.c b/drivers/video/screen_info_pci.c index 66bfc1d0a6dc..8f34d8a74f09 100644 --- a/drivers/video/screen_info_pci.c +++ b/drivers/video/screen_info_pci.c @@ -4,6 +4,7 @@ #include <linux/printk.h> #include <linux/screen_info.h> #include <linux/string.h> +#include <linux/sysfb.h> static struct pci_dev *screen_info_lfb_pdev; static size_t screen_info_lfb_bar; @@ -26,7 +27,7 @@ static bool __screen_info_relocation_is_valid(const struct screen_info *si, stru void screen_info_apply_fixups(void) { - struct screen_info *si = &screen_info; + struct screen_info *si = &sysfb_primary_display.screen; if (screen_info_lfb_pdev) { struct resource *pr = &screen_info_lfb_pdev->resource[screen_info_lfb_bar]; @@ -75,7 +76,7 @@ static void screen_info_fixup_lfb(struct pci_dev *pdev) .flags = IORESOURCE_MEM, }; const struct resource *pr; - const struct screen_info *si = &screen_info; + const struct screen_info *si = &sysfb_primary_display.screen; if (screen_info_lfb_pdev) return; // already found |
