Skip to contentSkip to conversation

firmware: sysfb: Consolidate config/code wrt. sysfb_primary_screen

PATCH In review Thomas Zimmermann 6 participants 24 messages Apr 2 – Apr 30

Subsystems (11)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover firmware: sysfb: Consolidate config/code wrt. sysfb_primary_screen

The global state sysfb_primary_screen holds information about the framebuffer provided by EFI/BIOS systems. It is part of the sysfb module, but used in several places without direct connection to sysfb. Fix this by making users of sysfb_primary_screen depend on CONFIG_SYSFB. Fix a few issues in the process.

Patches 1 and 2 fix general errors in the Kconfig rules. In any case, these patches should be considered even without the rest of the series.

Patch 3 makes CONFIG_SYSFB a user-controlled option, which gives users more control over the configuration.

Patches 4 to 6 slightly refactor the sysfb code. The PCI helpers are now in a separate source file. Support for relocating the PCI framebuffer is now located in sysfb, where it belongs.

Patches 7 and 8 make earlycon and the firmware EDID depend on sysfb. Both rely on sysfb_primary_display to work correctly.

Smoke-tested with bochs on qemu. Built with/without CONFIG_SYSFB enabled.

Note: vgaarb still guards sysfb_primary_display with CONFIG_X86 instead of CONFIG_SYSFB. That works reliably and is left in place, as a change to guard with SYSFB_SYSFB might affect non-x86 systems in unknown ways.

Thomas Zimmermann (8):
hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS
firmware: efi: Never declare sysfb_primary_display on x86
firmware: sysfb: Make CONFIG_SYSFB a user-selectable option
firmware: sysfb: Split sysfb.c into sysfb_primary.c and sysfb_pci.c
firmware: sysfb: Implement screen_info relocation for primary display
firmware: sysfb: Avoid forward-declaring sysfb_parent_dev()
firmware: efi: Make CONFIG_EFI_EARLYCON depend on CONFIG_SYSFB; clean
up
firmware: sysfb: Move CONFIG_FIRMWARE_EDID to firmware options

 arch/arm64/kernel/image-vars.h                |   2 +-
 arch/loongarch/configs/loongson32_defconfig   |   1 +
 arch/loongarch/configs/loongson64_defconfig   |   1 +
 arch/loongarch/kernel/efi.c                   |   4 +-
 arch/loongarch/kernel/image-vars.h            |   2 +-
 arch/riscv/kernel/image-vars.h                |   2 +-
 drivers/firmware/Kconfig                      |  38 ++++-
 drivers/firmware/Makefile                     |   7 +-
 drivers/firmware/efi/Kconfig                  |   3 +-
 drivers/firmware/efi/efi-init.c               |   6 +-
 drivers/firmware/efi/libstub/efi-stub-entry.c |   4 +-
 drivers/firmware/sysfb.h                      |  24 ++++
 drivers/firmware/sysfb_pci.c                  | 132 ++++++++++++++++++
 drivers/firmware/{sysfb.c => sysfb_primary.c} |  70 ++++------
 drivers/gpu/drm/sysfb/Kconfig                 |   4 +-
 drivers/hv/Kconfig                            |   2 +-
 drivers/video/Kconfig                         |  19 ---
 drivers/video/fbdev/Kconfig                   |   5 +-
 drivers/video/screen_info_pci.c               | 110 ---------------
 include/linux/screen_info.h                   |   3 -
 20 files changed, 241 insertions(+), 198 deletions(-)
 create mode 100644 drivers/firmware/sysfb.h
 create mode 100644 drivers/firmware/sysfb_pci.c
 rename drivers/firmware/{sysfb.c => sysfb_primary.c} (90%)

base-commit: 5d36e6d54e963f0c1137aaf2249d2baa781f08c2

Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/8 hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

Hyperv's sysfb access only exists in the VMBUS support. Therefore only select CONFIG_SYSFB for CONFIG_HYPERV_VMBUS. Avoids sysfb code on systems that don't need it.

Fixes 96959283a58d ("Drivers: hv: Always select CONFIG_SYSFB for Hyper-V guests")
Cc Michael Kelley <[email protected]>
Cc Saurabh Sengar <[email protected]>
Cc Wei Liu <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Dexuan Cui <[email protected]>
Cc Long Li <[email protected]>
Cc <[email protected]> # v6.16+
---
 drivers/hv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/Kconfig +1 -1
index 7937ac0cbd0f..2d0b3fcb0ff8 100644
@@ -9,7 +9,6 @@ config HYPERV
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR if X86
 	select OF_EARLY_FLATTREE if OF
-	select SYSFB if EFI && !HYPERV_VTL_MODE
 	select IRQ_MSI_LIB if X86
 	help
 	  Select this option to run Linux as a Hyper-V client operating
@@ -62,6 +61,7 @@ config HYPERV_VMBUS
 	tristate "Microsoft Hyper-V VMBus driver"
 	depends on HYPERV
 	default HYPERV
+	select SYSFB if EFI && !HYPERV_VTL_MODE
 	help
 	  Select this option to enable Hyper-V Vmbus driver.
 
Signature · 1 line
2.53.0
Reviewed-by Saurabh Sengar on v1 1/8
#2 lore raw

RE: [PATCH 1/8] hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

Quoted 41 lines

Hyperv's sysfb access only exists in the VMBUS support. Therefore only select CONFIG_SYSFB for CONFIG_HYPERV_VMBUS. Avoids sysfb code on systems that don't need it.

