Skip to contentSkip to conversation

drm: Move drawing to pixel-helper module

PATCH In review Thomas Zimmermann 3 participants 11 messages Oct 19

Subsystems (23)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm: Move drawing to pixel-helper module

Add the new module drm_pixel_helper.ko and link existing shared code for drawing to it. This includes format helpers, panic helpers and drawing helpers. Update drivers. No functional changes.

The existing helpers are currently part of KMS helpers or the DRM core. Neither is suitable for this. Adding drm_pixel_helper.ko resolves this. The new module only depends on the DRM core and common kernel functions.

Future directions: putting pixel-related helpers into the same module opens up the possibility of sharing more code among them. There is even more drawing code in vkms and a few other drivers. Hopefully this could be integrated into pixel helpers at some point.

Smoke-tested on qemu with vesadrm and bochs.

Thomas Zimmermann (4):
drm: Add helper module for working with pixel data drm/pixel: Link format helpers into drm_pixel_helper.ko drm/pixel: Link panic helpers into drm_pixel_helper.ko drm/pixel: Link draw helpers into drm_pixel_helper.ko

 drivers/gpu/drm/Kconfig                       | 15 ++++++--------
 drivers/gpu/drm/Kconfig.debug                 |  2 +-
 drivers/gpu/drm/Makefile                      | 12 +++++++----
 drivers/gpu/drm/amd/amdgpu/Kconfig            |  1 +
 drivers/gpu/drm/ast/Kconfig                   |  1 +
 drivers/gpu/drm/clients/Kconfig               |  2 +-
 .../gpu/drm/{drm_draw.c => drm_draw_helper.c} |  0
 drivers/gpu/drm/drm_kms_helper_common.c       | 13 ------------
 drivers/gpu/drm/drm_panic_helper.c            |  1 +
 drivers/gpu/drm/drm_panic_internal.h          | 14 -------------
 drivers/gpu/drm/drm_pixel_helper_common.c     | 20 +++++++++++++++++++
 drivers/gpu/drm/drm_pixel_helper_internal.h   | 20 +++++++++++++++++++
 drivers/gpu/drm/gud/Kconfig                   |  1 +
 drivers/gpu/drm/hisilicon/hibmc/Kconfig       |  1 +
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c    |  1 +
 drivers/gpu/drm/hyperv/Kconfig                |  1 +
 drivers/gpu/drm/i915/Kconfig                  |  1 +
 drivers/gpu/drm/imx/ipuv3/Kconfig             |  1 +
 drivers/gpu/drm/mgag200/Kconfig               |  1 +
 drivers/gpu/drm/nouveau/Kconfig               |  1 +
 drivers/gpu/drm/renesas/rcar-du/Kconfig       |  1 +
 drivers/gpu/drm/renesas/shmobile/Kconfig      |  1 +
 drivers/gpu/drm/sitronix/Kconfig              |  2 ++
 drivers/gpu/drm/solomon/Kconfig               |  1 +
 drivers/gpu/drm/sysfb/Kconfig                 |  1 +
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c     |  1 +
 drivers/gpu/drm/tidss/Kconfig                 |  1 +
 drivers/gpu/drm/tiny/Kconfig                  |  6 ++++++
 drivers/gpu/drm/tiny/bochs.c                  |  1 +
 drivers/gpu/drm/virtio/Kconfig                |  1 +
 30 files changed, 83 insertions(+), 42 deletions(-)
 rename drivers/gpu/drm/{drm_draw.c => drm_draw_helper.c} (100%)
 create mode 100644 drivers/gpu/drm/drm_pixel_helper_common.c
 create mode 100644 drivers/gpu/drm/drm_pixel_helper_internal.h

base-commit: 5b9ee97c47574138633a1cb70a32d118b6860a43

Signature · 1 line
2.56.0
author maintainer
#1 lore raw

PATCH 1/4 drm: Add helper module for working with pixel data

Add drm_pixel_helper.ko. This module will contain helpers that copy and process pixel data, such as framebuffers. Drivers that want to use the helpers should select DRM_PIXEL_HELPER.

---
 drivers/gpu/drm/Kconfig                   | 6 ++++++
 drivers/gpu/drm/Makefile                  | 4 ++++
 drivers/gpu/drm/drm_pixel_helper_common.c | 6 ++++++
 3 files changed, 16 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_pixel_helper_common.c
drivers/gpu/drm/Kconfig +6 -0
index 61111d50b1c6..dce5e25671ee 100644
@@ -49,6 +49,12 @@ config DRM_KMS_HELPER
 	help
 	  CRTC helpers for KMS drivers.
 
+config DRM_PIXEL_HELPER
+	tristate
+	depends on DRM
+	help
+	  Helpers for working with pixel data in DRM.
+
 config DRM_DRAW
 	bool
 	depends on DRM
drivers/gpu/drm/Makefile +4 -0
index 2c6bc093a923..5f555a2c1a4c 100644
@@ -99,6 +99,10 @@ obj-$(CONFIG_DRM_PANEL) += drm_panel.o
 obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
 obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
 
+drm_pixel_helper-y := \
+	drm_pixel_helper_common.o
+obj-$(CONFIG_DRM_PIXEL_HELPER) += drm_pixel_helper.o
+
 #
 # Memory-management helpers
 #
drivers/gpu/drm/drm_pixel_helper_common.c new file +6 -0
new file mode 100644
index 000000000000..743846e1e003
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+
+#include <linux/module.h>
+
+MODULE_DESCRIPTION("DRM pixel-data helpers");
+MODULE_LICENSE("GPL and additional rights");
Signature · 1 line
2.56.0
#2 lore raw

Re: [PATCH 1/4] drm: Add helper module for working with pixel data

Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

Add drm_pixel_helper.ko. This module will contain helpers that copy and process pixel data, such as framebuffers. Drivers that want to use the helpers should select DRM_PIXEL_HELPER.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw

PATCH 2/4 drm/pixel: Link format helpers into drm_pixel_helper.ko

In reply to Thomas Zimmermann

Move drm_format_helper.o from drm_kms_helper.ko to drm_pixel_helper.ko. Select DRM_PIXEL_HELPER from the drivers that use the format helpers. While at it, include <drm/drm_format_helper.h> in a few places where it is missing.

Format helpers copy pixel data from a DRM framebuffer to a hardware scanout buffer or some other destination. They can transform the color format as part of the copying operation. A number of drivers require this functionality as part of their display update.

The format helpers are currently part of drm_kms_helper.ko, which is for mode-setting helpers (i.e, helpers that modify the display pipeline).

---
 drivers/gpu/drm/Kconfig                        | 1 +
 drivers/gpu/drm/Kconfig.debug                  | 1 +
 drivers/gpu/drm/Makefile                       | 2 +-
 drivers/gpu/drm/ast/Kconfig                    | 1 +
 drivers/gpu/drm/gud/Kconfig                    | 1 +
 drivers/gpu/drm/hisilicon/hibmc/Kconfig        | 1 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 1 +
 drivers/gpu/drm/hyperv/Kconfig                 | 1 +
 drivers/gpu/drm/mgag200/Kconfig                | 1 +
 drivers/gpu/drm/sitronix/Kconfig               | 2 ++
 drivers/gpu/drm/solomon/Kconfig                | 1 +
 drivers/gpu/drm/sysfb/Kconfig                  | 1 +
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c      | 1 +
 drivers/gpu/drm/tiny/Kconfig                   | 6 ++++++
 drivers/gpu/drm/tiny/bochs.c                   | 1 +
 15 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/Kconfig +1 -0
