From d814c113bb75ee876124c62ced5d5b75dee946bc Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 25 Jul 2025 11:47:09 +0100 Subject: [PATCH] drm/tegra: Fix build for Linux v6.17 The arguments to the function drm_helper_mode_fill_fb_struct() and function pointer fb_create() have been updated in the Linux v6.17. Add the necessary conftest tests to check for the new variants of these functions and update the Tegra DRM driver accordingly. Bug 5420210 Change-Id: Ie1470df199d154d3f94f5f7773dcc1ba138e23da Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3423828 (cherry picked from commit dde42d012e4187e798d5d7c3cfa974f49059d0a1) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3462462 Reviewed-by: mobile promotions GVS: buildbot_gerritrpt Reviewed-by: Brad Griffis Tested-by: mobile promotions --- drivers/gpu/drm/tegra/drm.h | 6 ++++++ drivers/gpu/drm/tegra/fb.c | 16 ++++++++++++++ drivers/gpu/drm/tegra/fbdev.c | 6 +++++- scripts/conftest/Makefile | 2 ++ scripts/conftest/conftest.sh | 39 +++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index b602361d..886f004e 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -216,11 +216,17 @@ bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer); int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer, struct tegra_bo_tiling *tiling); struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *mode_cmd, struct tegra_bo **planes, unsigned int num_planes); struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, struct drm_file *file, +#if defined(NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *cmd); #if defined(NV_DRM_DRIVER_HAS_FBDEV_PROBE) /* Linux v6.13 */ diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 46170753..2e466213 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -102,6 +102,9 @@ static const struct drm_framebuffer_funcs tegra_fb_funcs = { }; struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *mode_cmd, struct tegra_bo **planes, unsigned int num_planes) @@ -114,7 +117,11 @@ struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, if (!fb) return ERR_PTR(-ENOMEM); +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + drm_helper_mode_fill_fb_struct(drm, fb, info, mode_cmd); +#else drm_helper_mode_fill_fb_struct(drm, fb, mode_cmd); +#endif for (i = 0; i < fb->format->num_planes; i++) fb->obj[i] = &planes[i]->gem; @@ -132,9 +139,14 @@ struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, struct drm_file *file, +#if defined(NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *cmd) { +#if !defined(NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG) /* Linux v6.17 */ const struct drm_format_info *info = drm_get_format_info(drm, cmd); +#endif struct tegra_bo *planes[4]; struct drm_gem_object *gem; struct drm_framebuffer *fb; @@ -166,7 +178,11 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, planes[i] = to_tegra_bo(gem); } +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + fb = tegra_fb_alloc(drm, info, cmd, planes, i); +#else fb = tegra_fb_alloc(drm, cmd, planes, i); +#endif if (IS_ERR(fb)) { err = PTR_ERR(fb); goto unreference; diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c index 87cffafc..f7865dd5 100644 --- a/drivers/gpu/drm/tegra/fbdev.c +++ b/drivers/gpu/drm/tegra/fbdev.c @@ -134,7 +134,11 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper, return PTR_ERR(info); } - fb = tegra_fb_alloc(drm, &cmd, &bo, 1); + fb = tegra_fb_alloc(drm, +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + drm_get_format_info(drm, cmd.pixel_format, cmd.modifier[0]), +#endif + &cmd, &bo, 1); if (IS_ERR(fb)) { err = PTR_ERR(fb); dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index de77aacc..b61a0133 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -139,7 +139,9 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_alloc_info NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_prepare_has_preferred_bpp_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_unregister_info NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_struct_has_info_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_helper_mode_fill_fb_struct_has_info_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_struct_has_fb_base_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_funcs_struct_fb_create_has_info_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_plane_helper_funcs_struct_atomic_async_check_has_bool_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_scdc_get_set_has_struct_drm_connector_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_keee_struct_present diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index c8b9c10d..b0612000 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7442,6 +7442,27 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_FB_HELPER_UNREGISTER_INFO_PRESENT" "" "functions" ;; + drm_helper_mode_fill_fb_struct_has_info_arg) + # + # Determine if the function 'drm_helper_mode_fill_fb_struct' has the + # argument 'info'. + # + # Commit a34cc7bf1034 ("drm: Allow the caller to pass in the format + # info to drm_helper_mode_fill_fb_struct()") made this change in + # Linux v6.17. + # + CODE=" + #undef CONFIG_ACPI + #include + void conftest(struct drm_device *dev, struct drm_framebuffer *fb, + const struct drm_format_info *info, + const struct drm_mode_fb_cmd2 *mode_cmd) { + drm_helper_mode_fill_fb_struct(dev, fb, info, mode_cmd); + }" + + compile_check_conftest "$CODE" "NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG" "" "types" + ;; + drm_mode_config_struct_has_fb_base_arg) # # Determine if the 'drm_mode_config' structure has the 'fb_base' argument. @@ -7458,6 +7479,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_MODE_CONFIG_STRUCT_HAS_FB_BASE_ARG" "" "types" ;; + drm_mode_config_funcs_struct_fb_create_has_info_arg) + # + # Determine if the 'fb_create' function pointer has an 'info' argument. + # + # Commit 81112eaac559 ("drm: Pass the format info to .fb_create()") + # made this change in Linux v6.17. + # + CODE=" + #include + void conftest(struct drm_mode_config_funcs *f) { + struct drm_framebuffer *(*fn)(struct drm_device *, struct drm_file *, + const struct drm_format_info *, + const struct drm_mode_fb_cmd2 *) = f->fb_create; + }" + + compile_check_conftest "$CODE" "NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG" "" "types" + ;; + drm_plane_helper_funcs_struct_atomic_async_check_has_bool_arg) # # Determine if the 'atomic_async_check' function pointer has a bool argument.