Fixes 96959283a58d ("Drivers: hv: Always select CONFIG_SYSFB for Hyper-V

guests")
Cc: Michael Kelley <[email protected]>
Cc: Saurabh Sengar <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Dexuan Cui <[email protected]>
Cc: Long Li <[email protected]>
Cc: [email protected]
Cc: <[email protected]> # v6.16+

---
 drivers/hv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/Kconfig index renamed from drivers/hv/Kconfig +0 -0

7937ac0cbd0f..2d0b3fcb0ff8 100644

drivers/hv/Kconfig +2 -2
@@ -9,7 +9,6 @@ config HYPERV
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR if X86
 	select OF_EARLY_FLATTREE if OF
-	select SYSFB if EFI && !HYPERV_VTL_MODE
 	select IRQ_MSI_LIB if X86
 	help
 	  Select this option to run Linux as a Hyper-V client operating @@ -62,6
+61,7 @@ config HYPERV_VMBUS
 	tristate "Microsoft Hyper-V VMBus driver"
 	depends on HYPERV
 	default HYPERV
+	select SYSFB if EFI && !HYPERV_VTL_MODE
 	help
 	  Select this option to enable Hyper-V Vmbus driver.
 
--
Quoted 1 line

2.53.0

author maintainer
#3 lore raw

Re: [PATCH 1/8] hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

Hi

Am 02.04.26 um 12:50 schrieb Saurabh Singh Sengar:

Quoted 40 lines
Quoted 40 lines

Hyperv's sysfb access only exists in the VMBUS support. Therefore only select CONFIG_SYSFB for CONFIG_HYPERV_VMBUS. Avoids sysfb code on systems that don't need it.

Fixes 96959283a58d ("Drivers: hv: Always select CONFIG_SYSFB for Hyper-V

guests")
Cc: Michael Kelley <[email protected]>
Cc: Saurabh Sengar <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Dexuan Cui <[email protected]>
Cc: Long Li <[email protected]>
Cc: [email protected]
Cc: <[email protected]> # v6.16+

---
  drivers/hv/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/Kconfig index renamed from drivers/hv/Kconfig +0 -0

7937ac0cbd0f..2d0b3fcb0ff8 100644

drivers/hv/Kconfig +2 -1
@@ -9,7 +9,6 @@ config HYPERV
  	select PARAVIRT
  	select X86_HV_CALLBACK_VECTOR if X86
  	select OF_EARLY_FLATTREE if OF
-	select SYSFB if EFI && !HYPERV_VTL_MODE
  	select IRQ_MSI_LIB if X86
  	help
  	  Select this option to run Linux as a Hyper-V client operating @@ -62,6
+61,7 @@ config HYPERV_VMBUS
  	tristate "Microsoft Hyper-V VMBus driver"
  	depends on HYPERV
  	default HYPERV
+	select SYSFB if EFI && !HYPERV_VTL_MODE
  	help
  	  Select this option to enable Hyper-V Vmbus driver.
Quoted 3 lines
Quoted 2 lines

--
2.53.0

This fix is independent from the rest of the series. Do you want to merge it or can I take it into DRM trees?

Best regards
Thomas

Quoted 1 line
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#4 lore raw

RE: [EXTERNAL] Re: [PATCH 1/8] hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

Quoted 45 lines

Hi

Am 02.04.26 um 12:50 schrieb Saurabh Singh Sengar:

Quoted 42 lines
Quoted 42 lines

Hyperv's sysfb access only exists in the VMBUS support. Therefore only select CONFIG_SYSFB for CONFIG_HYPERV_VMBUS. Avoids sysfb code on systems that don't need it.

Fixes 96959283a58d ("Drivers: hv: Always select CONFIG_SYSFB for

Hyper-V
guests")
Cc: Michael Kelley <[email protected]>
Cc: Saurabh Sengar <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Dexuan Cui <[email protected]>
Cc: Long Li <[email protected]>
Cc: [email protected]
Cc: <[email protected]> # v6.16+

---
  drivers/hv/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/Kconfig index renamed from drivers/hv/Kconfig +0 -0

7937ac0cbd0f..2d0b3fcb0ff8 100644

drivers/hv/Kconfig +2 -2
@@ -9,7 +9,6 @@ config HYPERV
  	select PARAVIRT
  	select X86_HV_CALLBACK_VECTOR if X86
  	select OF_EARLY_FLATTREE if OF
-	select SYSFB if EFI && !HYPERV_VTL_MODE
  	select IRQ_MSI_LIB if X86
  	help
  	  Select this option to run Linux as a Hyper-V client operating @@
-62,6
+61,7 @@ config HYPERV_VMBUS
  	tristate "Microsoft Hyper-V VMBus driver"
  	depends on HYPERV
  	default HYPERV
+	select SYSFB if EFI && !HYPERV_VTL_MODE
  	help
  	  Select this option to enable Hyper-V Vmbus driver.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

--
2.53.0

This fix is independent from the rest of the series. Do you want to merge it or can I take it into DRM trees?

Please feel free to take it via DRM tree.
CC : Wei Liu

- Saurabh

author maintainer
#5 lore raw

Re: [EXTERNAL] Re: [PATCH 1/8] hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

Am 13.04.26 um 10:22 schrieb Saurabh Singh Sengar:
[...]

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

This fix is independent from the rest of the series. Do you want to merge it or can I take it into DRM trees?

Please feel free to take it via DRM tree.

Done now. Thanks a lot.

Quoted 4 lines
CC Wei Liu

- Saurabh

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
author maintainer
#6 lore raw

PATCH 2/8 firmware: efi: Never declare sysfb_primary_display on x86

In reply to Thomas Zimmermann

The x86 architecture comes with its own instance of the global state variable sysfb_primary_display. Never declare it in the EFI subsystem. Fix the test for CONFIG_FIRMWARE_EDID accordingly.

Fixes e65ca1646311 ("efi: export sysfb_primary_display for EDID")
Cc kernel test robot <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Ilias Apalodimas <[email protected]>
---
 drivers/firmware/efi/efi-init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/efi-init.c +1 -1
index 5a595d026f58..6103b1a082d2 100644
@@ -60,7 +60,7 @@ extern __weak const efi_config_table_type_t efi_arch_tables[];
  * x86 defines its own instance of sysfb_primary_display and uses
  * it even without EFI, everything else can get them from here.
  */
-#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)) || defined(CONFIG_FIRMWARE_EDID)
+#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_FIRMWARE_EDID))
 struct sysfb_display_info sysfb_primary_display __section(".data");
 EXPORT_SYMBOL_GPL(sysfb_primary_display);
 #endif
Signature · 1 line
2.53.0
maintainer
#7 lore raw

Re: [PATCH 2/8] firmware: efi: Never declare sysfb_primary_display on x86

Hi Thomas,

Quoted 12 lines · Thomas Zimmermann

The x86 architecture comes with its own instance of the global state variable sysfb_primary_display. Never declare it in the EFI subsystem. Fix the test for CONFIG_FIRMWARE_EDID accordingly.

Fixes e65ca1646311 ("efi: export sysfb_primary_display for EDID")
Cc kernel test robot <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Quoted 4 lines
---
 drivers/firmware/efi/efi-init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Should this be sent out as a fix?

author maintainer
#8 lore raw

Re: [PATCH 2/8] firmware: efi: Never declare sysfb_primary_display on x86

Hi

Am 08.04.26 um 15:45 schrieb Ard Biesheuvel:

Quoted 19 lines

Hi Thomas,

Quoted 12 lines · Thomas Zimmermann

The x86 architecture comes with its own instance of the global state variable sysfb_primary_display. Never declare it in the EFI subsystem. Fix the test for CONFIG_FIRMWARE_EDID accordingly.

Fixes e65ca1646311 ("efi: export sysfb_primary_display for EDID")
Cc kernel test robot <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Quoted 4 lines
---
  drivers/firmware/efi/efi-init.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line

Should this be sent out as a fix?

Yes, please.

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
author maintainer
#9 lore raw

PATCH 3/8 firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

In reply to Thomas Zimmermann

Add a descriptive string and help text to CONFIG_SYSFB, so that users can modify it. Flip all implicit selects in the Kconfig options into dependencies. This avoids cyclic dependencies in the config.

Enabling CONFIG_SYSFB makes the kernel provide a device for the firmware framebuffer. As this can (slightly) affect system behavior, having a user-facing option seems preferable. Some users might also want to set every detail of their kernel config.

---
 drivers/firmware/Kconfig      | 18 ++++++++++++++++--
 drivers/gpu/drm/sysfb/Kconfig |  4 ++--
 drivers/hv/Kconfig            |  2 +-
 drivers/video/fbdev/Kconfig   |  5 +++--
 4 files changed, 22 insertions(+), 7 deletions(-)
drivers/firmware/Kconfig +16 -2
index bbd2155d8483..52f8253a46b1 100644
@@ -179,14 +179,28 @@ config MTK_ADSP_IPC
 	  Client might use shared memory to exchange information with ADSP.
 
 config SYSFB
-	bool
+	bool "Enable system framebuffer provided by boot loader"
 	select BOOT_VESA_SUPPORT
 	select SCREEN_INFO
+	help
+	  Use the system framebuffer provided by the boot loader. This will
+	  create a device representing the framebuffer. The output depends on
+	  EFI, VESA, VGA, or some other firmware-based interface.
+
+	  The firmware or boot loader sets the display resolution and color
+	  mode. See your boot loader's documentation on how to do this. On
+	  some systems the display can also be configured during boot with
+	  the kernel's video= or vga= parameters.
+
+	  Besides this option, you also have to enable a compatible graphics
+	  driver, such as efidrm or vesadrm.
+
+	  If unsure, say Y.
 
 config SYSFB_SIMPLEFB
 	bool "Mark VGA/VBE/EFI FB as generic system framebuffer"
+	depends on SYSFB
 	depends on X86 || EFI
-	select SYSFB
 	help
 	  Firmwares often provide initial graphics framebuffers so the BIOS,
 	  bootloader or kernel can show basic video-output during boot for
drivers/gpu/drm/sysfb/Kconfig +2 -2
index 2559ead6cf1f..74be3c8e6657 100644
@@ -26,12 +26,12 @@ config DRM_COREBOOTDRM
 config DRM_EFIDRM
 	tristate "EFI framebuffer driver"
 	depends on DRM && MMU && EFI && (!SYSFB_SIMPLEFB || COMPILE_TEST)
+	depends on SYSFB
 	select APERTURE_HELPERS
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
 	select DRM_SYSFB_HELPER
-	select SYSFB
 	help
 	  DRM driver for EFI framebuffers.
 
@@ -76,12 +76,12 @@ config DRM_SIMPLEDRM
 config DRM_VESADRM
 	tristate "VESA framebuffer driver"
 	depends on DRM && MMU && X86 && (!SYSFB_SIMPLEFB || COMPILE_TEST)
+	depends on SYSFB
 	select APERTURE_HELPERS
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
 	select DRM_SYSFB_HELPER
-	select SYSFB
 	help
 	  DRM driver for VESA framebuffers.
 
drivers/hv/Kconfig +1 -1
index 2d0b3fcb0ff8..af0ac6516159 100644
@@ -60,8 +60,8 @@ config HYPERV_BALLOON
 config HYPERV_VMBUS
 	tristate "Microsoft Hyper-V VMBus driver"
 	depends on HYPERV
+	depends on SYSFB if EFI && !HYPERV_VTL_MODE
 	default HYPERV
-	select SYSFB if EFI && !HYPERV_VTL_MODE
 	help
 	  Select this option to enable Hyper-V Vmbus driver.
 
drivers/video/fbdev/Kconfig +3 -2
index ac9ac4287c6a..6f55bec8c207 100644
@@ -333,6 +333,7 @@ config FB_IMSTT
 config FB_VGA16
 	tristate "VGA 16-color graphics support"
 	depends on FB && X86
+	depends on SYSFB
 	select APERTURE_HELPERS
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
@@ -424,9 +425,9 @@ config FB_UVESA
 config FB_VESA
 	bool "VESA VGA graphics support"
 	depends on (FB = y) && X86
+	depends on SYSFB
 	select APERTURE_HELPERS
 	select FB_IOMEM_HELPERS
-	select SYSFB
 	help
 	  This is the frame buffer device driver for generic VESA 2.0
 	  compliant graphic cards. The older VESA 1.2 cards are not supported.
@@ -436,10 +437,10 @@ config FB_VESA
 config FB_EFI
 	bool "EFI-based Framebuffer Support"
 	depends on (FB = y) && EFI
+	depends on SYSFB
 	select APERTURE_HELPERS
 	select DRM_PANEL_ORIENTATION_QUIRKS
 	select FB_IOMEM_HELPERS
-	select SYSFB
 	help
 	  This is the EFI frame buffer device driver. If the firmware on
 	  your platform is EFI 1.10 or UEFI 2.0, select Y to add support for
Signature · 1 line
2.53.0
#10 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Quoted 10 lines · Thomas Zimmermann

Add a descriptive string and help text to CONFIG_SYSFB, so that users can modify it. Flip all implicit selects in the Kconfig options into dependencies. This avoids cyclic dependencies in the config.

Enabling CONFIG_SYSFB makes the kernel provide a device for the firmware framebuffer. As this can (slightly) affect system behavior, having a user-facing option seems preferable. Some users might also want to set every detail of their kernel config.

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86 (and EFI) specific implementation detail, with the hope of eventually seperating out the x86 bits from the EFI ones.

In general, I am always in favor of properly using Kconfig dependencies over 'select' statements, for the same reasons you describe, but I don't want the the x86 logic for the legacy VESA and VGA console handling to leak into more architectures than necessary.

Do you think we could instead move the sysfb_init() function into the same two places that contain the sysfb_primary_display definition (arch/x86/kernel/setup.c, drivers/firmware/efi/efi-init.c) and simplify the efi version to take out the x86 bits? That would reduce the rest of sysfb-primary.c to the logic to unregister the device, and that could then be selected by both x86 and EFI.

Arnd

author maintainer
#11 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Hi

Am 02.04.26 um 15:08 schrieb Arnd Bergmann:

Quoted 10 lines · Thomas Zimmermann
Quoted 9 lines

Add a descriptive string and help text to CONFIG_SYSFB, so that users can modify it. Flip all implicit selects in the Kconfig options into dependencies. This avoids cyclic dependencies in the config.

Enabling CONFIG_SYSFB makes the kernel provide a device for the firmware framebuffer. As this can (slightly) affect system behavior, having a user-facing option seems preferable. Some users might also want to set every detail of their kernel config.

Quoted 5 lines
Quoted 1 line

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86 (and EFI) specific implementation detail, with the hope of eventually seperating out the x86 bits from the EFI ones.

You mean, you want to use the EFI-provided framebuffers without the intermediate step of going through sysfb_primary_display?

In that case, CONFIG_SYSFB would become an x86-internal thing, right?

Quoted 7 lines

In general, I am always in favor of properly using Kconfig dependencies over 'select' statements, for the same reasons you describe, but I don't want the the x86 logic for the legacy VESA and VGA console handling to leak into more architectures than necessary.

Quoted 7 lines

Do you think we could instead move the sysfb_init() function into the same two places that contain the sysfb_primary_display definition (arch/x86/kernel/setup.c, drivers/firmware/efi/efi-init.c) and simplify the efi version to take out the x86 bits? That would reduce the rest of sysfb-primary.c to the logic to unregister the device, and that could then be selected by both x86 and EFI.

No, I'm more than happy that sysfb finally consolidates all the init-framebuffer setup and detection that floated around in the kernel. I would not want it to be duplicated again.

For now, we could certainly keep CONFIG_SYSFB hidden and autoselected. Although I think this will require soem sort of solution at a later point.

Best regards
Thomas

Quoted 2 lines

Arnd

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#12 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Quoted 11 lines · Thomas Zimmermann

Am 02.04.26 um 15:08 schrieb Arnd Bergmann:

Quoted 5 lines · Thomas Zimmermann

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86 (and EFI) specific implementation detail, with the hope of eventually seperating out the x86 bits from the EFI ones.

You mean, you want to use the EFI-provided framebuffers without the intermediate step of going through sysfb_primary_display?

In that case, CONFIG_SYSFB would become an x86-internal thing, right?

The part that is still needed from sysfb is the arbitration between DRM_EFI and the PCI device driver for the same hardware, so I think some part of sysfb is clearly needed, in particular the sysfb_disable() function that removes the EFI framebuffer when there is a conflicting simpledrm or hardware specific driver.

The parts that I want to keep out of that is anything related to the x86 boot protocol, non-EFI framebuffers, text console, and kexec handoff, which we don't need on non-x86 UEFI systems.

I don't mind the idea of having a sysfb_primary_display in the EFI code if that helps keep EFI sane on x86, but it would be good to make that local to drivers/firmware/efi and (eventually) detached from include/uapi/linux/screen_info.h.

Quoted 14 lines
Quoted 6 lines

In general, I am always in favor of properly using Kconfig dependencies over 'select' statements, for the same reasons you describe, but I don't want the the x86 logic for the legacy VESA and VGA console handling to leak into more architectures than necessary.

Quoted 7 lines

Do you think we could instead move the sysfb_init() function into the same two places that contain the sysfb_primary_display definition (arch/x86/kernel/setup.c, drivers/firmware/efi/efi-init.c) and simplify the efi version to take out the x86 bits? That would reduce the rest of sysfb-primary.c to the logic to unregister the device, and that could then be selected by both x86 and EFI.

Quoted 6 lines

No, I'm more than happy that sysfb finally consolidates all the init-framebuffer setup and detection that floated around in the kernel. I would not want it to be duplicated again.

For now, we could certainly keep CONFIG_SYSFB hidden and autoselected. Although I think this will require soem sort of solution at a later point.

Can you clarify which problem you are trying to solve with that?

Arnd

author maintainer
#13 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Hi

Am 02.04.26 um 16:59 schrieb Arnd Bergmann:

Quoted 10 lines · Thomas Zimmermann
Quoted 9 lines

Am 02.04.26 um 15:08 schrieb Arnd Bergmann:

Quoted 5 lines · Thomas Zimmermann

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86 (and EFI) specific implementation detail, with the hope of eventually seperating out the x86 bits from the EFI ones.

You mean, you want to use the EFI-provided framebuffers without the intermediate step of going through sysfb_primary_display?

Quoted 7 lines
Quoted 1 line

In that case, CONFIG_SYSFB would become an x86-internal thing, right?

The part that is still needed from sysfb is the arbitration between DRM_EFI and the PCI device driver for the same hardware, so I think some part of sysfb is clearly needed, in particular the sysfb_disable() function that removes the EFI framebuffer when there is a conflicting simpledrm or hardware specific driver.

We do most of that in the aperture-helper module. (see <linux/aperture.h>). Calling sysfb_disable() from there is a workaround for some corner cases. We can have an EFI-specific function that does the same.

BTW, simpledrm-on-EFI/VESA is considered obsolete and should preferably be removed from that driver. Simpledrm should become a driver for Devicetree nodes of type simple-framebuffer (as it originally has been intended).

Quoted 11 lines

The parts that I want to keep out of that is anything related to the x86 boot protocol, non-EFI framebuffers, text console, and kexec handoff, which we don't need on non-x86 UEFI systems.

I don't mind the idea of having a sysfb_primary_display in the EFI code if that helps keep EFI sane on x86, but it would be good to make that local to drivers/firmware/efi and (eventually) detached from include/uapi/linux/screen_info.h.

Efidrm retrieves the framebuffer settings from the contained struct screen_info. Disconnecting from screen_info would require separate graphics drivers for x86 and non-x86. If we split off EFI from sysfb, we'd likely need a sysfbdrm driver of some sort. Just saying.

I think we'd also have to duplicate the framebuffer-relocation code that currently works on anything using struct screen_info (see patch 5).

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

In general, I am always in favor of properly using Kconfig dependencies over 'select' statements, for the same reasons you describe, but I don't want the the x86 logic for the legacy VESA and VGA console handling to leak into more architectures than necessary.

Do you think we could instead move the sysfb_init() function into the same two places that contain the sysfb_primary_display definition (arch/x86/kernel/setup.c, drivers/firmware/efi/efi-init.c) and simplify the efi version to take out the x86 bits? That would reduce the rest of sysfb-primary.c to the logic to unregister the device, and that could then be selected by both x86 and EFI.

Quoted 8 lines
Quoted 6 lines

No, I'm more than happy that sysfb finally consolidates all the init-framebuffer setup and detection that floated around in the kernel. I would not want it to be duplicated again.

For now, we could certainly keep CONFIG_SYSFB hidden and autoselected. Although I think this will require soem sort of solution at a later point.

Can you clarify which problem you are trying to solve with that?

One thing is that some users simply what control over their kernel build.

I also think that there might be systems that want to use sysfb_primary_display (plus the relocation feature), but not create the framebuffer device. Say for efi-earlycon. It needs user-control over the SYSFB option to do that.

As a side-effect, user-configurable SYSFB gives us a nice place to put SYSFB_SIMPLEFB and FIRMWARE_EDID; two options that currently float around in the config somewhat arbitrarily.

Best regards
Thomas

Quoted 2 lines

Arnd

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#14 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Quoted 19 lines · Thomas Zimmermann

Am 02.04.26 um 16:59 schrieb Arnd Bergmann:

Quoted 10 lines · Thomas Zimmermann
Quoted 9 lines

Am 02.04.26 um 15:08 schrieb Arnd Bergmann:

Quoted 5 lines · Thomas Zimmermann

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86 (and EFI) specific implementation detail, with the hope of eventually seperating out the x86 bits from the EFI ones.

You mean, you want to use the EFI-provided framebuffers without the intermediate step of going through sysfb_primary_display?

Quoted 7 lines
Quoted 1 line

In that case, CONFIG_SYSFB would become an x86-internal thing, right?

The part that is still needed from sysfb is the arbitration between DRM_EFI and the PCI device driver for the same hardware, so I think some part of sysfb is clearly needed, in particular the sysfb_disable() function that removes the EFI framebuffer when there is a conflicting simpledrm or hardware specific driver.

Quoted 4 lines

We do most of that in the aperture-helper module. (see <linux/aperture.h>). Calling sysfb_disable() from there is a workaround for some corner cases. We can have an EFI-specific function that does the same.

That sounds good, yes. The same change would need to go into of_platform_default_populate_init() then.

Quoted 4 lines

BTW, simpledrm-on-EFI/VESA is considered obsolete and should preferably be removed from that driver. Simpledrm should become a driver for Devicetree nodes of type simple-framebuffer (as it originally has been intended).

Sure, I was only thinking of the case where there are both sysfb (from Arm/riscv UEFI) and simpledrm (from devicetree) objects referring to the same one, not the simpledrm device created by sysfb_simplefb.

Quoted 11 lines
Quoted 10 lines

The parts that I want to keep out of that is anything related to the x86 boot protocol, non-EFI framebuffers, text console, and kexec handoff, which we don't need on non-x86 UEFI systems.

I don't mind the idea of having a sysfb_primary_display in the EFI code if that helps keep EFI sane on x86, but it would be good to make that local to drivers/firmware/efi and (eventually) detached from include/uapi/linux/screen_info.h.

Quoted 4 lines

Efidrm retrieves the framebuffer settings from the contained struct screen_info. Disconnecting from screen_info would require separate graphics drivers for x86 and non-x86. If we split off EFI from sysfb, we'd likely need a sysfbdrm driver of some sort. Just saying.

Yes, I saw that as well and don't have an immediate idea for how to best do it. I saw that you already abstracted the access to the screen_info members in drm_sysfb_screen_info.c, which I think is a step in that direction.

I also noticed that efidrm is mostly a subset of vesadrm, so in theory they could be merged back into an x86 drm driver along with the drm_sysfb_screen_info helpers, and have a non-x86 driver that constructs a drm_sysfb_device directly from the EFI structures.

Quoted 2 lines

I think we'd also have to duplicate the framebuffer-relocation code that currently works on anything using struct screen_info (see patch 5).

You mean the code from include/linux/screen_info.h? I think it would make sense to have an x86 specific version of that to operate on the x86 screen_info, and a simpler version that just updates the resource for the efirdrm driver, but that could also be done one level higher or lower.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

In general, I am always in favor of properly using Kconfig dependencies over 'select' statements, for the same reasons you describe, but I don't want the the x86 logic for the legacy VESA and VGA console handling to leak into more architectures than necessary.

Do you think we could instead move the sysfb_init() function into the same two places that contain the sysfb_primary_display definition (arch/x86/kernel/setup.c, drivers/firmware/efi/efi-init.c) and simplify the efi version to take out the x86 bits? That would reduce the rest of sysfb-primary.c to the logic to unregister the device, and that could then be selected by both x86 and EFI.

Quoted 8 lines
Quoted 6 lines

No, I'm more than happy that sysfb finally consolidates all the init-framebuffer setup and detection that floated around in the kernel. I would not want it to be duplicated again.

For now, we could certainly keep CONFIG_SYSFB hidden and autoselected. Although I think this will require soem sort of solution at a later point.

Can you clarify which problem you are trying to solve with that?

Quoted 6 lines

One thing is that some users simply what control over their kernel build.

I also think that there might be systems that want to use sysfb_primary_display (plus the relocation feature), but not create the framebuffer device. Say for efi-earlycon. It needs user-control over the SYSFB option to do that.

I'm still not following, sorry. efi-earlycon doesn't require CONFIG_SYSFB today, and I don't see why that would need to change, or why it couldn't just 'select SYSFB' if it it does change.

Quoted 3 lines

As a side-effect, user-configurable SYSFB gives us a nice place to put SYSFB_SIMPLEFB and FIRMWARE_EDID; two options that currently float around in the config somewhat arbitrarily.

You said that SYSFB_SIMPLEFB should get phased out in the future, right?

I'm also missing your plan for CONFIG_FIRMWARE_EDID. I only see three legacy drivers using the old fb_firmware_edid() interface, so I assume this is not what you are interested in.

For the global copy that is filled by x86 and efi, and consumed by vesadrm and efidrm, does that even need to be a configuration option rather than get always enabled?

Arnd

author maintainer
#15 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Hi

Am 02.04.26 um 18:47 schrieb Arnd Bergmann:

Quoted 19 lines · Thomas Zimmermann
Quoted 18 lines

Am 02.04.26 um 16:59 schrieb Arnd Bergmann:

Quoted 17 lines · Thomas Zimmermann
Quoted 10 lines

Am 02.04.26 um 15:08 schrieb Arnd Bergmann:

Quoted 5 lines · Thomas Zimmermann

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86 (and EFI) specific implementation detail, with the hope of eventually seperating out the x86 bits from the EFI ones.

You mean, you want to use the EFI-provided framebuffers without the intermediate step of going through sysfb_primary_display?

In that case, CONFIG_SYSFB would become an x86-internal thing, right?

The part that is still needed from sysfb is the arbitration between DRM_EFI and the PCI device driver for the same hardware, so I think some part of sysfb is clearly needed, in particular the sysfb_disable() function that removes the EFI framebuffer when there is a conflicting simpledrm or hardware specific driver.

Quoted 6 lines
Quoted 4 lines

We do most of that in the aperture-helper module. (see <linux/aperture.h>). Calling sysfb_disable() from there is a workaround for some corner cases. We can have an EFI-specific function that does the same.

That sounds good, yes. The same change would need to go into of_platform_default_populate_init() then.

The call to sysfb_disable() is a workaround for certain cases that aperture helpers don't handle well. In the longer term, I'd want aperture helpers to be more clever about aperture ownership. But as an intermediate step, adding other _disable() function would be an option. But there's no hurry.

Quoted 29 lines
Quoted 5 lines

BTW, simpledrm-on-EFI/VESA is considered obsolete and should preferably be removed from that driver. Simpledrm should become a driver for Devicetree nodes of type simple-framebuffer (as it originally has been intended).

Sure, I was only thinking of the case where there are both sysfb (from Arm/riscv UEFI) and simpledrm (from devicetree) objects referring to the same one, not the simpledrm device created by sysfb_simplefb.

Quoted 10 lines
Quoted 10 lines

The parts that I want to keep out of that is anything related to the x86 boot protocol, non-EFI framebuffers, text console, and kexec handoff, which we don't need on non-x86 UEFI systems.

I don't mind the idea of having a sysfb_primary_display in the EFI code if that helps keep EFI sane on x86, but it would be good to make that local to drivers/firmware/efi and (eventually) detached from include/uapi/linux/screen_info.h.

Quoted 4 lines

Efidrm retrieves the framebuffer settings from the contained struct screen_info. Disconnecting from screen_info would require separate graphics drivers for x86 and non-x86. If we split off EFI from sysfb, we'd likely need a sysfbdrm driver of some sort. Just saying.

Yes, I saw that as well and don't have an immediate idea for how to best do it. I saw that you already abstracted the access to the screen_info members in drm_sysfb_screen_info.c, which I think is a step in that direction.

Quoted 5 lines

I also noticed that efidrm is mostly a subset of vesadrm, so in theory they could be merged back into an x86 drm driver along with the drm_sysfb_screen_info helpers, and have a non-x86 driver that constructs a drm_sysfb_device directly from the EFI structures.

I would not want to have a unifed driver for all-things-screen_info. The code that can easily be shared is already in the sysfb helpers. But I don't mind adding a separate driver for EFI's Graphics Output Protocol. Then there would be current efidrm for EFI-from-screen_info and efigopdrm for EFI via the GOP interfaces. If EFI ever specifies another graphics interface, we could add another driver. The maintenance overhead is small on the DRM side.

What is the future of x86's boot_param and the related screen_info on x86-64?  Is it obsolete?  Will boot loaders run the EFI stub instead?

Quoted 8 lines
Quoted 3 lines

I think we'd also have to duplicate the framebuffer-relocation code that currently works on anything using struct screen_info (see patch 5).

You mean the code from include/linux/screen_info.h? I think it would make sense to have an x86 specific version of that to operate on the x86 screen_info, and a simpler version that just updates the resource for the efirdrm driver, but that could also be done one level higher or lower.

Makes me wonder if the relocation code could be integrated into the aperture helpers. It would have to track the relocation of all PCI graphics devices and probing DRM drivers would query the relocation offset for their given framebuffer.

Quoted 32 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines

In general, I am always in favor of properly using Kconfig dependencies over 'select' statements, for the same reasons you describe, but I don't want the the x86 logic for the legacy VESA and VGA console handling to leak into more architectures than necessary.

Quoted 7 lines

Do you think we could instead move the sysfb_init() function into the same two places that contain the sysfb_primary_display definition (arch/x86/kernel/setup.c, drivers/firmware/efi/efi-init.c) and simplify the efi version to take out the x86 bits? That would reduce the rest of sysfb-primary.c to the logic to unregister the device, and that could then be selected by both x86 and EFI.

No, I'm more than happy that sysfb finally consolidates all the init-framebuffer setup and detection that floated around in the kernel. I would not want it to be duplicated again.

For now, we could certainly keep CONFIG_SYSFB hidden and autoselected. Although I think this will require soem sort of solution at a later point.

Quoted 8 lines
Quoted 2 lines

Can you clarify which problem you are trying to solve with that?

One thing is that some users simply what control over their kernel build.

I also think that there might be systems that want to use sysfb_primary_display (plus the relocation feature), but not create the framebuffer device. Say for efi-earlycon. It needs user-control over the SYSFB option to do that.

I'm still not following, sorry. efi-earlycon doesn't require CONFIG_SYSFB today, and I don't see why that would need to change, or why it couldn't just 'select SYSFB' if it it does change.

Quoted 5 lines
Quoted 3 lines

As a side-effect, user-configurable SYSFB gives us a nice place to put SYSFB_SIMPLEFB and FIRMWARE_EDID; two options that currently float around in the config somewhat arbitrarily.

You said that SYSFB_SIMPLEFB should get phased out in the future, right?

Yes. Better sooner than later.

Quoted 8 lines

I'm also missing your plan for CONFIG_FIRMWARE_EDID. I only see three legacy drivers using the old fb_firmware_edid() interface, so I assume this is not what you are interested in.

For the global copy that is filled by x86 and efi, and consumed by vesadrm and efidrm, does that even need to be a configuration option rather than get always enabled?

There is code in x86's old 16-bit boot/init code that reads the EDID via VESA. The help text on CONFIG_FIRMWARE_EDID sounds like it needs to be configurable because some systems can't do the VESA calls. Hence, the logical step seems to be to make this consistent for all systems by adopting the option for all EDID retrieval.

If we can remove CONFIG_FIRMWARE_EDID and make EDID support unconditional, I'm all for it.

Best regards
Thomas

Quoted 2 lines

Arnd

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#16 lore raw

Re: [PATCH 3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option

Thomas Zimmermann <[email protected]> writes:

Hello,

[...]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Thomas Zimmermann

I don't really like this part of the series and would prefer to keep CONFIG_SYSFB hidden as much as possible as an x86

I tend to agree with Arnd here, I'm also not seeing that much value on making this symbol user selectable. For now I would just keep it hidden.

[...]

Quoted 11 lines
Quoted 10 lines

Yes, I saw that as well and don't have an immediate idea for how to best do it. I saw that you already abstracted the access to the screen_info members in drm_sysfb_screen_info.c, which I think is a step in that direction.

I also noticed that efidrm is mostly a subset of vesadrm, so in theory they could be merged back into an x86 drm driver along with the drm_sysfb_screen_info helpers, and have a non-x86 driver that constructs a drm_sysfb_device directly from the EFI structures.

Quoted 3 lines

I would not want to have a unifed driver for all-things-screen_info. The code that can easily be shared is already in the sysfb helpers. But I don't mind adding a separate driver for EFI's Graphics Output Protocol.

I agree. It is much more maintainable if we have dedicated DRM drivers that use shared helpers, than attempting to have a driver for different platforms.

As Thomas explained, the maintance effort is small on the DRM side and he has done a lot of work to split simpledrm in efidrm, vesadrm and ofdrm.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#17 lore raw

PATCH 4/8 firmware: sysfb: Split sysfb.c into sysfb_primary.c and sysfb_pci.c

In reply to Thomas Zimmermann

Move the init code for the primary graphics device and the PCI-helpers into separate source files. Only build the PCI helpers if CONFIG_PCI is set. Prepares sysfb for additional PCI helpers.

---
 drivers/firmware/Makefile                     |  7 ++++--
 drivers/firmware/sysfb.h                      | 19 ++++++++++++++
 drivers/firmware/sysfb_pci.c                  | 21 ++++++++++++++++
 drivers/firmware/{sysfb.c => sysfb_primary.c} | 25 ++-----------------
 4 files changed, 47 insertions(+), 25 deletions(-)
 create mode 100644 drivers/firmware/sysfb.h
 create mode 100644 drivers/firmware/sysfb_pci.c
 rename drivers/firmware/{sysfb.c => sysfb_primary.c} (92%)
drivers/firmware/Makefile +5 -2
index 4ddec2820c96..5b0592c078df 100644
@@ -16,13 +16,16 @@ obj-$(CONFIG_FIRMWARE_MEMMAP)	+= memmap.o
 obj-$(CONFIG_MTK_ADSP_IPC)	+= mtk-adsp-ipc.o
 obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o
 obj-$(CONFIG_FW_CFG_SYSFS)	+= qemu_fw_cfg.o
-obj-$(CONFIG_SYSFB)		+= sysfb.o
-obj-$(CONFIG_SYSFB_SIMPLEFB)	+= sysfb_simplefb.o
 obj-$(CONFIG_TH1520_AON_PROTOCOL) += thead,th1520-aon.o
 obj-$(CONFIG_TI_SCI_PROTOCOL)	+= ti_sci.o
 obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o
 obj-$(CONFIG_TURRIS_MOX_RWTM)	+= turris-mox-rwtm.o
 
+sysfb-y				:= sysfb_primary.o
+sysfb-$(CONFIG_PCI)		+= sysfb_pci.o
+sysfb-$(CONFIG_SYSFB_SIMPLEFB)	+= sysfb_simplefb.o
+obj-$(CONFIG_SYSFB)		+= sysfb.o
+
 obj-y				+= arm_ffa/
 obj-y				+= arm_scmi/
 obj-y				+= broadcom/
drivers/firmware/sysfb.h new file +19 -0
new file mode 100644
index 000000000000..9f7fe2e03f68
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef FIRMWARE_SYSFB_H
+#define FIRMWARE_SYSFB_H
+
+#include <linux/types.h>
+
+struct pci_dev;
+
+#ifdef CONFIG_PCI
+bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev);
+#else
+static inline bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
+{
+	return false;
+}
+#endif
+
+#endif
drivers/firmware/sysfb_pci.c new file +21 -0
new file mode 100644
index 000000000000..8f3adeef4fb1
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/pci.h>
+
+#include "sysfb.h"
+
+bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
+{
+	/*
+	 * TODO: Try to integrate this code into the PCI subsystem
+	 */
+	int ret;
+	u16 command;
+
+	ret = pci_read_config_word(pdev, PCI_COMMAND, &command);
+	if (ret != PCIBIOS_SUCCESSFUL)
+		return false;
+	if (!(command & PCI_COMMAND_MEMORY))
+		return false;
+	return true;
+}
drivers/firmware/sysfb_primary.c renamed from drivers/firmware/sysfb.c +2 -23
similarity index 92%
rename from drivers/firmware/sysfb.c
rename to drivers/firmware/sysfb_primary.c
index 8833582c1883..ab8d7fc468bb 100644
@@ -35,6 +35,8 @@
 #include <linux/screen_info.h>
 #include <linux/sysfb.h>
 
+#include "sysfb.h"
+
 static struct platform_device *pd;
 static DEFINE_MUTEX(disable_lock);
 static bool disabled;
@@ -98,29 +100,6 @@ bool sysfb_handles_screen_info(void)
 }
 EXPORT_SYMBOL_GPL(sysfb_handles_screen_info);
 
-#if defined(CONFIG_PCI)
-static bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
-{
-	/*
-	 * TODO: Try to integrate this code into the PCI subsystem
-	 */
-	int ret;
-	u16 command;
-
-	ret = pci_read_config_word(pdev, PCI_COMMAND, &command);
-	if (ret != PCIBIOS_SUCCESSFUL)
-		return false;
-	if (!(command & PCI_COMMAND_MEMORY))
-		return false;
-	return true;
-}
-#else
-static bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
-{
-	return false;
-}
-#endif
-
 static struct device *sysfb_parent_dev(const struct screen_info *si)
 {
 	struct pci_dev *pdev;
Signature · 1 line
2.53.0
author maintainer
#18 lore raw

PATCH 5/8 firmware: sysfb: Implement screen_info relocation for primary display

In reply to Thomas Zimmermann

Move the relocation tracking for screen_info from the screen_info helpers to sysfb. The relocation code operates on sysfb_primary_display, which belongs to sysfb. The remaining screen_info helpers are now free from global state.

Adapt some symbol names. Now prefer early returns in the helper sysfb_apply_screen_info_fixup() over nested branching. Also return an errno code from sysfb_apply_screen_info_fixup() if the relocation failed. In this case, do not create a device for the framebuffer. The original code advertised this behavior in a comment but never implemented it.

Framebuffer aperture relocation can happen during boot if the PCI graphics device is located behind a PCI bridge. If the bridge's sub- bus gets relocated, the framebuffer aperture moves accordingly. The helper for tracking these relocations fixes up the values stored in sysfb_primary_display so that they refer to the correct address range again. Generic system-framebuffer drivers would not work otherwise.

---
 drivers/firmware/sysfb.h         |   5 ++
 drivers/firmware/sysfb_pci.c     | 111 +++++++++++++++++++++++++++++++
 drivers/firmware/sysfb_primary.c |   9 ++-
 drivers/video/screen_info_pci.c  | 110 ------------------------------
 include/linux/screen_info.h      |   3 -
 5 files changed, 123 insertions(+), 115 deletions(-)
drivers/firmware/sysfb.h +5 -0
index 9f7fe2e03f68..1eaa3b0fa364 100644
@@ -8,8 +8,13 @@
 struct pci_dev;
 
 #ifdef CONFIG_PCI
+int sysfb_apply_screen_info_fixups(void);
 bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev);
 #else
+static inline int sysfb_apply_screen_info_fixups(void)
+{
+	return 0;
+}
 static inline bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
 {
 	return false;
drivers/firmware/sysfb_pci.c +111 -0

120 lines not on this page · raw message

drivers/firmware/sysfb_primary.c +7 -2
index ab8d7fc468bb..298f87a43a7e 100644
@@ -32,6 +32,7 @@
 #include <linux/pci.h>
 #include <linux/platform_data/simplefb.h>
 #include <linux/platform_device.h>
+#include <linux/printk.h>
 #include <linux/screen_info.h>
 #include <linux/sysfb.h>
 
@@ -127,11 +128,15 @@ static __init int sysfb_init(void)
 	struct simplefb_platform_data mode;
 	const char *name;
 	bool compatible;
-	int ret = 0;
+	int ret;
 
-	screen_info_apply_fixups();
+	ret = sysfb_apply_screen_info_fixups();
 
 	mutex_lock(&disable_lock);
+	if (ret) {
+		pr_warn("Invalid relocation, disabling system framebuffer\n");
+		disabled = true; /* screen_info relocation failed */
+	}
 	if (disabled)
 		goto unlock_mutex;
 
drivers/video/screen_info_pci.c +0 -110

117 lines not on this page · raw message

include/linux/screen_info.h +0 -3
index c022403c599a..2adbe25b88d8 100644
@@ -140,11 +140,8 @@ u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si);
 int screen_info_pixel_format(const struct screen_info *si, struct pixel_format *f);
 
 #if defined(CONFIG_PCI)
-void screen_info_apply_fixups(void);
 struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
 #else
-static inline void screen_info_apply_fixups(void)
-{ }
 static inline struct pci_dev *screen_info_pci_dev(const struct screen_info *si)
 {
 	return NULL;
Signature · 1 line
2.53.0
author maintainer
#19 lore raw

PATCH 6/8 firmware: sysfb: Avoid forward-declaring sysfb_parent_dev()

In reply to Thomas Zimmermann

Move sysfb_parent_dev() to the top of the source file to avoid the extra declaration. No functional changes.

---
 drivers/firmware/sysfb_primary.c | 36 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 19 deletions(-)
drivers/firmware/sysfb_primary.c +17 -19
index 298f87a43a7e..a7f8cede60ad 100644
@@ -42,7 +42,23 @@ static struct platform_device *pd;
 static DEFINE_MUTEX(disable_lock);
 static bool disabled;
 
-static struct device *sysfb_parent_dev(const struct screen_info *si);
+static struct device *sysfb_parent_dev(const struct screen_info *si)
+{
+	struct pci_dev *pdev;
+
+	pdev = screen_info_pci_dev(si);
+	if (IS_ERR(pdev)) {
+		return ERR_CAST(pdev);
+	} else if (pdev) {
+		if (!sysfb_pci_dev_is_enabled(pdev)) {
+			pci_dev_put(pdev);
+			return ERR_PTR(-ENODEV);
+		}
+		return &pdev->dev;
+	}
+
+	return NULL;
+}
 
 static bool sysfb_unregister(void)
 {
@@ -101,24 +117,6 @@ bool sysfb_handles_screen_info(void)
 }
 EXPORT_SYMBOL_GPL(sysfb_handles_screen_info);
 
-static struct device *sysfb_parent_dev(const struct screen_info *si)
-{
-	struct pci_dev *pdev;
-
-	pdev = screen_info_pci_dev(si);
-	if (IS_ERR(pdev)) {
-		return ERR_CAST(pdev);
-	} else if (pdev) {
-		if (!sysfb_pci_dev_is_enabled(pdev)) {
-			pci_dev_put(pdev);
-			return ERR_PTR(-ENODEV);
-		}
-		return &pdev->dev;
-	}
-
-	return NULL;
-}
-
 static __init int sysfb_init(void)
 {
 	struct sysfb_display_info *dpy = &sysfb_primary_display;
Signature · 1 line
2.53.0
author maintainer
#20 lore raw

PATCH 7/8 firmware: efi: Make CONFIG_EFI_EARLYCON depend on CONFIG_SYSFB; clean up

In reply to Thomas Zimmermann

Efi-earlycon uses sysfb_primary_display. Therefore make it depend on the corresponding config symbol. With this in place, go through the source files and reduce tests to CONFIG_SYSFB. Efi-earlycon is now just another regular user of sysfb.

This also enables the screen_info relocation feature for efi-earlycon. Systems might move the framebuffer aperture while booting the kernel. PCI bridges sometimes do this as part of relocating the sub-bus aperture.

---
 arch/arm64/kernel/image-vars.h                | 2 +-
 arch/loongarch/kernel/efi.c                   | 4 ++--
 arch/loongarch/kernel/image-vars.h            | 2 +-
 arch/riscv/kernel/image-vars.h                | 2 +-
 drivers/firmware/efi/Kconfig                  | 3 ++-
 drivers/firmware/efi/efi-init.c               | 6 ++----
 drivers/firmware/efi/libstub/efi-stub-entry.c | 4 +---
 7 files changed, 10 insertions(+), 13 deletions(-)
arch/arm64/kernel/image-vars.h +1 -1
index d7b0d12b1015..7e0e61385286 100644
@@ -37,7 +37,7 @@ PROVIDE(__efistub__text			= _text);
 PROVIDE(__efistub__end			= _end);
 PROVIDE(__efistub___inittext_end       	= __inittext_end);
 PROVIDE(__efistub__edata		= _edata);
-#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
+#if defined(CONFIG_SYSFB)
 PROVIDE(__efistub_sysfb_primary_display	= sysfb_primary_display);
 #endif
 PROVIDE(__efistub__ctype		= _ctype);
arch/loongarch/kernel/efi.c +2 -2
index 69dd83f8082f..6c25e2ecf45f 100644
@@ -74,7 +74,7 @@ bool efi_poweroff_required(void)
 
 unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR;
 
-#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)
+#if defined(CONFIG_SYSFB)
 struct sysfb_display_info sysfb_primary_display __section(".data");
 EXPORT_SYMBOL_GPL(sysfb_primary_display);
 #endif
@@ -129,7 +129,7 @@ void __init efi_init(void)
 
 	set_bit(EFI_CONFIG_TABLES, &efi.flags);
 
-	if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB))
+	if (IS_ENABLED(CONFIG_SYSFB))
 		init_primary_display();
 
 	if (boot_memmap == EFI_INVALID_TABLE_ADDR)
arch/loongarch/kernel/image-vars.h +1 -1
index e557ebd46c2b..c43f9326f344 100644
@@ -11,7 +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)
+#if defined(CONFIG_SYSFB)
 __efistub_sysfb_primary_display	= sysfb_primary_display;
 #endif
 
arch/riscv/kernel/image-vars.h +1 -1
index 3bd9d06a8b8f..3ab2529c4154 100644
@@ -28,7 +28,7 @@ __efistub__start_kernel		= _start_kernel;
 __efistub__end			= _end;
 __efistub__edata		= _edata;
 __efistub___init_text_end	= __init_text_end;
-#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
+#if defined(CONFIG_SYSFB)
 __efistub_sysfb_primary_display	= sysfb_primary_display;
 #endif
 
drivers/firmware/efi/Kconfig +2 -1
index 29e0729299f5..925ded080eb4 100644
@@ -219,8 +219,9 @@ config EFI_DISABLE_PCI_DMA
 config EFI_EARLYCON
 	def_bool y
 	depends on SERIAL_EARLYCON && !ARM
-	select FONT_SUPPORT
+	depends on SYSFB
 	select ARCH_USE_MEMREMAP_PROT
+	select FONT_SUPPORT
 
 config EFI_CUSTOM_SSDT_OVERLAYS
 	bool "Load custom ACPI SSDT overlay from an EFI variable"
drivers/firmware/efi/efi-init.c +2 -4
index 6103b1a082d2..002518b642ed 100644
@@ -60,7 +60,7 @@ extern __weak const efi_config_table_type_t efi_arch_tables[];
  * x86 defines its own instance of sysfb_primary_display and uses
  * it even without EFI, everything else can get them from here.
  */
-#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_FIRMWARE_EDID))
+#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_FIRMWARE_EDID))
 struct sysfb_display_info sysfb_primary_display __section(".data");
 EXPORT_SYMBOL_GPL(sysfb_primary_display);
 #endif
@@ -271,8 +271,6 @@ void __init efi_init(void)
 	memblock_reserve(data.phys_map & PAGE_MASK,
 			 PAGE_ALIGN(data.size + (data.phys_map & ~PAGE_MASK)));
 
-	if (IS_ENABLED(CONFIG_X86) ||
-	    IS_ENABLED(CONFIG_SYSFB) ||
-	    IS_ENABLED(CONFIG_EFI_EARLYCON))
+	if (IS_ENABLED(CONFIG_X86) || IS_ENABLED(CONFIG_SYSFB))
 		init_primary_display();
 }
