* [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation
@ 2026-10-28 9:46 wuqianhai
2026-10-28 23:15 ` Bjorn Helgaas
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: wuqianhai @ 2026-10-28 9:46 UTC (permalink / raw)
To: bhelgaas
Cc: wuqianhai, linux-pci, linux-kernel, tzimmermann, javierm, dri-devel
From: wuqianhai <wuqianhai@loongson.cn>
PCI resource assignment can relocate the firmware framebuffer BAR, which
leaves the base address in screen_info stale. The VGA arbiter then calls
screen_info_pci_dev() from vga_is_firmware_default(), which fails to match
the framebuffer against any PCI device's BARs. As a result, the boot VGA
device is not recognized and the arbiter may select the wrong default
device.
Fix this by calling screen_info_apply_fixups() in vga_arb_device_init()
before adding the VGA devices. This relocates lfb_base to the assigned
BAR address so that vga_is_firmware_default() matches the boot device
again.
Tested on a LoongArch platform, with vga_is_firmware_default()
additionally enabled for CONFIG_LOONGARCH via local changes.
Fixes: 337bf13aa9ddab8ae47f2677ab75cf69ae33437b ("PCI/VGA: Replace vga_is_firmware_default() with a screen info check")
Signed-off-by: wuqianhai <wuqianhai@loongson.cn>
---
drivers/pci/vgaarb.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 3e58b2c05c85..aca594651f58 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -1527,6 +1527,14 @@ static int __init vga_arb_device_init(void)
int rc;
struct pci_dev *pdev;
+ /*
+ * PCI resource assignment may have relocated the firmware
+ * framebuffer BAR. Update screen_info's lfb_base so that
+ * vga_is_firmware_default() can match it against the boot
+ * device's relocated resource.
+ */
+ screen_info_apply_fixups();
+
rc = misc_register(&vga_arb_device);
if (rc < 0)
pr_err("error %d registering device\n", rc);
--
2.34.1
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation 2026-10-28 9:46 [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation wuqianhai @ 2026-10-28 23:15 ` Bjorn Helgaas 2026-10-29 3:39 ` wuqianhai 2026-10-29 7:54 ` Thomas Zimmermann 2026-10-29 3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai ` (2 subsequent siblings) 3 siblings, 2 replies; 25+ messages in thread From: Bjorn Helgaas @ 2026-10-28 23:15 UTC (permalink / raw) To: wuqianhai Cc: bhelgaas, linux-pci, linux-kernel, tzimmermann, javierm, dri-devel On Wed, Oct 28, 2026 at 05:46:34PM +0800, wuqianhai@loongson.cn wrote: > From: wuqianhai <wuqianhai@loongson.cn> > > PCI resource assignment can relocate the firmware framebuffer BAR, which > leaves the base address in screen_info stale. The VGA arbiter then calls > screen_info_pci_dev() from vga_is_firmware_default(), which fails to match > the framebuffer against any PCI device's BARs. As a result, the boot VGA > device is not recognized and the arbiter may select the wrong default > device. > > Fix this by calling screen_info_apply_fixups() in vga_arb_device_init() > before adding the VGA devices. This relocates lfb_base to the assigned > BAR address so that vga_is_firmware_default() matches the boot device > again. > > Tested on a LoongArch platform, with vga_is_firmware_default() > additionally enabled for CONFIG_LOONGARCH via local changes. > > Fixes: 337bf13aa9ddab8ae47f2677ab75cf69ae33437b ("PCI/VGA: Replace vga_is_firmware_default() with a screen info check") > Signed-off-by: wuqianhai <wuqianhai@loongson.cn> > --- > drivers/pci/vgaarb.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c > index 3e58b2c05c85..aca594651f58 100644 > --- a/drivers/pci/vgaarb.c > +++ b/drivers/pci/vgaarb.c > @@ -1527,6 +1527,14 @@ static int __init vga_arb_device_init(void) > int rc; > struct pci_dev *pdev; > > + /* > + * PCI resource assignment may have relocated the firmware > + * framebuffer BAR. Update screen_info's lfb_base so that > + * vga_is_firmware_default() can match it against the boot > + * device's relocated resource. > + */ > + screen_info_apply_fixups(); I'm really confused about this. vga_is_firmware_default() relies on screen_info_pci_dev(&sysfb_primary_display.screen): vga_is_firmware_default screen_info_pci_dev(&sysfb_primary_display.screen) numres = screen_info_resources(&sysfb_primary_display.screen, res, ...) for (i = 0; i < numres; ++i) pdev = __screen_info_pci_dev(&res[i]) screen_info_resources() returns resource structs with PCI bus addresses in them. These are not valid CPU addresses, so that seems broken on any system where bus addresses are not the same as CPU addresses. screen_info_fixup_lfb() and screen_info_apply_fixups() may fix the issue you see, but I think the way this happens is questionable. screen_info_fixup_lfb() captures the framebuffer PCI bus address in screen_info_lfb_res_start. Then screen_info_apply_fixups() compares that PCI bus address with the CPU address in pdev->resource[]. That's broken on any system where bus addresses are not the same as CPU addresses. I think it's also broken because screen_info_lfb_res_start may not be at the beginning of the BAR. I think screen_info_fixup_lfb() should only capture the pci_dev, the BAR number, and the framebuffer offset into the BAR. When we need the CPU or bus address, we can always compute it from those values. > rc = misc_register(&vga_arb_device); > if (rc < 0) > pr_err("error %d registering device\n", rc); > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation 2026-10-28 23:15 ` Bjorn Helgaas @ 2026-10-29 3:39 ` wuqianhai 2026-10-29 20:03 ` Bjorn Helgaas 2026-10-29 7:54 ` Thomas Zimmermann 1 sibling, 1 reply; 25+ messages in thread From: wuqianhai @ 2026-10-29 3:39 UTC (permalink / raw) To: helgaas; +Cc: tzimmermann, linux-pci, linux-kernel Hi Bjorn, Thanks for the detailed analysis. You're right that screen_info_fixup_lfb()/screen_info_apply_fixups() stores a PCI bus address in screen_info_lfb_res_start and compares it with the CPU address in pdev->resource[].start, which is broken on systems where bus and CPU addresses differ. On LoongArch, though, bus and CPU addresses are identical: with modern firmware, acpi_prepare_root_resources() takes the PCIH path and leaves the window offset at 0 (see commit 49f33840dcc9). So the existing screen_info_apply_fixups() works correctly for LoongArch, and the address-space confusion you describe does not trigger there. I've sent a v2 that: - enables vga_is_firmware_default() for LoongArch, - restricts the screen_info_apply_fixups() call to LoongArch so x86 and other architectures are unaffected, - makes VGA_ARB select SYSFB on LoongArch to avoid the undefined reference when CONFIG_SCREEN_INFO is not set. The general bus != CPU problem in screen_info_pci.c is still worth fixing for ARM and friends, but I'd rather keep that separate from this LoongArch enablement. Happy to help with that follow-up if useful. Regards, wuqianhai ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation 2026-10-29 3:39 ` wuqianhai @ 2026-10-29 20:03 ` Bjorn Helgaas 0 siblings, 0 replies; 25+ messages in thread From: Bjorn Helgaas @ 2026-10-29 20:03 UTC (permalink / raw) To: wuqianhai, Huacai Chen, Jianmin Lv Cc: tzimmermann, linux-pci, linux-kernel, Chao Li, Dongyan Qian [+ Loongson folks] On Thu, Oct 29, 2026 at 11:39:14AM +0800, wuqianhai@loongson.cn wrote: > Hi Bjorn, > > Thanks for the detailed analysis. > > You're right that screen_info_fixup_lfb()/screen_info_apply_fixups() > stores a PCI bus address in screen_info_lfb_res_start and compares it > with the CPU address in pdev->resource[].start, which is broken on > systems where bus and CPU addresses differ. > > On LoongArch, though, bus and CPU addresses are identical: with modern > firmware, acpi_prepare_root_resources() takes the PCIH path and leaves > the window offset at 0 (see commit 49f33840dcc9). This is a tangent from the framebuffer question, but what in the world is 49f33840dcc9 ("LoongArch: Use per-root-bridge PCIH flag to skip mem resource fixup") doing? I see that if "PCIH" is non-zero, it skips some mem resource "fixup" that was added by 57fc7323a8e7 ("LoongArch: Add PCI controller support"). But I don't understand why that fixup is there in the first place. Evidently it takes the upper 24 bits of the MCFG address and ORs it into window addresses from host bridge _CRS? That sounds nuts. It sounds like the ACPI _CRS is just broken. The struct resource_entry.offset is the offset between PCI bus addresses and CPU addresses, so entry->offset being non-zero implies they are NOT identical, at least on non-PCIH platforms. And if you have to hack up the offset from the MCFG address, it sounds like the _CRS entries are missing the _TRA that is supposed to provide the offset. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation 2026-10-28 23:15 ` Bjorn Helgaas 2026-10-29 3:39 ` wuqianhai @ 2026-10-29 7:54 ` Thomas Zimmermann 1 sibling, 0 replies; 25+ messages in thread From: Thomas Zimmermann @ 2026-10-29 7:54 UTC (permalink / raw) To: Bjorn Helgaas, wuqianhai Cc: bhelgaas, linux-pci, linux-kernel, javierm, dri-devel Hi Am 29.10.26 um 00:15 schrieb Bjorn Helgaas: > On Wed, Oct 28, 2026 at 05:46:34PM +0800, wuqianhai@loongson.cn wrote: >> From: wuqianhai <wuqianhai@loongson.cn> >> >> PCI resource assignment can relocate the firmware framebuffer BAR, which >> leaves the base address in screen_info stale. The VGA arbiter then calls >> screen_info_pci_dev() from vga_is_firmware_default(), which fails to match >> the framebuffer against any PCI device's BARs. As a result, the boot VGA >> device is not recognized and the arbiter may select the wrong default >> device. >> >> Fix this by calling screen_info_apply_fixups() in vga_arb_device_init() >> before adding the VGA devices. This relocates lfb_base to the assigned >> BAR address so that vga_is_firmware_default() matches the boot device >> again. >> >> Tested on a LoongArch platform, with vga_is_firmware_default() >> additionally enabled for CONFIG_LOONGARCH via local changes. >> >> Fixes: 337bf13aa9ddab8ae47f2677ab75cf69ae33437b ("PCI/VGA: Replace vga_is_firmware_default() with a screen info check") >> Signed-off-by: wuqianhai <wuqianhai@loongson.cn> >> --- >> drivers/pci/vgaarb.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c >> index 3e58b2c05c85..aca594651f58 100644 >> --- a/drivers/pci/vgaarb.c >> +++ b/drivers/pci/vgaarb.c >> @@ -1527,6 +1527,14 @@ static int __init vga_arb_device_init(void) >> int rc; >> struct pci_dev *pdev; >> >> + /* >> + * PCI resource assignment may have relocated the firmware >> + * framebuffer BAR. Update screen_info's lfb_base so that >> + * vga_is_firmware_default() can match it against the boot >> + * device's relocated resource. >> + */ >> + screen_info_apply_fixups(); > I'm really confused about this. vga_is_firmware_default() relies on > screen_info_pci_dev(&sysfb_primary_display.screen): > > vga_is_firmware_default > screen_info_pci_dev(&sysfb_primary_display.screen) > numres = screen_info_resources(&sysfb_primary_display.screen, res, ...) > for (i = 0; i < numres; ++i) > pdev = __screen_info_pci_dev(&res[i]) > > screen_info_resources() returns resource structs with PCI bus > addresses in them. These are not valid CPU addresses, so that seems > broken on any system where bus addresses are not the same as CPU > addresses. What we get from the firmware for the framebuffer is a memory range. If the underlying PCI memory gets relocated during the boot, we need to update the framebuffer data accordingly. This has worked well for the last 20 yrs. > > screen_info_fixup_lfb() and screen_info_apply_fixups() may fix the > issue you see, but I think the way this happens is questionable. > > screen_info_fixup_lfb() captures the framebuffer PCI bus address in > screen_info_lfb_res_start. Then screen_info_apply_fixups() compares > that PCI bus address with the CPU address in pdev->resource[]. That's > broken on any system where bus addresses are not the same as CPU > addresses. I think it's also broken because screen_info_lfb_res_start > may not be at the beginning of the BAR. > > I think screen_info_fixup_lfb() should only capture the pci_dev, the > BAR number, and the framebuffer offset into the BAR. When we need the > CPU or bus address, we can always compute it from those values. This is not sufficient, I think. We did this until a while ago and got problems with relocated bars. IIRC aarch64 had a number of affected systems. See commit 2f29b5c23101 ("video: screen_info: Relocate framebuffers behind PCI bridges") for details. I'm happy to improve that code though, if we can do something better. Best regards Thomas > >> rc = misc_register(&vga_arb_device); >> if (rc < 0) >> pr_err("error %d registering device\n", rc); >> -- >> 2.34.1 >> -- -- 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] 25+ messages in thread
* [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch 2026-10-28 9:46 [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation wuqianhai 2026-10-28 23:15 ` Bjorn Helgaas @ 2026-10-29 3:34 ` wuqianhai 2026-10-29 8:10 ` Thomas Zimmermann ` (2 more replies) 2026-10-29 7:00 ` [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation kernel test robot 2026-10-29 13:30 ` kernel test robot 3 siblings, 3 replies; 25+ messages in thread From: wuqianhai @ 2026-10-29 3:34 UTC (permalink / raw) To: bhelgaas Cc: wuqianhai, linux-pci, linux-kernel, tzimmermann, javierm, dri-devel From: wuqianhai <wuqianhai@loongson.cn> On LoongArch, PCI resource assignment completes during subsys_initcall (acpi_init), before vga_arb_device_init() runs. By that time the firmware framebuffer BAR may already have been relocated, leaving screen_info's lfb_base stale. Enable vga_is_firmware_default() for LoongArch and refresh screen_info in vga_arb_device_init() before the boot device is matched. Unlike x86, sysfb_primary_display is only defined when CONFIG_SYSFB is enabled on LoongArch, so have VGA_ARB select SYSFB there. Signed-off-by: wuqianhai <wuqianhai@loongson.cn> --- Changes in v2: - Add VGA_ARB's select of SYSFB for LoongArch to avoid an undefined reference when CONFIG_SCREEN_INFO is not set. - Restrict the screen_info_apply_fixups() call to CONFIG_LOONGARCH so x86 and other architectures are unaffected. - Enable vga_is_firmware_default() for LoongArch. --- drivers/pci/Kconfig | 1 + drivers/pci/vgaarb.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 0c7408509ba2..55cc60f5d312 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -256,6 +256,7 @@ config VGA_ARB default y depends on !S390 select SCREEN_INFO if X86 + select SYSFB if 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..1b7e915629f9 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 +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) return pdev == screen_info_pci_dev(&sysfb_primary_display.screen); #else return false; @@ -1527,6 +1527,16 @@ static int __init vga_arb_device_init(void) int rc; struct pci_dev *pdev; +#if defined(CONFIG_LOONGARCH) + /* + * On LoongArch, PCI resource assignment completes during + * subsys_initcall (acpi_init), before the VGA arbiter runs. Refresh + * screen_info so vga_is_firmware_default() can match the relocated + * BAR. + */ + screen_info_apply_fixups(); +#endif + rc = misc_register(&vga_arb_device); if (rc < 0) pr_err("error %d registering device\n", rc); -- 2.34.1 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch 2026-10-29 3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai @ 2026-10-29 8:10 ` Thomas Zimmermann 2026-11-10 8:56 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 2026-11-10 9:01 ` [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device wuqianhai 2 siblings, 0 replies; 25+ messages in thread From: Thomas Zimmermann @ 2026-10-29 8:10 UTC (permalink / raw) To: wuqianhai, bhelgaas; +Cc: linux-pci, linux-kernel, javierm, dri-devel Hi Am 29.10.26 um 04:34 schrieb wuqianhai@loongson.cn: > From: wuqianhai <wuqianhai@loongson.cn> > > On LoongArch, PCI resource assignment completes during subsys_initcall > (acpi_init), before vga_arb_device_init() runs. By that time the > firmware framebuffer BAR may already have been relocated, leaving > screen_info's lfb_base stale. Enable vga_is_firmware_default() for > LoongArch and refresh screen_info in vga_arb_device_init() before the > boot device is matched. > > Unlike x86, sysfb_primary_display is only defined when CONFIG_SYSFB is > enabled on LoongArch, so have VGA_ARB select SYSFB there. > > Signed-off-by: wuqianhai <wuqianhai@loongson.cn> > --- > Changes in v2: > - Add VGA_ARB's select of SYSFB for LoongArch to avoid an undefined > reference when CONFIG_SCREEN_INFO is not set. > - Restrict the screen_info_apply_fixups() call to CONFIG_LOONGARCH so > x86 and other architectures are unaffected. > - Enable vga_is_firmware_default() for LoongArch. > --- > drivers/pci/Kconfig | 1 + > drivers/pci/vgaarb.c | 12 +++++++++++- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig > index 0c7408509ba2..55cc60f5d312 100644 > --- a/drivers/pci/Kconfig > +++ b/drivers/pci/Kconfig > @@ -256,6 +256,7 @@ config VGA_ARB > default y > depends on !S390 > select SCREEN_INFO if X86 > + select SYSFB if 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..1b7e915629f9 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 > +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) > return pdev == screen_info_pci_dev(&sysfb_primary_display.screen); > #else > return false; > @@ -1527,6 +1527,16 @@ static int __init vga_arb_device_init(void) > int rc; > struct pci_dev *pdev; > > +#if defined(CONFIG_LOONGARCH) > + /* > + * On LoongArch, PCI resource assignment completes during > + * subsys_initcall (acpi_init), before the VGA arbiter runs. Refresh > + * screen_info so vga_is_firmware_default() can match the relocated > + * BAR. > + */ > + screen_info_apply_fixups(); > +#endif No per-arch defines in generic code. All the setup should work the same on all architectures. All global screen-info state should be maintained by drivers/firmware/sysfb.c. Otherwise the framebuffer setup gets even more convoluted than it already is. My question is why does vga_is_firmware_default() run before sysfb_init()? [1] Does acpi_init call into it? [1] https://elixir.bootlin.com/linux/v7.3/source/drivers/firmware/sysfb.c#L225 Apart from that, we can decouple screen_info_apply_fixups() from sysfb_init(). After relocation happens, the PCI code could call the helper directly and let it update the global screen_info. Best regards Thomas > + > rc = misc_register(&vga_arb_device); > if (rc < 0) > pr_err("error %d registering device\n", rc); -- -- 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] 25+ messages in thread
* [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device 2026-10-29 3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai 2026-10-29 8:10 ` Thomas Zimmermann @ 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 2 siblings, 3 replies; 25+ 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] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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] 25+ 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; 25+ 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] 25+ 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; 25+ 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] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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] 25+ 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; 25+ 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 [flat|nested] 25+ messages in thread
* [PATCH v3 0/6] LoongArch: Identify the firmware/boot display device 2026-10-29 3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai 2026-10-29 8:10 ` Thomas Zimmermann 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) 2 siblings, 7 replies; 25+ 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] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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 [flat|nested] 25+ 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; 25+ 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] 25+ messages in thread
* Re: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation 2026-10-28 9:46 [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation wuqianhai 2026-10-28 23:15 ` Bjorn Helgaas 2026-10-29 3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai @ 2026-10-29 7:00 ` kernel test robot 2026-10-29 13:30 ` kernel test robot 3 siblings, 0 replies; 25+ messages in thread From: kernel test robot @ 2026-10-29 7:00 UTC (permalink / raw) To: wuqianhai, bhelgaas Cc: llvm, oe-kbuild-all, wuqianhai, linux-pci, linux-kernel, tzimmermann, javierm, dri-devel Hi, kernel test robot noticed the following build errors: [auto build test ERROR on pci/next] [also build test ERROR on pci/for-linus linus/master v7.3 next-20261028] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/wuqianhai-loongson-cn/PCI-VGA-Fix-boot-device-detection-after-framebuffer-relocation/20261028-174634 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20261028094634.766723-1-wuqianhai%40loongson.cn patch subject: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20261029/202610291418.tlsEIHSu-lkp@intel.com/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261029/202610291418.tlsEIHSu-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202610291418.tlsEIHSu-lkp@intel.com/ All errors (new ones prefixed by >>): >> ld.lld: error: undefined symbol: screen_info_apply_fixups >>> referenced by vgaarb.c >>> drivers/pci/vgaarb.o:(vga_arb_device_init) in archive vmlinux.a -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation 2026-10-28 9:46 [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation wuqianhai ` (2 preceding siblings ...) 2026-10-29 7:00 ` [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation kernel test robot @ 2026-10-29 13:30 ` kernel test robot 3 siblings, 0 replies; 25+ messages in thread From: kernel test robot @ 2026-10-29 13:30 UTC (permalink / raw) To: wuqianhai, bhelgaas Cc: oe-kbuild-all, wuqianhai, linux-pci, linux-kernel, tzimmermann, javierm, dri-devel Hi, kernel test robot noticed the following build errors: [auto build test ERROR on pci/next] [also build test ERROR on pci/for-linus linus/master v7.3 next-20261028] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/wuqianhai-loongson-cn/PCI-VGA-Fix-boot-device-detection-after-framebuffer-relocation/20261028-174634 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20261028094634.766723-1-wuqianhai%40loongson.cn patch subject: [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation config: microblaze-defconfig (https://download.01.org/0day-ci/archive/20261029/202610292159.Ls5pkJAS-lkp@intel.com/config) compiler: microblaze-linux-gcc (GCC) 16.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261029/202610292159.Ls5pkJAS-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202610292159.Ls5pkJAS-lkp@intel.com/ All errors (new ones prefixed by >>): microblaze-linux-ld: drivers/pci/vgaarb.o: in function `vga_arb_device_init': >> drivers/pci/vgaarb.c:1536:(.init.text+0x10): undefined reference to `screen_info_apply_fixups' vim +1536 drivers/pci/vgaarb.c 1524 1525 static int __init vga_arb_device_init(void) 1526 { 1527 int rc; 1528 struct pci_dev *pdev; 1529 1530 /* 1531 * PCI resource assignment may have relocated the firmware 1532 * framebuffer BAR. Update screen_info's lfb_base so that 1533 * vga_is_firmware_default() can match it against the boot 1534 * device's relocated resource. 1535 */ > 1536 screen_info_apply_fixups(); -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2026-11-10 16:25 UTC | newest] Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-10-28 9:46 [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation wuqianhai 2026-10-28 23:15 ` Bjorn Helgaas 2026-10-29 3:39 ` wuqianhai 2026-10-29 20:03 ` Bjorn Helgaas 2026-10-29 7:54 ` Thomas Zimmermann 2026-10-29 3:34 ` [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch wuqianhai 2026-10-29 8:10 ` Thomas Zimmermann 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 2026-10-29 7:00 ` [PATCH] PCI/VGA: Fix boot device detection after framebuffer relocation kernel test robot 2026-10-29 13:30 ` kernel test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®