[PATCH v1 3/4] misc: fastrpc: Introduce fastrpc_shared.h header
Ekansh Gupta
quic_ekangupt at quicinc.com
Mon Nov 18 08:40:45 UTC 2024
Move fastrpc structures and MACRO definitions to a new header file.
These definitions are consumed by other upcoming features like
debugfs, PDR support etc.
Signed-off-by: Ekansh Gupta <quic_ekangupt at quicinc.com>
---
drivers/misc/fastrpc/fastrpc_main.c | 136 +---------------------
drivers/misc/fastrpc/fastrpc_shared.h | 155 ++++++++++++++++++++++++++
2 files changed, 156 insertions(+), 135 deletions(-)
create mode 100644 drivers/misc/fastrpc/fastrpc_shared.h
diff --git a/drivers/misc/fastrpc/fastrpc_main.c b/drivers/misc/fastrpc/fastrpc_main.c
index 74181b8c386b..3163b4159de7 100644
--- a/drivers/misc/fastrpc/fastrpc_main.c
+++ b/drivers/misc/fastrpc/fastrpc_main.c
@@ -22,6 +22,7 @@
#include <linux/firmware/qcom/qcom_scm.h>
#include <uapi/misc/fastrpc.h>
#include <linux/of_reserved_mem.h>
+#include "fastrpc_shared.h"
#define ADSP_DOMAIN_ID (0)
#define MDSP_DOMAIN_ID (1)
@@ -29,8 +30,6 @@
#define CDSP_DOMAIN_ID (3)
#define CDSP1_DOMAIN_ID (4)
#define FASTRPC_DEV_MAX 5 /* adsp, mdsp, slpi, cdsp, cdsp1 */
-#define FASTRPC_MAX_SESSIONS 14
-#define FASTRPC_MAX_VMIDS 16
#define FASTRPC_ALIGN 128
#define FASTRPC_MAX_FDLIST 16
#define FASTRPC_MAX_CRCLIST 64
@@ -55,9 +54,6 @@
#define ADSP_MMAP_ADD_PAGES_LLC 0x3000,
#define DSP_UNSUPPORTED_API (0x80000414)
-/* MAX NUMBER of DSP ATTRIBUTES SUPPORTED */
-#define FASTRPC_MAX_DSP_ATTRIBUTES (256)
-#define FASTRPC_MAX_DSP_ATTRIBUTES_LEN (sizeof(u32) * FASTRPC_MAX_DSP_ATTRIBUTES)
/* Retrives number of input buffers from the scalars parameter */
#define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff)
@@ -118,22 +114,6 @@ struct fastrpc_invoke_buf {
u32 pgidx; /* index to start of contiguous region */
};
-struct fastrpc_remote_dmahandle {
- s32 fd; /* dma handle fd */
- u32 offset; /* dma handle offset */
- u32 len; /* dma handle length */
-};
-
-struct fastrpc_remote_buf {
- u64 pv; /* buffer pointer */
- u64 len; /* length of buffer */
-};
-
-union fastrpc_remote_arg {
- struct fastrpc_remote_buf buf;
- struct fastrpc_remote_dmahandle dma;
-};
-
struct fastrpc_mmap_rsp_msg {
u64 vaddr;
};
@@ -168,16 +148,6 @@ struct fastrpc_mem_unmap_req_msg {
u64 len;
};
-struct fastrpc_msg {
- int pid; /* process group id */
- int tid; /* thread id */
- u64 ctx; /* invoke caller context */
- u32 handle; /* handle to invoke */
- u32 sc; /* scalars structure describing the data */
- u64 addr; /* physical address */
- u64 size; /* size of contiguous region */
-};
-
struct fastrpc_invoke_rsp {
u64 ctx; /* invoke caller context */
int retval; /* invoke return value */
@@ -192,122 +162,18 @@ struct fastrpc_buf_overlap {
u64 offset;
};
-struct fastrpc_buf {
- struct fastrpc_user *fl;
- struct dma_buf *dmabuf;
- struct device *dev;
- void *virt;
- u64 phys;
- u64 size;
- /* Lock for dma buf attachments */
- struct mutex lock;
- struct list_head attachments;
- /* mmap support */
- struct list_head node; /* list of user requested mmaps */
- uintptr_t raddr;
-};
-
struct fastrpc_dma_buf_attachment {
struct device *dev;
struct sg_table sgt;
struct list_head node;
};
-struct fastrpc_map {
- struct list_head node;
- struct fastrpc_user *fl;
- int fd;
- struct dma_buf *buf;
- struct sg_table *table;
- struct dma_buf_attachment *attach;
- u64 phys;
- u64 size;
- void *va;
- u64 len;
- u64 raddr;
- u32 attr;
- struct kref refcount;
-};
-
-struct fastrpc_invoke_ctx {
- int nscalars;
- int nbufs;
- int retval;
- int pid;
- int tgid;
- u32 sc;
- u32 *crc;
- u64 ctxid;
- u64 msg_sz;
- struct kref refcount;
- struct list_head node; /* list of ctxs */
- struct completion work;
- struct work_struct put_work;
- struct fastrpc_msg msg;
- struct fastrpc_user *fl;
- union fastrpc_remote_arg *rpra;
- struct fastrpc_map **maps;
- struct fastrpc_buf *buf;
- struct fastrpc_invoke_args *args;
- struct fastrpc_buf_overlap *olaps;
- struct fastrpc_channel_ctx *cctx;
-};
-
-struct fastrpc_session_ctx {
- struct device *dev;
- int sid;
- bool used;
- bool valid;
-};
-
-struct fastrpc_channel_ctx {
- int domain_id;
- int sesscount;
- int vmcount;
- struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
- struct rpmsg_device *rpdev;
- struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
- spinlock_t lock;
- struct idr ctx_idr;
- struct list_head users;
- struct kref refcount;
- /* Flag if dsp attributes are cached */
- bool valid_attributes;
- u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
- struct fastrpc_device *secure_fdevice;
- struct fastrpc_device *fdevice;
- struct fastrpc_buf *remote_heap;
- struct list_head invoke_interrupted_mmaps;
- bool secure;
- bool unsigned_support;
- u64 dma_mask;
-};
-
struct fastrpc_device {
struct fastrpc_channel_ctx *cctx;
struct miscdevice miscdev;
bool secure;
};
-struct fastrpc_user {
- struct list_head user;
- struct list_head maps;
- struct list_head pending;
- struct list_head mmaps;
-
- struct fastrpc_channel_ctx *cctx;
- struct fastrpc_session_ctx *sctx;
- struct fastrpc_buf *init_mem;
-
- int tgid;
- int pd;
- bool is_secure_dev;
- /* Lock for lists */
- spinlock_t lock;
- /* lock for allocations */
- struct mutex mutex;
-};
-
static void fastrpc_free_map(struct kref *ref)
{
struct fastrpc_map *map;
diff --git a/drivers/misc/fastrpc/fastrpc_shared.h b/drivers/misc/fastrpc/fastrpc_shared.h
new file mode 100644
index 000000000000..8f1f1320a4c2
--- /dev/null
+++ b/drivers/misc/fastrpc/fastrpc_shared.h
@@ -0,0 +1,155 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+// Copyright (c) 2024 Qualcomm Innovation Center.
+#ifndef FASTRPC_SHARED_H
+#define FASTRPC_SHARED_H
+
+#include <linux/completion.h>
+#include <linux/device.h>
+#include <linux/dma-buf.h>
+#include <linux/idr.h>
+#include <linux/list.h>
+#include <linux/firmware/qcom/qcom_scm.h>
+
+#define FASTRPC_MAX_SESSIONS 14
+#define FASTRPC_MAX_VMIDS 16
+/* MAX NUMBER of DSP ATTRIBUTES SUPPORTED */
+#define FASTRPC_MAX_DSP_ATTRIBUTES (256)
+#define FASTRPC_MAX_DSP_ATTRIBUTES_LEN (sizeof(u32) * FASTRPC_MAX_DSP_ATTRIBUTES)
+
+struct fastrpc_remote_dmahandle {
+ s32 fd; /* dma handle fd */
+ u32 offset; /* dma handle offset */
+ u32 len; /* dma handle length */
+};
+
+struct fastrpc_remote_buf {
+ u64 pv; /* buffer pointer */
+ u64 len; /* length of buffer */
+};
+
+union fastrpc_remote_arg {
+ struct fastrpc_remote_buf buf;
+ struct fastrpc_remote_dmahandle dma;
+};
+
+struct fastrpc_buf {
+ struct fastrpc_user *fl;
+ struct dma_buf *dmabuf;
+ struct device *dev;
+ void *virt;
+ u64 phys;
+ u64 size;
+ /* Lock for dma buf attachments */
+ struct mutex lock;
+ struct list_head attachments;
+ /* mmap support */
+ struct list_head node; /* list of user requested mmaps */
+ uintptr_t raddr;
+};
+
+struct fastrpc_map {
+ struct list_head node;
+ struct fastrpc_user *fl;
+ int fd;
+ struct dma_buf *buf;
+ struct sg_table *table;
+ struct dma_buf_attachment *attach;
+ u64 phys;
+ u64 size;
+ void *va;
+ u64 len;
+ u64 raddr;
+ u32 attr;
+ struct kref refcount;
+};
+
+struct fastrpc_msg {
+ int pid; /* process group id */
+ int tid; /* thread id */
+ u64 ctx; /* invoke caller context */
+ u32 handle; /* handle to invoke */
+ u32 sc; /* scalars structure describing the data */
+ u64 addr; /* physical address */
+ u64 size; /* size of contiguous region */
+};
+
+struct fastrpc_invoke_ctx {
+ int nscalars;
+ int nbufs;
+ int retval;
+ int pid;
+ int tgid;
+ u32 sc;
+ u32 *crc;
+ u64 ctxid;
+ u64 msg_sz;
+ struct kref refcount;
+ struct list_head node; /* list of ctxs */
+ struct completion work;
+ struct work_struct put_work;
+ struct fastrpc_msg msg;
+ struct fastrpc_user *fl;
+ union fastrpc_remote_arg *rpra;
+ struct fastrpc_map **maps;
+ struct fastrpc_buf *buf;
+ struct fastrpc_invoke_args *args;
+ struct fastrpc_buf_overlap *olaps;
+ struct fastrpc_channel_ctx *cctx;
+};
+
+struct fastrpc_session_ctx {
+ struct device *dev;
+ int sid;
+ bool used;
+ bool valid;
+};
+
+struct fastrpc_channel_ctx {
+ int domain_id;
+ int sesscount;
+ int vmcount;
+ struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
+ struct rpmsg_device *rpdev;
+ struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
+ spinlock_t lock;
+ struct idr ctx_idr;
+ struct list_head users;
+ struct kref refcount;
+ /* Flag if dsp attributes are cached */
+ bool valid_attributes;
+ u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
+ struct fastrpc_device *secure_fdevice;
+ struct fastrpc_device *fdevice;
+ struct fastrpc_buf *remote_heap;
+ struct list_head invoke_interrupted_mmaps;
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *debugfs_dir;
+#endif
+ bool secure;
+ bool unsigned_support;
+ u64 dma_mask;
+};
+
+struct fastrpc_user {
+ struct list_head user;
+ struct list_head maps;
+ struct list_head pending;
+ struct list_head mmaps;
+
+ struct fastrpc_channel_ctx *cctx;
+ struct fastrpc_session_ctx *sctx;
+ struct fastrpc_buf *init_mem;
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *debugfs_file;
+#endif
+
+ int tgid;
+ int pd;
+ bool is_secure_dev;
+ /* Lock for lists */
+ spinlock_t lock;
+ /* lock for allocations */
+ struct mutex mutex;
+};
+
+#endif /* FASTRPC_SHARED_H */
--
2.34.1
More information about the dri-devel
mailing list