drivers/firmware/efi/libstub/efi-stub-entry.c +1 -3
index aa85e910fe59..214fa4d84df0 100644
@@ -19,9 +19,7 @@ struct sysfb_display_info *alloc_primary_display(void)
 	if (IS_ENABLED(CONFIG_ARM))
 		return __alloc_primary_display();
 
-	if (IS_ENABLED(CONFIG_X86) ||
-	    IS_ENABLED(CONFIG_EFI_EARLYCON) ||
-	    IS_ENABLED(CONFIG_SYSFB))
+	if (IS_ENABLED(CONFIG_X86) || IS_ENABLED(CONFIG_SYSFB))
 		return kernel_image_addr(&sysfb_primary_display);
 
 	return NULL;
Signature · 1 line
2.53.0
author maintainer
#21 lore raw

PATCH 8/8 firmware: sysfb: Move CONFIG_FIRMWARE_EDID to firmware options

In reply to Thomas Zimmermann

Move the Kconfig option for CONFIG_FIRMWARE_EDID to the firmware subsystem. The option controls architecture and firmware code, so it fits here better than in video.

Also make it depend on CONFIG_SYSFB. The EDID data is stored in sysfb_primary_display and only useful with a sysfb framebuffer. This further allows for removing an explicit test for CONFIG_FIRMWARE_EDID from the EFI init code. For loongson, select CONFIG_SYSFB in the defconfig files.