index dce5e25671ee..8e4a588e9111 100644
@@ -37,6 +37,7 @@ config DRM_MIPI_DBI
 	tristate
 	depends on DRM
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 
 config DRM_MIPI_DSI
 	bool
drivers/gpu/drm/Kconfig.debug +1 -0
index b909cd0a619f..1afb9cad850f 100644
@@ -70,6 +70,7 @@ config DRM_KUNIT_TEST
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KUNIT_TEST_HELPERS
 	select DRM_PANIC_HELPER
+	select DRM_PIXEL_HELPER
 	select DRM_SYSFB_HELPER
 	select PRIME_NUMBERS
 	default KUNIT_ALL_TESTS
drivers/gpu/drm/Makefile +1 -1
index 5f555a2c1a4c..fbc643747110 100644
@@ -100,6 +100,7 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
 obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
 
 drm_pixel_helper-y := \
+	drm_format_helper.o \
 	drm_pixel_helper_common.o
 obj-$(CONFIG_DRM_PIXEL_HELPER) += drm_pixel_helper.o
 
@@ -150,7 +151,6 @@ drm_kms_helper-y := \
 	drm_crtc_helper.o \
 	drm_damage_helper.o \
 	drm_flip_work.o \
-	drm_format_helper.o \
 	drm_gem_atomic_helper.o \
 	drm_gem_framebuffer_helper.o \
 	drm_kms_helper_common.o \
drivers/gpu/drm/ast/Kconfig +1 -0
index 242fbccdf844..1758debb8317 100644
@@ -5,6 +5,7 @@ config DRM_AST
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	select I2C
 	select I2C_ALGOBIT
 	help
drivers/gpu/drm/gud/Kconfig +1 -0
index b4d2136942f0..385702103633 100644
@@ -7,6 +7,7 @@ config DRM_GUD
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_SHMEM_HELPER
+	select DRM_PIXEL_HELPER
 	select BACKLIGHT_CLASS_DEVICE
 	help
 	  This is a DRM display driver for GUD USB Displays or display
drivers/gpu/drm/hisilicon/hibmc/Kconfig +1 -0
index adf4516bf8f6..f896f8cb8689 100644
@@ -7,6 +7,7 @@ config DRM_HISI_HIBMC
 	select DRM_DISPLAY_DP_HELPER
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	select I2C
 	select I2C_ALGOBIT
 	help
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +1 -0
index 7849abd0488e..aaef70153f7e 100644
@@ -17,6 +17,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_fourcc.h>
+#include <drm/drm_format_helper.h>
 #include <drm/drm_gem_atomic_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_vblank.h>
drivers/gpu/drm/hyperv/Kconfig +1 -0
index 86234f6a73f2..21146ed294e3 100644
@@ -5,6 +5,7 @@ config DRM_HYPERV
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_SHMEM_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	 This is a KMS driver for Hyper-V synthetic video device. Choose this
 	 option if you would like to enable drm driver for Hyper-V virtual
drivers/gpu/drm/mgag200/Kconfig +1 -0
index a962ae564a75..06bb23a888f9 100644
@@ -5,6 +5,7 @@ config DRM_MGAG200
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	select I2C
 	select I2C_ALGOBIT
 	help
drivers/gpu/drm/sitronix/Kconfig +2 -0
index 41a428ef8295..c4b54f4f4f69 100644
@@ -4,6 +4,7 @@ config DRM_ST7571
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	select VIDEOMODE_HELPERS
 	help
 	  Sitronix ST7571 is a driver and controller for 4-level gray
@@ -46,6 +47,7 @@ config DRM_ST7586
 	select DRM_KMS_HELPER
 	select DRM_GEM_DMA_HELPER
 	select DRM_MIPI_DBI
+	select DRM_PIXEL_HELPER
 	help
 	  DRM driver for the following Sitronix ST7586 panels:
 	  * LEGO MINDSTORMS EV3
drivers/gpu/drm/solomon/Kconfig +1 -0
index 400a6cab3a67..b65daabb2e96 100644
@@ -5,6 +5,7 @@ config DRM_SSD130X
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	  DRM driver for the SSD13xx Solomon and SINO WEALTH SH110x OLED
 	  controllers. This is only for the core driver, a driver for the
drivers/gpu/drm/sysfb/Kconfig +1 -0
index f7e48178885e..eaf6b8d1cd51 100644
@@ -5,6 +5,7 @@ menu "Drivers for system framebuffers"
 
 config DRM_SYSFB_HELPER
 	tristate
+	select DRM_PIXEL_HELPER
 	depends on DRM
 
 config DRM_COREBOOTDRM
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +1 -0
index 13df0925163a..c403c168c4c3 100644
@@ -10,6 +10,7 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_fourcc.h>
+#include <drm/drm_format_helper.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_panic.h>
drivers/gpu/drm/tiny/Kconfig +6 -0
index f0e72d4b6a47..176d75ce17ea 100644
@@ -6,6 +6,7 @@ config DRM_APPLETBDRM
 	depends on X86 || COMPILE_TEST
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	  Say Y here if you want support for the display of Touch Bars on x86
 	  MacBook Pros.
@@ -30,6 +31,7 @@ config DRM_BOCHS
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	  This is a KMS driver for qemu's stdvga output. Choose this option
 	  for qemu.
@@ -42,6 +44,7 @@ config DRM_CIRRUS_QEMU
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_SHMEM_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	 This is a KMS driver for emulated cirrus device in qemu.
 	 It is *NOT* intended for real cirrus devices. This requires
@@ -62,6 +65,7 @@ config DRM_GM12U320
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_SHMEM_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	 This is a KMS driver for projectors which use the GM12U320 chipset
 	 for video transfer over USB2/3, such as the Acer C120 mini projector.
@@ -186,6 +190,7 @@ config TINYDRM_REPAPER
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_DMA_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	  DRM driver for the following Pervasive Displays panels:
 	  1.44" TFT EPD Panel (E1144CS021)
@@ -201,6 +206,7 @@ config TINYDRM_SHARP_MEMORY
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_DMA_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	help
 	  DRM Driver for the following Sharp Memory Panels:
 	  * 1.00" Sharp Memory LCD (LS010B7DH04)
drivers/gpu/drm/tiny/bochs.c +1 -0
index 8192decddbc1..2744fe26dbeb 100644
@@ -13,6 +13,7 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_fbdev_shmem.h>
 #include <drm/drm_fourcc.h>
+#include <drm/drm_format_helper.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_gem_atomic_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
Signature · 1 line
2.56.0
#4 lore raw

