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

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 <javierm@redhat.com>
Acked-by: Khalid Azzi <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-6-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Arnd Bergmann and committed by
Greg Kroah-Hartman
acfc7882 fd90410e

+53 -34
+1 -1
arch/alpha/kernel/setup.c
··· 654 654 655 655 #ifdef CONFIG_VT 656 656 #if defined(CONFIG_VGA_CONSOLE) 657 - conswitchp = &vga_con; 657 + vgacon_register_screen(&screen_info); 658 658 #endif 659 659 #endif 660 660
+1 -1
arch/arm/kernel/setup.c
··· 1192 1192 1193 1193 #ifdef CONFIG_VT 1194 1194 #if defined(CONFIG_VGA_CONSOLE) 1195 - conswitchp = &vga_con; 1195 + vgacon_register_screen(&screen_info); 1196 1196 #endif 1197 1197 #endif 1198 1198
+1 -1
arch/ia64/kernel/setup.c
··· 619 619 * memory so we can avoid this problem. 620 620 */ 621 621 if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY) 622 - conswitchp = &vga_con; 622 + vgacon_register_screen(&screen_info); 623 623 # endif 624 624 } 625 625 #endif
+1 -1
arch/mips/kernel/setup.c
··· 794 794 795 795 #if defined(CONFIG_VT) 796 796 #if defined(CONFIG_VGA_CONSOLE) 797 - conswitchp = &vga_con; 797 + vgacon_register_screen(&screen_info); 798 798 #endif 799 799 #endif 800 800
+1 -1
arch/x86/kernel/setup.c
··· 1290 1290 #ifdef CONFIG_VT 1291 1291 #if defined(CONFIG_VGA_CONSOLE) 1292 1292 if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) 1293 - conswitchp = &vga_con; 1293 + vgacon_register_screen(&screen_info); 1294 1294 #endif 1295 1295 #endif 1296 1296 x86_init.oem.banner();
+1 -1
drivers/firmware/pcdp.c
··· 72 72 return -ENODEV; 73 73 } 74 74 75 - conswitchp = &vga_con; 75 + vgacon_register_screen(&screen_info); 76 76 printk(KERN_INFO "PCDP: VGA console\n"); 77 77 return 0; 78 78 #else
+40 -28
drivers/video/console/vgacon.c
··· 89 89 static int vga_scan_lines __read_mostly; 90 90 static unsigned int vga_rolled_over; /* last vc_origin offset before wrap */ 91 91 92 + static struct screen_info *vga_si; 93 + 92 94 static bool vga_hardscroll_enabled; 93 95 static bool vga_hardscroll_user_enable = true; 94 96 ··· 155 153 u16 saved1, saved2; 156 154 volatile u16 *p; 157 155 158 - if (screen_info.orig_video_isVGA == VIDEO_TYPE_VLFB || 159 - screen_info.orig_video_isVGA == VIDEO_TYPE_EFI) { 156 + if (!vga_si || 157 + vga_si->orig_video_isVGA == VIDEO_TYPE_VLFB || 158 + vga_si->orig_video_isVGA == VIDEO_TYPE_EFI) { 160 159 no_vga: 161 160 #ifdef CONFIG_DUMMY_CONSOLE 162 161 conswitchp = &dummy_con; ··· 167 164 #endif 168 165 } 169 166 170 - /* boot_params.screen_info reasonably initialized? */ 171 - if ((screen_info.orig_video_lines == 0) || 172 - (screen_info.orig_video_cols == 0)) 167 + /* vga_si reasonably initialized? */ 168 + if ((vga_si->orig_video_lines == 0) || 169 + (vga_si->orig_video_cols == 0)) 173 170 goto no_vga; 174 171 175 172 /* VGA16 modes are not handled by VGACON */ 176 - if ((screen_info.orig_video_mode == 0x0D) || /* 320x200/4 */ 177 - (screen_info.orig_video_mode == 0x0E) || /* 640x200/4 */ 178 - (screen_info.orig_video_mode == 0x10) || /* 640x350/4 */ 179 - (screen_info.orig_video_mode == 0x12) || /* 640x480/4 */ 180 - (screen_info.orig_video_mode == 0x6A)) /* 800x600/4 (VESA) */ 173 + if ((vga_si->orig_video_mode == 0x0D) || /* 320x200/4 */ 174 + (vga_si->orig_video_mode == 0x0E) || /* 640x200/4 */ 175 + (vga_si->orig_video_mode == 0x10) || /* 640x350/4 */ 176 + (vga_si->orig_video_mode == 0x12) || /* 640x480/4 */ 177 + (vga_si->orig_video_mode == 0x6A)) /* 800x600/4 (VESA) */ 181 178 goto no_vga; 182 179 183 - vga_video_num_lines = screen_info.orig_video_lines; 184 - vga_video_num_columns = screen_info.orig_video_cols; 180 + vga_video_num_lines = vga_si->orig_video_lines; 181 + vga_video_num_columns = vga_si->orig_video_cols; 185 182 vgastate.vgabase = NULL; 186 183 187 - if (screen_info.orig_video_mode == 7) { 184 + if (vga_si->orig_video_mode == 7) { 188 185 /* Monochrome display */ 189 186 vga_vram_base = 0xb0000; 190 187 vga_video_port_reg = VGA_CRT_IM; 191 188 vga_video_port_val = VGA_CRT_DM; 192 - if ((screen_info.orig_video_ega_bx & 0xff) != 0x10) { 189 + if ((vga_si->orig_video_ega_bx & 0xff) != 0x10) { 193 190 static struct resource ega_console_resource = 194 191 { .name = "ega", 195 192 .flags = IORESOURCE_IO, ··· 226 223 vga_vram_base = 0xb8000; 227 224 vga_video_port_reg = VGA_CRT_IC; 228 225 vga_video_port_val = VGA_CRT_DC; 229 - if ((screen_info.orig_video_ega_bx & 0xff) != 0x10) { 226 + if ((vga_si->orig_video_ega_bx & 0xff) != 0x10) { 230 227 int i; 231 228 232 229 vga_vram_size = 0x8000; 233 230 234 - if (!screen_info.orig_video_isVGA) { 231 + if (!vga_si->orig_video_isVGA) { 235 232 static struct resource ega_console_resource = 236 233 { .name = "ega", 237 234 .flags = IORESOURCE_IO, ··· 322 319 || vga_video_type == VIDEO_TYPE_VGAC 323 320 || vga_video_type == VIDEO_TYPE_EGAM) { 324 321 vga_hardscroll_enabled = vga_hardscroll_user_enable; 325 - vga_default_font_height = screen_info.orig_video_points; 326 - vga_video_font_height = screen_info.orig_video_points; 322 + vga_default_font_height = vga_si->orig_video_points; 323 + vga_video_font_height = vga_si->orig_video_points; 327 324 /* This may be suboptimal but is a safe bet - go with it */ 328 325 vga_scan_lines = 329 326 vga_video_font_height * vga_video_num_lines; 330 327 } 331 328 332 - vgacon_xres = screen_info.orig_video_cols * VGA_FONTWIDTH; 329 + vgacon_xres = vga_si->orig_video_cols * VGA_FONTWIDTH; 333 330 vgacon_yres = vga_scan_lines; 334 331 335 332 return display_desc; ··· 374 371 /* Only set the default if the user didn't deliberately override it */ 375 372 if (global_cursor_default == -1) 376 373 global_cursor_default = 377 - !(screen_info.flags & VIDEO_FLAGS_NOCURSOR); 374 + !(vga_si->flags & VIDEO_FLAGS_NOCURSOR); 378 375 } 379 376 380 377 static void vgacon_deinit(struct vc_data *c) ··· 592 589 { 593 590 int x = c->vc_cols * VGA_FONTWIDTH; 594 591 int y = c->vc_rows * c->vc_cell_height; 595 - int rows = screen_info.orig_video_lines * vga_default_font_height/ 592 + int rows = vga_si->orig_video_lines * vga_default_font_height/ 596 593 c->vc_cell_height; 597 594 /* 598 595 * We need to save screen size here as it's the only way ··· 612 609 613 610 if ((vgacon_xres != x || vgacon_yres != y) && 614 611 (!(vga_video_num_columns % 2) && 615 - vga_video_num_columns <= screen_info.orig_video_cols && 612 + vga_video_num_columns <= vga_si->orig_video_cols && 616 613 vga_video_num_lines <= rows)) 617 614 vgacon_doresize(c, c->vc_cols, c->vc_rows); 618 615 } ··· 1059 1056 * Ho ho! Someone (svgatextmode, eh?) may have reprogrammed 1060 1057 * the video mode! Set the new defaults then and go away. 1061 1058 */ 1062 - screen_info.orig_video_cols = width; 1063 - screen_info.orig_video_lines = height; 1059 + vga_si->orig_video_cols = width; 1060 + vga_si->orig_video_lines = height; 1064 1061 vga_default_font_height = c->vc_cell_height; 1065 1062 return 0; 1066 1063 } 1067 - if (width % 2 || width > screen_info.orig_video_cols || 1068 - height > (screen_info.orig_video_lines * vga_default_font_height)/ 1064 + if (width % 2 || width > vga_si->orig_video_cols || 1065 + height > (vga_si->orig_video_lines * vga_default_font_height)/ 1069 1066 c->vc_cell_height) 1070 1067 return -EINVAL; 1071 1068 ··· 1095 1092 * console initialization routines. 1096 1093 */ 1097 1094 vga_bootup_console = 1; 1098 - c->state.x = screen_info.orig_x; 1099 - c->state.y = screen_info.orig_y; 1095 + c->state.x = vga_si->orig_x; 1096 + c->state.y = vga_si->orig_y; 1100 1097 } 1101 1098 1102 1099 /* We can't copy in more than the size of the video buffer, ··· 1188 1185 .con_invert_region = vgacon_invert_region, 1189 1186 }; 1190 1187 EXPORT_SYMBOL(vga_con); 1188 + 1189 + void vgacon_register_screen(struct screen_info *si) 1190 + { 1191 + if (!si || vga_si) 1192 + return; 1193 + 1194 + conswitchp = &vga_con; 1195 + vga_si = si; 1196 + } 1191 1197 1192 1198 MODULE_LICENSE("GPL");
+7
include/linux/console.h
··· 101 101 extern const struct consw vga_con; /* VGA text console */ 102 102 extern const struct consw newport_con; /* SGI Newport console */ 103 103 104 + struct screen_info; 105 + #ifdef CONFIG_VGA_CONSOLE 106 + void vgacon_register_screen(struct screen_info *si); 107 + #else 108 + static inline void vgacon_register_screen(struct screen_info *si) { } 109 + #endif 110 + 104 111 int con_is_bound(const struct consw *csw); 105 112 int do_unregister_con_driver(const struct consw *csw); 106 113 int do_take_over_console(const struct consw *sw, int first, int last, int deflt);