---
 arch/loongarch/configs/loongson32_defconfig |  1 +
 arch/loongarch/configs/loongson64_defconfig |  1 +
 drivers/firmware/Kconfig                    | 20 ++++++++++++++++++++
 drivers/firmware/efi/efi-init.c             |  2 +-
 drivers/video/Kconfig                       | 19 -------------------
 5 files changed, 23 insertions(+), 20 deletions(-)
arch/loongarch/configs/loongson32_defconfig +1 -0
index 276b1577e0be..1c0897723247 100644
@@ -786,6 +786,7 @@ CONFIG_DRM_VIRTIO_GPU=m
 CONFIG_DRM_LOONGSON=y
 CONFIG_FB=y
 CONFIG_FB_RADEON=y
+CONFIG_SYSFB=y
 CONFIG_FIRMWARE_EDID=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_PLATFORM=m
arch/loongarch/configs/loongson64_defconfig +1 -0
index a14db1a95e7e..38340537dfd4 100644
@@ -816,6 +816,7 @@ CONFIG_DRM_VIRTIO_GPU=m
 CONFIG_DRM_LOONGSON=y
 CONFIG_FB=y
 CONFIG_FB_RADEON=y
+CONFIG_SYSFB=y
 CONFIG_FIRMWARE_EDID=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_PLATFORM=m
