From: Thomas Zimmermann <tzimmermann@suse.de>
To: wuqianhai@loongson.cn, bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
javierm@redhat.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] PCI/VGA: Enable firmware default device detection on LoongArch
Date: Thu, 29 Oct 2026 09:10:27 +0100 [thread overview]
Message-ID: <905d902c-461f-4a0e-9ac2-0ad02fe9cabe@suse.de> (raw)
In-Reply-To: <20261029033440.973077-1-wuqianhai@loongson.cn>
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)
next prev parent reply other threads:[~2026-10-29 8:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=905d902c-461f-4a0e-9ac2-0ad02fe9cabe@suse.de \
--to=tzimmermann@suse.de \
--cc=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=wuqianhai@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®