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

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 <javierm@redhat.com>
Acked-by: Khalid Aziz <khalid@gonehiking.org>
Acked-by: Helge Deller <deller@gmx.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20231009211845.3136536-7-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Arnd Bergmann and committed by
Greg Kroah-Hartman
555624c0 acfc7882

+74 -80
+2
arch/alpha/kernel/proto.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 #include <linux/interrupt.h> 3 + #include <linux/screen_info.h> 3 4 #include <linux/io.h> 4 5 5 6 /* Prototypes of functions used across modules here in this directory. */ ··· 114 113 #ifdef CONFIG_VERBOSE_MCHECK 115 114 extern unsigned long alpha_verbose_mcheck; 116 115 #endif 116 + extern struct screen_info vgacon_screen_info; 117 117 118 118 /* srmcons.c */ 119 119 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SRM)
+2 -4
arch/alpha/kernel/setup.c
··· 138 138 * code think we're on a VGA color display. 139 139 */ 140 140 141 - struct screen_info screen_info = { 141 + struct screen_info vgacon_screen_info = { 142 142 .orig_x = 0, 143 143 .orig_y = 25, 144 144 .orig_video_cols = 80, ··· 146 146 .orig_video_isVGA = 1, 147 147 .orig_video_points = 16 148 148 }; 149 - 150 - EXPORT_SYMBOL(screen_info); 151 149 #endif 152 150 153 151 /* ··· 652 654 653 655 #ifdef CONFIG_VT 654 656 #if defined(CONFIG_VGA_CONSOLE) 655 - vgacon_register_screen(&screen_info); 657 + vgacon_register_screen(&vgacon_screen_info); 656 658 #endif 657 659 #endif 658 660
+3 -3
arch/alpha/kernel/sys_sio.c
··· 60 60 #ifdef CONFIG_VGA_CONSOLE 61 61 /* The AlphaBook1 has LCD video fixed at 800x600, 62 62 37 rows and 100 cols. */ 63 - screen_info.orig_y = 37; 64 - screen_info.orig_video_cols = 100; 65 - screen_info.orig_video_lines = 37; 63 + vgacon_screen_info.orig_y = 37; 64 + vgacon_screen_info.orig_video_cols = 100; 65 + vgacon_screen_info.orig_video_lines = 37; 66 66 #endif 67 67 68 68 lca_init_arch();
+5
arch/arm/include/asm/setup.h
··· 11 11 #ifndef __ASMARM_SETUP_H 12 12 #define __ASMARM_SETUP_H 13 13 14 + #include <linux/screen_info.h> 14 15 #include <uapi/asm/setup.h> 15 16 16 17 ··· 35 34 void early_mm_init(const struct machine_desc *); 36 35 void adjust_lowmem_bounds(void); 37 36 void setup_dma_zone(const struct machine_desc *desc); 37 + 38 + #ifdef CONFIG_VGA_CONSOLE 39 + extern struct screen_info vgacon_screen_info; 40 + #endif 38 41 39 42 #endif
+9 -9
arch/arm/kernel/atags_parse.c
··· 72 72 #if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE) 73 73 static int __init parse_tag_videotext(const struct tag *tag) 74 74 { 75 - screen_info.orig_x = tag->u.videotext.x; 76 - screen_info.orig_y = tag->u.videotext.y; 77 - screen_info.orig_video_page = tag->u.videotext.video_page; 78 - screen_info.orig_video_mode = tag->u.videotext.video_mode; 79 - screen_info.orig_video_cols = tag->u.videotext.video_cols; 80 - screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; 81 - screen_info.orig_video_lines = tag->u.videotext.video_lines; 82 - screen_info.orig_video_isVGA = tag->u.videotext.video_isvga; 83 - screen_info.orig_video_points = tag->u.videotext.video_points; 75 + vgacon_screen_info.orig_x = tag->u.videotext.x; 76 + vgacon_screen_info.orig_y = tag->u.videotext.y; 77 + vgacon_screen_info.orig_video_page = tag->u.videotext.video_page; 78 + vgacon_screen_info.orig_video_mode = tag->u.videotext.video_mode; 79 + vgacon_screen_info.orig_video_cols = tag->u.videotext.video_cols; 80 + vgacon_screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx; 81 + vgacon_screen_info.orig_video_lines = tag->u.videotext.video_lines; 82 + vgacon_screen_info.orig_video_isVGA = tag->u.videotext.video_isvga; 83 + vgacon_screen_info.orig_video_points = tag->u.videotext.video_points; 84 84 return 0; 85 85 } 86 86
-6
arch/arm/kernel/efi.c
··· 123 123 { 124 124 efi_init(); 125 125 126 - if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI) { 127 - /* dummycon on ARM needs non-zero values for columns/lines */ 128 - screen_info.orig_video_cols = 80; 129 - screen_info.orig_video_lines = 25; 130 - } 131 - 132 126 /* ARM does not permit early mappings to persist across paging_init() */ 133 127 efi_memmap_unmap(); 134 128
+3 -3
arch/arm/kernel/setup.c
··· 928 928 request_resource(&ioport_resource, &lp2); 929 929 } 930 930 931 - #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) 932 - struct screen_info screen_info = { 931 + #if defined(CONFIG_VGA_CONSOLE) 932 + static struct screen_info vgacon_screen_info = { 933 933 .orig_video_lines = 30, 934 934 .orig_video_cols = 80, 935 935 .orig_video_mode = 0, ··· 1192 1192 1193 1193 #ifdef CONFIG_VT 1194 1194 #if defined(CONFIG_VGA_CONSOLE) 1195 - vgacon_register_screen(&screen_info); 1195 + vgacon_register_screen(&vgacon_screen_info); 1196 1196 #endif 1197 1197 #endif 1198 1198
+24 -25
arch/ia64/kernel/setup.c
··· 86 86 #endif 87 87 unsigned long ia64_cycles_per_usec; 88 88 struct ia64_boot_param *ia64_boot_param; 89 - #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_EFI) 89 + #if defined(CONFIG_EFI) 90 + /* No longer used on ia64, but needed for linking */ 90 91 struct screen_info screen_info; 91 92 #endif 92 93 #ifdef CONFIG_VGA_CONSOLE ··· 504 503 { 505 504 #ifdef CONFIG_VGA_CONSOLE 506 505 unsigned int orig_x, orig_y, num_cols, num_rows, font_height; 506 + static struct screen_info si; 507 507 508 - memset(&screen_info, 0, sizeof(screen_info)); 508 + memset(&si, 0, sizeof(si)); 509 509 510 510 if (!ia64_boot_param->console_info.num_rows || 511 511 !ia64_boot_param->console_info.num_cols) { ··· 524 522 font_height = 400 / num_rows; 525 523 } 526 524 527 - screen_info.orig_x = orig_x; 528 - screen_info.orig_y = orig_y; 529 - screen_info.orig_video_cols = num_cols; 530 - screen_info.orig_video_lines = num_rows; 531 - screen_info.orig_video_points = font_height; 532 - screen_info.orig_video_mode = 3; /* XXX fake */ 533 - screen_info.orig_video_isVGA = 1; /* XXX fake */ 534 - screen_info.orig_video_ega_bx = 3; /* XXX fake */ 525 + si.orig_x = orig_x; 526 + si.orig_y = orig_y; 527 + si.orig_video_cols = num_cols; 528 + si.orig_video_lines = num_rows; 529 + si.orig_video_points = font_height; 530 + si.orig_video_mode = 3; /* XXX fake */ 531 + si.orig_video_isVGA = 1; /* XXX fake */ 532 + si.orig_video_ega_bx = 3; /* XXX fake */ 533 + 534 + if (!conswitchp) { 535 + /* 536 + * Non-legacy systems may route legacy VGA MMIO range to system 537 + * memory. vga_con probes the MMIO hole, so memory looks like 538 + * a VGA device to it. The EFI memory map can tell us if it's 539 + * memory so we can avoid this problem. 540 + */ 541 + if (efi_mem_type(vga_console_membase + 0xA0000) != 542 + EFI_CONVENTIONAL_MEMORY) { 543 + vgacon_register_screen(&si); 544 + } 535 545 #endif 536 546 } 537 547 ··· 622 608 623 609 cpu_init(); /* initialize the bootstrap CPU */ 624 610 mmu_context_init(); /* initialize context_id bitmap */ 625 - 626 - #ifdef CONFIG_VT 627 - if (!conswitchp) { 628 - # if defined(CONFIG_VGA_CONSOLE) 629 - /* 630 - * Non-legacy systems may route legacy VGA MMIO range to system 631 - * memory. vga_con probes the MMIO hole, so memory looks like 632 - * a VGA device to it. The EFI memory map can tell us if it's 633 - * memory so we can avoid this problem. 634 - */ 635 - if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY) 636 - vgacon_register_screen(&screen_info); 637 - # endif 638 - } 639 - #endif 640 611 641 612 /* enable IA-64 Machine Check Abort Handling unless disabled */ 642 613 if (!nomca)
-11
arch/mips/kernel/setup.c
··· 15 15 #include <linux/delay.h> 16 16 #include <linux/ioport.h> 17 17 #include <linux/export.h> 18 - #include <linux/screen_info.h> 19 18 #include <linux/memblock.h> 20 19 #include <linux/initrd.h> 21 20 #include <linux/root_dev.h> ··· 52 53 struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; 53 54 54 55 EXPORT_SYMBOL(cpu_data); 55 - 56 - #ifdef CONFIG_VGA_CONSOLE 57 - struct screen_info screen_info; 58 - #endif 59 56 60 57 /* 61 58 * Setup information ··· 786 791 cpu_report(); 787 792 if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64)) 788 793 check_bugs64_early(); 789 - 790 - #if defined(CONFIG_VT) 791 - #if defined(CONFIG_VGA_CONSOLE) 792 - vgacon_register_screen(&screen_info); 793 - #endif 794 - #endif 795 794 796 795 arch_mem_init(cmdline_p); 797 796 dmi_setup();
+3 -1
arch/mips/mti-malta/malta-setup.c
··· 161 161 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) 162 162 static void __init screen_info_setup(void) 163 163 { 164 - screen_info = (struct screen_info) { 164 + static struct screen_info si = { 165 165 .orig_x = 0, 166 166 .orig_y = 25, 167 167 .ext_mem_k = 0, ··· 175 175 .orig_video_isVGA = VIDEO_TYPE_VGAC, 176 176 .orig_video_points = 16 177 177 }; 178 + 179 + vgacon_register_screen(&si); 178 180 } 179 181 #endif 180 182
+14 -10
arch/mips/sibyte/swarm/setup.c
··· 112 112 } 113 113 } 114 114 115 + #ifdef CONFIG_VGA_CONSOLE 116 + static struct screen_info vgacon_screen_info = { 117 + .orig_video_page = 52, 118 + .orig_video_mode = 3, 119 + .orig_video_cols = 80, 120 + .flags = 12, 121 + .orig_video_ega_bx = 3, 122 + .orig_video_lines = 25, 123 + .orig_video_isVGA = 0x22, 124 + .orig_video_points = 16, 125 + }; 126 + #endif 127 + 115 128 void __init plat_mem_setup(void) 116 129 { 117 130 #ifdef CONFIG_SIBYTE_BCM1x80 ··· 143 130 swarm_rtc_type = RTC_M41T81; 144 131 145 132 #ifdef CONFIG_VGA_CONSOLE 146 - screen_info = (struct screen_info) { 147 - .orig_video_page = 52, 148 - .orig_video_mode = 3, 149 - .orig_video_cols = 80, 150 - .flags = 12, 151 - .orig_video_ega_bx = 3, 152 - .orig_video_lines = 25, 153 - .orig_video_isVGA = 0x22, 154 - .orig_video_points = 16, 155 - }; 133 + vgacon_register_screen(&vgacon_screen_info); 156 134 /* XXXKW for CFE, get lines/cols from environment */ 157 135 #endif 158 136 }
+9 -7
arch/mips/sni/setup.c
··· 39 39 static void __init sni_display_setup(void) 40 40 { 41 41 #if defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_FW_ARC) 42 - struct screen_info *si = &screen_info; 42 + static struct screen_info si; 43 43 DISPLAY_STATUS *di; 44 44 45 45 di = ArcGetDisplayStatus(1); 46 46 47 47 if (di) { 48 - si->orig_x = di->CursorXPosition; 49 - si->orig_y = di->CursorYPosition; 50 - si->orig_video_cols = di->CursorMaxXPosition; 51 - si->orig_video_lines = di->CursorMaxYPosition; 52 - si->orig_video_isVGA = VIDEO_TYPE_VGAC; 53 - si->orig_video_points = 16; 48 + si.orig_x = di->CursorXPosition; 49 + si.orig_y = di->CursorYPosition; 50 + si.orig_video_cols = di->CursorMaxXPosition; 51 + si.orig_video_lines = di->CursorMaxYPosition; 52 + si.orig_video_isVGA = VIDEO_TYPE_VGAC; 53 + si.orig_video_points = 16; 54 + 55 + vgacon_register_screen(&si); 54 56 } 55 57 #endif 56 58 }
-1
drivers/firmware/pcdp.c
··· 72 72 return -ENODEV; 73 73 } 74 74 75 - vgacon_register_screen(&screen_info); 76 75 printk(KERN_INFO "PCDP: VGA console\n"); 77 76 return 0; 78 77 #else