drivers/firmware/Kconfig +20 -0
index 52f8253a46b1..edfb171d9eab 100644
@@ -225,6 +225,26 @@ config SYSFB_SIMPLEFB
 
 	  If unsure, say Y.
 
+config FIRMWARE_EDID
+	bool "Enable firmware EDID"
+	depends on SYSFB
+	depends on EFI_GENERIC_STUB || X86
+	help
+	  This enables access to the EDID transferred from the firmware.
+	  On EFI systems, the EDID comes from the same device as the
+	  primary GOP. On x86 with BIOS, it comes from the VESA BIOS.
+	  DRM display drivers will be able to export the information
+	  to userspace.
+
+	  Also enable this if DDC/I2C transfers do not work for your driver
+	  and if you are using nvidiafb, i810fb or savagefb.
+
+	  In general, choosing Y for this option is safe.  If you
+	  experience extremely long delays while booting before you get
+	  something on your display, try setting this to N.  Matrox cards in
+	  combination with certain motherboards and monitors are known to
+	  suffer from this problem.
+
 config TH1520_AON_PROTOCOL
 	tristate "Always-On firmware protocol"
 	depends on ARCH_THEAD || COMPILE_TEST
drivers/firmware/efi/efi-init.c +1 -1
index 002518b642ed..c4088fb8482b 100644
@@ -60,7 +60,7 @@ extern __weak const efi_config_table_type_t efi_arch_tables[];
  * x86 defines its own instance of sysfb_primary_display and uses
  * it even without EFI, everything else can get them from here.
  */
-#if !defined(CONFIG_X86) && (defined(CONFIG_SYSFB) || defined(CONFIG_FIRMWARE_EDID))
+#if !defined(CONFIG_X86) && defined(CONFIG_SYSFB)
 struct sysfb_display_info sysfb_primary_display __section(".data");
 EXPORT_SYMBOL_GPL(sysfb_primary_display);
 #endif
drivers/video/Kconfig +0 -19
index a7144d275f54..1c9ac3b029a7 100644
@@ -62,25 +62,6 @@ config HDMI
 
 endif # HAS_IOMEM
 
-config FIRMWARE_EDID
-	bool "Enable firmware EDID"
-	depends on EFI_GENERIC_STUB || X86
-	help
-	  This enables access to the EDID transferred from the firmware.
-	  On EFI systems, the EDID comes from the same device as the
-	  primary GOP. On x86 with BIOS, it comes from the VESA BIOS.
-	  DRM display drivers will be able to export the information
-	  to userspace.
-
-	  Also enable this if DDC/I2C transfers do not work for your driver
-	  and if you are using nvidiafb, i810fb or savagefb.
-
-	  In general, choosing Y for this option is safe.  If you
-	  experience extremely long delays while booting before you get
-	  something on your display, try setting this to N.  Matrox cards in
-	  combination with certain motherboards and monitors are known to
-	  suffer from this problem.
-
 if VT
 	source "drivers/video/console/Kconfig"
 endif