Re: [PATCH 2/4] drm/pixel: Link format helpers into drm_pixel_helper.ko

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] drm: undefined drm_format_conv_state_*() references in drm_kms_helper - [Low] drm/sitronix: missing…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] drm: undefined drm_format_conv_state_*() references in drm_kms_helper
- [Low] drm/sitronix: missing DRM_PIXEL_HELPER select in config DRM_ST7920 --

commit 5297070737eb21b200d62be5b5e13861b6e29b57
Author: Thomas Zimmermann <[email protected]>

drm/pixel: Link format helpers into drm_pixel_helper.ko

This commit moves drm_format_helper.o from drm_kms_helper.ko into drm_pixel_helper.ko and updates drivers using format helpers to select DRM_PIXEL_HELPER and include <drm/drm_format_helper.h>.

Quoted 13 lines
drivers/gpu/drm/Makefile +1 -0
index 5f555a2c1a4c8..fbc643747110f 100644
@@ -100,6 +100,7 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
 obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
 
 drm_pixel_helper-y := \
+	drm_format_helper.o \
 	drm_pixel_helper_common.o
 obj-$(CONFIG_DRM_PIXEL_HELPER) += drm_pixel_helper.o
 

drivers/gpu/drm/Makefile drm_kms_helper-y := \ · line 156

Quoted 7 lines
drivers/gpu/drm/Makefile +0 -1
@@ -150,7 +151,6 @@ drm_kms_helper-y := \
 	drm_crtc_helper.o \
 	drm_damage_helper.o \
 	drm_flip_work.o \
-	drm_format_helper.o \
 	drm_gem_atomic_helper.o \
 	drm_gem_framebuffer_helper.o \
 	drm_kms_helper_common.o \

[Severity: Low]
Will moving drm_format_helper.o to drm_pixel_helper-y while leaving drm_gem_atomic_helper.o in drm_kms_helper-y cause undefined symbol references when CONFIG_DRM_KMS_HELPER is enabled without CONFIG_DRM_PIXEL_HELPER (or when CONFIG_DRM_KMS_HELPER=y and CONFIG_DRM_PIXEL_HELPER=m)?

In drivers/gpu/drm/drm_gem_atomic_helper.c, the shadow plane helpers call functions defined in drivers/gpu/drm/drm_format_helper.c:

drivers/gpu/drm/drm_gem_atomic_helper.c:
__drm_gem_shadow_plane_state_init()

	__drm_atomic_helper_plane_state_init(&shadow_plane_state->base, plane);
	drm_format_conv_state_init(&shadow_plane_state->fmtcnv_state);

__drm_gem_duplicate_shadow_plane_state()

	drm_format_conv_state_copy(&new_shadow_plane_state->fmtcnv_state,
				   &shadow_plane_state->fmtcnv_state);

__drm_gem_destroy_shadow_plane_state()

	drm_format_conv_state_release(&shadow_plane_state->fmtcnv_state);
	__drm_atomic_helper_plane_destroy_state(&shadow_plane_state->base);

Because config DRM_KMS_HELPER in drivers/gpu/drm/Kconfig does not select DRM_PIXEL_HELPER, linking drm_kms_helper fails with undefined references to drm_format_conv_state_init(), drm_format_conv_state_copy(), and drm_format_conv_state_release().

[ ... ]

Quoted 13 lines
drivers/gpu/drm/sitronix/Kconfig +1 -0
index 41a428ef8295e..c4b54f4f4f69a 100644
@@ -4,6 +4,7 @@ config DRM_ST7571
 	select DRM_CLIENT_SELECTION
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER
 	select VIDEOMODE_HELPERS
 	help
 	  Sitronix ST7571 is a driver and controller for 4-level gray

drivers/gpu/drm/sitronix/Kconfig config DRM_ST7586 · line 53

Quoted 7 lines
drivers/gpu/drm/sitronix/Kconfig +1 -0
@@ -46,6 +47,7 @@ config DRM_ST7586
 	select DRM_KMS_HELPER
 	select DRM_GEM_DMA_HELPER
 	select DRM_MIPI_DBI
+	select DRM_PIXEL_HELPER
 	help
 	  DRM driver for the following Sitronix ST7586 panels:
 	  * LEGO MINDSTORMS EV3

[Severity: Low]
Should config DRM_ST7920 in drivers/gpu/drm/sitronix/Kconfig also select DRM_PIXEL_HELPER (and include <drm/drm_format_helper.h> in drivers/gpu/drm/sitronix/st7920.c)?

In drivers/gpu/drm/sitronix/st7920.c, the driver calls format helpers directly:

st7920_fb_blit_rect()

	iosys_map_set_vaddr(&dst, buf);
	drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, vmap, fb, rect, fmtcnv_state);

st7920_primary_plane_atomic_check()

	/* format conversion necessary; reserve buffer */
	buf = drm_format_conv_state_reserve(&shadow_plane_state->fmtcnv_state,
					    pitch, GFP_KERNEL);

Without selecting DRM_PIXEL_HELPER in DRM_ST7920, building st7920 when CONFIG_DRM_PIXEL_HELPER is disabled (or when CONFIG_DRM_ST7920=y and CONFIG_DRM_PIXEL_HELPER=m) fails with undefined references to drm_fb_xrgb8888_to_mono() and drm_format_conv_state_reserve().

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#5 lore raw

PATCH 3/4 drm/pixel: Link panic helpers into drm_pixel_helper.ko

In reply to Thomas Zimmermann

Move panic helpers from drm_kms_helper to drm_pixel_helper.ko. Select DRM_PIXEL_HELPER in the drivers that use the panic helpers.

Drop the Kconfig option DRM_PANIC_HELPER. With the user selecting panic support via DRM_PANIC, panic helpers will become available to drivers.

Related module init and exit functions are now declared in the new header file drm_pixel_helper_internal.h. Other internal functions for pixel helpers can later go there as well.

---
 drivers/gpu/drm/Kconfig                     |  9 ++-------
 drivers/gpu/drm/Kconfig.debug               |  1 -
 drivers/gpu/drm/Makefile                    |  4 ++--
 drivers/gpu/drm/amd/amdgpu/Kconfig          |  1 +
 drivers/gpu/drm/drm_kms_helper_common.c     | 13 -------------
 drivers/gpu/drm/drm_panic_helper.c          |  1 +
 drivers/gpu/drm/drm_panic_internal.h        | 14 --------------
 drivers/gpu/drm/drm_pixel_helper_common.c   | 14 ++++++++++++++
 drivers/gpu/drm/drm_pixel_helper_internal.h | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/Kconfig                |  1 +
 drivers/gpu/drm/imx/ipuv3/Kconfig           |  1 +
 drivers/gpu/drm/nouveau/Kconfig             |  1 +
 drivers/gpu/drm/renesas/rcar-du/Kconfig     |  1 +
 drivers/gpu/drm/renesas/shmobile/Kconfig    |  1 +
 drivers/gpu/drm/tidss/Kconfig               |  1 +
 drivers/gpu/drm/virtio/Kconfig              |  1 +
 16 files changed, 47 insertions(+), 37 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_pixel_helper_internal.h
