mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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>
This commit is contained in:
parent
b945922619
commit
a41e0ab394
17 changed files with 68 additions and 55 deletions
|
|
@ -38,7 +38,7 @@ PROVIDE(__efistub__end = _end);
|
|||
PROVIDE(__efistub___inittext_end = __inittext_end);
|
||||
PROVIDE(__efistub__edata = _edata);
|
||||
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
|
||||
PROVIDE(__efistub_screen_info = screen_info);
|
||||
PROVIDE(__efistub_sysfb_primary_display = sysfb_primary_display);
|
||||
#endif
|
||||
PROVIDE(__efistub__ctype = _ctype);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include <linux/kobject.h>
|
||||
#include <linux/memblock.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/screen_info.h>
|
||||
#include <linux/sysfb.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include <asm/early_ioremap.h>
|
||||
|
|
@ -75,11 +75,11 @@ bool efi_poweroff_required(void)
|
|||
unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
|
||||
|
||||
#if 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;
|
||||
|
||||
|
|
@ -91,11 +91,12 @@ 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));
|
||||
|
||||
memblock_reserve(__screen_info_lfb_base(&screen_info), screen_info.lfb_size);
|
||||
memblock_reserve(__screen_info_lfb_base(&sysfb_primary_display.screen),
|
||||
sysfb_primary_display.screen.lfb_size);
|
||||
}
|
||||
|
||||
void __init efi_init(void)
|
||||
|
|
@ -129,7 +130,7 @@ void __init efi_init(void)
|
|||
set_bit(EFI_CONFIG_TABLES, &efi.flags);
|
||||
|
||||
if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB))
|
||||
init_screen_info();
|
||||
init_primary_display();
|
||||
|
||||
if (boot_memmap == EFI_INVALID_TABLE_ADDR)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ __efistub_kernel_entry = kernel_entry;
|
|||
__efistub_kernel_asize = kernel_asize;
|
||||
__efistub_kernel_fsize = kernel_fsize;
|
||||
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
|
||||
__efistub_screen_info = screen_info;
|
||||
__efistub_sysfb_primary_display = sysfb_primary_display;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ __efistub__end = _end;
|
|||
__efistub__edata = _edata;
|
||||
__efistub___init_text_end = __init_text_end;
|
||||
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
|
||||
__efistub_screen_info = screen_info;
|
||||
__efistub_sysfb_primary_display = sysfb_primary_display;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <linux/of_fdt.h>
|
||||
#include <linux/efi.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/sysfb.h>
|
||||
|
||||
#include <asm/bootparam.h>
|
||||
#include <asm/setup.h>
|
||||
|
|
@ -303,7 +304,8 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
|
|||
params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch;
|
||||
|
||||
/* Copying screen_info will do? */
|
||||
memcpy(¶ms->screen_info, &screen_info, sizeof(struct screen_info));
|
||||
memcpy(¶ms->screen_info, &sysfb_primary_display.screen,
|
||||
sizeof(sysfb_primary_display.screen));
|
||||
|
||||
/* Fill in memsize later */
|
||||
params->screen_info.ext_mem_k = 0;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <linux/random.h>
|
||||
#include <linux/root_dev.h>
|
||||
#include <linux/static_call.h>
|
||||
#include <linux/sysfb.h>
|
||||
#include <linux/swiotlb.h>
|
||||
#include <linux/tboot.h>
|
||||
#include <linux/usb/xhci-dbgp.h>
|
||||
|
|
@ -211,8 +212,9 @@ arch_initcall(init_x86_sysctl);
|
|||
/*
|
||||
* Setup options
|
||||
*/
|
||||
struct screen_info screen_info;
|
||||
EXPORT_SYMBOL(screen_info);
|
||||
|
||||
struct sysfb_display_info sysfb_primary_display;
|
||||
EXPORT_SYMBOL(sysfb_primary_display);
|
||||
#if defined(CONFIG_FIRMWARE_EDID)
|
||||
struct edid_info edid_info;
|
||||
EXPORT_SYMBOL_GPL(edid_info);
|
||||
|
|
@ -526,7 +528,7 @@ static void __init parse_setup_data(void)
|
|||
static void __init parse_boot_params(void)
|
||||
{
|
||||
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
|
||||
screen_info = boot_params.screen_info;
|
||||
sysfb_primary_display.screen = boot_params.screen_info;
|
||||
#if defined(CONFIG_FIRMWARE_EDID)
|
||||
edid_info = boot_params.edid_info;
|
||||
#endif
|
||||
|
|
@ -1254,7 +1256,7 @@ void __init setup_arch(char **cmdline_p)
|
|||
#ifdef CONFIG_VT
|
||||
#if defined(CONFIG_VGA_CONSOLE)
|
||||
if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
|
||||
vgacon_register_screen(&screen_info);
|
||||
vgacon_register_screen(&sysfb_primary_display.screen);
|
||||
#endif
|
||||
#endif
|
||||
x86_init.oem.banner();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/screen_info.h>
|
||||
#include <linux/sysfb.h>
|
||||
#include <linux/vgaarb.h>
|
||||
|
||||
#include <asm/video.h>
|
||||
|
|
@ -29,7 +29,7 @@ EXPORT_SYMBOL(pgprot_framebuffer);
|
|||
bool video_is_primary_device(struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_SCREEN_INFO
|
||||
struct screen_info *si = &screen_info;
|
||||
struct screen_info *si = &sysfb_primary_display.screen;
|
||||
struct resource res[SCREEN_INFO_MAX_RESOURCES];
|
||||
ssize_t i, numres;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -151,6 +151,4 @@ static inline struct pci_dev *screen_info_pci_dev(const struct screen_info *si)
|
|||
}
|
||||
#endif
|
||||
|
||||
extern struct screen_info screen_info;
|
||||
|
||||
#endif /* _SCREEN_INFO_H */
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@
|
|||
*/
|
||||
|
||||
#include <linux/err.h>
|
||||
#include <linux/platform_data/simplefb.h>
|
||||
#include <linux/screen_info.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <linux/platform_data/simplefb.h>
|
||||
|
||||
struct device;
|
||||
struct platform_device;
|
||||
struct screen_info;
|
||||
|
|
@ -65,6 +64,8 @@ struct sysfb_display_info {
|
|||
struct screen_info screen;
|
||||
};
|
||||
|
||||
extern struct sysfb_display_info sysfb_primary_display;
|
||||
|
||||
#ifdef CONFIG_SYSFB
|
||||
|
||||
void sysfb_disable(struct device *dev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue