Hi, Qianhai, On Tue, Nov 10, 2026 at 5:04 PM <[email protected]> wrote: > > From: wuqianhai <[email protected]> > > 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 <[email protected]> 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 >
