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 <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3028575
(cherry picked from commit ed5ae591c9)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3036792
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Laxman Dewangan
2023-12-06 04:43:03 +00:00
committed by mobile promotions
parent b5178e70d8
commit 6b290b7f84
5 changed files with 24 additions and 8 deletions

View File

@@ -53,12 +53,6 @@ subdir-ccflags-y += -DNV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME
export CONFIG_SKIP_CRYPTO=y export CONFIG_SKIP_CRYPTO=y
endif endif
# Changes done in Linux 6.7 onwards
ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_7); echo $$?),0)
# get_file_rcu() have change the argument
subdir-ccflags-y += -DNV_GET_FILE_RCU_HAS_PTR_FILE_ARGS
endif
ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y)
subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION
endif endif

View File

@@ -5,6 +5,8 @@
* Handle allocation and freeing routines for nvmap * Handle allocation and freeing routines for nvmap
*/ */
#include <nvidia/conftest.h>
#define pr_fmt(fmt) "%s: " fmt, __func__ #define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/err.h> #include <linux/err.h>
@@ -515,7 +517,7 @@ struct nvmap_handle_ref *nvmap_dup_handle_ro(struct nvmap_client *client,
return ERR_CAST(h->dmabuf_ro); return ERR_CAST(h->dmabuf_ro);
} }
} else { } 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)) { if (!get_file_rcu(&h->dmabuf_ro->file)) {
#else #else
if (!get_file_rcu(h->dmabuf_ro->file)) { if (!get_file_rcu(h->dmabuf_ro->file)) {

View File

@@ -5,6 +5,8 @@
* mapping between nvmap_hnadle and sci_ipc entery * mapping between nvmap_hnadle and sci_ipc entery
*/ */
#include <nvidia/conftest.h>
#define pr_fmt(fmt) "%s: " fmt, __func__ #define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/slab.h> #include <linux/slab.h>
@@ -249,7 +251,7 @@ int nvmap_get_handle_from_sci_ipc_id(struct nvmap_client *client, u32 flags,
goto unlock; goto unlock;
} }
} else { } 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)) { if (!get_file_rcu(&h->dmabuf_ro->file)) {
#else #else
if (!get_file_rcu(h->dmabuf_ro->file)) { if (!get_file_rcu(h->dmabuf_ro->file)) {

View File

@@ -115,6 +115,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 += 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_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 += 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 += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg

View File

@@ -2448,6 +2448,23 @@ compile_test() {
compile_check_conftest "$CODE" "NV_PCI_DEV_HAS_ATS_ENABLED" "" "types" 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 <linux/fs.h>
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) get_user_pages)
# #
# Conftest for get_user_pages() # Conftest for get_user_pages()