* [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device [not found] <20261029033440.973077-1-wuqianhai@loongson.cn> @ 2026-11-10 8:56 ` wuqianhai 2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai ` (2 more replies) 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 1 sibling, 3 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 8:56 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> On LoongArch the kernel cannot reliably identify the display device that was set up by the firmware and used for the boot console. Two code paths need this information and currently get it wrong: * The PCI VGA arbiter: vga_is_firmware_default() is compiled only on x86, so on LoongArch vga_default_device() may select the wrong GPU when several are present (for example an integrated display controller and a discrete card). * The framebuffer console: LoongArch does not implement video_is_primary_device(), so with CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y the console falls back to the generic stub that always returns false and binds to the first registered framebuffer instead of the boot display. This series fixes both by publishing the firmware framebuffer information through screen_info on LoongArch and consuming it the same way x86 does. Patch 1 always defines and initializes sysfb_primary_display, and always provides its EFI stub alias, instead of guarding them behind SYSFB/EFI_EARLYCON. Patch 2 refreshes screen_info from the PCI resource-assignment path after the root-bus resources are assigned, so the framebuffer address is final before the VGA arbiter and sysfb_init() consume it. The call is placed in the LoongArch PCI scan path because only LoongArch has this ordering: acpi_init() relocates the BAR before vga_arb_device_init() runs. On x86 the screen_info address is still accurate at that point. If you would rather have the helper called from the generic pci_assign_unassigned_root_bus_resources() path so that all architectures share it, that can be done instead. Patch 3 removes pci_fixup_vgadev(), which overrides the VGA default device to a discrete card after the arbiter has already selected the firmware framebuffer device, so vga_default_device() consistently reflects the boot display. Patch 4 implements video_is_primary_device() for LoongArch by reusing the VGA default device selected by the arbiter. Patch 5 lets the EFI stub link directly to sysfb_primary_display on LoongArch, so the firmware framebuffer information is always populated. Patch 6 lets the VGA arbiter use CONFIG_SCREEN_INFO instead of an architecture check and makes VGA_ARB select SCREEN_INFO on LoongArch. Patches 1-4 are LoongArch-specific. Patches 5 and 6 touch generic code (the EFI stub and the PCI VGA arbiter) and are placed last so they can be reviewed and merged separately. Patches 3 and 4 depend on patch 6 taking effect, but are ordered ahead of it only to group the LoongArch changes together. Changes since v2: - Split the screen_info refresh out of vga_arb_device_init() into the LoongArch PCI resource-assignment path (patch 2), following Thomas' suggestion to decouple it from sysfb_init(). - Drop the per-architecture check in vgaarb.c and the select of SYSFB in favour of CONFIG_SCREEN_INFO and select SCREEN_INFO (patch 6). - Always define and initialize sysfb_primary_display, and let the EFI stub link to it directly (patches 1 and 5), instead of guarding them behind SYSFB/EFI_EARLYCON. - Remove the vga_default_device() override (patch 3) so the arbiter's firmware-framebuffer selection takes effect. - Implement video_is_primary_device() (patch 4) by reusing the arbiter's default device, so FRAMEBUFFER_CONSOLE_DETECT_PRIMARY works. Build-tested on loongarch64 with GCC 8.3.0. wuqianhai (6): LoongArch: efi: Provide sysfb_primary_display for screen_info users LoongArch/PCI: Refresh screen_info after resource assignment LoongArch/PCI: Remove vga default device override LoongArch: video: Implement primary framebuffer device detection efi/libstub: Enable direct sysfb_primary_display access on LoongArch PCI/VGA: Enable firmware default device detection on LoongArch arch/loongarch/Makefile | 3 ++ arch/loongarch/include/asm/video.h | 7 +++++ arch/loongarch/kernel/efi.c | 5 +--- arch/loongarch/kernel/image-vars.h | 2 -- arch/loongarch/pci/acpi.c | 4 +++ arch/loongarch/pci/pci.c | 18 ------------ arch/loongarch/video/Makefile | 3 ++ arch/loongarch/video/video-common.c | 29 +++++++++++++++++++ drivers/firmware/efi/libstub/efi-stub-entry.c | 1 + drivers/pci/Kconfig | 2 +- drivers/pci/vgaarb.c | 2 +- 11 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 arch/loongarch/video/Makefile create mode 100644 arch/loongarch/video/video-common.c -- 2.34.1 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users 2026-11-10 8:56 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai @ 2026-11-10 8:56 ` wuqianhai 2026-11-10 14:34 ` Thomas Zimmermann ` (2 more replies) 2026-11-10 8:56 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai 2026-11-10 8:56 ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai 2 siblings, 3 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 8:56 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> LoongArch defines and initializes sysfb_primary_display only when CONFIG_SYSFB or CONFIG_EFI_EARLYCON is enabled. The PCI VGA arbiter and the framebuffer console need the firmware framebuffer information through screen_info whenever CONFIG_SCREEN_INFO is enabled, even if neither of those options is set. Drop the guards so sysfb_primary_display is always defined and initialized, and its EFI stub alias is always provided, mirroring x86. This avoids selecting SYSFB just to obtain the symbol. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/kernel/efi.c | 5 +---- arch/loongarch/kernel/image-vars.h | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index 69dd83f8082f..e491a82b2e0d 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -74,10 +74,8 @@ bool efi_poweroff_required(void) unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR; -#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) struct sysfb_display_info sysfb_primary_display __section(".data"); EXPORT_SYMBOL_GPL(sysfb_primary_display); -#endif static void __init init_primary_display(void) { @@ -129,8 +127,7 @@ void __init efi_init(void) set_bit(EFI_CONFIG_TABLES, &efi.flags); - if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) - init_primary_display(); + init_primary_display(); 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 e557ebd46c2b..4d1d7978553a 100644 --- a/arch/loongarch/kernel/image-vars.h +++ b/arch/loongarch/kernel/image-vars.h @@ -11,9 +11,7 @@ __efistub_strcmp = strcmp; __efistub_kernel_entry = kernel_entry; __efistub_kernel_asize = kernel_asize; __efistub_kernel_fsize = kernel_fsize; -#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) __efistub_sysfb_primary_display = sysfb_primary_display; -#endif #endif -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users 2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai @ 2026-11-10 14:34 ` Thomas Zimmermann 2026-11-10 14:39 ` Thomas Zimmermann 2026-11-10 16:25 ` Thomas Zimmermann 2 siblings, 0 replies; 16+ messages in thread From: Thomas Zimmermann @ 2026-11-10 14:34 UTC (permalink / raw) To: wuqianhai, chenhuacai, kernel, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel Hi Am 10.11.26 um 09:56 schrieb wuqianhai@loongson.cn: > From: wuqianhai <wuqianhai@loongson.cn> > > LoongArch defines and initializes sysfb_primary_display only when > CONFIG_SYSFB or CONFIG_EFI_EARLYCON is enabled. The PCI VGA arbiter and > the framebuffer console need the firmware framebuffer information through > screen_info whenever CONFIG_SCREEN_INFO is enabled, even if neither of > those options is set. > > Drop the guards so sysfb_primary_display is always defined and > initialized, and its EFI stub alias is always provided, mirroring x86. > This avoids selecting SYSFB just to obtain the symbol. > > Signed-off-by: wuqianhai <wuqianhai@loongson.cn> > --- > arch/loongarch/kernel/efi.c | 5 +---- > arch/loongarch/kernel/image-vars.h | 2 -- > 2 files changed, 1 insertion(+), 6 deletions(-) > > diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c > index 69dd83f8082f..e491a82b2e0d 100644 > --- a/arch/loongarch/kernel/efi.c > +++ b/arch/loongarch/kernel/efi.c > @@ -74,10 +74,8 @@ bool efi_poweroff_required(void) > > unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR; > > -#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) > struct sysfb_display_info sysfb_primary_display __section(".data"); > EXPORT_SYMBOL_GPL(sysfb_primary_display); > -#endif I never understood how linking works. I would assume that this symbol interferes with the shared one at [1]. Can't loongarch use that as well? [1] https://elixir.bootlin.com/linux/v7.3.1/source/drivers/firmware/efi/efi-init.c#L64 Best regards Thomas > > static void __init init_primary_display(void) > { > @@ -129,8 +127,7 @@ void __init efi_init(void) > > set_bit(EFI_CONFIG_TABLES, &efi.flags); > > - if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) > - init_primary_display(); > + init_primary_display(); > > 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 e557ebd46c2b..4d1d7978553a 100644 > --- a/arch/loongarch/kernel/image-vars.h > +++ b/arch/loongarch/kernel/image-vars.h > @@ -11,9 +11,7 @@ __efistub_strcmp = strcmp; > __efistub_kernel_entry = kernel_entry; > __efistub_kernel_asize = kernel_asize; > __efistub_kernel_fsize = kernel_fsize; > -#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) > __efistub_sysfb_primary_display = sysfb_primary_display; > -#endif > > #endif > -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users 2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai 2026-11-10 14:34 ` Thomas Zimmermann @ 2026-11-10 14:39 ` Thomas Zimmermann 2026-11-10 16:25 ` Thomas Zimmermann 2 siblings, 0 replies; 16+ messages in thread From: Thomas Zimmermann @ 2026-11-10 14:39 UTC (permalink / raw) To: wuqianhai, chenhuacai, kernel, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel Hi Am 10.11.26 um 09:56 schrieb wuqianhai@loongson.cn: > From: wuqianhai <wuqianhai@loongson.cn> > > LoongArch defines and initializes sysfb_primary_display only when > CONFIG_SYSFB or CONFIG_EFI_EARLYCON is enabled. The PCI VGA arbiter and > the framebuffer console need the firmware framebuffer information through > screen_info whenever CONFIG_SCREEN_INFO is enabled, even if neither of > those options is set. > > Drop the guards so sysfb_primary_display is always defined and > initialized, and its EFI stub alias is always provided, mirroring x86. > This avoids selecting SYSFB just to obtain the symbol. The idea is that you select SYSFB is you're interested in that information. I guess we could make sysfb_primary_display available if CONFIG_VGA_ARB=y. Best regards Thomas > > Signed-off-by: wuqianhai <wuqianhai@loongson.cn> > --- > arch/loongarch/kernel/efi.c | 5 +---- > arch/loongarch/kernel/image-vars.h | 2 -- > 2 files changed, 1 insertion(+), 6 deletions(-) > > diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c > index 69dd83f8082f..e491a82b2e0d 100644 > --- a/arch/loongarch/kernel/efi.c > +++ b/arch/loongarch/kernel/efi.c > @@ -74,10 +74,8 @@ bool efi_poweroff_required(void) > > unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR; > > -#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) > struct sysfb_display_info sysfb_primary_display __section(".data"); > EXPORT_SYMBOL_GPL(sysfb_primary_display); > -#endif > > static void __init init_primary_display(void) > { > @@ -129,8 +127,7 @@ void __init efi_init(void) > > set_bit(EFI_CONFIG_TABLES, &efi.flags); > > - if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) > - init_primary_display(); > + init_primary_display(); > > 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 e557ebd46c2b..4d1d7978553a 100644 > --- a/arch/loongarch/kernel/image-vars.h > +++ b/arch/loongarch/kernel/image-vars.h > @@ -11,9 +11,7 @@ __efistub_strcmp = strcmp; > __efistub_kernel_entry = kernel_entry; > __efistub_kernel_asize = kernel_asize; > __efistub_kernel_fsize = kernel_fsize; > -#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) > __efistub_sysfb_primary_display = sysfb_primary_display; > -#endif > > #endif > -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg) ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users 2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai 2026-11-10 14:34 ` Thomas Zimmermann 2026-11-10 14:39 ` Thomas Zimmermann @ 2026-11-10 16:25 ` Thomas Zimmermann 2 siblings, 0 replies; 16+ messages in thread From: Thomas Zimmermann @ 2026-11-10 16:25 UTC (permalink / raw) To: wuqianhai, chenhuacai, kernel, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel Hi Am 10.11.26 um 09:56 schrieb wuqianhai@loongson.cn: > From: wuqianhai <wuqianhai@loongson.cn> > > LoongArch defines and initializes sysfb_primary_display only when > CONFIG_SYSFB or CONFIG_EFI_EARLYCON is enabled. The PCI VGA arbiter and > the framebuffer console need the firmware framebuffer information through > screen_info whenever CONFIG_SCREEN_INFO is enabled, even if neither of > those options is set. > > Drop the guards so sysfb_primary_display is always defined and > initialized, and its EFI stub alias is always provided, mirroring x86. > This avoids selecting SYSFB just to obtain the symbol. The idea is that you select SYSFB is you're interested in that information. I guess we could make sysfb_primary_display available if CONFIG_VGA_ARB=y. Best regards Thomas > > Signed-off-by: wuqianhai <wuqianhai@loongson.cn> > --- > arch/loongarch/kernel/efi.c | 5 +---- > arch/loongarch/kernel/image-vars.h | 2 -- > 2 files changed, 1 insertion(+), 6 deletions(-) > > diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c > index 69dd83f8082f..e491a82b2e0d 100644 > --- a/arch/loongarch/kernel/efi.c > +++ b/arch/loongarch/kernel/efi.c > @@ -74,10 +74,8 @@ bool efi_poweroff_required(void) > > unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR; > > -#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) > struct sysfb_display_info sysfb_primary_display __section(".data"); > EXPORT_SYMBOL_GPL(sysfb_primary_display); > -#endif > > static void __init init_primary_display(void) > { > @@ -129,8 +127,7 @@ void __init efi_init(void) > > set_bit(EFI_CONFIG_TABLES, &efi.flags); > > - if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) > - init_primary_display(); > + init_primary_display(); > > 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 e557ebd46c2b..4d1d7978553a 100644 > --- a/arch/loongarch/kernel/image-vars.h > +++ b/arch/loongarch/kernel/image-vars.h > @@ -11,9 +11,7 @@ __efistub_strcmp = strcmp; > __efistub_kernel_entry = kernel_entry; > __efistub_kernel_asize = kernel_asize; > __efistub_kernel_fsize = kernel_fsize; > -#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) > __efistub_sysfb_primary_display = sysfb_primary_display; > -#endif > > #endif > -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment 2026-11-10 8:56 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai @ 2026-11-10 8:56 ` wuqianhai 2026-11-10 14:46 ` Thomas Zimmermann 2026-11-10 8:56 ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai 2 siblings, 1 reply; 16+ messages in thread From: wuqianhai @ 2026-11-10 8:56 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> PCI resource assignment runs from acpi_init() at subsys_initcall time. The firmware framebuffer BAR can be relocated, leaving screen_info's lfb_base stale. vga_arb_device_init() runs later at subsys_initcall_sync time and reads screen_info to identify the firmware default VGA device. Update screen_info through the generic screen_info_apply_fixups() helper right after the root bus resources have been assigned, so both the VGA arbiter and sysfb_init() observe the final framebuffer address. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/pci/acpi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c index ccbcea61fcd9..cb313ff67f7e 100644 --- a/arch/loongarch/pci/acpi.c +++ b/arch/loongarch/pci/acpi.c @@ -9,6 +9,7 @@ #include <linux/slab.h> #include <linux/pci-acpi.h> #include <linux/pci-ecam.h> +#include <linux/screen_info.h> #include <asm/pci.h> #include <asm/numa.h> @@ -256,6 +257,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) */ pci_assign_unassigned_root_bus_resources(bus); + if (IS_ENABLED(CONFIG_SCREEN_INFO)) + screen_info_apply_fixups(); + list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); } -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment 2026-11-10 8:56 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai @ 2026-11-10 14:46 ` Thomas Zimmermann 0 siblings, 0 replies; 16+ messages in thread From: Thomas Zimmermann @ 2026-11-10 14:46 UTC (permalink / raw) To: wuqianhai, chenhuacai, kernel, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel Hi Am 10.11.26 um 09:56 schrieb wuqianhai@loongson.cn: > From: wuqianhai <wuqianhai@loongson.cn> > > PCI resource assignment runs from acpi_init() at subsys_initcall time. > The firmware framebuffer BAR can be relocated, leaving screen_info's > lfb_base stale. vga_arb_device_init() runs later at subsys_initcall_sync > time and reads screen_info to identify the firmware default VGA device. > > Update screen_info through the generic screen_info_apply_fixups() helper > right after the root bus resources have been assigned, so both the VGA > arbiter and sysfb_init() observe the final framebuffer address. I don't know much about the internals of the PCI subsystem. But I would assume that there's a common function that sets up PCI resources on all architectures. And this is the place where we'd want to call screen_info_apply_fixups(). Best regards Thomas > > Signed-off-by: wuqianhai <wuqianhai@loongson.cn> > --- > arch/loongarch/pci/acpi.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c > index ccbcea61fcd9..cb313ff67f7e 100644 > --- a/arch/loongarch/pci/acpi.c > +++ b/arch/loongarch/pci/acpi.c > @@ -9,6 +9,7 @@ > #include <linux/slab.h> > #include <linux/pci-acpi.h> > #include <linux/pci-ecam.h> > +#include <linux/screen_info.h> > > #include <asm/pci.h> > #include <asm/numa.h> > @@ -256,6 +257,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) > */ > pci_assign_unassigned_root_bus_resources(bus); > > + if (IS_ENABLED(CONFIG_SCREEN_INFO)) > + screen_info_apply_fixups(); > + > list_for_each_entry(child, &bus->children, node) > pcie_bus_configure_settings(child); > } -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override 2026-11-10 8:56 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai 2026-11-10 8:56 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai @ 2026-11-10 8:56 ` wuqianhai 2 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 8:56 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> pci_fixup_vgadev() forces the VGA default device to a non-Loongson VGA device whenever a Loongson display controller is present. This was added to prefer a discrete graphics card as the default boot device, but it makes vga_default_device() inconsistent with the firmware boot display: the firmware framebuffer lives on the integrated controller, while the override points the default at a discrete card (or leaves it unset when there is no discrete card). The fixup runs from pci_bus_add_device(), i.e. after the VGA arbiter has already selected the default device through the firmware framebuffer, so it overrides that choice. Drop it so vga_default_device() consistently reflects the boot display. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/pci/pci.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/arch/loongarch/pci/pci.c b/arch/loongarch/pci/pci.c index f33c7ea1443d..b756a44272ab 100644 --- a/arch/loongarch/pci/pci.c +++ b/arch/loongarch/pci/pci.c @@ -8,7 +8,6 @@ #include <linux/delay.h> #include <linux/types.h> #include <linux/pci.h> -#include <linux/vgaarb.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <asm/cacheflush.h> #include <asm/loongson.h> @@ -88,23 +87,6 @@ int pcibios_alloc_irq(struct pci_dev *dev) return acpi_pci_irq_enable(dev); } -static void pci_fixup_vgadev(struct pci_dev *pdev) -{ - struct pci_dev *devp = NULL; - - while ((devp = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, devp))) { - if (devp->vendor != PCI_VENDOR_ID_LOONGSON) { - vga_set_default_device(devp); - dev_info(&pdev->dev, - "Overriding boot device as %X:%X\n", - devp->vendor, devp->device); - } - } -} -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC1, pci_fixup_vgadev); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC2, pci_fixup_vgadev); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC3, pci_fixup_vgadev); - #define CRTC_NUM_MAX 2 #define CRTC_OUTPUT_ENABLE 0x100 -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device [not found] <20261029033440.973077-1-wuqianhai@loongson.cn> 2026-11-10 8:56 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai @ 2026-11-10 9:01 ` wuqianhai 2026-11-10 9:01 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai ` (6 more replies) 1 sibling, 7 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:01 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> On LoongArch the kernel cannot reliably identify the display device that was set up by the firmware and used for the boot console. Two code paths need this information and currently get it wrong: * The PCI VGA arbiter: vga_is_firmware_default() is compiled only on x86, so on LoongArch vga_default_device() may select the wrong GPU when several are present (for example an integrated display controller and a discrete card). * The framebuffer console: LoongArch does not implement video_is_primary_device(), so with CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y the console falls back to the generic stub that always returns false and binds to the first registered framebuffer instead of the boot display. This series fixes both by publishing the firmware framebuffer information through screen_info on LoongArch and consuming it the same way x86 does. Patch 1 always defines and initializes sysfb_primary_display, and always provides its EFI stub alias, instead of guarding them behind SYSFB/EFI_EARLYCON. Patch 2 refreshes screen_info from the PCI resource-assignment path after the root-bus resources are assigned, so the framebuffer address is final before the VGA arbiter and sysfb_init() consume it. The call is placed in the LoongArch PCI scan path because only LoongArch has this ordering: acpi_init() relocates the BAR before vga_arb_device_init() runs. On x86 the screen_info address is still accurate at that point. If you would rather have the helper called from the generic pci_assign_unassigned_root_bus_resources() path so that all architectures share it, that can be done instead. Patch 3 removes pci_fixup_vgadev(), which overrides the VGA default device to a discrete card after the arbiter has already selected the firmware framebuffer device, so vga_default_device() consistently reflects the boot display. Patch 4 implements video_is_primary_device() for LoongArch by reusing the VGA default device selected by the arbiter. Patch 5 lets the EFI stub link directly to sysfb_primary_display on LoongArch, so the firmware framebuffer information is always populated. Patch 6 lets the VGA arbiter use CONFIG_SCREEN_INFO instead of an architecture check and makes VGA_ARB select SCREEN_INFO on LoongArch. Patches 1-4 are LoongArch-specific. Patches 5 and 6 touch generic code (the EFI stub and the PCI VGA arbiter) and are placed last so they can be reviewed and merged separately. Patches 3 and 4 depend on patch 6 taking effect, but are ordered ahead of it only to group the LoongArch changes together. Changes since v2: - Split the screen_info refresh out of vga_arb_device_init() into the LoongArch PCI resource-assignment path (patch 2), following Thomas' suggestion to decouple it from sysfb_init(). - Drop the per-architecture check in vgaarb.c and the select of SYSFB in favour of CONFIG_SCREEN_INFO and select SCREEN_INFO (patch 6). - Always define and initialize sysfb_primary_display, and let the EFI stub link to it directly (patches 1 and 5), instead of guarding them behind SYSFB/EFI_EARLYCON. - Remove the vga_default_device() override (patch 3) so the arbiter's firmware-framebuffer selection takes effect. - Implement video_is_primary_device() (patch 4) by reusing the arbiter's default device, so FRAMEBUFFER_CONSOLE_DETECT_PRIMARY works. Build-tested on loongarch64 with GCC 8.3.0. wuqianhai (6): LoongArch: efi: Provide sysfb_primary_display for screen_info users LoongArch/PCI: Refresh screen_info after resource assignment LoongArch/PCI: Remove vga default device override LoongArch: video: Implement primary framebuffer device detection efi/libstub: Enable direct sysfb_primary_display access on LoongArch PCI/VGA: Enable firmware default device detection on LoongArch arch/loongarch/Makefile | 3 ++ arch/loongarch/include/asm/video.h | 7 +++++ arch/loongarch/kernel/efi.c | 5 +--- arch/loongarch/kernel/image-vars.h | 2 -- arch/loongarch/pci/acpi.c | 4 +++ arch/loongarch/pci/pci.c | 18 ------------ arch/loongarch/video/Makefile | 3 ++ arch/loongarch/video/video-common.c | 29 +++++++++++++++++++ drivers/firmware/efi/libstub/efi-stub-entry.c | 1 + drivers/pci/Kconfig | 2 +- drivers/pci/vgaarb.c | 2 +- 11 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 arch/loongarch/video/Makefile create mode 100644 arch/loongarch/video/video-common.c -- 2.34.1 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai @ 2026-11-10 9:01 ` wuqianhai 2026-11-10 9:01 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai ` (5 subsequent siblings) 6 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:01 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> LoongArch defines and initializes sysfb_primary_display only when CONFIG_SYSFB or CONFIG_EFI_EARLYCON is enabled. The PCI VGA arbiter and the framebuffer console need the firmware framebuffer information through screen_info whenever CONFIG_SCREEN_INFO is enabled, even if neither of those options is set. Drop the guards so sysfb_primary_display is always defined and initialized, and its EFI stub alias is always provided, mirroring x86. This avoids selecting SYSFB just to obtain the symbol. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/kernel/efi.c | 5 +---- arch/loongarch/kernel/image-vars.h | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index 69dd83f8082f..e491a82b2e0d 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -74,10 +74,8 @@ bool efi_poweroff_required(void) unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR; -#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) struct sysfb_display_info sysfb_primary_display __section(".data"); EXPORT_SYMBOL_GPL(sysfb_primary_display); -#endif static void __init init_primary_display(void) { @@ -129,8 +127,7 @@ void __init efi_init(void) set_bit(EFI_CONFIG_TABLES, &efi.flags); - if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) - init_primary_display(); + init_primary_display(); 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 e557ebd46c2b..4d1d7978553a 100644 --- a/arch/loongarch/kernel/image-vars.h +++ b/arch/loongarch/kernel/image-vars.h @@ -11,9 +11,7 @@ __efistub_strcmp = strcmp; __efistub_kernel_entry = kernel_entry; __efistub_kernel_asize = kernel_asize; __efistub_kernel_fsize = kernel_fsize; -#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) __efistub_sysfb_primary_display = sysfb_primary_display; -#endif #endif -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 2026-11-10 9:01 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai @ 2026-11-10 9:01 ` wuqianhai 2026-11-10 9:02 ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai ` (4 subsequent siblings) 6 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:01 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> PCI resource assignment runs from acpi_init() at subsys_initcall time. The firmware framebuffer BAR can be relocated, leaving screen_info's lfb_base stale. vga_arb_device_init() runs later at subsys_initcall_sync time and reads screen_info to identify the firmware default VGA device. Update screen_info through the generic screen_info_apply_fixups() helper right after the root bus resources have been assigned, so both the VGA arbiter and sysfb_init() observe the final framebuffer address. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/pci/acpi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c index ccbcea61fcd9..cb313ff67f7e 100644 --- a/arch/loongarch/pci/acpi.c +++ b/arch/loongarch/pci/acpi.c @@ -9,6 +9,7 @@ #include <linux/slab.h> #include <linux/pci-acpi.h> #include <linux/pci-ecam.h> +#include <linux/screen_info.h> #include <asm/pci.h> #include <asm/numa.h> @@ -256,6 +257,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) */ pci_assign_unassigned_root_bus_resources(bus); + if (IS_ENABLED(CONFIG_SCREEN_INFO)) + screen_info_apply_fixups(); + list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); } -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 2026-11-10 9:01 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai 2026-11-10 9:01 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai @ 2026-11-10 9:02 ` wuqianhai 2026-11-10 9:24 ` [PATCH v3 4/6] LoongArch: video: Implement primary framebuffer device detection wuqianhai ` (3 subsequent siblings) 6 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:02 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> pci_fixup_vgadev() forces the VGA default device to a non-Loongson VGA device whenever a Loongson display controller is present. This was added to prefer a discrete graphics card as the default boot device, but it makes vga_default_device() inconsistent with the firmware boot display: the firmware framebuffer lives on the integrated controller, while the override points the default at a discrete card (or leaves it unset when there is no discrete card). The fixup runs from pci_bus_add_device(), i.e. after the VGA arbiter has already selected the default device through the firmware framebuffer, so it overrides that choice. Drop it so vga_default_device() consistently reflects the boot display. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/pci/pci.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/arch/loongarch/pci/pci.c b/arch/loongarch/pci/pci.c index f33c7ea1443d..b756a44272ab 100644 --- a/arch/loongarch/pci/pci.c +++ b/arch/loongarch/pci/pci.c @@ -8,7 +8,6 @@ #include <linux/delay.h> #include <linux/types.h> #include <linux/pci.h> -#include <linux/vgaarb.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <asm/cacheflush.h> #include <asm/loongson.h> @@ -88,23 +87,6 @@ int pcibios_alloc_irq(struct pci_dev *dev) return acpi_pci_irq_enable(dev); } -static void pci_fixup_vgadev(struct pci_dev *pdev) -{ - struct pci_dev *devp = NULL; - - while ((devp = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, devp))) { - if (devp->vendor != PCI_VENDOR_ID_LOONGSON) { - vga_set_default_device(devp); - dev_info(&pdev->dev, - "Overriding boot device as %X:%X\n", - devp->vendor, devp->device); - } - } -} -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC1, pci_fixup_vgadev); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC2, pci_fixup_vgadev); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC3, pci_fixup_vgadev); - #define CRTC_NUM_MAX 2 #define CRTC_OUTPUT_ENABLE 0x100 -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 4/6] LoongArch: video: Implement primary framebuffer device detection 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai ` (2 preceding siblings ...) 2026-11-10 9:02 ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai @ 2026-11-10 9:24 ` wuqianhai 2026-11-10 9:24 ` [PATCH v3 5/6] efi/libstub: Enable direct sysfb_primary_display access on LoongArch wuqianhai ` (2 subsequent siblings) 6 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:24 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> The LoongArch port does not implement video_is_primary_device(), so it falls back to the generic stub that always returns false. As a result, with CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y the framebuffer console cannot map itself to the primary display device and instead binds to the first registered framebuffer, which is not necessarily the one the firmware used for the boot console. Implement video_is_primary_device() by returning whether the device is the VGA default device. This reuses the VGA arbiter's choice instead of matching the firmware framebuffer by address, so it is stable across BAR resizing: the default device is fixed before any driver runs. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- arch/loongarch/Makefile | 3 +++ arch/loongarch/include/asm/video.h | 7 +++++++ arch/loongarch/video/Makefile | 3 +++ arch/loongarch/video/video-common.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 arch/loongarch/video/Makefile create mode 100644 arch/loongarch/video/video-common.c diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 4b22f95aaafb..7fca93298cef 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -166,6 +166,9 @@ bootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) drivers-$(CONFIG_PCI) += arch/loongarch/pci/ +# framebuffer console primary device detection +drivers-$(CONFIG_VIDEO) += arch/loongarch/video/ + KBUILD_AFLAGS += $(cflags-y) KBUILD_CFLAGS += $(cflags-y) KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) diff --git a/arch/loongarch/include/asm/video.h b/arch/loongarch/include/asm/video.h index 9f76845f2d4f..7b38881ea1d6 100644 --- a/arch/loongarch/include/asm/video.h +++ b/arch/loongarch/include/asm/video.h @@ -8,6 +8,13 @@ #include <linux/compiler.h> #include <linux/string.h> +struct device; + +#ifdef CONFIG_VIDEO +bool video_is_primary_device(struct device *dev); +#define video_is_primary_device video_is_primary_device +#endif + static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n) { memcpy(to, (void __force *)from, n); diff --git a/arch/loongarch/video/Makefile b/arch/loongarch/video/Makefile new file mode 100644 index 000000000000..f1b2a7e54033 --- /dev/null +++ b/arch/loongarch/video/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_VIDEO) += video-common.o diff --git a/arch/loongarch/video/video-common.c b/arch/loongarch/video/video-common.c new file mode 100644 index 000000000000..6fea46661cb6 --- /dev/null +++ b/arch/loongarch/video/video-common.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2026 Loongson Technology Corporation Limited + */ + +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/vgaarb.h> + +#include <asm/video.h> + +bool video_is_primary_device(struct device *dev) +{ + struct pci_dev *pdev; + + if (!dev_is_pci(dev)) + return false; + + pdev = to_pci_dev(dev); + + if (!pci_is_display(pdev)) + return false; + + return pdev == vga_default_device(); +} +EXPORT_SYMBOL(video_is_primary_device); + +MODULE_DESCRIPTION("LoongArch video helpers"); +MODULE_LICENSE("GPL"); -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 5/6] efi/libstub: Enable direct sysfb_primary_display access on LoongArch 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai ` (3 preceding siblings ...) 2026-11-10 9:24 ` [PATCH v3 4/6] LoongArch: video: Implement primary framebuffer device detection wuqianhai @ 2026-11-10 9:24 ` wuqianhai 2026-11-10 9:24 ` [PATCH v3 6/6] PCI/VGA: Enable firmware default device detection " wuqianhai 2026-11-10 10:00 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device Huacai Chen 6 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:24 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> alloc_primary_display() returns NULL on LoongArch when neither CONFIG_EFI_EARLYCON nor CONFIG_SYSFB is enabled, so the EFI stub does not populate the core kernel's sysfb_primary_display. Allow LoongArch to link directly to sysfb_primary_display, like x86, so the firmware framebuffer information is always available. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- drivers/firmware/efi/libstub/efi-stub-entry.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c index efa3ab8ad1c6..2ac22720675c 100644 --- a/drivers/firmware/efi/libstub/efi-stub-entry.c +++ b/drivers/firmware/efi/libstub/efi-stub-entry.c @@ -20,6 +20,7 @@ struct sysfb_display_info *alloc_primary_display(void) return __alloc_primary_display(); if (IS_ENABLED(CONFIG_X86) || + IS_ENABLED(CONFIG_LOONGARCH) || IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB)) return kernel_image_addr(&sysfb_primary_display); -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 6/6] PCI/VGA: Enable firmware default device detection on LoongArch 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai ` (4 preceding siblings ...) 2026-11-10 9:24 ` [PATCH v3 5/6] efi/libstub: Enable direct sysfb_primary_display access on LoongArch wuqianhai @ 2026-11-10 9:24 ` wuqianhai 2026-11-10 10:00 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device Huacai Chen 6 siblings, 0 replies; 16+ messages in thread From: wuqianhai @ 2026-11-10 9:24 UTC (permalink / raw) To: chenhuacai, kernel, tzimmermann, deller, bhelgaas Cc: ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel, wuqianhai From: wuqianhai <wuqianhai@loongson.cn> Use CONFIG_SCREEN_INFO rather than an architecture-specific condition to guard vga_is_firmware_default(). LoongArch now provides sysfb_primary_display whenever CONFIG_SCREEN_INFO is enabled, so have VGA_ARB select SCREEN_INFO on LoongArch as well. The screen_info staleness is handled by the PCI resource-assignment path in the previous patch, so vga_arb_device_init() no longer has to refresh screen_info itself. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- drivers/pci/Kconfig | 2 +- drivers/pci/vgaarb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 0c7408509ba2..01e6378effae 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -255,7 +255,7 @@ config VGA_ARB bool "VGA Arbitration" if EXPERT default y depends on !S390 - select SCREEN_INFO if X86 + select SCREEN_INFO if X86 || LOONGARCH help Some "legacy" VGA devices implemented on PCI typically have the same hard-decoded addresses as they did on ISA. When multiple PCI devices diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 3e58b2c05c85..4528ad038610 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -566,7 +566,7 @@ EXPORT_SYMBOL(vga_put); static bool vga_is_firmware_default(struct pci_dev *pdev) { -#if defined CONFIG_X86 +#ifdef CONFIG_SCREEN_INFO return pdev == screen_info_pci_dev(&sysfb_primary_display.screen); #else return false; -- 2.34.1 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai ` (5 preceding siblings ...) 2026-11-10 9:24 ` [PATCH v3 6/6] PCI/VGA: Enable firmware default device detection " wuqianhai @ 2026-11-10 10:00 ` Huacai Chen 6 siblings, 0 replies; 16+ messages in thread From: Huacai Chen @ 2026-11-10 10:00 UTC (permalink / raw) To: wuqianhai Cc: kernel, tzimmermann, deller, bhelgaas, ardb, ilias.apalodimas, javierm, loongarch, linux-pci, linux-efi, dri-devel, linux-fbdev, linux-kernel Hi, Qianhai, On Tue, Nov 10, 2026 at 5:04 PM <wuqianhai@loongson.cn> wrote: > > From: wuqianhai <wuqianhai@loongson.cn> > > On LoongArch the kernel cannot reliably identify the display device that > was set up by the firmware and used for the boot console. Two code paths > need this information and currently get it wrong: > > * The PCI VGA arbiter: vga_is_firmware_default() is compiled only on > x86, so on LoongArch vga_default_device() may select the wrong GPU > when several are present (for example an integrated display > controller and a discrete card). > > * The framebuffer console: LoongArch does not implement > video_is_primary_device(), so with > CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y the console falls back to > the generic stub that always returns false and binds to the first > registered framebuffer instead of the boot display. > > This series fixes both by publishing the firmware framebuffer information > through screen_info on LoongArch and consuming it the same way x86 does. > > Patch 1 always defines and initializes sysfb_primary_display, and always > provides its EFI stub alias, instead of guarding them behind > SYSFB/EFI_EARLYCON. > > Patch 2 refreshes screen_info from the PCI resource-assignment path after > the root-bus resources are assigned, so the framebuffer address is final > before the VGA arbiter and sysfb_init() consume it. The call is placed > in the LoongArch PCI scan path because only LoongArch has this ordering: > acpi_init() relocates the BAR before vga_arb_device_init() runs. On x86 > the screen_info address is still accurate at that point. If you would > rather have the helper called from the generic > pci_assign_unassigned_root_bus_resources() path so that all architectures > share it, that can be done instead. > > Patch 3 removes pci_fixup_vgadev(), which overrides the VGA default > device to a discrete card after the arbiter has already selected the > firmware framebuffer device, so vga_default_device() consistently > reflects the boot display. > > Patch 4 implements video_is_primary_device() for LoongArch by reusing the > VGA default device selected by the arbiter. > > Patch 5 lets the EFI stub link directly to sysfb_primary_display on > LoongArch, so the firmware framebuffer information is always populated. > > Patch 6 lets the VGA arbiter use CONFIG_SCREEN_INFO instead of an > architecture check and makes VGA_ARB select SCREEN_INFO on LoongArch. > > Patches 1-4 are LoongArch-specific. Patches 5 and 6 touch generic code > (the EFI stub and the PCI VGA arbiter) and are placed last so they can be > reviewed and merged separately. Patches 3 and 4 depend on patch 6 taking > effect, but are ordered ahead of it only to group the LoongArch changes > together. > > Changes since v2: > - Split the screen_info refresh out of vga_arb_device_init() into the > LoongArch PCI resource-assignment path (patch 2), following Thomas' > suggestion to decouple it from sysfb_init(). > - Drop the per-architecture check in vgaarb.c and the select of SYSFB > in favour of CONFIG_SCREEN_INFO and select SCREEN_INFO (patch 6). > - Always define and initialize sysfb_primary_display, and let the EFI > stub link to it directly (patches 1 and 5), instead of guarding them > behind SYSFB/EFI_EARLYCON. > - Remove the vga_default_device() override (patch 3) so the arbiter's > firmware-framebuffer selection takes effect. > - Implement video_is_primary_device() (patch 4) by reusing the arbiter's > default device, so FRAMEBUFFER_CONSOLE_DETECT_PRIMARY works. > > Build-tested on loongarch64 with GCC 8.3.0. > > wuqianhai (6): > LoongArch: efi: Provide sysfb_primary_display for screen_info users > LoongArch/PCI: Refresh screen_info after resource assignment > LoongArch/PCI: Remove vga default device override > LoongArch: video: Implement primary framebuffer device detection > efi/libstub: Enable direct sysfb_primary_display access on LoongArch Please fold this patch to the first one. And your signature should be: Qianhai Wu <wuqianhai@loongson.cn> Huacai > PCI/VGA: Enable firmware default device detection on LoongArch > > arch/loongarch/Makefile | 3 ++ > arch/loongarch/include/asm/video.h | 7 +++++ > arch/loongarch/kernel/efi.c | 5 +--- > arch/loongarch/kernel/image-vars.h | 2 -- > arch/loongarch/pci/acpi.c | 4 +++ > arch/loongarch/pci/pci.c | 18 ------------ > arch/loongarch/video/Makefile | 3 ++ > arch/loongarch/video/video-common.c | 29 +++++++++++++++++++ > drivers/firmware/efi/libstub/efi-stub-entry.c | 1 + > drivers/pci/Kconfig | 2 +- > drivers/pci/vgaarb.c | 2 +- > 11 files changed, 50 insertions(+), 26 deletions(-) > create mode 100644 arch/loongarch/video/Makefile > create mode 100644 arch/loongarch/video/video-common.c > > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-11-10 16:25 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261029033440.973077-1-wuqianhai@loongson.cn>
2026-11-10 8:56 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai
2026-11-10 8:56 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai
2026-11-10 14:34 ` Thomas Zimmermann
2026-11-10 14:39 ` Thomas Zimmermann
2026-11-10 16:25 ` Thomas Zimmermann
2026-11-10 8:56 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai
2026-11-10 14:46 ` Thomas Zimmermann
2026-11-10 8:56 ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai
2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai
2026-11-10 9:01 ` [PATCH v3 1/6] LoongArch: efi: Provide sysfb_primary_display for screen_info users wuqianhai
2026-11-10 9:01 ` [PATCH v3 2/6] LoongArch/PCI: Refresh screen_info after resource assignment wuqianhai
2026-11-10 9:02 ` [PATCH v3 3/6] LoongArch/PCI: Remove vga default device override wuqianhai
2026-11-10 9:24 ` [PATCH v3 4/6] LoongArch: video: Implement primary framebuffer device detection wuqianhai
2026-11-10 9:24 ` [PATCH v3 5/6] efi/libstub: Enable direct sysfb_primary_display access on LoongArch wuqianhai
2026-11-10 9:24 ` [PATCH v3 6/6] PCI/VGA: Enable firmware default device detection " wuqianhai
2026-11-10 10:00 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device Huacai Chen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox