From 4293b09251490fe493c3fc5e0d3de7168fe70039 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 9 Oct 2023 23:18:39 +0200 Subject: dummycon: limit Arm console size hack to footbridge The dummycon default console size used to be determined by architecture, but now this is a Kconfig setting on everything except ARM. Tracing this back in the historic git trees, this was used to match the size of VGA console or VGA framebuffer on early machines, but nowadays that code is no longer used, except probably on the old footbridge/netwinder since that is the only one that supports vgacon. On machines with a framebuffer, booting with DT so far results in always using the hardcoded 80x30 size in dummycon, while on ATAGS the setting can come from a bootloader specific override. Both seem to be worse choices than the Kconfig setting, since the actual text size for fbcon also depends on the selected font. Make this work the same way as everywhere else and use the normal Kconfig setting, except for the footbridge with vgacon, which keeps using the traditional code. If vgacon is disabled, footbridge can also ignore the setting. This means the screen_info only has to be provided when either vgacon or EFI are enabled now. To limit the amount of surprises on Arm, change the Kconfig default to the previously used 80x30 setting instead of the usual 80x25. Reviewed-by: Thomas Zimmermann Tested-by: Linus Walleij Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20231009211845.3136536-4-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm/kernel/atags_parse.c | 2 +- arch/arm/kernel/setup.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c index 33f6eb5213a5..4c815da3b77b 100644 --- a/arch/arm/kernel/atags_parse.c +++ b/arch/arm/kernel/atags_parse.c @@ -69,7 +69,7 @@ static int __init parse_tag_mem32(const struct tag *tag) __tagtable(ATAG_MEM, parse_tag_mem32); -#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) +#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) static int __init parse_tag_videotext(const struct tag *tag) { screen_info.orig_x = tag->u.videotext.x; diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index c66b560562b3..40326a35a179 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -928,8 +928,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) request_resource(&ioport_resource, &lp2); } -#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) || \ - defined(CONFIG_EFI) +#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) struct screen_info screen_info = { .orig_video_lines = 30, .orig_video_cols = 80, -- cgit v1.2.3 From acfc788233263fee9413434d39d4201a8de592ba Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 9 Oct 2023 23:18:41 +0200 Subject: vgacon: remove screen_info dependency The vga console driver is fairly self-contained, and only used by architectures that explicitly initialize the screen_info settings. Chance every instance that picks the vga console by setting conswitchp to call a function instead, and pass a reference to the screen_info there. Reviewed-by: Javier Martinez Canillas Acked-by: Khalid Azzi Acked-by: Helge Deller Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20231009211845.3136536-6-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/alpha/kernel/setup.c | 2 +- arch/arm/kernel/setup.c | 2 +- arch/ia64/kernel/setup.c | 2 +- arch/mips/kernel/setup.c | 2 +- arch/x86/kernel/setup.c | 2 +- drivers/firmware/pcdp.c | 2 +- drivers/video/console/vgacon.c | 68 +++++++++++++++++++++++++----------------- include/linux/console.h | 7 +++++ 8 files changed, 53 insertions(+), 34 deletions(-) (limited to 'arch/arm') diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index 85a679ce061c..c00493346860 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -654,7 +654,7 @@ setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - conswitchp = &vga_con; + vgacon_register_screen(&screen_info); #endif #endif diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 40326a35a179..5d8a7fb3eba4 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1192,7 +1192,7 @@ void __init setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - conswitchp = &vga_con; + vgacon_register_screen(&screen_info); #endif #endif diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index d2c66efdde56..2c9283fcd375 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -619,7 +619,7 @@ setup_arch (char **cmdline_p) * memory so we can avoid this problem. */ if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY) - conswitchp = &vga_con; + vgacon_register_screen(&screen_info); # endif } #endif diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 1aba7dc95132..6c3fae62a9f6 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -794,7 +794,7 @@ void __init setup_arch(char **cmdline_p) #if defined(CONFIG_VT) #if defined(CONFIG_VGA_CONSOLE) - conswitchp = &vga_con; + vgacon_register_screen(&screen_info); #endif #endif diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index b098b1fa2470..d626e13c921a 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1290,7 +1290,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)) - conswitchp = &vga_con; + vgacon_register_screen(&screen_info); #endif #endif x86_init.oem.banner(); diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c index 715a45442d1c..667a595373b2 100644 --- a/drivers/firmware/pcdp.c +++ b/drivers/firmware/pcdp.c @@ -72,7 +72,7 @@ setup_vga_console(struct pcdp_device *dev) return -ENODEV; } - conswitchp = &vga_con; + vgacon_register_screen(&screen_info); printk(KERN_INFO "PCDP: VGA console\n"); return 0; #else diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 7ad047bcae17..8ef1579fa57f 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -89,6 +89,8 @@ static int vga_video_font_height; static int vga_scan_lines __read_mostly; static unsigned int vga_rolled_over; /* last vc_origin offset before wrap */ +static struct screen_info *vga_si; + static bool vga_hardscroll_enabled; static bool vga_hardscroll_user_enable = true; @@ -153,8 +155,9 @@ static const char *vgacon_startup(void) u16 saved1, saved2; volatile u16 *p; - if (screen_info.orig_video_isVGA == VIDEO_TYPE_VLFB || - screen_info.orig_video_isVGA == VIDEO_TYPE_EFI) { + if (!vga_si || + vga_si->orig_video_isVGA == VIDEO_TYPE_VLFB || + vga_si->orig_video_isVGA == VIDEO_TYPE_EFI) { no_vga: #ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con; @@ -164,29 +167,29 @@ static const char *vgacon_startup(void) #endif } - /* boot_params.screen_info reasonably initialized? */ - if ((screen_info.orig_video_lines == 0) || - (screen_info.orig_video_cols == 0)) + /* vga_si reasonably initialized? */ + if ((vga_si->orig_video_lines == 0) || + (vga_si->orig_video_cols == 0)) goto no_vga; /* VGA16 modes are not handled by VGACON */ - if ((screen_info.orig_video_mode == 0x0D) || /* 320x200/4 */ - (screen_info.orig_video_mode == 0x0E) || /* 640x200/4 */ - (screen_info.orig_video_mode == 0x10) || /* 640x350/4 */ - (screen_info.orig_video_mode == 0x12) || /* 640x480/4 */ - (screen_info.orig_video_mode == 0x6A)) /* 800x600/4 (VESA) */ + if ((vga_si->orig_video_mode == 0x0D) || /* 320x200/4 */ + (vga_si->orig_video_mode == 0x0E) || /* 640x200/4 */ + (vga_si->orig_video_mode == 0x10) || /* 640x350/4 */ + (vga_si->orig_video_mode == 0x12) || /* 640x480/4 */ + (vga_si->orig_video_mode == 0x6A)) /* 800x600/4 (VESA) */ goto no_vga; - vga_video_num_lines = screen_info.orig_video_lines; - vga_video_num_columns = screen_info.orig_video_cols; + vga_video_num_lines = vga_si->orig_video_lines; + vga_video_num_columns = vga_si->orig_video_cols; vgastate.vgabase = NULL; - if (screen_info.orig_video_mode == 7) { + if (vga_si->orig_video_mode == 7) { /* Monochrome display */ vga_vram_base = 0xb0000; vga_video_port_reg = VGA_CRT_IM; vga_video_port_val = VGA_CRT_DM; - if ((screen_info.orig_video_ega_bx & 0xff) != 0x10) { + if ((vga_si->orig_video_ega_bx & 0xff) != 0x10) { static struct resource ega_console_resource = { .name = "ega", .flags = IORESOURCE_IO, @@ -223,12 +226,12 @@ static const char *vgacon_startup(void) vga_vram_base = 0xb8000; vga_video_port_reg = VGA_CRT_IC; vga_video_port_val = VGA_CRT_DC; - if ((screen_info.orig_video_ega_bx & 0xff) != 0x10) { + if ((vga_si->orig_video_ega_bx & 0xff) != 0x10) { int i; vga_vram_size = 0x8000; - if (!screen_info.orig_video_isVGA) { + if (!vga_si->orig_video_isVGA) { static struct resource ega_console_resource = { .name = "ega", .flags = IORESOURCE_IO, @@ -319,14 +322,14 @@ static const char *vgacon_startup(void) || vga_video_type == VIDEO_TYPE_VGAC || vga_video_type == VIDEO_TYPE_EGAM) { vga_hardscroll_enabled = vga_hardscroll_user_enable; - vga_default_font_height = screen_info.orig_video_points; - vga_video_font_height = screen_info.orig_video_points; + vga_default_font_height = vga_si->orig_video_points; + vga_video_font_height = vga_si->orig_video_points; /* This may be suboptimal but is a safe bet - go with it */ vga_scan_lines = vga_video_font_height * vga_video_num_lines; } - vgacon_xres = screen_info.orig_video_cols * VGA_FONTWIDTH; + vgacon_xres = vga_si->orig_video_cols * VGA_FONTWIDTH; vgacon_yres = vga_scan_lines; return display_desc; @@ -371,7 +374,7 @@ static void vgacon_init(struct vc_data *c, int init) /* Only set the default if the user didn't deliberately override it */ if (global_cursor_default == -1) global_cursor_default = - !(screen_info.flags & VIDEO_FLAGS_NOCURSOR); + !(vga_si->flags & VIDEO_FLAGS_NOCURSOR); } static void vgacon_deinit(struct vc_data *c) @@ -589,7 +592,7 @@ static int vgacon_switch(struct vc_data *c) { int x = c->vc_cols * VGA_FONTWIDTH; int y = c->vc_rows * c->vc_cell_height; - int rows = screen_info.orig_video_lines * vga_default_font_height/ + int rows = vga_si->orig_video_lines * vga_default_font_height/ c->vc_cell_height; /* * We need to save screen size here as it's the only way @@ -609,7 +612,7 @@ static int vgacon_switch(struct vc_data *c) if ((vgacon_xres != x || vgacon_yres != y) && (!(vga_video_num_columns % 2) && - vga_video_num_columns <= screen_info.orig_video_cols && + vga_video_num_columns <= vga_si->orig_video_cols && vga_video_num_lines <= rows)) vgacon_doresize(c, c->vc_cols, c->vc_rows); } @@ -1056,13 +1059,13 @@ static int vgacon_resize(struct vc_data *c, unsigned int width, * Ho ho! Someone (svgatextmode, eh?) may have reprogrammed * the video mode! Set the new defaults then and go away. */ - screen_info.orig_video_cols = width; - screen_info.orig_video_lines = height; + vga_si->orig_video_cols = width; + vga_si->orig_video_lines = height; vga_default_font_height = c->vc_cell_height; return 0; } - if (width % 2 || width > screen_info.orig_video_cols || - height > (screen_info.orig_video_lines * vga_default_font_height)/ + if (width % 2 || width > vga_si->orig_video_cols || + height > (vga_si->orig_video_lines * vga_default_font_height)/ c->vc_cell_height) return -EINVAL; @@ -1092,8 +1095,8 @@ static void vgacon_save_screen(struct vc_data *c) * console initialization routines. */ vga_bootup_console = 1; - c->state.x = screen_info.orig_x; - c->state.y = screen_info.orig_y; + c->state.x = vga_si->orig_x; + c->state.y = vga_si->orig_y; } /* We can't copy in more than the size of the video buffer, @@ -1186,4 +1189,13 @@ const struct consw vga_con = { }; EXPORT_SYMBOL(vga_con); +void vgacon_register_screen(struct screen_info *si) +{ + if (!si || vga_si) + return; + + conswitchp = &vga_con; + vga_si = si; +} + MODULE_LICENSE("GPL"); diff --git a/include/linux/console.h b/include/linux/console.h index 7de11c763eb3..5ff6f11c47b1 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -101,6 +101,13 @@ extern const struct consw dummy_con; /* dummy console buffer */ extern const struct consw vga_con; /* VGA text console */ extern const struct consw newport_con; /* SGI Newport console */ +struct screen_info; +#ifdef CONFIG_VGA_CONSOLE +void vgacon_register_screen(struct screen_info *si); +#else +static inline void vgacon_register_screen(struct screen_info *si) { } +#endif + int con_is_bound(const struct consw *csw); int do_unregister_con_driver(const struct consw *csw); int do_take_over_console(const struct consw *sw, int first, int last, int deflt); -- cgit v1.2.3 From 555624c0d10bf09c62c45a86a47e752013f86fb5 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 9 Oct 2023 23:18:42 +0200 Subject: vgacon: clean up global screen_info instances To prepare for completely separating the VGA console screen_info from the one used in EFI/sysfb, rename the vgacon instances and make them local as much as possible. ia64 and arm both have confurations with vgacon and efi, but the contents never overlaps because ia64 has no EFI framebuffer, and arm only has vga console on legacy platforms without EFI. Renaming these is required before the EFI screen_info can be moved into drivers/firmware. The ia64 vga console is actually registered in two places from setup_arch(), but one of them is wrong, so drop the one in pcdp.c and fix the one in setup.c to use the correct conditional. x86 has to keep them together, as the boot protocol is used to switch between VGA text console and framebuffer through the screen_info data. Acked-by: Javier Martinez Canillas Acked-by: Khalid Aziz Acked-by: Helge Deller Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20231009211845.3136536-7-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/alpha/kernel/proto.h | 2 ++ arch/alpha/kernel/setup.c | 6 ++--- arch/alpha/kernel/sys_sio.c | 6 ++--- arch/arm/include/asm/setup.h | 5 ++++ arch/arm/kernel/atags_parse.c | 18 +++++++------- arch/arm/kernel/efi.c | 6 ----- arch/arm/kernel/setup.c | 6 ++--- arch/ia64/kernel/setup.c | 49 +++++++++++++++++++-------------------- arch/mips/kernel/setup.c | 11 --------- arch/mips/mti-malta/malta-setup.c | 4 +++- arch/mips/sibyte/swarm/setup.c | 24 +++++++++++-------- arch/mips/sni/setup.c | 16 +++++++------ drivers/firmware/pcdp.c | 1 - 13 files changed, 74 insertions(+), 80 deletions(-) (limited to 'arch/arm') diff --git a/arch/alpha/kernel/proto.h b/arch/alpha/kernel/proto.h index 5816a31c1b38..2c89c1c55712 100644 --- a/arch/alpha/kernel/proto.h +++ b/arch/alpha/kernel/proto.h @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include +#include #include /* Prototypes of functions used across modules here in this directory. */ @@ -113,6 +114,7 @@ extern int boot_cpuid; #ifdef CONFIG_VERBOSE_MCHECK extern unsigned long alpha_verbose_mcheck; #endif +extern struct screen_info vgacon_screen_info; /* srmcons.c */ #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SRM) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index c00493346860..0738f9396f95 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -138,7 +138,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE]; * code think we're on a VGA color display. */ -struct screen_info screen_info = { +struct screen_info vgacon_screen_info = { .orig_x = 0, .orig_y = 25, .orig_video_cols = 80, @@ -146,8 +146,6 @@ struct screen_info screen_info = { .orig_video_isVGA = 1, .orig_video_points = 16 }; - -EXPORT_SYMBOL(screen_info); #endif /* @@ -654,7 +652,7 @@ setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - vgacon_register_screen(&screen_info); + vgacon_register_screen(&vgacon_screen_info); #endif #endif diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c index 7de8a5d2d206..086488ed83a7 100644 --- a/arch/alpha/kernel/sys_sio.c +++ b/arch/alpha/kernel/sys_sio.c @@ -60,9 +60,9 @@ alphabook1_init_arch(void) #ifdef CONFIG_VGA_CONSOLE /* The AlphaBook1 has LCD video fixed at 800x600, 37 rows and 100 cols. */ - screen_info.orig_y = 37; - screen_info.orig_video_cols = 100; - screen_info.orig_video_lines = 37; + vgacon_screen_info.orig_y = 37; + vgacon_screen_info.orig_video_cols = 100; + vgacon_screen_info.orig_video_lines = 37; #endif lca_init_arch(); diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h index 546af8b1e3f6..cc106f946c69 100644 --- a/arch/arm/include/asm/setup.h +++ b/arch/arm/include/asm/setup.h @@ -11,6 +11,7 @@ #ifndef __ASMARM_SETUP_H #define __ASMARM_SETUP_H +#include #include @@ -35,4 +36,8 @@ void early_mm_init(const struct machine_desc *); void adjust_lowmem_bounds(void); void setup_dma_zone(const struct machine_desc *desc); +#ifdef CONFIG_VGA_CONSOLE +extern struct screen_info vgacon_screen_info; +#endif + #endif diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c index 4c815da3b77b..4ec591bde3df 100644 --- a/arch/arm/kernel/atags_parse.c +++ b/arch/arm/kernel/atags_parse.c @@ -72,15 +72,15 @@ __tagtable(ATAG_MEM, parse_tag_mem32); #if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) static int __init parse_tag_videotext(const struct tag *tag) { - screen_info.orig_x = tag->u.videotext.x; - screen_info.orig_y = tag->u.videotext.y; - screen_info.orig_video_page = tag->u.videotext.video_page; - screen_info.orig_video_mode = tag->u.videotext.video_mode; - screen_info.orig_video_cols = tag->u.videotext.video_cols; - screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; - screen_info.orig_video_lines = tag->u.videotext.video_lines; - screen_info.orig_video_isVGA = tag->u.videotext.video_isvga; - screen_info.orig_video_points = tag->u.videotext.video_points; + vgacon_screen_info.orig_x = tag->u.videotext.x; + vgacon_screen_info.orig_y = tag->u.videotext.y; + vgacon_screen_info.orig_video_page = tag->u.videotext.video_page; + vgacon_screen_info.orig_video_mode = tag->u.videotext.video_mode; + vgacon_screen_info.orig_video_cols = tag->u.videotext.video_cols; + vgacon_screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; + vgacon_screen_info.orig_video_lines = tag->u.videotext.video_lines; + vgacon_screen_info.orig_video_isVGA = tag->u.videotext.video_isvga; + vgacon_screen_info.orig_video_points = tag->u.videotext.video_points; return 0; } diff --git a/arch/arm/kernel/efi.c b/arch/arm/kernel/efi.c index e94655ef16bb..6f9ec7d28a71 100644 --- a/arch/arm/kernel/efi.c +++ b/arch/arm/kernel/efi.c @@ -123,12 +123,6 @@ void __init arm_efi_init(void) { efi_init(); - if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI) { - /* dummycon on ARM needs non-zero values for columns/lines */ - screen_info.orig_video_cols = 80; - screen_info.orig_video_lines = 25; - } - /* ARM does not permit early mappings to persist across paging_init() */ efi_memmap_unmap(); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 5d8a7fb3eba4..135b7eff03f7 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -928,8 +928,8 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) request_resource(&ioport_resource, &lp2); } -#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) -struct screen_info screen_info = { +#if defined(CONFIG_VGA_CONSOLE) +static struct screen_info vgacon_screen_info = { .orig_video_lines = 30, .orig_video_cols = 80, .orig_video_mode = 0, @@ -1192,7 +1192,7 @@ void __init setup_arch(char **cmdline_p) #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - vgacon_register_screen(&screen_info); + vgacon_register_screen(&vgacon_screen_info); #endif #endif diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 2c9283fcd375..82feae1323f4 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -86,7 +86,8 @@ EXPORT_SYMBOL(local_per_cpu_offset); #endif unsigned long ia64_cycles_per_usec; struct ia64_boot_param *ia64_boot_param; -#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) +#if defined(CONFIG_EFI) +/* No longer used on ia64, but needed for linking */ struct screen_info screen_info; #endif #ifdef CONFIG_VGA_CONSOLE @@ -503,8 +504,9 @@ screen_info_setup(void) { #ifdef CONFIG_VGA_CONSOLE unsigned int orig_x, orig_y, num_cols, num_rows, font_height; + static struct screen_info si; - memset(&screen_info, 0, sizeof(screen_info)); + memset(&si, 0, sizeof(si)); if (!ia64_boot_param->console_info.num_rows || !ia64_boot_param->console_info.num_cols) { @@ -522,14 +524,26 @@ screen_info_setup(void) font_height = 400 / num_rows; } - screen_info.orig_x = orig_x; - screen_info.orig_y = orig_y; - screen_info.orig_video_cols = num_cols; - screen_info.orig_video_lines = num_rows; - screen_info.orig_video_points = font_height; - screen_info.orig_video_mode = 3; /* XXX fake */ - screen_info.orig_video_isVGA = 1; /* XXX fake */ - screen_info.orig_video_ega_bx = 3; /* XXX fake */ + si.orig_x = orig_x; + si.orig_y = orig_y; + si.orig_video_cols = num_cols; + si.orig_video_lines = num_rows; + si.orig_video_points = font_height; + si.orig_video_mode = 3; /* XXX fake */ + si.orig_video_isVGA = 1; /* XXX fake */ + si.orig_video_ega_bx = 3; /* XXX fake */ + + if (!conswitchp) { + /* + * Non-legacy systems may route legacy VGA MMIO range to system + * memory. vga_con probes the MMIO hole, so memory looks like + * a VGA device to it. The EFI memory map can tell us if it's + * memory so we can avoid this problem. + */ + if (efi_mem_type(vga_console_membase + 0xA0000) != + EFI_CONVENTIONAL_MEMORY) { + vgacon_register_screen(&si); + } #endif } @@ -609,21 +623,6 @@ setup_arch (char **cmdline_p) cpu_init(); /* initialize the bootstrap CPU */ mmu_context_init(); /* initialize context_id bitmap */ -#ifdef CONFIG_VT - if (!conswitchp) { -# if defined(CONFIG_VGA_CONSOLE) - /* - * Non-legacy systems may route legacy VGA MMIO range to system - * memory. vga_con probes the MMIO hole, so memory looks like - * a VGA device to it. The EFI memory map can tell us if it's - * memory so we can avoid this problem. - */ - if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY) - vgacon_register_screen(&screen_info); -# endif - } -#endif - /* enable IA-64 Machine Check Abort Handling unless disabled */ if (!nomca) ia64_mca_init(); diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 6c3fae62a9f6..cae181bbfee1 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -54,10 +53,6 @@ struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; EXPORT_SYMBOL(cpu_data); -#ifdef CONFIG_VGA_CONSOLE -struct screen_info screen_info; -#endif - /* * Setup information * @@ -792,12 +787,6 @@ void __init setup_arch(char **cmdline_p) if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64)) check_bugs64_early(); -#if defined(CONFIG_VT) -#if defined(CONFIG_VGA_CONSOLE) - vgacon_register_screen(&screen_info); -#endif -#endif - arch_mem_init(cmdline_p); dmi_setup(); diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c index 21cb3ac1237b..3a2836e9d856 100644 --- a/arch/mips/mti-malta/malta-setup.c +++ b/arch/mips/mti-malta/malta-setup.c @@ -161,7 +161,7 @@ static void __init pci_clock_check(void) #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) static void __init screen_info_setup(void) { - screen_info = (struct screen_info) { + static struct screen_info si = { .orig_x = 0, .orig_y = 25, .ext_mem_k = 0, @@ -175,6 +175,8 @@ static void __init screen_info_setup(void) .orig_video_isVGA = VIDEO_TYPE_VGAC, .orig_video_points = 16 }; + + vgacon_register_screen(&si); } #endif diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c index 37df504d3ecb..74e7c242b690 100644 --- a/arch/mips/sibyte/swarm/setup.c +++ b/arch/mips/sibyte/swarm/setup.c @@ -112,6 +112,19 @@ int update_persistent_clock64(struct timespec64 now) } } +#ifdef CONFIG_VGA_CONSOLE +static struct screen_info vgacon_screen_info = { + .orig_video_page = 52, + .orig_video_mode = 3, + .orig_video_cols = 80, + .flags = 12, + .orig_video_ega_bx = 3, + .orig_video_lines = 25, + .orig_video_isVGA = 0x22, + .orig_video_points = 16, +}; +#endif + void __init plat_mem_setup(void) { #ifdef CONFIG_SIBYTE_BCM1x80 @@ -130,16 +143,7 @@ void __init plat_mem_setup(void) swarm_rtc_type = RTC_M41T81; #ifdef CONFIG_VGA_CONSOLE - screen_info = (struct screen_info) { - .orig_video_page = 52, - .orig_video_mode = 3, - .orig_video_cols = 80, - .flags = 12, - .orig_video_ega_bx = 3, - .orig_video_lines = 25, - .orig_video_isVGA = 0x22, - .orig_video_points = 16, - }; + vgacon_register_screen(&vgacon_screen_info); /* XXXKW for CFE, get lines/cols from environment */ #endif } diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c index 9984cf91be7d..42fdb939c88d 100644 --- a/arch/mips/sni/setup.c +++ b/arch/mips/sni/setup.c @@ -39,18 +39,20 @@ extern void sni_machine_power_off(void); static void __init sni_display_setup(void) { #if defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_FW_ARC) - struct screen_info *si = &screen_info; + static struct screen_info si; DISPLAY_STATUS *di; di = ArcGetDisplayStatus(1); if (di) { - si->orig_x = di->CursorXPosition; - si->orig_y = di->CursorYPosition; - si->orig_video_cols = di->CursorMaxXPosition; - si->orig_video_lines = di->CursorMaxYPosition; - si->orig_video_isVGA = VIDEO_TYPE_VGAC; - si->orig_video_points = 16; + si.orig_x = di->CursorXPosition; + si.orig_y = di->CursorYPosition; + si.orig_video_cols = di->CursorMaxXPosition; + si.orig_video_lines = di->CursorMaxYPosition; + si.orig_video_isVGA = VIDEO_TYPE_VGAC; + si.orig_video_points = 16; + + vgacon_register_screen(&si); } #endif } diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c index 667a595373b2..876b3e9b37e2 100644 --- a/drivers/firmware/pcdp.c +++ b/drivers/firmware/pcdp.c @@ -72,7 +72,6 @@ setup_vga_console(struct pcdp_device *dev) return -ENODEV; } - vgacon_register_screen(&screen_info); printk(KERN_INFO "PCDP: VGA console\n"); return 0; #else -- cgit v1.2.3 From 0059bc9a29e02853dbbaa0f6d0635a687c8b9835 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 17 Oct 2023 11:39:47 +0200 Subject: console: fix up ARM screen_info reference Separating the VGA console screen_info from the EFI one unfortunately caused a build failure for footbridge that I had never caught with randconfig builds: arch/arm/kernel/setup.c:932:27: error: static declaration of 'vgacon_screen_info' follows non-static declaration 932 | static struct screen_info vgacon_screen_info = { | ^~~~~~~~~~~~~~~~~~ In file included from arch/arm/kernel/setup.c:44: arch/arm/include/asm/setup.h:40:27: note: previous declaration of 'vgacon_screen_info' with type 'struct screen_info' 40 | extern struct screen_info vgacon_screen_info; | ^~~~~~~~~~~~~~~~~~ arm-linux-gnueabi-ld: drivers/video/console/dummycon.o: in function `dummycon_init': dummycon.c:(.text+0xe4): undefined reference to `screen_info' Make sure the variable is global to avoid the conflict with the extern declaration, and make it work in dummycon.c Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20231017093947.3627976-2-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/vga.h | 1 + arch/arm/kernel/setup.c | 2 +- drivers/video/console/dummycon.c | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/include/asm/vga.h b/arch/arm/include/asm/vga.h index 7c0bee57855a..6c430ec371df 100644 --- a/arch/arm/include/asm/vga.h +++ b/arch/arm/include/asm/vga.h @@ -5,6 +5,7 @@ #include extern unsigned long vga_base; +extern struct screen_info vgacon_screen_info; #define VGA_MAP_MEM(x,s) (vga_base + (x)) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 135b7eff03f7..1623ae1aec45 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -929,7 +929,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) } #if defined(CONFIG_VGA_CONSOLE) -static struct screen_info vgacon_screen_info = { +struct screen_info vgacon_screen_info = { .orig_video_lines = 30, .orig_video_cols = 80, .orig_video_mode = 0, diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 70549fecee12..14af5d9e13b0 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -19,8 +19,9 @@ */ #if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) -#define DUMMY_COLUMNS screen_info.orig_video_cols -#define DUMMY_ROWS screen_info.orig_video_lines +#include +#define DUMMY_COLUMNS vgacon_screen_info.orig_video_cols +#define DUMMY_ROWS vgacon_screen_info.orig_video_lines #else /* set by Kconfig. Use 80x25 for 640x480 and 160x64 for 1280x1024 */ #define DUMMY_COLUMNS CONFIG_DUMMY_CONSOLE_COLUMNS -- cgit v1.2.3