Skip to content

Commit 0c61526

Browse files
committed
Merge tag 'efi-next-for-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI updates from Ard Biesheuvel: - Quirk the broken EFI framebuffer geometry on the Valve Steam Deck - Capture the EDID information of the primary display also on non-x86 EFI systems when booting via the EFI stub. * tag 'efi-next-for-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efi: Support EDID information sysfb: Move edid_info into sysfb_primary_display sysfb: Pass sysfb_primary_display to devices sysfb: Replace screen_info with sysfb_primary_display sysfb: Add struct sysfb_display_info efi: sysfb_efi: Reduce number of references to global screen_info efi: earlycon: Reduce number of references to global screen_info efi: sysfb_efi: Fix efidrmfb and simpledrmfb on Valve Steam Deck efi: sysfb_efi: Convert swap width and height quirk to a callback efi: sysfb_efi: Fix lfb_linelength calculation when applying quirks efi: sysfb_efi: Replace open coded swap with the macro
2 parents 33120a2 + c5a8f13 commit 0c61526

34 files changed

Lines changed: 358 additions & 251 deletions

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: 16 additions & 15 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>
@@ -72,30 +72,31 @@ bool efi_poweroff_required(void)
7272
(acpi_gbl_reduced_hardware || acpi_no_s5);
7373
}
7474

