From patchwork Tue Oct 17 09:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13424924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AA4ECDB474 for ; Tue, 17 Oct 2023 09:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=F6VqTBpVvsl9S7AhVIth2+5McTVhTd8FbPnWYiNym4A=; b=jkHgZFPfXmW0Gg uor4LBT8temUZMsSsss+TqFqePZty2WAhPuOPQequ5aHhOWN4+dDK5985QlrMiOWx71Kj1SUPIRLR RLdTVbJ5Q3u8ykkqpvKwxonkJxU4ShzbwIh+4VN++Jo5GGU9tzHm2CbRlelC3yrjkhrfjCbU93d56 2sgEKG93sKWmqOP7z25S3RERmAHlcV5ysndDWh9hgAiTLV9znAgGaiOGZgKBjhXKxXS4sWUzkfkM2 +jl2MM0oAFEgujNny/yH2iuD3KD+4NcQ0vJ5rt9mCd2+mwz7ZQhegH3TVJBABtOBcPwaVpo5n0L0+ TcBRLLUJOP3NQ0WXJbOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsgYV-00BqmH-1d; Tue, 17 Oct 2023 09:40:03 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsgYS-00BqkN-0P for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2023 09:40:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id D1453B81D07; Tue, 17 Oct 2023 09:39:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 014DFC433C8; Tue, 17 Oct 2023 09:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697535598; bh=F5RcJpz6n6tELuxNxNyEcSyKRIgUtiYBPAb5RiIKHpo=; h=From:To:Cc:Subject:Date:From; b=WBnKQWsYpPgp4Opd8VBte4yLHLYA6BqtJOYGvKnkSo9yXD6wc2IK9hRVyglNsbzLo Dxx+u8yG4/RaIP+xMn7gOpe9dEOVrPWRyjAyvoQTZ3QDWYDaki6vpUDdxDf0GqYG+i 1JP9u+azCGiMfXEc2A26TneZGYweKH1ywqRCq+eYW43arz+rQz5XX04A6o9lasP797 /uWwNcSteBgT547xAlXmfoMyu37e51nLGRNUMNaEa6KuUp6owLL1C90NVP9q7LRpm4 5YYT4BxqSEfkN9g3M+mUPkiEE4UITBJjCZAVQVfoD/Mf7swrV0Tm+YkrNvRU2EljOZ TrrjJI0KUXA3g== From: Arnd Bergmann To: Greg Kroah-Hartman , linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Javier Martinez Canillas , Ard Biesheuvel , Helge Deller , Thomas Zimmermann , Arnd Bergmann Subject: [PATCH 1/2] [v2] efi: move screen_info into efi init code Date: Tue, 17 Oct 2023 11:39:46 +0200 Message-Id: <20231017093947.3627976-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231017_024000_439659_882F0E49 X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann After the vga console no longer relies on global screen_info, there are only two remaining use cases: - on the x86 architecture, it is used for multiple boot methods (bzImage, EFI, Xen, kexec) to commucate the initial VGA or framebuffer settings to a number of device drivers. - on other architectures, it is only used as part of the EFI stub, and only for the three sysfb framebuffers (simpledrm, simplefb, efifb). Remove the duplicate data structure definitions by moving it into the efi-init.c file that sets it up initially for the EFI case, leaving x86 as an exception that retains its own definition for non-EFI boots. The added #ifdefs here are optional, I added them to further limit the reach of screen_info to configurations that have at least one of the users enabled. Reviewed-by: Ard Biesheuvel Reviewed-by: Javier Martinez Canillas Acked-by: Helge Deller Signed-off-by: Arnd Bergmann --- v2: fix up loongarch code, which has a separate copy of the efi-init.c file. --- arch/arm/kernel/setup.c | 4 ---- arch/arm64/kernel/efi.c | 4 ---- arch/arm64/kernel/image-vars.h | 2 ++ arch/loongarch/kernel/efi.c | 8 +++++++- arch/loongarch/kernel/image-vars.h | 2 ++ arch/loongarch/kernel/setup.c | 5 ----- arch/riscv/kernel/image-vars.h | 2 ++ arch/riscv/kernel/setup.c | 5 ----- drivers/firmware/efi/efi-init.c | 14 +++++++++++++- drivers/firmware/efi/libstub/efi-stub-entry.c | 8 +++++++- 10 files changed, 33 insertions(+), 21 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index c15dfdbe3d5ae..b808712e85981 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -939,10 +939,6 @@ static struct screen_info vgacon_screen_info = { }; #endif -#if defined(CONFIG_EFI) -struct screen_info screen_info; -#endif - static int __init customize_machine(void) { /* diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 3f8c9c143552f..0228001347bea 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -71,10 +71,6 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) return pgprot_val(PAGE_KERNEL_EXEC); } -/* we will fill this structure from the stub, so don't put it in .bss */ -struct screen_info screen_info __section(".data"); -EXPORT_SYMBOL(screen_info); - int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) { pteval_t prot_val = create_mapping_protection(md); diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h index 35f3c79595137..5e4dc72ab1bda 100644 --- a/arch/arm64/kernel/image-vars.h +++ b/arch/arm64/kernel/image-vars.h @@ -27,7 +27,9 @@ PROVIDE(__efistub__text = _text); 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); +#endif PROVIDE(__efistub__ctype = _ctype); PROVIDE(__pi___memcpy = __pi_memcpy); diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index 9fc10cea21e10..acb5d3385675c 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -68,6 +68,11 @@ void __init efi_runtime_init(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); +#endif + static void __init init_screen_info(void) { struct screen_info *si; @@ -115,7 +120,8 @@ void __init efi_init(void) set_bit(EFI_CONFIG_TABLES, &efi.flags); - init_screen_info(); + if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) + init_screen_info(); if (boot_memmap == EFI_INVALID_TABLE_ADDR) return; diff --git a/arch/loongarch/kernel/image-vars.h b/arch/loongarch/kernel/image-vars.h index e561989d02de9..5087416b9678d 100644 --- a/arch/loongarch/kernel/image-vars.h +++ b/arch/loongarch/kernel/image-vars.h @@ -12,7 +12,9 @@ __efistub_kernel_entry = kernel_entry; __efistub_kernel_asize = kernel_asize; __efistub_kernel_fsize = kernel_fsize; __efistub_kernel_offset = kernel_offset; +#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) __efistub_screen_info = screen_info; +#endif #endif diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 0d5edf1f7e4a1..407cd6b49bef6 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -57,10 +56,6 @@ #define SMBIOS_CORE_PACKAGE_OFFSET 0x23 #define LOONGSON_EFI_ENABLE (1 << 3) -#ifdef CONFIG_EFI -struct screen_info screen_info __section(".data"); -#endif - unsigned long fw_arg0, fw_arg1, fw_arg2; DEFINE_PER_CPU(unsigned long, kernelsp); struct cpuinfo_loongarch cpu_data[NR_CPUS] __read_mostly; diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h index ea1a10355ce90..3df30dd1c458b 100644 --- a/arch/riscv/kernel/image-vars.h +++ b/arch/riscv/kernel/image-vars.h @@ -28,7 +28,9 @@ __efistub__start_kernel = _start_kernel; __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; +#endif #endif diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 0c466a50f1744..0624f44d43eca 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -40,10 +39,6 @@ #include "head.h" -#if defined(CONFIG_EFI) -struct screen_info screen_info __section(".data"); -#endif - /* * The lucky hart to first increment this variable will boot the other cores. * This is used before the kernel initializes the BSS so it can't be in the diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index ef0820f1a9246..d4987d0130801 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -55,6 +55,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. + */ +#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)) +struct screen_info screen_info __section(".data"); +EXPORT_SYMBOL_GPL(screen_info); +#endif + static void __init init_screen_info(void) { struct screen_info *si; @@ -240,5 +249,8 @@ void __init efi_init(void) memblock_reserve(data.phys_map & PAGE_MASK, PAGE_ALIGN(data.size + (data.phys_map & ~PAGE_MASK))); - init_screen_info(); + if (IS_ENABLED(CONFIG_X86) || + IS_ENABLED(CONFIG_SYSFB) || + IS_ENABLED(CONFIG_EFI_EARLYCON)) + init_screen_info(); } diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c index 2f1902e5d4075..a6c0498351905 100644 --- a/drivers/firmware/efi/libstub/efi-stub-entry.c +++ b/drivers/firmware/efi/libstub/efi-stub-entry.c @@ -13,7 +13,13 @@ struct screen_info *alloc_screen_info(void) { if (IS_ENABLED(CONFIG_ARM)) return __alloc_screen_info(); - return (void *)&screen_info + screen_info_offset; + + if (IS_ENABLED(CONFIG_X86) || + IS_ENABLED(CONFIG_EFI_EARLYCON) || + IS_ENABLED(CONFIG_SYSFB)) + return (void *)&screen_info + screen_info_offset; + + return NULL; } /* From patchwork Tue Oct 17 09:39:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13424925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52643CDB474 for ; Tue, 17 Oct 2023 09:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SOfnGiSahBAu2sDPFUOfp89QY/6ETShngwXd5MMXQMQ=; b=VWMCVjmLv1usK7 X2//r9WnR/DMcvQmc/vXlcVfCcZIz46mPzXsKi1lDg3j/KWyv5J8Gt0q7SQ8iSkfdzg+VEovK17lU /osA1tbR/S5d74Ed7pKDcalwoptSe3YTmu39Dltrsan5aqldBfCumrVImxfj1OYXhVzisUmkkODGj U+fLRqeSWIUlNn7DpqB2hmdJfTweHiHZ1becrykv60MPcYxLpCrPy35msOS7vIURBJMxTuKkwZ12+ KnxlYcWYAFz7N4RRjS/u9K4ONpG26apUNa0rh4fauDwR256XVuyV4V7tlFYFojaOsrTwvVoBIbIeS 5HaVo4VfqE68FYPsW/cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsgYc-00Bqoq-0j; Tue, 17 Oct 2023 09:40:10 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsgYX-00Bqlr-2L for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2023 09:40:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A668ACE1D6F; Tue, 17 Oct 2023 09:40:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A97CAC433CB; Tue, 17 Oct 2023 09:39:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697535600; bh=K50Y7pAstCn0vIlPs9oEq/dIQQ7sSFid9QIZDsnEC58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E7pNPOWwMNsnxJiNu+/ulgNnBPDAK35fhQY/w7ONBieXm4cxYawjWgp+kN+LC7hSs 9GJ9Tcb6m25A1HX7BzUn4rev268Rkgkrbkob8CL0e393Bikj1yJFTFiqAcGV7/vxMB YNvql7JqXrq6bvENwo+N7rGrSMwXCMgsoPUBzktAVO29HeHYQR6CXNEsPEXMU8AEw+ Z/nNofFXDLIJNcfRYEqfhQMUKuf3vP/Ywv31+csIT9PN4yDoiI/cXtRwng0kDUwiwD wB9rHCuJNUzxssMimXgA+/Jldhu15olqxUYcne59UwMrXksyGLTyAHL6x9ZURDDCbH vS8plkDZ4H3/w== From: Arnd Bergmann To: Greg Kroah-Hartman , linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Javier Martinez Canillas , Ard Biesheuvel , Helge Deller , Thomas Zimmermann , Arnd Bergmann Subject: [PATCH 2/2] console: fix up ARM screen_info reference Date: Tue, 17 Oct 2023 11:39:47 +0200 Message-Id: <20231017093947.3627976-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017093947.3627976-1-arnd@kernel.org> References: <20231017093947.3627976-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231017_024006_106511_B8F0CA87 X-CRM114-Status: GOOD ( 17.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann 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 --- Greg, this was caused by patch "vgacon: clean up global screen_info instances" in tty-testing. You can either apply this patch on top or fold it into that, or I can just resend the fixed series if you prefer. --- 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(-) diff --git a/arch/arm/include/asm/vga.h b/arch/arm/include/asm/vga.h index 7c0bee57855ab..6c430ec371df2 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 b808712e85981..ff2299ce1ad7a 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 70549fecee12c..14af5d9e13b00 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