Signature · 1 line
2.53.0
#22 lore raw
In reply to Thomas Zimmermann
This series was applied to riscv/linux.git (fixes) by Ard Biesheuvel <[email protected]>:

Hello:

This series was applied to riscv/linux.git (fixes) by Ard Biesheuvel <[email protected]>:

Quoted 10 lines · On Thu, 2 Apr 2026 11:09:14 +0200 you wrote:

The global state sysfb_primary_screen holds information about the framebuffer provided by EFI/BIOS systems. It is part of the sysfb module, but used in several places without direct connection to sysfb. Fix this by making users of sysfb_primary_screen depend on CONFIG_SYSFB. Fix a few issues in the process.

Patches 1 and 2 fix general errors in the Kconfig rules. In any case, these patches should be considered even without the rest of the series.

[...]

Here is the summary with links:
- [1/8] hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

    https://git.kernel.org/riscv/c/d33db956c961
  - [2/8] firmware: efi: Never declare sysfb_primary_display on x86
    https://git.kernel.org/riscv/c/5241c2ca33bb

- [3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option (no matching commit)
- [4/8] firmware: sysfb: Split sysfb.c into sysfb_primary.c and sysfb_pci.c (no matching commit)
- [5/8] firmware: sysfb: Implement screen_info relocation for primary display (no matching commit)
- [6/8] firmware: sysfb: Avoid forward-declaring sysfb_parent_dev() (no matching commit)
- [7/8] firmware: efi: Make CONFIG_EFI_EARLYCON depend on CONFIG_SYSFB; clean up (no matching commit)
- [8/8] firmware: sysfb: Move CONFIG_FIRMWARE_EDID to firmware options (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#23 lore raw

Hi

Am 30.04.26 um 05:25 schrieb [email protected]:

Quoted 4 lines

Hello:

This series was applied to riscv/linux.git (fixes) by Ard Biesheuvel <[email protected]>:

Patch 3 was fairly controversial.

Best regards
Thomas

Quoted 31 lines · On Thu, 2 Apr 2026 11:09:14 +0200 you wrote:
Quoted 10 lines

The global state sysfb_primary_screen holds information about the framebuffer provided by EFI/BIOS systems. It is part of the sysfb module, but used in several places without direct connection to sysfb. Fix this by making users of sysfb_primary_screen depend on CONFIG_SYSFB. Fix a few issues in the process.

Patches 1 and 2 fix general errors in the Kconfig rules. In any case, these patches should be considered even without the rest of the series.

[...]

Here is the summary with links:
- [1/8] hv: Select CONFIG_SYSFB only for CONFIG_HYPERV_VMBUS

     https://git.kernel.org/riscv/c/d33db956c961
   - [2/8] firmware: efi: Never declare sysfb_primary_display on x86
     https://git.kernel.org/riscv/c/5241c2ca33bb

- [3/8] firmware: sysfb: Make CONFIG_SYSFB a user-selectable option (no matching commit)
- [4/8] firmware: sysfb: Split sysfb.c into sysfb_primary.c and sysfb_pci.c (no matching commit)
- [5/8] firmware: sysfb: Implement screen_info relocation for primary display (no matching commit)
- [6/8] firmware: sysfb: Avoid forward-declaring sysfb_parent_dev() (no matching commit)
- [7/8] firmware: efi: Make CONFIG_EFI_EARLYCON depend on CONFIG_SYSFB; clean up (no matching commit)
- [8/8] firmware: sysfb: Move CONFIG_FIRMWARE_EDID to firmware options (no matching commit)

You are awesome, thank you!

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)