Add generic framebuffer support to EFI earlycon driver
Subsystems (5)
v3 cover Add generic framebuffer support to EFI earlycon driver
Make the EFI earlycon driver be suitable for any linear framebuffers. This should be helpful for early porting of boards with no other means of output, like smartphones/tablets. There seems to be an issue with early_ioremap function on ARM32, but I am unable to find the exact cause. It appears the mappings returned by it are somehow incorrect, thus the driver is disabled on ARM. EFI early console was disabled on IA64 previously because of missing early_memremap_prot, and this is inherited to this driver.
This patch also changes behavior on EFI systems, by selecting the mapping type based on if the framebuffer region intersects with system RAM. If it does, it's common sense that it should be in RAM as a whole, and so the system RAM mapping is used. It was tested to be working on my PC (Intel Z490 platform), as well as several ARM64 boards (Samsung Galaxy S9 (Exynos), iPad Air 2, Xiaomi Mi Pad 4, ...).
Markuss Broks (2):
drivers: serial: earlycon: Pass device-tree node
efi: earlycon: Add support for generic framebuffers and move to fbdev
subsystem
v1 -> v2:
- a new patch correcting serial/earlycon.c argument name to "offset" instead of "node"
- move IA64 exclusion from EFI earlycon Kconfig to earlycon driver Kconfig (IA64 has no early_memremap_prot)
- move driver from fbdev to console subsystem
- select EFI earlycon by default
- fetch stride manually from device-tree, as on some devices it seems stride doesn't match the horizontal resolution * bpp.
- use saner format (e.g. 1920x1080x32 instead of 1920,1080,32).
Markuss Broks (3):
drivers: serial: earlycon: Pass device-tree node
efi: earlycon: move to video/console to prepare for changes
efi: earlycon: Add support for generic framebuffers
.../admin-guide/kernel-parameters.txt | 12 +- MAINTAINERS | 5 + drivers/firmware/efi/Kconfig | 7 +- drivers/firmware/efi/Makefile | 1 - drivers/firmware/efi/earlycon.c | 246 -------------- drivers/tty/serial/earlycon.c | 3 + drivers/video/console/Kconfig | 11 + drivers/video/console/Makefile | 1 + drivers/video/console/earlycon.c | 305 ++++++++++++++++++ include/linux/serial_core.h | 1 + 10 files changed, 336 insertions(+), 256 deletions(-) delete mode 100644 drivers/firmware/efi/earlycon.c create mode 100644 drivers/video/console/earlycon.c
Signature · 1 line
2.39.0
PATCH v3 1/3 drivers: serial: earlycon: Pass device-tree node
Pass a pointer to device-tree node in case the driver probed from OF. This makes early console drivers able to fetch options from device-tree node properties.
--- drivers/tty/serial/earlycon.c | 3 +++ include/linux/serial_core.h | 1 + 2 files changed, 4 insertions(+)
drivers/tty/serial/earlycon.c +3 -0
@@ -307,6 +307,9 @@ int __init of_setup_earlycon(const struct earlycon_id *match,strscpy (early_console_dev.options, options,sizeof (early_console_dev.options)); } + + early_console_dev.node = node; +earlycon_init (&early_console_dev, match->name); err = match->setup (&early_console_dev, options);earlycon_print_info (&early_console_dev);
include/linux/serial_core.h +1 -0
@@ -783,6 +783,7 @@ struct earlycon_device {struct uart_port port;char options[16 ];/* e.g., 115200n8 */ unsigned int baud; +unsigned long node; };struct earlycon_id {
Signature · 1 line
2.39.0
PATCH v3 2/3 efi: earlycon: move to video/console to prepare for changes
In reply to Markuss BroksThis would make the next patch in series with this one to show a clear diff, instead of just removing the previous driver and creating a new one.
---
drivers/{firmware/efi => video/console}/earlycon.c | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename drivers/{firmware/efi => video/console}/earlycon.c (100%)drivers/video/console/earlycon.c renamed from drivers/firmware/efi/earlycon.c +0 -0
Signature · 1 line
2.39.0
PATCH v3 3/3 efi: earlycon: Add support for generic framebuffers
In reply to Markuss BroksAdd early console support for generic linear framebuffer devices. This driver supports probing from cmdline early parameters
or from the device-tree using information in simple-framebuffer node. The EFI functionality should be retained in whole.
The driver was disabled on ARM because of a bug in early_ioremap implementation on ARM and on IA64 because of lack of early_memremap_prot.
--- .../admin-guide/kernel-parameters.txt | 12 +- MAINTAINERS | 5 + drivers/firmware/efi/Kconfig | 7 +- drivers/firmware/efi/Makefile | 1 - drivers/video/console/Kconfig | 11 + drivers/video/console/Makefile | 1 + drivers/video/console/earlycon.c | 247 +++++++++++------- 7 files changed, 180 insertions(+), 104 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +7 -5
@@ -1302,12 +1302,9 @@ specified address. The serial port must already be setup and configured. Options are not yet supported. - efifb,[options] + efifb Start an early, unaccelerated console on the EFI - memory mapped framebuffer (if available). On cache - coherent non-x86 systems that use system memory for - the framebuffer, pass the 'ram' option so that it is - mapped with the correct attributes. + memory mapped framebuffer (if available). linflex,<addr> Use early console provided by Freescale LINFlexD UART
@@ -1315,6 +1312,11 @@ address must be provided, and the serial port must already be setup and configured. + simplefb,<addr>,<width>x<height>x<bpp> + Use early console with simple framebuffer that is + pre-initialized by firmware. A valid base address, + width, height and pixel size must be provided. + earlyprintk= [X86,SH,ARM,M68k,S390] earlyprintk=vga earlyprintk=sclp
MAINTAINERS +5 -0
@@ -7373,6 +7373,11 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/ T: git git://linuxtv.org/anttip/media_tree.git F: drivers/media/tuners/e4000* +EARLY CONSOLE FRAMEBUFFER DRIVER +M: Markuss Broks <[email protected]> +S: Maintained +F: drivers/video/console/earlycon.c + EARTH_PT1 MEDIA DRIVER M: Akihiro Tsukada <[email protected]> L: [email protected]
drivers/firmware/efi/Kconfig +3 -4
@@ -223,10 +223,9 @@ config EFI_DISABLE_PCI_DMA may be used to override this option. config EFI_EARLYCON - def_bool y - depends on SERIAL_EARLYCON && !ARM && !IA64 - select FONT_SUPPORT - select ARCH_USE_MEMREMAP_PROT + bool "EFI early console support" + select FB_EARLYCON + default y config EFI_CUSTOM_SSDT_OVERLAYS bool "Load custom ACPI SSDT overlay from an EFI variable"
drivers/firmware/efi/Makefile +0 -1
@@ -38,6 +38,5 @@ obj-$(CONFIG_ARM64) += $(arm-obj-y) riscv-obj-$(CONFIG_EFI) := efi-init.o riscv-runtime.o obj-$(CONFIG_RISCV) += $(riscv-obj-y) obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o -obj-$(CONFIG_EFI_EARLYCON) += earlycon.o obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o
drivers/video/console/Kconfig +11 -0
@@ -70,6 +70,17 @@ config DUMMY_CONSOLE_ROWS monitor. Select 25 if you use a 640x480 resolution by default. +config FB_EARLYCON + bool "Generic framebuffer early console" + depends on SERIAL_EARLYCON && !ARM && !IA64 + select FONT_SUPPORT + select ARCH_USE_MEMREMAP_PROT + help + Say Y here if you want early console support for firmware established + linear framebuffer. Unless you are using EFI framebuffer, you need to + specify framebuffer geometry and address in device-tree or in kernel + command line. + config FRAMEBUFFER_CONSOLE bool "Framebuffer Console support" depends on FB && !UML
drivers/video/console/Makefile +1 -0
@@ -9,4 +9,5 @@ obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o obj-$(CONFIG_VGA_CONSOLE) += vgacon.o obj-$(CONFIG_MDA_CONSOLE) += mdacon.o +obj-$(CONFIG_FB_EARLYCON) += earlycon.o obj-$(CONFIG_FB_STI) += sticore.o
drivers/video/console/earlycon.c +153 -94
389 lines not on this page · raw message
Signature · 1 line
2.39.0
Ard Biesheuvel
maintainer(cc Andy)
Quoted 6 lines · Markuss Broks
Make the EFI earlycon driver be suitable for any linear framebuffers. This should be helpful for early porting of boards with no other means of output, like smartphones/tablets. There seems to be an issue with
early_ioremapfunction on ARM32, but I am unable to find the exact cause. It appears the mappings returned by it are somehow incorrect, thus the driver is disabled on ARM.
The reason that this driver is disabled on ARM is because the struct screen_info is not populated early enough, as it is retrieved from a UEFI configuration table.
early_ioremap() works fine on ARM as long as they mapping is torn down before paging_init()
Quoted 5 lines
EFI early
console was disabled on IA64 previously because of missingearly_memremap_prot, and this is inherited to this driver.This patch also changes
"This patch also changes ..." is usually a strong hint to self that the patches need to be split up.
Quoted 47 lines
behavior on EFI systems, by selecting the mapping type
based on if the framebuffer region intersects with system RAM. If it does, it's common sense that it should be in RAM as a whole, and so the system RAM mapping is used. It was tested to be working on my PC (Intel Z490 platform), as well as several ARM64 boards (Samsung Galaxy S9 (Exynos), iPad Air 2, Xiaomi Mi Pad 4, ...).Markuss Broks (2):
drivers: serial: earlycon: Pass device-tree node
efi: earlycon: Add support for generic framebuffers and move to fbdev
subsystemv1 -> v2:
- a new patch correcting
serial/earlycon.cargument name to "offset" instead of "node"
- move IA64 exclusion from EFI earlyconKconfigto earlycon driverKconfig(IA64 has noearly_memremap_prot)
- move driver from fbdev to console subsystem
- select EFI earlycon by default
- fetch stride manually from device-tree, as on some devices it seems stride doesn't match the horizontal resolution * bpp.
- use saner format (e.g. 1920x1080x32 instead of 1920,1080,32).Markuss Broks (3):
drivers: serial: earlycon: Pass device-tree node
efi: earlycon: move to video/console to prepare for changes
efi: earlycon: Add support for generic framebuffers.../admin-guide/kernel-parameters.txt | 12 +- MAINTAINERS | 5 + drivers/firmware/efi/Kconfig | 7 +- drivers/firmware/efi/Makefile | 1 - drivers/firmware/efi/earlycon.c | 246 -------------- drivers/tty/serial/earlycon.c | 3 + drivers/video/console/Kconfig | 11 + drivers/video/console/Makefile | 1 + drivers/video/console/earlycon.c | 305 ++++++++++++++++++ include/linux/serial_core.h | 1 + 10 files changed, 336 insertions(+), 256 deletions(-) delete mode 100644 drivers/firmware/efi/earlycon.c create mode 100644 drivers/video/console/earlycon.c--
2.39.0
Hi Ard,
Quoted 4 lines · Ard Biesheuvel
(cc Andy)
On Wed, 21 Dec 2022 at 11:54, Markuss Broks <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Make the EFI earlycon driver be suitable for any linear framebuffers. This should be helpful for early porting of boards with no other means of output, like smartphones/tablets. There seems to be an issue with
early_ioremapfunction on ARM32, but I am unable to find the exact cause. It appears the mappings returned by it are somehow incorrect, thus the driver is disabled on ARM.The reason that this driver is disabled on ARM is because the struct
screen_infois not populated early enough, as it is retrieved from a UEFI configuration table.
I believe I must be hitting some other bug then, since my driver should not use struct screen_info when the arguments are specified manually (e.g. in device-tree or in kernel command line options), and it still is broken on ARM when they are. I got it to work on ARM when I moved the early console initialization later into the kernel booting process, but that mostly defeats the purpose of early console driver, I believe. I've been thinking that it could be some stuff not getting initialized early enough indeed, but I've got no clue what could it be.
Quoted 4 lines
early_ioremap()works fine on ARM as long as they mapping is torn down beforepaging_init()
Quoted 55 lines
Quoted 5 lines
EFI early
console was disabled on IA64 previously because of missingearly_memremap_prot, and this is inherited to this driver.This patch also changes
"This patch also changes ..." is usually a strong hint to self that the patches need to be split up.
Quoted 47 lines
behavior on EFI systems, by selecting the mapping type
based on if the framebuffer region intersects with system RAM. If it does, it's common sense that it should be in RAM as a whole, and so the system RAM mapping is used. It was tested to be working on my PC (Intel Z490 platform), as well as several ARM64 boards (Samsung Galaxy S9 (Exynos), iPad Air 2, Xiaomi Mi Pad 4, ...).Markuss Broks (2):
drivers: serial: earlycon: Pass device-tree node
efi: earlycon: Add support for generic framebuffers and move to fbdev
subsystemv1 -> v2:
- a new patch correcting
serial/earlycon.cargument name to "offset" instead of "node"
- move IA64 exclusion from EFI earlyconKconfigto earlycon driverKconfig(IA64 has noearly_memremap_prot)
- move driver from fbdev to console subsystem
- select EFI earlycon by default
- fetch stride manually from device-tree, as on some devices it seems stride doesn't match the horizontal resolution * bpp.
- use saner format (e.g. 1920x1080x32 instead of 1920,1080,32).Markuss Broks (3):
drivers: serial: earlycon: Pass device-tree node
efi: earlycon: move to video/console to prepare for changes
efi: earlycon: Add support for generic framebuffers.../admin-guide/kernel-parameters.txt | 12 +- MAINTAINERS | 5 + drivers/firmware/efi/Kconfig | 7 +- drivers/firmware/efi/Makefile | 1 - drivers/firmware/efi/earlycon.c | 246 -------------- drivers/tty/serial/earlycon.c | 3 + drivers/video/console/Kconfig | 11 + drivers/video/console/Makefile | 1 + drivers/video/console/earlycon.c | 305 ++++++++++++++++++ include/linux/serial_core.h | 1 + 10 files changed, 336 insertions(+), 256 deletions(-)delete mode 100644
drivers/firmware/efi/earlycon.ccreate mode 100644drivers/video/console/earlycon.c--
2.39.0
- Markuss
P.S. Just noticed I forgot to Ctrl^S the cover letter before saving... The main change v3 does is separate the moving action and edit action into two separate commits, I don't think there're more major changes. With v4 I'd try to attach the proper version log.
Ard Biesheuvel
maintainerQuoted 13 lines · Markuss Broks
Hi Ard,
Quoted 9 lines · Ard Biesheuvel
(cc Andy)
Quoted 5 lines · Markuss Broks
Make the EFI earlycon driver be suitable for any linear framebuffers. This should be helpful for early porting of boards with no other means of output, like smartphones/tablets. There seems to be an issue with
early_ioremapfunction on ARM32, but I am unable to find the exact cause. It appears the mappings returned by it are somehow incorrect, thus the driver is disabled on ARM.
Quoted 8 lines
Quoted 3 lines
The reason that this driver is disabled on ARM is because the struct
screen_infois not populated early enough, as it is retrieved from a UEFI configuration table.I believe I must be hitting some other bug then, since my driver should not use
struct screen_infowhen the arguments are specified manually (e.g. in device-tree or in kernel command line options), and it still is broken on ARM when they are.
Define 'broken'
Quoted 6 lines
I got it to work on ARM when I moved the
early console initialization later into the kernel booting process, but that mostly defeats the purpose of early console driver, I believe. I've been thinking that it could be some stuff not getting initialized early enough indeed, but I've got no clue what could it be.
This is likely due to the fact that the ARM init code sets up the PTE bits for various memory types, and using them beforehand is likely to result in problems.
Quoted 1 line · Ard Biesheuvel
(cc Andy)
I believe there are two reasons I'm Cc'ed now:
- the Cc was forgotten. because I remember reviewing some parts of this contribution
- this conflicts (to some extent) with my patch that speeds up the scrolling
For the first it's obvious what to do, I think Markuss can include me in his v4.
For the second I don't see the functional clash. The scrolling in this series is not anyhow optimized. I think my patch should go first as
- it is less intrusive
- it has been tested, or can be tested easily
Tell me if I'm missing something here.
Quoted 29 lines · Markuss Broks
Quoted 6 lines
Make the EFI earlycon driver be suitable for any linear framebuffers. This should be helpful for early porting of boards with no other means of output, like smartphones/tablets. There seems to be an issue with
early_ioremapfunction on ARM32, but I am unable to find the exact cause. It appears the mappings returned by it are somehow incorrect, thus the driver is disabled on ARM.The reason that this driver is disabled on ARM is because the struct
screen_infois not populated early enough, as it is retrieved from a UEFI configuration table.
early_ioremap()works fine on ARM as long as they mapping is torn down beforepaging_init()Quoted 5 lines
EFI early
console was disabled on IA64 previously because of missingearly_memremap_prot, and this is inherited to this driver.This patch also changes
"This patch also changes ..." is usually a strong hint to self that the patches need to be split up.
Quoted 5 lines
behavior on EFI systems, by selecting the mapping type
based on if the framebuffer region intersects with system RAM. If it does, it's common sense that it should be in RAM as a whole, and so the system RAM mapping is used. It was tested to be working on my PC (Intel Z490 platform), as well as several ARM64 boards (Samsung Galaxy S9 (Exynos), iPad Air 2, Xiaomi Mi Pad 4, ...).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Ard Biesheuvel
maintainerQuoted 13 lines · Andy Shevchenko
Quoted 1 line · Ard Biesheuvel
(cc Andy)
I believe there are two reasons I'm Cc'ed now:
- the Cc was forgotten. because I remember reviewing some parts of this contribution
- this conflicts (to some extent) with my patch that speeds up the scrollingFor the first it's obvious what to do, I think Markuss can include me in his v4.
Quoted 7 lines
For the second I don't see the functional clash. The scrolling in this series is not anyhow optimized. I think my patch should go first as
- it is less intrusive
- it has been tested, or can be tested easilyTell me if I'm missing something here.
Thanks for your input.