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 <jonathanh@nvidia.com>
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 <svcmobile_promotions@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2025-07-25 11:47:09 +01:00
committed by mobile promotions
parent 2800fd5f4b
commit d814c113bb
5 changed files with 68 additions and 1 deletions

View File

@@ -216,11 +216,17 @@ bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer, int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
struct tegra_bo_tiling *tiling); struct tegra_bo_tiling *tiling);
struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, 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, const struct drm_mode_fb_cmd2 *mode_cmd,
struct tegra_bo **planes, struct tegra_bo **planes,
unsigned int num_planes); unsigned int num_planes);
struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
struct drm_file *file, 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); const struct drm_mode_fb_cmd2 *cmd);
#if defined(NV_DRM_DRIVER_HAS_FBDEV_PROBE) /* Linux v6.13 */ #if defined(NV_DRM_DRIVER_HAS_FBDEV_PROBE) /* Linux v6.13 */

View File

@@ -102,6 +102,9 @@ static const struct drm_framebuffer_funcs tegra_fb_funcs = {
}; };
struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, 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, const struct drm_mode_fb_cmd2 *mode_cmd,
struct tegra_bo **planes, struct tegra_bo **planes,
unsigned int num_planes) unsigned int num_planes)
@@ -114,7 +117,11 @@ struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm,
if (!fb) if (!fb)
return ERR_PTR(-ENOMEM); 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); drm_helper_mode_fill_fb_struct(drm, fb, mode_cmd);
#endif
for (i = 0; i < fb->format->num_planes; i++) for (i = 0; i < fb->format->num_planes; i++)
fb->obj[i] = &planes[i]->gem; 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_framebuffer *tegra_fb_create(struct drm_device *drm,
struct drm_file *file, 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) 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); const struct drm_format_info *info = drm_get_format_info(drm, cmd);
#endif
struct tegra_bo *planes[4]; struct tegra_bo *planes[4];
struct drm_gem_object *gem; struct drm_gem_object *gem;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
@@ -166,7 +178,11 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
planes[i] = to_tegra_bo(gem); 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); fb = tegra_fb_alloc(drm, cmd, planes, i);
#endif
if (IS_ERR(fb)) { if (IS_ERR(fb)) {
err = PTR_ERR(fb); err = PTR_ERR(fb);
goto unreference; goto unreference;

View File

@@ -134,7 +134,11 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
return PTR_ERR(info); 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)) { if (IS_ERR(fb)) {
err = PTR_ERR(fb); err = PTR_ERR(fb);
dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n",

View File

@@ -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_prepare_has_preferred_bpp_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_unregister_info 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_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_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_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 += drm_scdc_get_set_has_struct_drm_connector_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_keee_struct_present NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_keee_struct_present

View File

@@ -7442,6 +7442,27 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_FB_HELPER_UNREGISTER_INFO_PRESENT" "" "functions" 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 <drm/drm_modeset_helper.h>
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) drm_mode_config_struct_has_fb_base_arg)
# #
# Determine if the 'drm_mode_config' structure has the 'fb_base' argument. # 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" 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 <drm/drm_mode_config.h>
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) drm_plane_helper_funcs_struct_atomic_async_check_has_bool_arg)
# #
# Determine if the 'atomic_async_check' function pointer has a bool argument. # Determine if the 'atomic_async_check' function pointer has a bool argument.