Add splash DRM client
Subsystems (6)
v7 cover Add splash DRM client
This is the seventh version of the splash client, which I took over from Francesco with v4. As Thomas suggested [1], it holds only the part that can go in now: patches 1 to 6 and 8 of v6, with the MAINTAINERS entry squashed into the patch that adds drm_splash.c. The device tree source and its binding, the placement and rotation, and the connector orientation will follow as a separate series on top of this one.
The client draws a splash on every output, including those plugged in later, until userspace takes over. The image comes from the EFI BGRT or, failing that, from a BMP loaded as firmware, named at build time ("drm_splash.bmp" by default); with neither, only the background is drawn, in a colour set at build time. A BGRT image is drawn at the table offsets, a BMP loaded as firmware is centred. A BGRT whose ACPI 6.2 orientation bits are set is skipped for now; turning it comes with the rotation in the later series.
Changes since v6
----------------
From the reviews of v6 [1]-[6]:
- MAINTAINERS: I am listed as M: and Francesco as R:, in patch 4
(Thomas [2], Francesco [3]).
- The firmware source is DRM_SPLASH_SRC_FW, and its Kconfig options DRM_CLIENT_SPLASH_SRC_FW and DRM_CLIENT_SPLASH_FW_NAME, since the BGRT is a BMP too (Thomas [4]).
- The drm_splash_fw_load() stub returns 0 (Thomas [5]), and drm_splash_image_load() does not call it when the firmware source is disabled.
- Thomas, I have kept your Reviewed-by on patch 4, as you said [6].
From sashiko's review of v6 [7], and further review:
- Patch 4: restore leaves the commit to the work, which draws whatever is missing first, so a restore that comes while the device is suspended is no longer lost [7]; a forced restore stays forced across suspend, and the work commits even when no scanout is left.
- Patch 4: a hotplug while userspace has the display waits for the next restore, as fbdev does; only a lack of memory makes the image be drawn again; unregister cancels the work before it looks for a firmware request, which the work can now make too; the tile group id is read under mode_config.mutex, which an EDID update holds while it changes or frees the group.
- Patch 2: the image address and size are 0 when efi_bgrt_has_image() says there is no image, so that they never disagree on kernels with 32-bit physical addresses.
- Patch 3: the comment on the DIB header says that a negative width is invalid.
Testing
-------
- QEMU versatilepb (pl111, 16 bpp): no image, and the BMP loaded as firmware, compared pixel by pixel.
- x86-64 with OVMF: the BGRT through the new accessors; with CONFIG_DRM_CLIENT_SPLASH_SRC_FW=n, with and without a BGRT (bgrt_disable), the background alone and no error.
- i386 without PAE on 32-bit OVMF, with the BGRT replaced from the initrd so that it points above 4 GiB: the background alone.
- QEMU virt arm64 (virtio-gpu, 32 bpp) with KASAN and kmemleak: the driver bound and unbound repeatedly, a crafted bitmap offset, and the firmware arriving only after the unbind; no reports. With lockdep too, over several outputs, tiled displays and the bind
cycles: no reports.
- Several outputs, one of them off, and tiled displays from 2x1 up to 3x3, 4x2 and 2x4 tiles, in several CRTC orders, simulated with DisplayID tiled topology EDIDs on virtio-gpu heads. The layouts with more than one row and column need a fix to the client modeset code that is not part of this series.
- The error paths, with a debug patch forcing them: buffers and formats that fail on one output, work queued while suspended, a restore during suspend or with a master, a hotplug with a master, a fill that fails, a firmware request made by the work and raced against the unbind; no WARN or KASAN report in any of them.
- An AM335x board (tilcdc, 16 bpp), booting over TFTP and NFS, with the BMP built in and from an initramfs, an 8 bpp BMP that is rejected, and 5 unbind and bind cycles of tilcdc, checked by reading the scanout buffer back.
- W=1 and sparse clean; every patch builds on its own on arm and x86-64; checkpatch --strict clean apart from a quoted modpost line in patch 2 and the MAINTAINERS reminder on patch 3, whose new header FRAMEBUFFER LAYER already covers.
Open questions
--------------
- Unbinding waits for a pending firmware request, as it cannot be cancelled and its callback uses the splash, and it waits under the device's clientlist_mutex. Normally the request is long over; with the sysfs fallback it can take up to the loading timeout. Not waiting would mean giving the callback its own refcounted object; I can do that as a follow-up.
- The BGRT offsets are for the mode the firmware drew in. When KMS picks another one, the x86 check taken from efifb leaves the screen without a logo, and elsewhere the logo lands off centre. The offsets could be used only when the scanout matches the firmware's framebuffer, and the image centred otherwise.
- The splash is a DRM client, so a device using it has no fbdev emulation and no /dev/fb0.
Based on drm-misc-next-2026-10-23 (cf5d8e390e2a).
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/avTjrfIEPgyvPDti@bywater/
[4] https://lore.kernel.org/all/[email protected]/
[5] https://lore.kernel.org/all/[email protected]/
[6] https://lore.kernel.org/all/[email protected]/
[7] https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/r/[email protected]
v5: https://lore.kernel.org/r/[email protected]
v4: https://lore.kernel.org/r/[email protected]
v3: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]
Màxim
Francesco Valla (2):
drm: client: add splash client
drm: docs: remove bootsplash from TODO
Màxim Pedraza Padilla (4):
drm/clients: Kconfig: indent DRM_CLIENT_DEFAULT with tabs
efi: bgrt: add accessors for the boot graphics
fbdev: efifb: move the BMP headers to <video/bmp.h> drm/client: splash: pick the image source in one place
Documentation/gpu/todo.rst | 17 - MAINTAINERS | 8 + drivers/firmware/efi/efi-bgrt.c | 76 +- drivers/gpu/drm/clients/Kconfig | 80 +- drivers/gpu/drm/clients/Makefile | 1 + drivers/gpu/drm/clients/drm_client_internal.h | 9 + drivers/gpu/drm/clients/drm_client_setup.c | 8 + drivers/gpu/drm/clients/drm_splash.c | 1060 +++++++++++++++++ drivers/video/fbdev/efifb.c | 49 +- include/linux/efi-bgrt.h | 39 +- include/video/bmp.h | 40 + 11 files changed, 1330 insertions(+), 57 deletions(-) create mode 100644 drivers/gpu/drm/clients/drm_splash.c create mode 100644 include/video/bmp.h
base-commit: cf5d8e390e2ac2cfa24a50645efdbb9f0eebe65f
Signature · 1 line
2.39.5
PATCH v7 1/6 drm/clients: Kconfig: indent DRM_CLIENT_DEFAULT with tabs
The body of DRM_CLIENT_DEFAULT is indented with spaces, unlike every other entry in the file. Use tabs, so that the next client added to the list does not have to pick one or the other.
No functional change.
--- drivers/gpu/drm/clients/Kconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/clients/Kconfig +5 -5
@@ -114,10 +114,10 @@ config DRM_CLIENT_DEFAULT_LOG endchoice config DRM_CLIENT_DEFAULT - string - depends on DRM_CLIENT - default "fbdev" if DRM_CLIENT_DEFAULT_FBDEV - default "log" if DRM_CLIENT_DEFAULT_LOG - default "" + string + depends on DRM_CLIENT + default "fbdev" if DRM_CLIENT_DEFAULT_FBDEV + default "log" if DRM_CLIENT_DEFAULT_LOG + default "" endmenu
Signature · 1 line
2.39.5
PATCH v7 2/6 efi: bgrt: add accessors for the boot graphics
In reply to Màxim Pedraza PadillaThe DRM splash client shows the boot graphics the firmware left behind, and needs the image address and size, its offsets and the status bits. Reading them from bgrt_tab and bgrt_image_size works with drm_client_lib built in, but it can be a module, and neither is exported:
ERROR: modpost: drivers/gpu/drm/clients/drm_client_lib.ko: symbol 'bgrt_tab' undefined!
ERROR: modpost: drivers/gpu/drm/clients/drm_client_lib.ko: symbol 'bgrt_image_size' undefined!
Rather than export the data, add an accessor for each of them, exported GPL only, with stubs in efi-bgrt.h for CONFIG_ACPI_BGRT=n so that users need no #ifdef of their own. The variables stay global for drivers/acpi/bgrt.c, and are only written by efi_bgrt_init(): mark them __ro_after_init.
The table gives the image address as a u64. efi_bgrt_has_image() only says yes when phys_addr_t can hold it, and the address and size are 0 when it says no, so that they never disagree on kernels with 32-bit physical addresses.
--- drivers/firmware/efi/efi-bgrt.c | 76 ++++++++++++++++++++++++++++++++- include/linux/efi-bgrt.h | 39 ++++++++++++++++- 2 files changed, 112 insertions(+), 3 deletions(-)
drivers/firmware/efi/efi-bgrt.c +74 -2
@@ -16,8 +16,8 @@#include <linux/efi.h> #include <linux/efi-bgrt.h> -struct acpi_table_bgrt bgrt_tab; -size_t bgrt_image_size; +struct acpi_table_bgrt bgrt_tab__ro_after_init ; +size_t bgrt_image_size__ro_after_init ;struct bmp_header {u16 id;
@@ -89,3 +89,75 @@ void __init efi_bgrt_init(struct acpi_table_header *table) out:memset (bgrt,0 ,sizeof (bgrt_tab)); } + +/** +* efi_bgrt_has_image() - Whether the firmware left a boot graphic +* +* Return: true if the BGRT points at a BMP image, which efi_bgrt_init() +* checked and reserved, at an address that phys_addr_t can hold. The +* other accessors only mean something when it returns true. +*/ +bool efi_bgrt_has_image (void ) +{ +return bgrt_tab.image_address && + bgrt_tab.image_address == (phys_addr_t )bgrt_tab.image_address; +} +EXPORT_SYMBOL_GPL (efi_bgrt_has_image); + +/** +* efi_bgrt_image_address() - Physical address of the boot graphic +* +* Return: the address of the BMP image, or 0 if there is none. +*/ +phys_addr_t efi_bgrt_image_address (void ) +{ +return efi_bgrt_has_image () ? bgrt_tab.image_address :0 ; +} +EXPORT_SYMBOL_GPL (efi_bgrt_image_address); + +/** +* efi_bgrt_image_size() - Size of the boot graphic +* +* Return: the size of the BMP image, as its header gives it, or 0 if there +* is none. +*/ +size_t efi_bgrt_image_size (void ) +{ +return efi_bgrt_has_image () ? bgrt_image_size :0 ; +} +EXPORT_SYMBOL_GPL (efi_bgrt_image_size); + +/** +* efi_bgrt_status() - Status field of the BGRT +* +* Return: the status byte. Bit 0 tells whether the image is still on +* screen and, since ACPI 6.2, bits 1-2 how far it has to be turned to show +* upright (ACPI_BGRT_ORIENTATION_OFFSET). +*/ +u8 efi_bgrt_status (void ) +{ +return bgrt_tab.status; +} +EXPORT_SYMBOL_GPL (efi_bgrt_status); + +/** +* efi_bgrt_image_offset_x() - Horizontal position of the boot graphic +* +* Return: the X offset, in pixels, at which the firmware drew the image. +*/ +u32 efi_bgrt_image_offset_x (void ) +{ +return bgrt_tab.image_offset_x; +} +EXPORT_SYMBOL_GPL (efi_bgrt_image_offset_x); + +/** +* efi_bgrt_image_offset_y() - Vertical position of the boot graphic +* +* Return: the Y offset, in pixels, at which the firmware drew the image. +*/ +u32 efi_bgrt_image_offset_y (void ) +{ +return bgrt_tab.image_offset_y; +} +EXPORT_SYMBOL_GPL (efi_bgrt_image_offset_y);
include/linux/efi-bgrt.h +38 -1
@@ -9,7 +9,14 @@void efi_bgrt_init (struct acpi_table_header *table);int __init acpi_parse_bgrt (struct acpi_table_header *table); -/* The BGRT data itself; only valid if bgrt_image != NULL. */ +bool efi_bgrt_has_image (void ); +phys_addr_t efi_bgrt_image_address (void ); +size_t efi_bgrt_image_size (void ); +u8 efi_bgrt_status (void ); +u32 efi_bgrt_image_offset_x (void ); +u32 efi_bgrt_image_offset_y (void ); + +/* The BGRT data itself; only valid if efi_bgrt_has_image(). */ extern size_t bgrt_image_size;extern struct acpi_table_bgrt bgrt_tab;
@@ -21,6 +28,36 @@ static inline int __init acpi_parse_bgrt(struct acpi_table_header *table)return 0 ; } +static inline bool efi_bgrt_has_image (void ) +{ +return false; +} + +static inline phys_addr_t efi_bgrt_image_address (void ) +{ +return 0 ; +} + +static inline size_t efi_bgrt_image_size (void ) +{ +return 0 ; +} + +static inline u8 efi_bgrt_status (void ) +{ +return 0 ; +} + +static inline u32 efi_bgrt_image_offset_x (void ) +{ +return 0 ; +} + +static inline u32 efi_bgrt_image_offset_y (void ) +{ +return 0 ; +} +#endif /* !CONFIG_ACPI_BGRT */ #endif /* _LINUX_EFI_BGRT_H */
Signature · 1 line
2.39.5
PATCH v7 3/6 fbdev: efifb: move the BMP headers to <video/bmp.h>
In reply to Màxim Pedraza PadillaThe DRM splash client parses the same BMP headers as efifb. Rather than keep a second copy of the structures, move them to include/video/bmp.h with the magic number.
BMP is little endian whatever the CPU, so the header gives the fields as __le16 and __le32, and efifb now reads them with get_unaligned_le16() and get_unaligned_le32(). Width and height are read signed, as the format has them. No change on the little endian systems EFI runs on.
--- drivers/video/fbdev/efifb.c | 49 ++++++++++++++----------------------- include/video/bmp.h | 40 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 include/video/bmp.h
drivers/video/fbdev/efifb.c +18 -31
@@ -16,32 +16,13 @@#include <linux/platform_device.h> #include <linux/printk.h> #include <linux/sysfb.h> +#include <linux/unaligned.h> +#include <video/bmp.h> #include <video/vga.h> #include <asm/efi.h> #include <drm/drm_connector.h> /* For DRM_MODE_PANEL_ORIENTATION_* */ #include <drm/drm_panel_quirks.h> /* For drm_get_panel_orientation_quirk */ -struct bmp_file_header { -u16 id; -u32 file_size; -u32 reserved; -u32 bitmap_offset; -} __packed; - -struct bmp_dib_header { -u32 dib_header_size; -s32 width; -s32 height; -u16 planes; -u16 bpp; -u32 compression; -u32 bitmap_size; -u32 horz_resolution; -u32 vert_resolution; -u32 colors_used; -u32 colors_important; -} __packed; -static bool use_bgrt = true;static bool request_mem_succeeded = false;static u64 mem_flags =EFI_MEMORY_WC |EFI_MEMORY_UC ;
@@ -145,9 +126,10 @@ static bool efifb_bgrt_sanity_check(const struct screen_info *si, u32 bmp_width)static void efifb_show_boot_graphics (struct fb_info *info,const struct screen_info *si) { -u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y; +u32 bmp_width, bmp_height, bmp_pitch, bitmap_offset, dst_x, y, src_y;struct bmp_file_header *file_header;struct bmp_dib_header *dib_header; +s32 width, height;void *bgrt_image =NULL ;u8 *dst = info->screen_base;
@@ -186,20 +168,25 @@ static void efifb_show_boot_graphics(struct fb_info *info, const struct screen_i goto error; file_header = bgrt_image; -if (file_header->id !=0x4d42 || file_header->reserved !=0 ) +if (get_unaligned_le16 (&file_header->id) !=BMP_FILE_MAGIC_ID || +get_unaligned_le32 (&file_header->reserved) !=0 ) goto error; + bitmap_offset =get_unaligned_le32 (&file_header->bitmap_offset); dib_header = bgrt_image +sizeof (*file_header); -if (dib_header->dib_header_size !=40 || dib_header->width <0 || - dib_header->planes !=1 || dib_header->bpp !=24 || - dib_header->compression !=0 ) + width =get_unaligned_le32 (&dib_header->width); + height =get_unaligned_le32 (&dib_header->height); +if (get_unaligned_le32 (&dib_header->dib_header_size) !=40 || + width <0 ||get_unaligned_le16 (&dib_header->planes) !=1 || +get_unaligned_le16 (&dib_header->bpp) !=24 || +get_unaligned_le32 (&dib_header->compression) !=0 ) goto error; - bmp_width = dib_header->width; - bmp_height =abs (dib_header->height); + bmp_width = width; + bmp_height =abs (height); bmp_pitch =round_up (3 * bmp_width,4 ); -if ((file_header->bitmap_offset + bmp_pitch * bmp_height) > +if ((bitmap_offset + bmp_pitch * bmp_height) > bgrt_image_size) goto error;
@@ -222,12 +209,12 @@ static void efifb_show_boot_graphics(struct fb_info *info, const struct screen_i src_y = y - bgrt_tab.image_offset_y;/* Positive header height means upside down row order */ -if (dib_header->height >0 ) +if (height >0 ) src_y = (bmp_height -1 ) - src_y;memset (dst,0 , bgrt_tab.image_offset_x *4 ); dst_x = bgrt_tab.image_offset_x; -efifb_copy_bmp (bgrt_image + file_header->bitmap_offset + +efifb_copy_bmp (bgrt_image + bitmap_offset + src_y * bmp_pitch, (u32 *)dst + dst_x, bmp_width, si); dst_x += bmp_width;
include/video/bmp.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _VIDEO_BMP_H +#define _VIDEO_BMP_H + +#include <linux/types.h> + +/* "BM", the first two bytes of a BMP file */ +#define BMP_FILE_MAGIC_ID 0x4d42 + +/* +* The headers at the start of a BMP file. Every field is little endian, +* whatever the CPU, and the headers need not be aligned in memory: read them +* with get_unaligned_le16() and get_unaligned_le32(). +*/ +struct bmp_file_header { +__le16 id; +__le32 file_size; +__le32 reserved; +__le32 bitmap_offset; +} __packed; + +/* +* BITMAPINFOHEADER. Width and height are signed: a negative width is +* invalid, and a negative height means the rows go top to bottom. +*/ +struct bmp_dib_header { +__le32 dib_header_size; +__le32 width; +__le32 height; +__le16 planes; +__le16 bpp; +__le32 compression; +__le32 bitmap_size; +__le32 horz_resolution; +__le32 vert_resolution; +__le32 colors_used; +__le32 colors_important; +} __packed; + +#endif /* _VIDEO_BMP_H */
Signature · 1 line
2.39.5
PATCH v7 4/6 drm: client: add splash client
In reply to Màxim Pedraza PadillaFrom: Francesco Valla <[email protected]>
Add a DRM client that draws a simple splash, with possibility to show:
- the logo provided by EFI BGRT;
- a static BMP image (loaded as firmware);
- a colored background.
The client is not meant to replace a full-featured bootsplash, but rather to remove some complexity (and hopefully boot time) on small embedded platforms or on systems with a limited scope (e.g: recovery or manufacturing images).
The background color is set at build time from a dedicated config option. Any color in RGB888 format can be used.
If enabled, the static BMP image is loaded using the kernel firmware infrastructure; a valid BMP image with 24bpp color and no compression is expected. The name of the image is set at build time, with the default being 'drm_splash.bmp'.
Just like the existing DRM clients, the splash can be enabled from the kernel command line using drm_client_lib.active=splash.
v7:
- restore leaves the commit to the work, which draws what is missing first, commits even with no scanouts left, and keeps a forced restore forced across suspend
- a hotplug while userspace has the display waits for the next restore, as fbdev does
- only a lack of memory makes the image be drawn again
- unregister cancels the work before it looks for a firmware request, which a restore can now make too
- the MAINTAINERS entry comes with this patch, with Màxim as maintainer and Francesco as reviewer
- rename the BMP source to FW, which is where it comes from: the BGRT is a BMP too
- fw_load() returns 0 when the firmware source is disabled, and image_load() does not call it then
- read the tile group id under mode_config.mutex, which an EDID update holds while it changes or frees the group
v6:
- draw from a work item on system_power_efficient_wq instead of a render thread
- set the scanouts up again on every hotplug, and keep the image for the outputs plugged in later
- keep the scanouts on screen until the new ones are committed, so that a hotplug does not blank every output
- also when the commit or the hotplug fails; restore retires them too
- redraw the image after a background that is drawn again
- accept the V4 and V5 BMP headers
- limit the background color to RGB888
- point no modeset at the framebuffer it had, which a probe without connectors leaves in place
- leave restore to the work while the device is suspended
- say in DRM_CLIENT_SPLASH_BMP_NAME that the BMP is requested only once
- don't fail a hotplug, which would stop the later ones for good
- restore commits whatever the modesets hold: an output without a buffer has no mode either, and is switched off
- take the BMP headers from <video/bmp.h>
- draw the image in two steps: the BMP upright in XRGB8888, then into the buffer's format, taken from its drm_format_info
- drop the splash_color and splash_bmp parameters: the color is set at build time only, and so is the BMP's name, with DRM_CLIENT_SPLASH_BMP_NAME
- read the 24 bpp source pixels with get_unaligned_le24() instead of a u32 load that runs past the pixel
- check the BGRT offsets without overflowing
- size a tiled framebuffer from the tile offsets, whatever order the CRTCs come in, and leave out a tile whose plane cannot take the format of its group
- don't pick a preferred format that cannot be drawn to, such as C8; without one from the driver, pick the one fbdev would
- only pick formats the plane takes with the linear modifier, the layout of a dumb buffer
- switch off a modeset left without a buffer instead of failing the commit for every output
- mark the background drawn only once it is
- hold the work back while the device is suspended, drawing included, and queue it on resume
- drop the fallback to a BMP that was never requested when the BGRT fails to load, and the unused struct device
- log with drm_dbg() rather than drm_info(), and end the messages with a newline
- destroy the mutex at unregister, and when registering fails
- sort the selects of DRM_CLIENT_SELECTION, use unsigned loop counters, and reword the comment on the x86 BGRT sanity check
v5:
- clear the modesets' framebuffers when the scanouts are freed
- free the scanouts when setting up fails
- release a firmware that lands after the drawing is done
- read the BGRT through the efi_bgrt_*() accessors
- drop "static inline" from the .c file
v4:
- fix the render thread never exiting when the BMP firmware is missing, a lost wake-up, and stopping a thread that had exited, never existed or failed to start
- fix buffers going to the wrong modesets and tiled groups in drm_splash_init_client(), and take modeset_mutex there
- don't keep an ERR_PTR as a buffer
- unmap the image only once
- fix use-after-frees on unbind and in the firmware callback
- check the BMP size without overflowing
- indent the Kconfig entry with tabs
--- MAINTAINERS | 8 + drivers/gpu/drm/clients/Kconfig | 70 +- drivers/gpu/drm/clients/Makefile | 1 + drivers/gpu/drm/clients/drm_client_internal.h | 9 + drivers/gpu/drm/clients/drm_client_setup.c | 8 + drivers/gpu/drm/clients/drm_splash.c | 1032 +++++++++++++++++ 6 files changed, 1127 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/clients/drm_splash.c
MAINTAINERS +8 -0
@@ -9168,6 +9168,14 @@ F: Documentation/gpu/drm-ras.rst F: drivers/gpu/drm/drm_ras* F: include/drm/drm_ras* +DRM SPLASH +M: Màxim Pedraza Padilla <[email protected]> +R: Francesco Valla <[email protected]> +L: [email protected] +S: Maintained +T: git https://gitlab.freedesktop.org/drm/misc/kernel.git +F: drivers/gpu/drm/clients/drm_splash.c + DRM TTM SUBSYSTEM M: Natalie Vock <[email protected]> M: Arun Pravin <[email protected]>
drivers/gpu/drm/clients/Kconfig +69 -1
97 lines not on this page · raw message
drivers/gpu/drm/clients/Makefile +1 -0
@@ -6,4 +6,5 @@ drm_client_lib-y := drm_client_setup.o drm_client_lib-$(CONFIG_DRM_CLIENT_LOG) += drm_log.o drm_client_lib-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fbdev_client.o \ drm_fbdev_helper.o +drm_client_lib-$(CONFIG_DRM_CLIENT_SPLASH) += drm_splash.o obj-$(CONFIG_DRM_CLIENT_LIB) += drm_client_lib.o
drivers/gpu/drm/clients/drm_client_internal.h +9 -0
@@ -22,4 +22,13 @@ void drm_log_register(struct drm_device *dev);static inline void drm_log_register (struct drm_device *dev) {}#endif +#ifdef CONFIG_DRM_CLIENT_SPLASH +void drm_splash_register (struct drm_device *dev, +const struct drm_format_info *format); +#else +static inline void drm_splash_register (struct drm_device *dev, +const struct drm_format_info *format) +{} +#endif +#endif
drivers/gpu/drm/clients/drm_client_setup.c +8 -0
@@ -56,6 +56,14 @@ void drm_client_setup(struct drm_device *dev, const struct drm_format_info *form return; }#endif + +#ifdef CONFIG_DRM_CLIENT_SPLASH +if (!strcmp (drm_client_default,"splash" )) { +drm_splash_register (dev, format); +return ; + } +#endif +if (strcmp (drm_client_default,"" ))drm_warn (dev,"Unknown DRM client %s\n" , drm_client_default); }
drivers/gpu/drm/clients/drm_splash.c new file +1032 -0
1,032 lines not on this page · raw message
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH v7 4/6] drm: client: add splash client
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/client: splash: stale modeset kept when probe finds no connectors --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/client: splash: stale modeset kept when probe finds no connectors
--
commit fb1584c86189774bc202b28de7ab532767373aff
Author: Francesco Valla <[email protected]>
drm: client: add splash client
This commit adds an in-kernel DRM client that displays a solid background color, an EFI BGRT logo, or a BMP firmware image until userspace takes over the display.
Quoted 6 lines
drivers/gpu/drm/clients/drm_splash.c new file +0
-0@@ -0,0 +1,1032 @@
[ ... ]
Quoted 35 lines
drivers/gpu/drm/clients/drm_splash.c new file +35
-0+static int drm_splash_init_client (struct drm_splash *splash) +{ +struct drm_client_dev *client = &splash->client; +struct drm_mode_set *modeset; +unsigned int fb_count =0 ; +unsigned int i, k; +int err = -ENODEV ; + +if (drm_client_modeset_probe (client,0 ,0 )) +return -EIO ; + +mutex_lock (&client->modeset_mutex); + +/* +* Collect one scanout per usable modeset, or per tile group. Each +* scanout records the modesets it feeds by their position in the +* list, so that the second pass below can find them again whatever +* was skipped in between. +*/ + i =0 ; +drm_client_for_each_modeset (modeset, client) { +struct drm_splash_scanout *tmp; +struct drm_splash_scanout *scanout; +unsigned int idx = i++; +u32 format; +int id; + +if (WARN_ON_ONCE (idx >=32 )) +break ; + +/* Skip modesets without a mode */ +if (!modeset->mode) +continue ; + + id =drm_splash_tile_group_id (modeset->connectors[0 ]);
[ ... ]
Quoted 23 lines
drivers/gpu/drm/clients/drm_splash.c new file +23
-0+/* +* And point every modeset at the buffer of its scanout. One left +* without, whatever the reason, is switched off: a mode without a +* framebuffer fails the commit, and with it every other output. +* Never the old one: a probe without connectors leaves it there. +*/ + i =0 ; +drm_client_for_each_modeset (modeset, client) { +unsigned int idx = i++; + + modeset->fb =NULL ; +for (k =0 ; idx <32 && k < splash->n_scanout; k++) { +struct drm_splash_scanout *scanout = &splash->scanout[k]; + +if (scanout->buffer && (scanout->modesets &BIT (idx))) { + modeset->fb = scanout->buffer->fb; +break ; + } + } + +if (!modeset->fb) +drm_splash_modeset_off (client->dev, modeset); + }
[ ... ]
Quoted 11 lines
drivers/gpu/drm/clients/drm_splash.c new file +11
-0+static void drm_splash_rebuild (struct drm_splash *splash) +{ +struct drm_client_dev *client = &splash->client; +int ret; + +/* +* Every hotplug starts over, with the outputs there are now. The +* scanouts on screen stay there until the work or restore has +* committed the new ones; with some still waiting for that, the +* current ones were never committed and can go. +*/
drivers/gpu/drm/clients/drm_splash.c line 843
Quoted 10 lines
drivers/gpu/drm/clients/drm_splash.c new file +10
-0+if (splash->old_scanout) { +drm_splash_free_scanout (client); + }else { + splash->old_scanout = splash->scanout; + splash->n_old_scanout = splash->n_scanout; + splash->scanout =NULL ; + splash->n_scanout =0 ; + } + + ret =drm_splash_init_client (splash);
[Severity: Medium]
Does drm_splash_init_client() rebuild and commit a stale modeset when all connectors are removed?
After a commit clears splash->old_scanout, drm_splash_rebuild() moves splash->scanout to splash->old_scanout without calling drm_splash_free_scanout(), leaving client->modesets populated. If all dynamic connectors (such as DP MST outputs) have been removed, drm_client_modeset_probe() returns 0 before calling drm_client_modeset_release():
drivers/gpu/drm/drm_client_modeset.c:drm_client_modeset_probe() {
...
if (!connector_count)
return 0;
...
drm_client_modeset_release(client);
}Because the old modeset->mode and modeset->connectors[0] remain in place, the first loop in drm_splash_init_client() sees modeset->mode != NULL, reads the stale modeset->connectors[0], and creates a new scanout and dumb buffer for the removed output, so the final loop sets modeset->fb to the new buffer instead of calling drm_splash_modeset_off().
Clearing client->modesets with drm_splash_modeset_off() in the else branch of drm_splash_rebuild() before probing would avoid reusing the old modeset state.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v7 5/6 drm: docs: remove bootsplash from TODO
In reply to Màxim Pedraza PadillaFrom: Francesco Valla <[email protected]>
Now that a splash client exists, remove the bootsplash task from the TODO list for the DRM subsystem.
--- Documentation/gpu/todo.rst | 17 ----------------- 1 file changed, 17 deletions(-)
Documentation/gpu/todo.rst +0 -17
@@ -756,23 +756,6 @@ See drivers/gpu/drm/amd/display/TODO for tasks. Contact: Harry Wentland, Alex Deucher -Bootsplash -========== - -There is support in place now for writing internal DRM clients making it -possible to pick up the bootsplash work that was rejected because it was written -for fbdev. - -- [v6,8/8] drm/client: Hack: Add bootsplash example - https://patchwork.freedesktop.org/patch/306579/ - -- [RFC PATCH v2 00/13] Kernel based bootsplash - https://lore.kernel.org/r/[email protected] - -Contact: Sam Ravnborg - -Level: Advanced - Brightness handling on devices with multiple internal panels ============================================================
Signature · 1 line
2.39.5
PATCH v7 6/6 drm/client: splash: pick the image source in one place
In reply to Màxim Pedraza PadillaThe client chooses between two sources with a boolean: the BGRT if the firmware left one, otherwise the BMP loaded as firmware. A third one is coming, and with it an order of preference that a boolean cannot hold.
Name the source in use with an enum, picked once by drm_splash_pick_source(), and have drm_splash_image_load() switch on it. No functional change.
v7:
- DRM_SPLASH_SRC_FW for DRM_SPLASH_SRC_BMP: the BGRT is a BMP too
--- drivers/gpu/drm/clients/drm_splash.c | 46 ++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-)
drivers/gpu/drm/clients/drm_splash.c +37 -9
@@ -39,6 +39,16 @@* a static image. */ +/* +* Where the image comes from. drm_splash_pick_source() sets the order of +* preference; NONE is zero, so that a new splash starts without a source. +*/ +enum drm_splash_source { +DRM_SPLASH_SRC_NONE , +DRM_SPLASH_SRC_BGRT , +DRM_SPLASH_SRC_FW , +}; +struct drm_splash_scanout {int id;/* Modesets scanning this buffer out, by position in the list */
@@ -91,7 +101,7 @@ struct drm_splash {const struct firmware *fw;void *map_data; -bool use_bgrt; +enum drm_splash_source src; };static struct drm_splash *client_to_drm_splash (struct drm_client_dev *client)
@@ -439,7 +449,7 @@ static int drm_splash_bmp_to_scanout(struct drm_splash *splash,return -EINVAL ; } -if (splash->use_bgrt) { +if (splash->src ==DRM_SPLASH_SRC_BGRT ) { x_pad =efi_bgrt_image_offset_x (); y_pad =efi_bgrt_image_offset_y ();
@@ -509,13 +519,31 @@ static int drm_splash_bmp_to_scanout(struct drm_splash *splash,static int drm_splash_image_load (struct drm_splash *splash,const u8 **img_data,size_t *img_data_len) { -if (splash->use_bgrt) +switch (splash->src) { +case DRM_SPLASH_SRC_BGRT :return drm_splash_bgrt_load (splash, img_data, img_data_len); +case DRM_SPLASH_SRC_FW : +return drm_splash_fw_load (splash, img_data, img_data_len); +case DRM_SPLASH_SRC_NONE : +break ; + } -if (!IS_ENABLED (CONFIG_DRM_CLIENT_SPLASH_SRC_FW )) -return -ENOENT ; +return -ENOENT ; +} + +/* +* Pick the one source the image will come from: the BGRT is whatever the +* firmware shows, and the BMP loaded as firmware is the fallback. With +* neither, only the background colour is drawn. +*/ +static enum drm_splash_source drm_splash_pick_source (struct drm_splash *splash) +{ +if (drm_splash_bgrt_available (splash)) +return DRM_SPLASH_SRC_BGRT ; +if (IS_ENABLED (CONFIG_DRM_CLIENT_SPLASH_SRC_FW )) +return DRM_SPLASH_SRC_FW ; -return drm_splash_fw_load (splash, img_data, img_data_len); +return DRM_SPLASH_SRC_NONE ; }/* At unregister, once nothing else can use the image */
@@ -858,10 +886,10 @@ static void drm_splash_rebuild(struct drm_splash *splash)if (!splash->source_picked) { splash->source_picked = true; - splash->use_bgrt =drm_splash_bgrt_available (splash); + splash->src =drm_splash_pick_source (splash); -/* If no other image has been loaded, try to load a BMP as firmware */ -if (IS_ENABLED (CONFIG_DRM_CLIENT_SPLASH_SRC_FW ) && !splash->use_bgrt) { +/* The BMP loaded as firmware is the only source that arrives later */ +if (splash->src ==DRM_SPLASH_SRC_FW ) { ret =drm_splash_fw_request (splash); splash->fw_requested = !ret;if (ret)
Signature · 1 line
2.39.5