From b5178e70d8f7338ba94b5e084d9e1643ab45d843 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 21 Nov 2023 16:06:59 +0000 Subject: [PATCH] nvmap: Pass proper argument for get_file_rcu() for Linux 6.7 The function get_file_rcu() has modification in its argument to take the pointer to pointer of file from Linux 6.7 from below change *** commit 0ede61d8589cc2d93aa78230d74ac58b5b8d0244 Author: Christian Brauner file: convert to SLAB_TYPESAFE_BY_RCU *** Add support for Linux 6.7. Bug 4346767 Change-Id: I1e2e005900c7d2c57ac487b5f6ac5e1fcbfbafe7 Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3020000 (cherry picked from commit 4ef0a332e861701b8b8781fb362a652bb9c654ee) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3036791 Reviewed-by: Jonathan Hunter Tested-by: Jonathan Hunter GVS: Gerrit_Virtual_Submit --- Makefile | 6 ++++++ drivers/video/tegra/nvmap/nvmap_handle.c | 4 ++++ drivers/video/tegra/nvmap/nvmap_sci_ipc.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 076165df..cda77883 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,12 @@ subdir-ccflags-y += -DNV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME export CONFIG_SKIP_CRYPTO=y 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) subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION endif diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c index 9953b78c..42f07981 100644 --- a/drivers/video/tegra/nvmap/nvmap_handle.c +++ b/drivers/video/tegra/nvmap/nvmap_handle.c @@ -515,7 +515,11 @@ 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 (!get_file_rcu(&h->dmabuf_ro->file)) { +#else if (!get_file_rcu(h->dmabuf_ro->file)) { +#endif mutex_unlock(&h->lock); remain = wait_event_interruptible_timeout(h->waitq, !h->dmabuf_ro, (long)msecs_to_jiffies(100U)); diff --git a/drivers/video/tegra/nvmap/nvmap_sci_ipc.c b/drivers/video/tegra/nvmap/nvmap_sci_ipc.c index a808a2de..80855815 100644 --- a/drivers/video/tegra/nvmap/nvmap_sci_ipc.c +++ b/drivers/video/tegra/nvmap/nvmap_sci_ipc.c @@ -249,7 +249,11 @@ 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 (!get_file_rcu(&h->dmabuf_ro->file)) { +#else if (!get_file_rcu(h->dmabuf_ro->file)) { +#endif mutex_unlock(&h->lock); remain = wait_event_interruptible_timeout(h->waitq, !h->dmabuf_ro, (long)msecs_to_jiffies(100U));