From 6f11b7dffbcdbf7a8003d2ece7b9acef4526cafa Mon Sep 17 00:00:00 2001 From: koenz Date: Wed, 1 Mar 2023 10:35:18 +0800 Subject: [PATCH] driver: Fix mods_bpmpipc build issue with kernel v6.2+ - Fix build issue with mods_bpmpipc Bug 3974855 Change-Id: I77c7f49b56f0eceea8e500dc8217e9ae76585f63 Signed-off-by: koenz Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2865209 Tested-by: Rohit Khanna Reviewed-by: Rohit Khanna Reviewed-by: Sachin Nikam GVS: Gerrit_Virtual_Submit --- drivers/misc/mods/Makefile | 2 +- drivers/misc/mods/mods_bpmpipc.c | 46 +++++++++++++++++++++++++++++--- drivers/misc/mods/mods_krnl.c | 4 --- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/drivers/misc/mods/Makefile b/drivers/misc/mods/Makefile index 12af1408..bf620452 100644 --- a/drivers/misc/mods/Makefile +++ b/drivers/misc/mods/Makefile @@ -22,8 +22,8 @@ mods-$(CONFIG_TEGRA_NVADSP) += mods_adsp.o # and so skip for Linux v6.2+ ifeq ($(shell test $(LINUX_VERSION) -lt $(LINUX_VERSION_6_2); echo $$?),0) mods-$(CONFIG_ARM_FFA_TRANSPORT) += mods_arm_ffa.o -mods-$(CONFIG_TEGRA_IVC) += mods_bpmpipc.o endif +mods-$(CONFIG_TEGRA_IVC) += mods_bpmpipc.o mods-$(CONFIG_COMMON_CLK) += mods_clock.o mods-$(CONFIG_DEBUG_FS) += mods_debugfs.o mods-$(CONFIG_DMA_ENGINE) += mods_dma.o diff --git a/drivers/misc/mods/mods_bpmpipc.c b/drivers/misc/mods/mods_bpmpipc.c index 6c78fc7c..eba4cad5 100644 --- a/drivers/misc/mods/mods_bpmpipc.c +++ b/drivers/misc/mods/mods_bpmpipc.c @@ -26,6 +26,11 @@ #include #include +#include + +#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) +#include +#endif #define IVC_CHANNEL_SIZE 256 #define MRQ_MSG_SIZE 128 @@ -81,6 +86,18 @@ static int bpmp_ipc_send(struct mods_client *client, const void *data, size_t sz) { +#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) + int err; + struct iosys_map ob; + + err = tegra_ivc_write_get_next_frame(ivc, &ob); + if (err) { + cl_error("failed to get next tegra-ivc output frame!\n"); + iosys_map_clear(&ob); + return err; + } + iosys_map_memcpy_to(&ob, 0, data, sz); +#else void *frame; frame = tegra_ivc_write_get_next_frame(ivc); @@ -90,10 +107,9 @@ static int bpmp_ipc_send(struct mods_client *client, } memcpy_toio(frame, data, sz); +#endif - tegra_ivc_write_advance(ivc); - - return 0; + return tegra_ivc_write_advance(ivc); } static int bpmp_ipc_recv(struct mods_client *client, @@ -103,10 +119,32 @@ static int bpmp_ipc_recv(struct mods_client *client, u32 timeout_ms) { int err; +#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) + struct iosys_map ib; +#else const void *frame; +#endif ktime_t end; end = ktime_add_ms(ktime_get(), timeout_ms); + +#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) + do { + err = tegra_ivc_read_get_next_frame(ivc, &ib); + if (!err) + break; + } while (ktime_before(ktime_get(), end)); + if (err) { + iosys_map_clear(&ib); + err = tegra_ivc_read_get_next_frame(ivc, &ib); + if (err) { + cl_error("get next tegra-ivc input frame timeout\n"); + iosys_map_clear(&ib); + return err; + } + } + iosys_map_memcpy_from(data, &ib, 0, sz); +#else do { frame = tegra_ivc_read_get_next_frame(ivc); if (!IS_ERR(frame)) @@ -121,8 +159,8 @@ static int bpmp_ipc_recv(struct mods_client *client, return -ETIMEDOUT; } } - memcpy_fromio(data, frame, sz); +#endif err = tegra_ivc_read_advance(ivc); if (err < 0) diff --git a/drivers/misc/mods/mods_krnl.c b/drivers/misc/mods/mods_krnl.c index 975de0ff..1820724f 100644 --- a/drivers/misc/mods/mods_krnl.c +++ b/drivers/misc/mods/mods_krnl.c @@ -1040,9 +1040,7 @@ static int mods_krnl_close(struct inode *ip, struct file *fp) #endif #if defined(CONFIG_TEGRA_IVC) -#if (KERNEL_VERSION(6, 2, 0) > LINUX_VERSION_CODE) mods_bpmpipc_cleanup(); -#endif #endif mods_disable_all_devices(client); @@ -2744,13 +2742,11 @@ static long mods_krnl_ioctl(struct file *fp, break; #ifdef CONFIG_TEGRA_IVC -#if (KERNEL_VERSION(6, 2, 0) > LINUX_VERSION_CODE) case MODS_ESC_BPMP_UPHY_LANE_EOM_SCAN: MODS_IOCTL(MODS_ESC_BPMP_UPHY_LANE_EOM_SCAN, esc_mods_bpmp_uphy_lane_eom_scan, MODS_BPMP_UPHY_LANE_EOM_SCAN_PARAMS); break; -#endif #endif default: