Skip to contentSkip to conversation

drm/tests: Move test EDID data to separate .c file

PATCH Superseded Nicolas Frattaroli 3 participants 3 messages Jun 10 – Jun 11

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/tests: Move test EDID data to separate .c file

Having the test EDID arrays defined in the .h directly will duplicate them across every user of the EDID arrays. This works fine as long as there's only one user, but may produce build warnings/errors when there are multiple users and not all of them use all definitions.

Move the array definitions to a new .c file, and mark the declarations in the header as "extern" to avoid the linker throwing a fit, and give them an explicit size (either 128 or 256, depending on EDID) to avoid the compiler inferring that they must be size 1.

Fixes ce1d0139adac ("drm/tests: bridge: Add test for HDMI output bus formats helper")
Fixes 082fbc179c01 ("drm/tests: bridge: Add KUnit tests for bridge chain format selection")

---
Changes in v2:
- Move comment blocks to .c file
- Add EXPORT_SYMBOL for all the definitions
- Link to v1: https://patch.msgid.link/20260610-test-edid-array-definition-fix-v1-1-4467ba487886@collabora.com

---
 drivers/gpu/drm/tests/Makefile         |   3 +-
 drivers/gpu/drm/tests/drm_kunit_edid.c | 991 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/tests/drm_kunit_edid.h | 985 +-------------------------------
 3 files changed, 1002 insertions(+), 977 deletions(-)
drivers/gpu/drm/tests/Makefile +2 -1
index 3b83e6616fb2..e7193b49cf91 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
 	drm_probe_helper_test.o \
 	drm_rect_test.o \
 	drm_sysfb_modeset_test.o \
-	drm_fixp_test.o
+	drm_fixp_test.o \
+	drm_kunit_edid.o
 
 CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
drivers/gpu/drm/tests/drm_kunit_edid.c new file +991 -0

991 lines not on this page · raw message

drivers/gpu/drm/tests/drm_kunit_edid.h +9 -976

990 lines not on this page · raw message

---
base-commit: 2df5efb45425b48fbf5a3c1f36a686af26871009
change-id: 20260610-test-edid-array-definition-fix-43fca4e76b0a

Best regards,

Signature · 1 line
Nicolas Frattaroli <[email protected]>
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The newly added drm_kunit_edid.c file is built as a loadable module but lacks a MODULE_LICENSE()…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The newly added drm_kunit_edid.c file is built as a loadable module but lacks a MODULE_LICENSE() declaration. --

commit 6969a389dfc7ebf286991ec9afae031d0abd753f
Author: Nicolas Frattaroli <[email protected]>

drm/tests: Move test EDID data to separate .c file

This commit moves the test EDID array definitions from a header file into a newly created drm_kunit_edid.c file. The arrays are exported so they can be shared among different KUnit tests without duplicating data across multiple users.

Quoted 11 lines
drivers/gpu/drm/tests/Makefile +2 -1
index 3b83e6616fb25..e7193b49cf91f 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
 	drm_probe_helper_test.o \
 	drm_rect_test.o \
 	drm_sysfb_modeset_test.o \
-	drm_fixp_test.o
+	drm_fixp_test.o \
+	drm_kunit_edid.o

[ ... ]

drivers/gpu/drm/tests/drm_kunit_edid.c line 5

Quoted 11 lines
drivers/gpu/drm/tests/drm_kunit_edid.c new file +5 -0
new file mode 100644
index 0000000000000..0976372860627
@@ -0,0 +1,991 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/export.h>
+
+#include "drm_kunit_edid.h"

[Severity: Low]
Because drm_kunit_edid.o is added directly to obj-$(CONFIG_DRM_KUNIT_TEST) in the Makefile, it will be built as a standalone module when that config is set to 'm'. Does this new file need to include <linux/module.h> and provide a MODULE_LICENSE() declaration to prevent modpost warnings and a tainted kernel when loaded?

Quoted 5 lines
drivers/gpu/drm/tests/drm_kunit_edid.c new file +5 -0
+
+/*
+ * edid-decode (hex):
+ *
+ * 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260610-test-edid-array-definition-fix-v2-1-9de4605c4869@collabora.com?part=1
maintainer Acked-by on v2 1/1
#2 lore raw
In reply to Nicolas Frattaroli
Quoted 7 lines · Nicolas Frattaroli

Having the test EDID arrays defined in the .h directly will duplicate them across every user of the EDID arrays. This works fine as long as there's only one user, but may produce build warnings/errors when there are multiple users and not all of them use all definitions.

[ ... ]

Thanks!
Maxime