75-
unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
75+
unsigned long __initdata primary_display_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
{
84-
struct screen_info *si;
84+
struct sysfb_display_info *dpy;
8585

86-
if (screen_info_table == EFI_INVALID_TABLE_ADDR)
86+
if (primary_display_table == EFI_INVALID_TABLE_ADDR)
8787
return;
8888

89-
si = early_memremap(screen_info_table, sizeof(*si));
90-
if (!si) {
91-
pr_err("Could not map screen_info config table\n");
89+
dpy = early_memremap(primary_display_table, sizeof(*dpy));
90+
if (!dpy) {
91+
pr_err("Could not map primary_display config table\n");
9292
return;
9393
}
94-
screen_info = *si;
95-
memset(si, 0, sizeof(*si));
96-
early_memunmap(si, sizeof(*si));
94+
sysfb_primary_display = *dpy;
95+
memset(dpy, 0, sizeof(*dpy));
96+
early_memunmap(dpy, sizeof(*dpy));
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: 7 additions & 9 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,12 +212,9 @@ arch_initcall(init_x86_sysctl);
211212
/*
212213
* Setup options
213214
*/
214-
struct screen_info screen_info;
215-
EXPORT_SYMBOL(screen_info);
216-
#if defined(CONFIG_FIRMWARE_EDID)
217-
struct edid_info edid_info;
218-
EXPORT_SYMBOL_GPL(edid_info);
219-
#endif
215+
216+
struct sysfb_display_info sysfb_primary_display;
217+
EXPORT_SYMBOL(sysfb_primary_display);
220218

221219
extern int root_mountflags;
222220

@@ -526,9 +524,9 @@ static void __init parse_setup_data(void)
526524
static void __init parse_boot_params(void)
527525
{
528526
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
529-
screen_info = boot_params.screen_info;
527+
sysfb_primary_display.screen = boot_params.screen_info;
530528
#if defined(CONFIG_FIRMWARE_EDID)
531-
edid_info = boot_params.edid_info;
529+
sysfb_primary_display.edid = boot_params.edid_info;
532530
#endif
533531
#ifdef CONFIG_X86_32
534532
apm_info.bios = boot_params.apm_bios_info;
@@ -1254,7 +1252,7 @@ void __init setup_arch(char **cmdline_p)
12541252
#ifdef CONFIG_VT
12551253
#if defined(CONFIG_VGA_CONSOLE)
12561254
if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
1257-
vgacon_register_screen(&screen_info);
1255+
vgacon_register_screen(&sysfb_primary_display.screen);
12581256
#endif
12591257
#endif
12601258
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: 21 additions & 21 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,12 +32,13 @@ static void *efi_fb;
3232
*/
3333
static int __init efi_earlycon_remap_fb(void)
3434
{
35+
const struct screen_info *si = &sysfb_primary_display.screen;
36+
3537
/* bail if there is no bootconsole or it was unregistered already */
3638
if (!earlycon_console || !console_is_registered(earlycon_console))
3739
return 0;
3840

39-
efi_fb = memremap(fb_base, screen_info.lfb_size,
40-
fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
41+
efi_fb = memremap(fb_base, si->lfb_size, fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
4142

4243
return efi_fb ? 0 : -ENOMEM;
4344
}
@@ -71,12 +72,12 @@ static __ref void efi_earlycon_unmap(void *addr, unsigned long len)
7172
early_memunmap(addr, len);
7273
}
7374

74-
static void efi_earlycon_clear_scanline(unsigned int y)
75+
static void efi_earlycon_clear_scanline(unsigned int y, const struct screen_info *si)
7576
{
7677
unsigned long *dst;
7778
u16 len;
7879

79-
len = screen_info.lfb_linelength;
80+
len = si->lfb_linelength;
8081
dst = efi_earlycon_map(y*len, len);
8182
if (!dst)
8283
return;
@@ -85,7 +86,7 @@ static void efi_earlycon_clear_scanline(unsigned int y)
8586
efi_earlycon_unmap(dst, len);
8687
}
8788

88-
static void efi_earlycon_scroll_up(void)
89+
static void efi_earlycon_scroll_up(const struct screen_info *si)
8990
{
9091
unsigned long *dst, *src;
9192
u16 maxlen = 0;
@@ -99,8 +100,8 @@ static void efi_earlycon_scroll_up(void)
99100
}
100101
maxlen *= 4;
101102

102-
len = screen_info.lfb_linelength;
103-
height = screen_info.lfb_height;
103+
len = si->lfb_linelength;
104+
height = si->lfb_height;
104105

105106
for (i = 0; i < height - font->height; i++) {
106107
dst = efi_earlycon_map(i*len, len);
@@ -120,7 +121,8 @@ static void efi_earlycon_scroll_up(void)
120121
}
121122
}
122123

123-
static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
124+
static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h,
125+
const struct screen_info *si)
124126
{
125127
const u32 color_black = 0x00000000;
126128
const u32 color_white = 0x00ffffff;
@@ -145,13 +147,12 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
145147
static void
146148
efi_earlycon_write(struct console *con, const char *str, unsigned int num)
147149
{
148-
struct screen_info *si;
150+
const struct screen_info *si = &sysfb_primary_display.screen;
149151
u32 cur_efi_x = efi_x;
150152
unsigned int len;
151153
const char *s;
152154
void *dst;
153155

154-
si = &screen_info;
155156
len = si->lfb_linelength;
156157

157158
while (num) {
@@ -174,7 +175,7 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
174175
x = efi_x;
175176

176177
while (n-- > 0) {
177-
efi_earlycon_write_char(dst + x*4, *s, h);
178+
efi_earlycon_write_char(dst + x * 4, *s, h, si);
178179
x += font->width;
179180
s++;
180181
}
@@ -207,10 +208,10 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
207208
cur_line_y = (cur_line_y + 1) % max_line_y;
208209

209210
efi_y -= font->height;
210-
efi_earlycon_scroll_up();
211+
efi_earlycon_scroll_up(si);
211212

212213
for (i = 0; i < font->height; i++)
213-
efi_earlycon_clear_scanline(efi_y + i);
214+
efi_earlycon_clear_scanline(efi_y + i, si);
214215
}
215216
}
216217
}
@@ -226,22 +227,21 @@ void __init efi_earlycon_reprobe(void)
226227
static int __init efi_earlycon_setup(struct earlycon_device *device,
227228
const char *opt)
228229
{
229-
struct screen_info *si;
230+
const struct screen_info *si = &sysfb_primary_display.screen;
230231
u16 xres, yres;
231232
u32 i;
232233

233234
fb_wb = opt && !strcmp(opt, "ram");
234235

235-
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) {
236+
if (si->orig_video_isVGA != VIDEO_TYPE_EFI) {
236237
fb_probed = true;
237238
return -ENODEV;
238239
}
239240

240-
fb_base = screen_info.lfb_base;
241-
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
242-
fb_base |= (u64)screen_info.ext_lfb_base << 32;
241+
fb_base = si->lfb_base;
242+
if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
243+
fb_base |= (u64)si->ext_lfb_base << 32;
243244

244-
si = &screen_info;
245245
xres = si->lfb_width;
246246
yres = si->lfb_height;
247247

@@ -266,7 +266,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
266266

267267
efi_y -= font->height;
268268
for (i = 0; i < (yres - efi_y) / font->height; i++)
269-
efi_earlycon_scroll_up();
269+
efi_earlycon_scroll_up(si);
270270

271271
device->con->write = efi_earlycon_write;
272272
earlycon_console = device->con;

drivers/firmware/efi/efi-init.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
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

26-
unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
26+
unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR;
2727

2828
static int __init is_memory(efi_memory_desc_t *md)
2929
{
@@ -57,31 +57,31 @@ 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
{
70-
struct screen_info *si;
70+
struct sysfb_display_info *dpy;
7171

72-
if (screen_info_table != EFI_INVALID_TABLE_ADDR) {
73-
si = early_memremap(screen_info_table, sizeof(*si));
74-
if (!si) {
75-
pr_err("Could not map screen_info config table\n");
72+
if (primary_display_table != EFI_INVALID_TABLE_ADDR) {
73+
dpy = early_memremap(primary_display_table, sizeof(*dpy));
74+
if (!dpy) {
75+
pr_err("Could not map primary_display config table\n");
7676
return;
7777
}
78-
screen_info = *si;
79-
memset(si, 0, sizeof(*si));
80-
early_memunmap(si, sizeof(*si));
78+
sysfb_primary_display = *dpy;
79+
memset(dpy, 0, sizeof(*dpy));
80+
early_memunmap(dpy, sizeof(*dpy));
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
}

0 commit comments

Comments
 (0)