drivers/gpu/drm/Kconfig +2 -7
index 8e4a588e9111..bf7c59944340 100644
@@ -46,13 +46,14 @@ config DRM_MIPI_DSI
 config DRM_KMS_HELPER
 	tristate
 	depends on DRM
-	select DRM_PANIC_HELPER if DRM_PANIC
 	help
 	  CRTC helpers for KMS drivers.
 
 config DRM_PIXEL_HELPER
 	tristate
 	depends on DRM
+	select DRM_DRAW if DRM_PANIC
+	select FONT_SUPPORT if DRM_PANIC
 	help
 	  Helpers for working with pixel data in DRM.
 
@@ -135,12 +136,6 @@ config DRM_PANIC_SCREEN_QR_VERSION
 	  Smaller QR code are easier to read, but will contain less debugging
 	  data. Default is 40.
 
-config DRM_PANIC_HELPER
-	bool
-	depends on DRM
-	select DRM_DRAW
-	select FONT_SUPPORT
-
 config DRM_RAS
 	bool "DRM RAS support"
 	depends on DRM
drivers/gpu/drm/Kconfig.debug +0 -1
index 1afb9cad850f..4573cad368a2 100644
@@ -69,7 +69,6 @@ config DRM_KUNIT_TEST
 	select DRM_EXPORT_FOR_TESTS if m
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KUNIT_TEST_HELPERS
-	select DRM_PANIC_HELPER
 	select DRM_PIXEL_HELPER
 	select DRM_SYSFB_HELPER
 	select PRIME_NUMBERS
drivers/gpu/drm/Makefile +2 -2
index fbc643747110..18a5a5baf029 100644
@@ -102,6 +102,8 @@ obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
 drm_pixel_helper-y := \
 	drm_format_helper.o \
 	drm_pixel_helper_common.o
+drm_pixel_helper-$(CONFIG_DRM_PANIC) += drm_panic_helper.o
+drm_pixel_helper-$(CONFIG_DRM_PANIC_SCREEN_QR_CODE) += drm_panic_helper_qr.o
 obj-$(CONFIG_DRM_PIXEL_HELPER) += drm_pixel_helper.o
 
 #
@@ -160,8 +162,6 @@ drm_kms_helper-y := \
 	drm_self_refresh_helper.o \
 	drm_simple_kms_helper.o \
 	drm_vblank_helper.o
-drm_kms_helper-$(CONFIG_DRM_PANIC_HELPER) += drm_panic_helper.o
-drm_kms_helper-$(CONFIG_DRM_PANIC_SCREEN_QR_CODE) += drm_panic_helper_qr.o
 obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 
 #
drivers/gpu/drm/amd/amdgpu/Kconfig +1 -0
index 12e4a41bf1f0..78584d8aeb52 100644
@@ -12,6 +12,7 @@ config DRM_AMDGPU
 	select DRM_DISPLAY_HDCP_HELPER
 	select DRM_DISPLAY_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select DRM_SCHED
 	select DRM_TTM
 	select DRM_TTM_HELPER
drivers/gpu/drm/drm_kms_helper_common.c +0 -13
index 1e55ecac4698..76c7297b24e9 100644
@@ -30,7 +30,6 @@
 #include <linux/moduleparam.h>
 
 #include "drm_crtc_helper_internal.h"
-#include "drm_panic_internal.h"
 
 #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
 bool drm_fbdev_emulation = true;
@@ -68,18 +67,6 @@ MODULE_PARM_DESC(drm_leak_fbdev_smem,
 
 #endif
 
-static int __init drm_kms_helper_init(void)
-{
-	return drm_panic_helper_init();
-}
-module_init(drm_kms_helper_init);
-
-static void __exit drm_kms_helper_exit(void)
-{
-	drm_panic_helper_exit();
-}
-module_exit(drm_kms_helper_exit);
-
 MODULE_AUTHOR("David Airlie, Jesse Barnes");
 MODULE_DESCRIPTION("DRM KMS helper");
 MODULE_LICENSE("GPL and additional rights");
drivers/gpu/drm/drm_panic_helper.c +1 -0
index 8913c3d22e8d..6f0d3a2df6b3 100644
@@ -20,6 +20,7 @@
 
 #include "drm_draw_internal.h"
 #include "drm_panic_internal.h"
+#include "drm_pixel_helper_internal.h"
 
 struct drm_panic_line {
 	u32 len;
drivers/gpu/drm/drm_panic_internal.h +0 -14
index fe6d514a0833..c68d64c56e15 100644
@@ -52,18 +52,4 @@ static inline void drm_panic_lock(struct drm_device *dev, unsigned long flags) {
 static inline void drm_panic_unlock(struct drm_device *dev, unsigned long flags) {}
 #endif
 
-#if IS_ENABLED(CONFIG_DRM_PANIC_HELPER)
-/* drm_panic_helper.c */
-int __init drm_panic_helper_init(void);
-void __exit drm_panic_helper_exit(void);
-#else
-static inline int __init drm_panic_helper_init(void)
-{
-	return 0;
-}
-
-static inline void __exit drm_panic_helper_exit(void)
-{ }
-#endif
-
 #endif /* __DRM_PANIC_INTERNAL_H__ */
drivers/gpu/drm/drm_pixel_helper_common.c +14 -0
index 743846e1e003..0213c59b82f0 100644
@@ -2,5 +2,19 @@
 
 #include <linux/module.h>
 
+#include "drm_pixel_helper_internal.h"
+
+static int __init drm_pixel_helper_init(void)
+{
+	return drm_panic_helper_init();
+}
+module_init(drm_pixel_helper_init);
+
+static void __exit drm_pixel_helper_exit(void)
+{
+	drm_panic_helper_exit();
+}
+module_exit(drm_pixel_helper_exit);
+
 MODULE_DESCRIPTION("DRM pixel-data helpers");
 MODULE_LICENSE("GPL and additional rights");
drivers/gpu/drm/drm_pixel_helper_internal.h new file +20 -0
new file mode 100644
index 000000000000..1606cbb0a460
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+
+#ifndef DRM_PIXEL_HELPER_INTERNAL_H
+#define DRM_PIXEL_HELPER_INTERNAL_H
+
+#if IS_ENABLED(CONFIG_DRM_PANIC)
+/* drm_panic_helper.c */
+int __init drm_panic_helper_init(void);
+void __exit drm_panic_helper_exit(void);
+#else
+static inline int __init drm_panic_helper_init(void)
+{
+	return 0;
+}
+
+static inline void __exit drm_panic_helper_exit(void)
+{ }
+#endif
+
+#endif
drivers/gpu/drm/i915/Kconfig +1 -0
index 5e939004b646..1c65b14bf0f4 100644
@@ -19,6 +19,7 @@ config DRM_I915
 	select DRM_KMS_HELPER
 	select DRM_PANEL
 	select DRM_MIPI_DSI
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
 	select RELAY
 	select I2C
drivers/gpu/drm/imx/ipuv3/Kconfig +1 -0
index 3ca237515e46..19b51835cdd3 100644
@@ -3,6 +3,7 @@ config DRM_IMX
 	tristate "DRM Support for Freescale i.MX"
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select VIDEOMODE_HELPERS
 	select DRM_GEM_DMA_HELPER
 	depends on DRM && (ARCH_MXC || COMPILE_TEST)
drivers/gpu/drm/nouveau/Kconfig +1 -0
index 3b5757aed9c8..3850b27861fa 100644
@@ -10,6 +10,7 @@ config DRM_NOUVEAU
 	select DRM_DISPLAY_HDMI_HELPER
 	select DRM_DISPLAY_HELPER
 	select DRM_KMS_HELPER
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select DRM_TTM
 	select DRM_TTM_HELPER
 	select DRM_EXEC
drivers/gpu/drm/renesas/rcar-du/Kconfig +1 -0
index 80bd770ae0f6..33337ff84c2e 100644
@@ -9,6 +9,7 @@ config DRM_RCAR_DU
 	select DRM_DISPLAY_HELPER
 	select DRM_BRIDGE_CONNECTOR
 	select DRM_GEM_DMA_HELPER
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select VIDEOMODE_HELPERS
 	help
 	  Choose this option if you have an R-Car chipset.
drivers/gpu/drm/renesas/shmobile/Kconfig +1 -0
index 52e160464001..dbb86f068499 100644
@@ -9,6 +9,7 @@ config DRM_SHMOBILE
 	select DRM_DISPLAY_HELPER
 	select DRM_BRIDGE_CONNECTOR
 	select DRM_GEM_DMA_HELPER
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select VIDEOMODE_HELPERS
 	help
 	  Choose this option if you have an SH Mobile chipset.
drivers/gpu/drm/tidss/Kconfig +1 -0
index 52a64fa1ad5d..be60ec720544 100644
@@ -8,6 +8,7 @@ config DRM_TIDSS
 	select DRM_BRIDGE_CONNECTOR
 	select DRM_GEM_DMA_HELPER
 	select DRM_PANEL
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	help
 	  The TI Keystone family SoCs introduced a new generation of
 	  Display SubSystem. There is currently three Keystone family
drivers/gpu/drm/virtio/Kconfig +1 -0
index fc884fb57b7e..6440a8f39e04 100644
@@ -6,6 +6,7 @@ config DRM_VIRTIO_GPU
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_SHMEM_HELPER
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select VIRTIO_DMA_SHARED_BUFFER
 	help
 	   This is the virtual GPU driver for virtio.  It can be used with
Signature · 1 line
2.56.0
#6 lore raw

Re: [PATCH 3/4] drm/pixel: Link panic helpers into drm_pixel_helper.ko

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Low] drm: missing DRM_PIXEL_HELPER select in DRM_KMS_HELPER for drm_crtc_init() - [Low] drm/tests: link…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] drm: missing DRM_PIXEL_HELPER select in DRM_KMS_HELPER for drm_crtc_init()
- [Low] drm/tests: link failure in drm_panic_helper_test when CONFIG_DRM_PANIC=n
- [Low] drm/xe: missing DRM_PIXEL_HELPER dependency when DRM_PANIC=y
--

commit d010f0f67d242682650aa0651dfd5a1e57612943
Author: Thomas Zimmermann <[email protected]>

drm/pixel: Link panic helpers into drm_pixel_helper.ko

This commit moves the DRM panic helpers from drm_kms_helper into drm_pixel_helper.ko, drops the DRM_PANIC_HELPER Kconfig option, and selects DRM_PIXEL_HELPER in drivers using the panic helpers.

drivers/gpu/drm/Kconfig config DRM_MIPI_DSI · line 50

Quoted 11 lines
drivers/gpu/drm/Kconfig +0 -1
index 8e4a588e9111d..bf7c599443403 100644
@@ -46,13 +46,14 @@ config DRM_MIPI_DSI
 config DRM_KMS_HELPER
 	tristate
 	depends on DRM
-	select DRM_PANIC_HELPER if DRM_PANIC
 	help
 	  CRTC helpers for KMS drivers.

[Severity: Low]
Does DRM_KMS_HELPER also need to select DRM_PIXEL_HELPER if DRM_PANIC?

drivers/gpu/drm/drm_modeset_helper.c is unconditionally compiled into drm_kms_helper, and its primary_plane_funcs structure (used by drm_crtc_init()) includes DRM_PANIC_PLANE_FUNCS:

drivers/gpu/drm/drm_modeset_helper.c:

    static const struct drm_plane_funcs primary_plane_funcs = {
            DRM_PLANE_NON_ATOMIC_FUNCS,
            DRM_PANIC_PLANE_FUNCS,
    };

When CONFIG_DRM_PANIC is enabled, DRM_PANIC_PLANE_FUNCS expands in include/drm/drm_panic_helper.h to reference drm_plane_helper_display_panic_screen, which is now built into drm_pixel_helper. If CONFIG_DRM_PANIC=y and DRM_KMS_HELPER is enabled without a matching built-in or modular DRM_PIXEL_HELPER, linking fails with an undefined reference to drm_plane_helper_display_panic_screen.

[ ... ]

drivers/gpu/drm/Kconfig.debug config DRM_KUNIT_TEST · line 74

Quoted 12 lines
drivers/gpu/drm/Kconfig.debug +0 -1
index 1afb9cad850f6..4573cad368a28 100644
@@ -69,7 +69,6 @@ config DRM_KUNIT_TEST
 	select DRM_EXPORT_FOR_TESTS if m
 	select DRM_GEM_SHMEM_HELPER
 	select DRM_KUNIT_TEST_HELPERS
-	select DRM_PANIC_HELPER
 	select DRM_PIXEL_HELPER
 	select DRM_SYSFB_HELPER
 	select PRIME_NUMBERS

[Severity: Low]
Can removing select DRM_PANIC_HELPER from DRM_KUNIT_TEST cause a link failure when CONFIG_DRM_PANIC is disabled?

With this change, drm_panic_helper.o is only built into drm_pixel_helper when CONFIG_DRM_PANIC is enabled:

drivers/gpu/drm/Makefile:

    drm_pixel_helper-$(CONFIG_DRM_PANIC) += drm_panic_helper.o

However, drivers/gpu/drm/tests/Makefile still builds drm_panic_helper_test.o unconditionally under obj-$(CONFIG_DRM_KUNIT_TEST), and functions such as drm_panic_helper_draw_screen_user_default() in drivers/gpu/drm/tests/drm_panic_helper_test.c call drm_panic_helper_draw_screen_user(), drm_panic_helper_draw_screen_kmsg(), drm_panic_helper_set_description(), and drm_panic_helper_clear_description(). When CONFIG_DRM_KUNIT_TEST is enabled and CONFIG_DRM_PANIC=n, linking fails with undefined references to those symbols.

[ ... ]

drivers/gpu/drm/i915/Kconfig config DRM_I915 · line 25

Quoted 12 lines
drivers/gpu/drm/i915/Kconfig +1 -0
index 71426b9c91f00..f698d3c8daa9e 100644
@@ -19,6 +19,7 @@ config DRM_I915
 	select DRM_KMS_HELPER
 	select DRM_PANEL
 	select DRM_MIPI_DSI
+	select DRM_PIXEL_HELPER if DRM_PANIC
 	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
 	select RELAY
 	select I2C

[Severity: Low]
Should DRM_XE or DRM_XE_DISPLAY in drivers/gpu/drm/xe/Kconfig also select DRM_PIXEL_HELPER if DRM_PANIC?

When CONFIG_DRM_XE_DISPLAY=y, drivers/gpu/drm/xe/Makefile compiles drivers/gpu/drm/i915/display/skl_universal_plane.c into xe.ko, where skl_plane_funcs, icl_plane_funcs, and tgl_plane_funcs use DRM_PANIC_PLANE_FUNCS:

drivers/gpu/drm/i915/display/skl_universal_plane.c:

    static const struct drm_plane_funcs skl_plane_funcs = {
            ...
            DRM_PANIC_PLANE_FUNCS,
    };

If CONFIG_DRM_XE=m, CONFIG_DRM_XE_DISPLAY=y, and CONFIG_DRM_PANIC=y are enabled while CONFIG_DRM_PIXEL_HELPER=n, modpost fails with an undefined reference to drm_plane_helper_display_panic_screen in xe.ko.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author maintainer
#7 lore raw

Re: [PATCH 3/4] drm/pixel: Link panic helpers into drm_pixel_helper.ko

Am 19.10.26 um 18:19 schrieb [email protected]:

Quoted 2 lines

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] drm: missing DRM_PIXEL_HELPER select in DRM_KMS_HELPER for drm_crtc_init()

