From f6d27d0561c15c7a1783c62d7288a35bd51ace6e Mon Sep 17 00:00:00 2001 From: Prashant Kumar Shaw Date: Thu, 1 Dec 2022 08:03:47 +0000 Subject: [PATCH] FSICOM: IOVA per client kernel changes - IOCTL datatype and call added for sending IOVA, offset and channel id data to FSI JIRA SS-3385 JIRA SS-4628 Bug 3855033 Change-Id: I1212913a7ede879108800a68eafbe8240211572b Signed-off-by: Rahul Bedarkar Signed-off-by: Prashant Kumar Shaw Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2819743 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- drivers/platform/tegra/tegra-fsicom.c | 28 ++++++++++++++++++++++----- include/uapi/linux/tegra-fsicom.h | 8 ++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/platform/tegra/tegra-fsicom.c b/drivers/platform/tegra/tegra-fsicom.c index 2dfcc09f..f15b834e 100644 --- a/drivers/platform/tegra/tegra-fsicom.c +++ b/drivers/platform/tegra/tegra-fsicom.c @@ -19,7 +19,9 @@ /* Timeout in milliseconds */ #define TIMEOUT 1000 -/* Data type for mailbox client and channel details */ +#define IOVA_UNI_CODE 0xFE0D + +/*Data type for mailbox client and channel details*/ struct fsi_hsp_sm { struct mbox_client client; struct mbox_chan *chan; @@ -118,15 +120,16 @@ static ssize_t device_file_ioctl( struct rw_data *user_input; int ret = 0; uint32_t pdata[4] = {0}; + struct iova_data ldata; - user_input = (struct rw_data *)arg; - if (copy_from_user(&input, (void __user *)arg, - sizeof(struct rw_data))) - return -EACCES; switch (cmd) { case NVMAP_SMMU_MAP: + user_input = (struct rw_data *)arg; + if (copy_from_user(&input, (void __user *)arg, + sizeof(struct rw_data))) + return -EACCES; dmabuf = dma_buf_get(input.handle); if (IS_ERR_OR_NULL(dmabuf)) @@ -159,6 +162,9 @@ static ssize_t device_file_ioctl( break; case TEGRA_HSP_WRITE: + if (copy_from_user(&input, (void __user *)arg, + sizeof(struct rw_data))) + return -EACCES; pdata[0] = input.handle; ret = mbox_send_message(fsi_hsp_v->tx.chan, (void *)pdata); @@ -168,6 +174,18 @@ static ssize_t device_file_ioctl( task = get_current(); break; + case TEGRA_IOVA_DATA: + if (copy_from_user(&ldata, (void __user *)arg, + sizeof(struct iova_data))) + return -EACCES; + pdata[0] = ldata.offset; + pdata[1] = ldata.iova; + pdata[2] = ldata.chid; + pdata[3] = IOVA_UNI_CODE; + ret = mbox_send_message(fsi_hsp_v->tx.chan, + (void *)pdata); + break; + default: return -EINVAL; } diff --git a/include/uapi/linux/tegra-fsicom.h b/include/uapi/linux/tegra-fsicom.h index bf3fa36c..82b22df9 100644 --- a/include/uapi/linux/tegra-fsicom.h +++ b/include/uapi/linux/tegra-fsicom.h @@ -14,6 +14,13 @@ struct rw_data { uint64_t iova; }; +/*Data type for sending the offset,IOVA and channel Id details to FSI */ +struct iova_data { + uint32_t offset; + uint32_t iova; + uint32_t chid; +}; + /* signal value */ #define SIG_DRIVER_RESUME 43 #define SIG_FSI_WRITE_EVENT 44 @@ -23,5 +30,6 @@ struct rw_data { #define NVMAP_SMMU_UNMAP _IOWR('q', 2, struct rw_data *) #define TEGRA_HSP_WRITE _IOWR('q', 3, struct rw_data *) #define TEGRA_SIGNAL_REG _IOWR('q', 4, struct rw_data *) +#define TEGRA_IOVA_DATA _IOWR('q', 5, struct iova_data *) #endif /* _UAPI_TEGRA_FSICOM_H_ */