drm/amd/display: Fix amdgpu_dm KUnit allmodconfig build
Subsystems (3)
PATCH 1/1 drm/amd/display: Fix amdgpu_dm KUnit allmodconfig build
[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, 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.
- Export amdgpu_dm_supported_{degam,shaper,blnd}_tfs via EXPORT_IF_KUNIT().
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.h | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 4 ++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h | 5 ++++- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h | 2 +- .../drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.h +1 -1
@@ -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,
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +4 -0
@@ -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
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h +4 -1
@@ -27,8 +27,11 @@#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);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h +1 -1
@@ -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
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h +1 -1
@@ -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
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c +1 -1
@@ -72,7 +72,7 @@ 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) |
Signature · 1 line
2.43.0
Quoted 21 lines · Ray Wu
[Why]
WithCONFIG_DRM_AMD_DC_KUNIT_TEST=m, allmodconfig only defines the_MODULEvariant. Four KUnit helper headers gate their declarations with #ifdefCONFIG_DRM_AMD_DC_KUNIT_TEST, so the declarations vanish while the matching .c files (driven byIS_ENABLED()viaSTATIC_IFN_KUNIT) keep the functions non-static. The build breaks with implicit declarations and -Werror=missing-prototypes.
amdgpu_dm_crc.hadditionally uses symbols that its test file does not pull in indirectly,amdgpu_dm_colorop_test.chas a copy-paste duplicate function, and the three colorop TF bitmasks are not exported for modpost.[How]
- Switch the crc/hdcp/color/psr KUnit guards toIS_ENABLED().
- Makeamdgpu_dm_crc.hself-contained (dc_types.h+ forward decl).
- Rename the duplicated shaper test back to its intended name.
- Export amdgpu_dm_supported_{degam,shaper,blnd}_tfs viaEXPORT_IF_KUNIT().
Quoted 4 lines
Assisted-by Copilot:claude-4-opusReviewed-by Alex Hung <[email protected]>Signed-off-by Ray Wu <[email protected]>
Quoted 123 lines
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.h | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 4 ++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h | 5 ++++- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h | 2 +- .../drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.h +1
-1@@ -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, drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +4
-0@@ -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 10drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h +4
-1@@ -27,8 +27,11 @@#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);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h +1
-1@@ -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 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h +1
-1@@ -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 drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c +1
-2@@ -72,7 +72,7 @@ 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) | --2.43.0