I see this is still an issue. The fix here is to move drm_crtc_init() into drivers. The only remaining callers of drm_crtc_init() are in radeon and amdgpu. There was recently a patch to move the helper there, [1] but the effort appears to have stalled.

[1] https://lore.kernel.org/dri-devel/[email protected]/

I'll do this before continuing with the pixel helpers.

Quoted 113 lines

- [Low] drm/tests: link failure in drm_panic_helper_test when CONFIG_DRM_PANIC=n
- [Low] drm/xe: missing DRM_PIXEL_HELPER dependency when DRM_PANIC=y --

commit d010f0f67d242682650aa0651dfd5a1e57612943
Author: Thomas Zimmermann <[email protected]>

drm/pixel: Link panic helpers into drm_pixel_helper.ko

This commit moves the DRM panic helpers from drm_kms_helper into drm_pixel_helper.ko, drops the DRM_PANIC_HELPER Kconfig option, and selects DRM_PIXEL_HELPER in drivers using the panic helpers.

drivers/gpu/drm/Kconfig config DRM_MIPI_DSI · line 50

Quoted 11 lines
drivers/gpu/drm/Kconfig +0 -1
index 8e4a588e9111d..bf7c599443403 100644
@@ -46,13 +46,14 @@ config DRM_MIPI_DSI
  config DRM_KMS_HELPER
  	tristate
  	depends on DRM
-	select DRM_PANIC_HELPER if DRM_PANIC
  	help
  	  CRTC helpers for KMS drivers.

[Severity: Low]
Does DRM_KMS_HELPER also need to select DRM_PIXEL_HELPER if DRM_PANIC?

drivers/gpu/drm/drm_modeset_helper.c is unconditionally compiled into drm_kms_helper, and its primary_plane_funcs structure (used by drm_crtc_init()) includes DRM_PANIC_PLANE_FUNCS:

drivers/gpu/drm/drm_modeset_helper.c:

     static const struct drm_plane_funcs primary_plane_funcs = {
             DRM_PLANE_NON_ATOMIC_FUNCS,
             DRM_PANIC_PLANE_FUNCS,
     };

When CONFIG_DRM_PANIC is enabled, DRM_PANIC_PLANE_FUNCS expands in include/drm/drm_panic_helper.h to reference drm_plane_helper_display_panic_screen, which is now built into drm_pixel_helper. If CONFIG_DRM_PANIC=y and DRM_KMS_HELPER is enabled without a matching built-in or modular DRM_PIXEL_HELPER, linking fails with an undefined reference to drm_plane_helper_display_panic_screen.

[ ... ]

drivers/gpu/drm/Kconfig.debug config DRM_KUNIT_TEST · line 74

Quoted 12 lines
drivers/gpu/drm/Kconfig.debug +0 -1
index 1afb9cad850f6..4573cad368a28 100644
@@ -69,7 +69,6 @@ config DRM_KUNIT_TEST
  	select DRM_EXPORT_FOR_TESTS if m
  	select DRM_GEM_SHMEM_HELPER
  	select DRM_KUNIT_TEST_HELPERS
-	select DRM_PANIC_HELPER
  	select DRM_PIXEL_HELPER
  	select DRM_SYSFB_HELPER
  	select PRIME_NUMBERS

[Severity: Low]
Can removing select DRM_PANIC_HELPER from DRM_KUNIT_TEST cause a link failure when CONFIG_DRM_PANIC is disabled?

With this change, drm_panic_helper.o is only built into drm_pixel_helper when CONFIG_DRM_PANIC is enabled:

drivers/gpu/drm/Makefile:

     drm_pixel_helper-$(CONFIG_DRM_PANIC) += drm_panic_helper.o

However, drivers/gpu/drm/tests/Makefile still builds drm_panic_helper_test.o unconditionally under obj-$(CONFIG_DRM_KUNIT_TEST), and functions such as drm_panic_helper_draw_screen_user_default() in drivers/gpu/drm/tests/drm_panic_helper_test.c call drm_panic_helper_draw_screen_user(), drm_panic_helper_draw_screen_kmsg(), drm_panic_helper_set_description(), and drm_panic_helper_clear_description(). When CONFIG_DRM_KUNIT_TEST is enabled and CONFIG_DRM_PANIC=n, linking fails with undefined references to those symbols.

[ ... ]

drivers/gpu/drm/i915/Kconfig config DRM_I915 · line 25

Quoted 12 lines
drivers/gpu/drm/i915/Kconfig +1 -0
index 71426b9c91f00..f698d3c8daa9e 100644
@@ -19,6 +19,7 @@ config DRM_I915
  	select DRM_KMS_HELPER
  	select DRM_PANEL
  	select DRM_MIPI_DSI
+	select DRM_PIXEL_HELPER if DRM_PANIC
  	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
  	select RELAY
  	select I2C

[Severity: Low]
Should DRM_XE or DRM_XE_DISPLAY in drivers/gpu/drm/xe/Kconfig also select DRM_PIXEL_HELPER if DRM_PANIC?

When CONFIG_DRM_XE_DISPLAY=y, drivers/gpu/drm/xe/Makefile compiles drivers/gpu/drm/i915/display/skl_universal_plane.c into xe.ko, where skl_plane_funcs, icl_plane_funcs, and tgl_plane_funcs use DRM_PANIC_PLANE_FUNCS:

drivers/gpu/drm/i915/display/skl_universal_plane.c:

     static const struct drm_plane_funcs skl_plane_funcs = {
             ...
             DRM_PANIC_PLANE_FUNCS,
     };

If CONFIG_DRM_XE=m, CONFIG_DRM_XE_DISPLAY=y, and CONFIG_DRM_PANIC=y are enabled while CONFIG_DRM_PIXEL_HELPER=n, modpost fails with an undefined reference to drm_plane_helper_display_panic_screen in xe.ko.

