]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Fix amdgpu_dm KUnit allmodconfig build
authorRay Wu <ray.wu@amd.com>
Tue, 19 May 2026 03:44:55 +0000 (11:44 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 14:22:49 +0000 (10:22 -0400)
[Why]
With CONFIG_DRM_AMD_DC_KUNIT_TEST=m, allmodconfig only defines the
_MODULE variant. Four KUnit helper headers gate their declarations
with #ifdef CONFIG_DRM_AMD_DC_KUNIT_TEST, so the declarations vanish
while the matching .c files (driven by IS_ENABLED() via
STATIC_IFN_KUNIT) keep the functions non-static. The build breaks
with implicit declarations and -Werror=missing-prototypes.

amdgpu_dm_crc.h additionally uses symbols that its test file does not
pull in indirectly, amdgpu_dm_colorop_test.c has a copy-paste
duplicate function with the wrong expected bitmask, and the three
colorop TF bitmasks are not exported for modpost.

[How]
- Switch the crc/hdcp/color/psr KUnit guards to IS_ENABLED().
- Make amdgpu_dm_crc.h self-contained (dc_types.h + forward decl).
- Rename the duplicated shaper test back to its intended name and
  fix its expected bitmask.
- Export amdgpu_dm_supported_{degam,shaper,blnd}_tfs via
  EXPORT_IF_KUNIT().

Assisted-by: Copilot:claude-4-opus
Reviewed-by: Alex Hung <alex.hung@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.h
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c

index 5e484359b8a735b34755a246e2e98a588babb9a1..19d3a13572f55fdc7cbd372bd27bf077139adbbf 100644 (file)
@@ -42,7 +42,7 @@ struct dc_rgb;
 struct fixed31_32;
 struct tetrahedral_params;
 
-#ifdef CONFIG_DRM_AMD_DC_KUNIT_TEST
+#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
 /*
  * Prototypes for functions exposed to KUnit tests. The enum types
  * used below (dc_transfer_func_predefined, amdgpu_transfer_function,
index 7ee051cb3c0563860d13a9b4c89866f437211205..ab20e3f41d604b0736ec326c42fbc4e70fe5dcf0 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_dm_colorop.h"
+#include "amdgpu_dm_kunit_helpers.h"
 #include "dc.h"
 
 const u64 amdgpu_dm_supported_degam_tfs =
@@ -38,18 +39,21 @@ const u64 amdgpu_dm_supported_degam_tfs =
        BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
        BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
        BIT(DRM_COLOROP_1D_CURVE_GAMMA22);
+EXPORT_IF_KUNIT(amdgpu_dm_supported_degam_tfs);
 
 const u64 amdgpu_dm_supported_shaper_tfs =
        BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) |
        BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF) |
        BIT(DRM_COLOROP_1D_CURVE_BT2020_OETF) |
        BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+EXPORT_IF_KUNIT(amdgpu_dm_supported_shaper_tfs);
 
 const u64 amdgpu_dm_supported_blnd_tfs =
        BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
        BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
        BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
        BIT(DRM_COLOROP_1D_CURVE_GAMMA22);
+EXPORT_IF_KUNIT(amdgpu_dm_supported_blnd_tfs);
 
 #define MAX_COLOR_PIPELINE_OPS 10
 
index 76731ee44e13c92ddb7aa693011fd61d402f24d0..c9aa0c82038fee999f40ebb830eb0cee4fbfebf2 100644 (file)
 #ifndef AMD_DAL_DEV_AMDGPU_DM_AMDGPU_DM_CRC_H_
 #define AMD_DAL_DEV_AMDGPU_DM_AMDGPU_DM_CRC_H_
 
+#include "dc_types.h"
+
 struct drm_crtc;
 struct dm_crtc_state;
+struct amdgpu_device;
 
 enum amdgpu_dm_pipe_crc_source {
        AMDGPU_DM_PIPE_CRC_SOURCE_NONE = 0,
@@ -148,7 +151,7 @@ void amdgpu_dm_crtc_secure_display_create_contexts(struct amdgpu_device *adev);
 #define amdgpu_dm_crtc_secure_display_create_contexts(x)
 #endif
 
-#ifdef CONFIG_DRM_AMD_DC_KUNIT_TEST
+#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
 enum amdgpu_dm_pipe_crc_source dm_parse_crc_source(const char *source);
 bool dm_is_crc_source_crtc(enum amdgpu_dm_pipe_crc_source src);
 bool dm_is_crc_source_dprx(enum amdgpu_dm_pipe_crc_source src);
index 4bb072cfac1ed4bdcf6b9d502bedd288645547b4..90b18c450ca61eb9cff98c084fd267b5bdade2a0 100644 (file)
@@ -94,7 +94,7 @@ void hdcp_destroy(struct kobject *kobj, struct hdcp_workqueue *work);
 
 struct hdcp_workqueue *hdcp_create_workqueue(struct amdgpu_device *adev, struct cp_psp *cp_psp, struct dc *dc);
 
-#ifdef CONFIG_DRM_AMD_DC_KUNIT_TEST
+#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
 void process_output(struct hdcp_workqueue *hdcp_work);
 #endif
 
index 1a41d9b99eb42c8626eb78cf01e8dcdbd5e62587..9f3e22520ca027f3024f0f73ed2645e9edbf04f6 100644 (file)
@@ -40,7 +40,7 @@ bool amdgpu_dm_psr_set_event(struct amdgpu_display_manager *dm,
                struct dc_stream_state *stream, bool set_event, enum psr_event event,
                bool wait_for_disable);
 
-#ifdef CONFIG_DRM_AMD_DC_KUNIT_TEST
+#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
 void amdgpu_dm_psr_fill_caps(struct dc_link *link, struct psr_caps *caps);
 #endif
 
index 8bdebcaf42b207ebd83de38733c26463c573a607..6c77a7159188efe25844596094a2fb41f3fe784c 100644 (file)
@@ -72,12 +72,12 @@ static void dm_test_supported_shaper_tfs_has_gamma22(struct kunit *test)
                          BIT(DRM_COLOROP_1D_CURVE_GAMMA22));
 }
 
-static void dm_test_supported_degam_tfs_no_extra_bits(struct kunit *test)
+static void dm_test_supported_shaper_tfs_no_extra_bits(struct kunit *test)
 {
-       u64 expected = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
-                      BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
-                      BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
-                      BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+       u64 expected = BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) |
+                      BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF) |
+                      BIT(DRM_COLOROP_1D_CURVE_BT2020_OETF) |
+                      BIT(DRM_COLOROP_1D_CURVE_GAMMA22);
 
        KUNIT_EXPECT_EQ(test, amdgpu_dm_supported_shaper_tfs, expected);
 }