From 3d806c0cd2511204897e578053325177a9c5322e Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 9 Aug 2024 12:38:56 +0200 Subject: [PATCH] gpu/drm: tegra: Fix support for Linux v6.12 In Linux v6.12, commit 641bb4394f40 ("fs: move FMODE_UNSIGNED_OFFSET to fop_flags") moves the setting of the FMODE_UNSIGNED_OFFSET into the various drivers and renames this flag. This change is causing various tests to fail because opening the DRM device is failing. Use the presence of the new FOP_UNSIGNED_OFFSET flag in the kernel to determine if we need to set this flag in the Tegra DRM driver. Bug 4876974 Change-Id: Ie72a9340187b1c206f0cda6d7e3dab44d603a41c Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3269063 (cherry picked from commit a680b4881fb8e6ace46f409c33307f3bc10366a4) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3338872 Reviewed-by: Brad Griffis Tested-by: Ilies Chergui GVS: buildbot_gerritrpt Reviewed-by: Ilies Chergui --- drivers/gpu/drm/tegra/drm.c | 3 +++ scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 43621c5d..df7e33d3 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -802,6 +802,9 @@ static const struct file_operations tegra_drm_fops = { .read = drm_read, .compat_ioctl = drm_compat_ioctl, .llseek = noop_llseek, +#if defined(NV_FOP_UNSIGNED_OFFSET_PRESENT) /* Linux v6.12 */ + .fop_flags = FOP_UNSIGNED_OFFSET, +#endif }; static int tegra_drm_context_cleanup(int id, void *p, void *data) diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index b52bae21..2218998a 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -129,6 +129,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_rxfh_has_rxfh_param_ar NV_CONFTEST_FUNCTION_COMPILE_TESTS += fd_empty NV_CONFTEST_FUNCTION_COMPILE_TESTS += fd_file NV_CONFTEST_FUNCTION_COMPILE_TESTS += folio_entire_mapcount +NV_CONFTEST_FUNCTION_COMPILE_TESTS += fop_unsigned_offset NV_CONFTEST_FUNCTION_COMPILE_TESTS += genpd_xlate_t_has_const_of_phandle_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 11be7472..2cbce08b 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7286,6 +7286,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_FOLIO_ENTIRE_MAPCOUNT_PRESENT" "" "functions" ;; + fop_unsigned_offset) + # + # Determine if definition FOP_UNSIGNED_OFFSET is present. + # + # Commit 641bb4394f40 ("fs: move FMODE_UNSIGNED_OFFSET to fop_flags") + # added the definition FOP_UNSIGNED_OFFSET in Linux v6.12. + # + CODE=" + #include + int conftest(void) + { + return FOP_UNSIGNED_OFFSET; + }" + + compile_check_conftest "$CODE" "NV_FOP_UNSIGNED_OFFSET_PRESENT" "" "types" + ;; + + genpd_xlate_t_has_const_of_phandle_args) # # Determine if genpd_xlate_t function pointer has a