[ ... ]

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

PATCH 4/4 drm/pixel: Link draw helpers into drm_pixel_helper.ko

In reply to Thomas Zimmermann

Move drm_draw.o from the DRM core to drm_pixel_helper.ko. Remove the Kconfig option DRM_DRAW and provide the draw helpers unconditionally.

Having draw code in the DRM core is a left-over fro when panic handling was entirely located in the DRM core as well. With all the panic drawing in drm_pixel_helper.ko, the drawing helpers can go there as well. DRM's log clients also uses the drawing helpers for output. Update the Kconfig rules to select DRM_PIXEL_HELPER instead of DRM_DRAW for this client.

The format and the draw helpers share the per-pixel color-format code from drm_format_internal. Putting it all into one place will hopefully help with sharing more code in the future.

---
 drivers/gpu/drm/Kconfig                           | 5 -----
 drivers/gpu/drm/Makefile                          | 2 +-
 drivers/gpu/drm/clients/Kconfig                   | 2 +-
 drivers/gpu/drm/{drm_draw.c => drm_draw_helper.c} | 0
 4 files changed, 2 insertions(+), 7 deletions(-)
 rename drivers/gpu/drm/{drm_draw.c => drm_draw_helper.c} (100%)
drivers/gpu/drm/Kconfig +0 -5
index bf7c59944340..1b16e6101a53 100644
@@ -52,15 +52,10 @@ config DRM_KMS_HELPER
 config DRM_PIXEL_HELPER
 	tristate
 	depends on DRM
-	select DRM_DRAW if DRM_PANIC
 	select FONT_SUPPORT if DRM_PANIC
 	help
 	  Helpers for working with pixel data in DRM.
 
-config DRM_DRAW
-	bool
-	depends on DRM
-
 config DRM_PANIC
 	bool "Display a user-friendly message when a kernel panic occurs"
 	depends on DRM && PRINTK
drivers/gpu/drm/Makefile +1 -1
index 18a5a5baf029..ab9eb4c21264 100644
@@ -91,7 +91,6 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += \
 	drm_privacy_screen_x86.o
 drm-$(CONFIG_DRM_ACCEL) += ../../accel/drm_accel.o
 drm-$(CONFIG_DRM_PANIC) += drm_panic.o
-drm-$(CONFIG_DRM_DRAW) += drm_draw.o
 drm-$(CONFIG_DRM_RAS) += drm_ras.o drm_ras_nl.o drm_ras_genl_family.o
 obj-$(CONFIG_DRM)	+= drm.o
 
@@ -100,6 +99,7 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
 obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
 
 drm_pixel_helper-y := \
+	drm_draw_helper.o \
 	drm_format_helper.o \
 	drm_pixel_helper_common.o
 drm_pixel_helper-$(CONFIG_DRM_PANIC) += drm_panic_helper.o
drivers/gpu/drm/clients/Kconfig +1 -1
index 6096c623d9d5..8d21edc4cc5b 100644
@@ -3,6 +3,7 @@
 config DRM_CLIENT_LIB
 	tristate
 	depends on DRM
+	select DRM_PIXEL_HELPER if DRM_CLIENT_LOG
 	select DRM_KMS_HELPER if DRM_FBDEV_EMULATION
 	select FB_CORE if DRM_FBDEV_EMULATION
 	help
@@ -76,7 +77,6 @@ config DRM_CLIENT_LOG
 	depends on DRM_CLIENT_SELECTION
 	select DRM_CLIENT
 	select DRM_CLIENT_SETUP
-	select DRM_DRAW
 	select FONT_SUPPORT
 	help
 	  This enable a drm logger, that will print the kernel messages to the
drivers/gpu/drm/drm_draw_helper.c renamed from drivers/gpu/drm/drm_draw.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/drm_draw.c
rename to drivers/gpu/drm/drm_draw_helper.c
Signature · 1 line
2.56.0
#9 lore raw

Re: [PATCH 4/4] drm/pixel: Link draw helpers into drm_pixel_helper.ko

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] drm: missing DRM_PIXEL_HELPER dependency in DRM_KMS_HELPER - [Medium] drm/pixel: missing…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] drm: missing DRM_PIXEL_HELPER dependency in DRM_KMS_HELPER
- [Medium] drm/pixel: missing DRM_PIXEL_HELPER select in DRM_ST7920, DRM_XE, and DRM_KMS_HELPER
- [Low] drm/pixel: stale drm_draw.c reference in MAINTAINERS after rename
- [Low] drm: drm_panic_helper.o omitted when DRM_KUNIT_TEST=y and DRM_PANIC=n
--

commit 8f1149ac31f00f33aec39cba3d1477d5b9456a23
Author: Thomas Zimmermann <[email protected]>

drm/pixel: Link draw helpers into drm_pixel_helper.ko

This commit moves drm_draw.c (renamed to drm_draw_helper.c) from the DRM core into drm_pixel_helper.ko, removes the DRM_DRAW Kconfig symbol, and updates DRM_CLIENT_LIB to select DRM_PIXEL_HELPER when DRM_CLIENT_LOG is enabled.

Quoted 10 lines
drivers/gpu/drm/Kconfig +0 -1
index bf7c599443403..1b16e6101a53a 100644
@@ -52,15 +52,10 @@ config DRM_KMS_HELPER
 config DRM_PIXEL_HELPER
 	tristate
 	depends on DRM
-	select DRM_DRAW if DRM_PANIC
 	select FONT_SUPPORT if DRM_PANIC

drivers/gpu/drm/Kconfig config DRM_KMS_HELPER · line 61

Quoted 10 lines
drivers/gpu/drm/Kconfig +0 -4
 	help
 	  Helpers for working with pixel data in DRM.
 
-config DRM_DRAW
-	bool
-	depends on DRM
-
 config DRM_PANIC
 	bool "Display a user-friendly message when a kernel panic occurs"
 	depends on DRM && PRINTK

[Severity: High]
With drm_format_helper.o and drm_panic_helper.o moved from drm_kms_helper.ko into drm_pixel_helper.ko in this series, does DRM_KMS_HELPER in drivers/gpu/drm/Kconfig also need to select DRM_PIXEL_HELPER?

In drivers/gpu/drm/Makefile, drm_kms_helper.o unconditionally links in drm_gem_atomic_helper.o and drm_modeset_helper.o.

In drivers/gpu/drm/drm_gem_atomic_helper.c, the shadow plane helpers call format conversion functions that are now in drm_pixel_helper.ko:

drivers/gpu/drm/drm_gem_atomic_helper.c:__drm_gem_shadow_plane_state_init() {
	__drm_atomic_helper_plane_state_init(&shadow_plane_state->base, plane);
	drm_format_conv_state_init(&shadow_plane_state->fmtcnv_state);
}

Along with drm_format_conv_state_copy() in __drm_gem_duplicate_shadow_plane_state() and drm_format_conv_state_release() in __drm_gem_destroy_shadow_plane_state().

