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 <koenz@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2865209
Tested-by: Rohit Khanna <rokhanna@nvidia.com>
Reviewed-by: Rohit Khanna <rokhanna@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
koenz
2023-03-01 10:35:18 +08:00
committed by Laxman Dewangan
parent b2f9fe02de
commit 6f11b7dffb
3 changed files with 43 additions and 9 deletions

View File

@@ -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

View File

@@ -26,6 +26,11 @@
#include <soc/tegra/ivc.h>
#include <soc/tegra/bpmp.h>
#include <linux/version.h>
#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
#include <linux/iosys-map.h>
#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)

View File

@@ -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: