From ed5ae591c99d0e37186ba726144ad260910f46e5 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 6 Dec 2023 04:43:03 +0000 Subject: [PATCH] nvmap: Use conftest to find get_rcu_file() argument type The argument of get_rcu_file() get changed to pointer type of file handle form Linux 6.7 with commit 0ede61d8589cc ("file: convert to SLAB_TYPESAFE_BY_RCU"). Use conftest to findout this new argument type. Bug 4346767 Change-Id: I18943421dd4c2ed4f409ce071b182e68d3d393e6 Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3028575 Tested-by: mobile promotions Reviewed-by: mobile promotions --- Makefile | 3 --- drivers/video/tegra/nvmap/nvmap_handle.c | 4 +++- drivers/video/tegra/nvmap/nvmap_sci_ipc.c | 4 +++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 17 +++++++++++++++++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2366f0f0..6b7265d6 100644 --- a/Makefile +++ b/Makefile @@ -80,9 +80,6 @@ subdir-ccflags-y += -DNV_ASOC_XXX_DROP # drm_debugfs_remove_files has root argument subdir-ccflags-y += -DNV_DRM_DEBUGFS_REMOVE_HAS_ROOT_ARGS - -# get_file_rcu() have change the argument -subdir-ccflags-y += -DNV_GET_FILE_RCU_HAS_PTR_FILE_ARGS endif ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index 6f4bf8f9..eff5bb2b 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -5,6 +5,8 @@ * Handle allocation and freeing routines for nvmap */ +#include + #define pr_fmt(fmt) "%s: " fmt, __func__ #include @@ -515,7 +517,7 @@ struct nvmap_handle_ref *nvmap_dup_handle_ro(struct nvmap_client *client, return ERR_CAST(h->dmabuf_ro); } } else { -#if defined(NV_GET_FILE_RCU_HAS_PTR_FILE_ARGS) +#if defined(NV_GET_FILE_RCU_HAS_DOUBLE_PTR_FILE_ARG) /* Linux 6.7 */ if (!get_file_rcu(&h->dmabuf_ro->file)) { #else if (!get_file_rcu(h->dmabuf_ro->file)) { diff --git a/drivers/video/tegra/nvmap/nvmap_sci_ipc.c b/drivers/video/tegra/nvmap/nvmap_sci_ipc.c index 80855815..a8ca565a 100644 --- a/drivers/video/tegra/nvmap/nvmap_sci_ipc.c +++ b/drivers/video/tegra/nvmap/nvmap_sci_ipc.c @@ -5,6 +5,8 @@ * mapping between nvmap_hnadle and sci_ipc entery */ +#include + #define pr_fmt(fmt) "%s: " fmt, __func__ #include @@ -249,7 +251,7 @@ int nvmap_get_handle_from_sci_ipc_id(struct nvmap_client *client, u32 flags, goto unlock; } } else { -#if defined(NV_GET_FILE_RCU_HAS_PTR_FILE_ARGS) +#if defined(NV_GET_FILE_RCU_HAS_DOUBLE_PTR_FILE_ARG) /* Linux 6.7 */ if (!get_file_rcu(&h->dmabuf_ro->file)) { #else if (!get_file_rcu(h->dmabuf_ro->file)) { diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 9f709623..5f10e5d1 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -114,6 +114,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_struct_has_fb_base_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_scdc_get_set_has_struct_drm_connector_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_coalesce_has_coal_and_extack_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args +NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 17250543..fd11da65 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -2448,6 +2448,23 @@ compile_test() { compile_check_conftest "$CODE" "NV_PCI_DEV_HAS_ATS_ENABLED" "" "types" ;; + get_file_rcu_has_double_ptr_file_arg) + # + # Determine if the function 'get_file_rcu()' has pointer to pointer of file + # type argument or not. + # + # In Linux v6.7, commit 0ede61d8589cc2 ("file: convert to SLAB_TYPESAFE_BY_RCU") + # changed the argument of file handle to pointer type. + # + CODE=" + #include + struct file *conftest_get_file_rcu_has_double_ptr_file_arg(struct file __rcu *f) { + return get_file_rcu(&f); + }" + + compile_check_conftest "$CODE" "NV_GET_FILE_RCU_HAS_DOUBLE_PTR_FILE_ARG" "" "types" + ;; + get_user_pages) # # Conftest for get_user_pages()