Similarly, in drivers/gpu/drm/drm_modeset_helper.c, primary_plane_funcs uses DRM_PANIC_PLANE_FUNCS:

static const struct drm_plane_funcs primary_plane_funcs = {
DRM_PLANE_NON_ATOMIC_FUNCS, DRM_PANIC_PLANE_FUNCS,
};

When CONFIG_DRM_PANIC=y, DRM_PANIC_PLANE_FUNCS references drm_plane_helper_display_panic_screen(), which is now defined in drm_panic_helper.c inside drm_pixel_helper.ko.

Without DRM_KMS_HELPER selecting DRM_PIXEL_HELPER, won't configurations with CONFIG_DRM_KMS_HELPER enabled and CONFIG_DRM_PIXEL_HELPER=n (or CONFIG_DRM_KMS_HELPER=y and CONFIG_DRM_PIXEL_HELPER=m) fail to link with undefined references to drm_format_conv_state_init(), drm_format_conv_state_copy(), drm_format_conv_state_release(), and drm_plane_helper_display_panic_screen()?

[Severity: Medium]
Are there also a couple of drivers missing a select of DRM_PIXEL_HELPER after moving the format and panic helpers into drm_pixel_helper.ko?

1. In drivers/gpu/drm/sitronix/Kconfig, DRM_ST7571 and DRM_ST7586 were updated to select DRM_PIXEL_HELPER, but DRM_ST7920 was not:

config DRM_ST7920

	tristate "DRM support for Sitronix ST7920 LCD displays"
	depends on DRM && SPI && MMU
	select DRM_GEM_SHMEM_HELPER
	select DRM_KMS_HELPER
	select REGMAP_SPI

However, drivers/gpu/drm/sitronix/st7920.c calls drm_fb_xrgb8888_to_mono() in st7920_fb_blit_rect() and drm_format_conv_state_reserve() in st7920_primary_plane_atomic_check(), both of which are in drm_format_helper.c.

2. In drivers/gpu/drm/xe/Kconfig, neither DRM_XE nor DRM_XE_DISPLAY selects DRM_PIXEL_HELPER if DRM_PANIC (unlike DRM_I915), even though drivers/gpu/drm/xe/Makefile compiles i915-display/skl_universal_plane.o into xe.ko when CONFIG_DRM_XE_DISPLAY=y, which uses DRM_PANIC_PLANE_FUNCS and references drm_plane_helper_display_panic_screen().

Could these cause link failures when building DRM_ST7920 or DRM_XE without DRM_PIXEL_HELPER enabled?

Quoted 13 lines
drivers/gpu/drm/Makefile +0 -1
index 18a5a5baf0293..ab9eb4c212648 100644
@@ -91,7 +91,6 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += \
 	drm_privacy_screen_x86.o
 drm-$(CONFIG_DRM_ACCEL) += ../../accel/drm_accel.o
 drm-$(CONFIG_DRM_PANIC) += drm_panic.o
-drm-$(CONFIG_DRM_DRAW) += drm_draw.o
 drm-$(CONFIG_DRM_RAS) += drm_ras.o drm_ras_nl.o drm_ras_genl_family.o
 obj-$(CONFIG_DRM)	+= drm.o
 

drivers/gpu/drm/Makefile obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o · line 105

Quoted 7 lines
drivers/gpu/drm/Makefile +1 -0
@@ -100,6 +99,7 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
 obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
 
 drm_pixel_helper-y := \
+	drm_draw_helper.o \
 	drm_format_helper.o \
 	drm_pixel_helper_common.o
 drm_pixel_helper-$(CONFIG_DRM_PANIC) += drm_panic_helper.o

[Severity: Low]
What happens when CONFIG_DRM_KUNIT_TEST is enabled while CONFIG_DRM_PANIC=n (such as with the default drivers/gpu/drm/tests/.kunitconfig)?

In drivers/gpu/drm/tests/Makefile, drm_panic_helper_test.o is built unconditionally under CONFIG_DRM_KUNIT_TEST, and drivers/gpu/drm/tests/drm_panic_helper_test.c calls drm_panic_helper_draw_screen_user(), drm_panic_helper_draw_screen_kmsg(), drm_panic_helper_set_description(), and drm_panic_helper_clear_description():

static int drm_panic_helper_draw_screen_user_default(struct drm_scanout_buffer *sb)

{
	return drm_panic_helper_draw_screen_user(sb, 0x00ffffff, 0x00000000);
}

Previously, DRM_KUNIT_TEST selected DRM_PANIC_HELPER, which built drm_panic_helper.o and selected FONT_SUPPORT even when CONFIG_DRM_PANIC=n.

Now that DRM_KUNIT_TEST in drivers/gpu/drm/Kconfig.debug selects DRM_PIXEL_HELPER instead of DRM_PANIC_HELPER, and drm_panic_helper.o is only compiled into drm_pixel_helper when CONFIG_DRM_PANIC is enabled (and DRM_PIXEL_HELPER only selects FONT_SUPPORT if DRM_PANIC), won't building DRM_KUNIT_TEST with CONFIG_DRM_PANIC=n fail at link time with undefined references to the drm_panic_helper_* functions?

[ ... ]

drivers/gpu/drm/drm_draw_helper.c

Quoted 4 lines
drivers/gpu/drm/drm_draw_helper.c renamed from drivers/gpu/drm/drm_draw.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/drm_draw.c
rename to drivers/gpu/drm/drm_draw_helper.c

[Severity: Low]
Should theDRM PANIC entry in MAINTAINERS also be updated to reflect the rename from drivers/gpu/drm/drm_draw.c to drivers/gpu/drm/drm_draw_helper.c?

DRM PANIC
M: Jocelyn Falempe <[email protected]>
M: Javier Martinez Canillas <[email protected]>
L: [email protected]
S: Supported
T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
F: drivers/gpu/drm/drm_draw.c

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#10 lore raw

✗ Fi.CI.BUILD: failure for drm: Move drawing to pixel-helper module

In reply to Thomas Zimmermann
== Series Details ==

== Series Details ==

Series: drm: Move drawing to pixel-helper module
URL : https://patchwork.freedesktop.org/series/176408/
State : failure

== Summary ==

Error: make failed
DESCEND objtool
HDRTEST drivers/gpu/drm/xe/generated/xe_wa_oob.h
HDRTEST drivers/gpu/drm/xe/generated/xe_device_wa_oob.h
MODPOST Module.symvers
ERROR: modpost: drivers/gpu/drm/tests/drm_panic_helper_test.ko: symbol 'drm_panic_helper_clear_description' undefined!
ERROR: modpost: drivers/gpu/drm/tests/drm_panic_helper_test.ko: symbol 'drm_panic_helper_set_description' undefined!
ERROR: modpost: drivers/gpu/drm/tests/drm_panic_helper_test.ko: symbol 'drm_panic_helper_draw_screen_kmsg' undefined!
ERROR: modpost: drivers/gpu/drm/tests/drm_panic_helper_test.ko: symbol 'drm_panic_helper_draw_screen_user' undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1
make[1]: *** [/home/kbuild2/kernel/Makefile:2179: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2
Build failed, no error log produced