* [PATCH v1 0/5] Add multimode invoke request IOCTl support
@ 2023-08-31 16:28 Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support Ekansh Gupta
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Ekansh Gupta @ 2023-08-31 16:28 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
Add changes to support multimode invocation ioctl request. This
ioctl call facilitates multiple types of requests from user including
CRC check, performance counters, shared context bank usage, etc.
This series also carries patch to save and restore interrupted
context.
Ekansh Gupta (5):
misc: fastrpc: Add fastrpc multimode invoke request support
misc: fastrpc: Add CRC support for remote buffers
misc: fastrpc: Capture kernel and DSP performance counters
misc: fastrpc: Add support to save and restore interrupted
misc: fastrpc: Add support to allocate shared context bank
drivers/misc/fastrpc.c | 478 ++++++++++++++++++++++++++++++++++++--------
include/uapi/misc/fastrpc.h | 39 ++++
2 files changed, 433 insertions(+), 84 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support
2023-08-31 16:28 [PATCH v1 0/5] Add multimode invoke request IOCTl support Ekansh Gupta
@ 2023-08-31 16:28 ` Ekansh Gupta
2023-08-31 21:26 ` kernel test robot
2023-08-31 16:28 ` [PATCH v1 2/5] misc: fastrpc: Add CRC support for remote buffers Ekansh Gupta
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Ekansh Gupta @ 2023-08-31 16:28 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
Multimode invocation request is intended to support multiple
different type of requests. This will include enhanced invoke
request to support CRC check and performance counter enablement.
This will also support few driver level user controllable
mechanisms like usage of shared context banks, wakelock support,
etc. This IOCTL is also added with the aim to support few
new fastrpc features like DSP PD notification framework,
DSP Signalling mechanism etc.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 149 ++++++++++++++++++++++++++++++++------------
include/uapi/misc/fastrpc.h | 25 ++++++++
2 files changed, 133 insertions(+), 41 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 9666d28..04eaf6c 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -572,7 +572,7 @@ static void fastrpc_get_buff_overlaps(struct fastrpc_invoke_ctx *ctx)
static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
struct fastrpc_user *user, u32 kernel, u32 sc,
- struct fastrpc_invoke_args *args)
+ struct fastrpc_enhanced_invoke *invoke)
{
struct fastrpc_channel_ctx *cctx = user->cctx;
struct fastrpc_invoke_ctx *ctx = NULL;
@@ -603,7 +603,7 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
kfree(ctx);
return ERR_PTR(-ENOMEM);
}
- ctx->args = args;
+ ctx->args = (struct fastrpc_invoke_args *)invoke->inv.args;
fastrpc_get_buff_overlaps(ctx);
}
@@ -1130,12 +1130,12 @@ static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
}
static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
- u32 handle, u32 sc,
- struct fastrpc_invoke_args *args)
+ struct fastrpc_enhanced_invoke *invoke)
{
struct fastrpc_invoke_ctx *ctx = NULL;
struct fastrpc_buf *buf, *b;
-
+ struct fastrpc_invoke *inv = &invoke->inv;
+ u32 handle, sc;
int err = 0;
if (!fl->sctx)
@@ -1144,12 +1144,14 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (!fl->cctx->rpdev)
return -EPIPE;
+ handle = inv->handle;
+ sc = inv->sc;
if (handle == FASTRPC_INIT_HANDLE && !kernel) {
dev_warn_ratelimited(fl->sctx->dev, "user app trying to send a kernel RPC message (%d)\n", handle);
return -EPERM;
}
- ctx = fastrpc_context_alloc(fl, kernel, sc, args);
+ ctx = fastrpc_context_alloc(fl, kernel, sc, invoke);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
@@ -1235,6 +1237,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
{
struct fastrpc_init_create_static init;
struct fastrpc_invoke_args *args;
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_phy_page pages[1];
char *name;
int err;
@@ -1243,7 +1246,6 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
u32 namelen;
u32 pageslen;
} inbuf;
- u32 sc;
args = kcalloc(FASTRPC_CREATE_STATIC_PROCESS_NARGS, sizeof(*args), GFP_KERNEL);
if (!args)
@@ -1310,10 +1312,11 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
args[2].length = sizeof(*pages);
args[2].fd = -1;
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_STATIC, 3, 0);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_STATIC, 3, 0);
+ ioctl.inv.args = (__u64)args;
- err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
- sc, args);
+ err = fastrpc_internal_invoke(fl, true, &ioctl);
if (err)
goto err_invoke;
@@ -1348,6 +1351,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
{
struct fastrpc_init_create init;
struct fastrpc_invoke_args *args;
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_phy_page pages[1];
struct fastrpc_map *map = NULL;
struct fastrpc_buf *imem = NULL;
@@ -1361,7 +1365,6 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
u32 attrs;
u32 siglen;
} inbuf;
- u32 sc;
bool unsigned_module = false;
args = kcalloc(FASTRPC_CREATE_PROCESS_NARGS, sizeof(*args), GFP_KERNEL);
@@ -1435,12 +1438,13 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
args[5].length = sizeof(inbuf.siglen);
args[5].fd = -1;
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE, 4, 0);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE, 4, 0);
if (init.attrs)
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_ATTR, 4, 0);
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_ATTR, 4, 0);
+ ioctl.inv.args = (__u64)args;
- err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
- sc, args);
+ err = fastrpc_internal_invoke(fl, true, &ioctl);
if (err)
goto err_invoke;
@@ -1492,17 +1496,19 @@ static void fastrpc_session_free(struct fastrpc_channel_ctx *cctx,
static int fastrpc_release_current_dsp_process(struct fastrpc_user *fl)
{
struct fastrpc_invoke_args args[1];
+ struct fastrpc_enhanced_invoke ioctl;
int tgid = 0;
- u32 sc;
tgid = fl->tgid;
args[0].ptr = (u64)(uintptr_t) &tgid;
args[0].length = sizeof(tgid);
args[0].fd = -1;
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_RELEASE, 1, 0);
- return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
- sc, &args[0]);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_RELEASE, 1, 0);
+ ioctl.inv.args = (__u64)args;
+
+ return fastrpc_internal_invoke(fl, true, &ioctl);
}
static int fastrpc_device_release(struct inode *inode, struct file *file)
@@ -1638,22 +1644,25 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp)
static int fastrpc_init_attach(struct fastrpc_user *fl, int pd)
{
struct fastrpc_invoke_args args[1];
+ struct fastrpc_enhanced_invoke ioctl;
int tgid = fl->tgid;
- u32 sc;
args[0].ptr = (u64)(uintptr_t) &tgid;
args[0].length = sizeof(tgid);
args[0].fd = -1;
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
fl->pd = pd;
- return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
- sc, &args[0]);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
+ ioctl.inv.args = (__u64)args;
+
+ return fastrpc_internal_invoke(fl, true, &ioctl);
}
static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)
{
struct fastrpc_invoke_args *args = NULL;
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_invoke inv;
u32 nscalars;
int err;
@@ -1675,16 +1684,59 @@ static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)
}
}
- err = fastrpc_internal_invoke(fl, false, inv.handle, inv.sc, args);
+ ioctl.inv = inv;
+ ioctl.inv.args = (__u64)args;
+
+ err = fastrpc_internal_invoke(fl, false, &ioctl);
kfree(args);
return err;
}
+static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp)
+{
+ struct fastrpc_enhanced_invoke einv;
+ struct fastrpc_invoke_args *args = NULL;
+ struct fastrpc_ioctl_multimode_invoke invoke;
+ u32 nscalars;
+ int err;
+
+ if (copy_from_user(&invoke, argp, sizeof(invoke)))
+ return -EFAULT;
+
+ switch (invoke.req) {
+ case FASTRPC_INVOKE:
+ /* nscalars is truncated here to max supported value */
+ if (copy_from_user(&einv, (void __user *)(uintptr_t)invoke.invparam,
+ invoke.size))
+ return -EFAULT;
+ nscalars = REMOTE_SCALARS_LENGTH(einv.inv.sc);
+ if (nscalars) {
+ args = kcalloc(nscalars, sizeof(*args), GFP_KERNEL);
+ if (!args)
+ return -ENOMEM;
+ if (copy_from_user(args, (void __user *)(uintptr_t)einv.inv.args,
+ nscalars * sizeof(*args))) {
+ kfree(args);
+ return -EFAULT;
+ }
+ }
+ einv.inv.args = (__u64)args;
+ err = fastrpc_internal_invoke(fl, false, &einv);
+ kfree(args);
+ break;
+ default:
+ err = -ENOTTY;
+ break;
+ }
+ return err;
+}
+
static int fastrpc_get_info_from_dsp(struct fastrpc_user *fl, uint32_t *dsp_attr_buf,
uint32_t dsp_attr_buf_len)
{
struct fastrpc_invoke_args args[2] = { 0 };
+ struct fastrpc_enhanced_invoke ioctl;
/* Capability filled in userspace */
dsp_attr_buf[0] = 0;
@@ -1697,8 +1749,11 @@ static int fastrpc_get_info_from_dsp(struct fastrpc_user *fl, uint32_t *dsp_attr
args[1].fd = -1;
fl->pd = USER_PD;
- return fastrpc_internal_invoke(fl, true, FASTRPC_DSP_UTILITIES_HANDLE,
- FASTRPC_SCALARS(0, 1, 1), args);
+ ioctl.inv.handle = FASTRPC_DSP_UTILITIES_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(0, 1, 1);
+ ioctl.inv.args = (__u64)args;
+
+ return fastrpc_internal_invoke(fl, true, &ioctl);
}
static int fastrpc_get_info_from_kernel(struct fastrpc_ioctl_capability *cap,
@@ -1785,10 +1840,10 @@ static int fastrpc_get_dsp_info(struct fastrpc_user *fl, char __user *argp)
static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, struct fastrpc_buf *buf)
{
struct fastrpc_invoke_args args[1] = { [0] = { 0 } };
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_munmap_req_msg req_msg;
struct device *dev = fl->sctx->dev;
int err;
- u32 sc;
req_msg.pgid = fl->tgid;
req_msg.size = buf->size;
@@ -1797,9 +1852,11 @@ static int fastrpc_req_munmap_impl(struct fastrpc_user *fl, struct fastrpc_buf *
args[0].ptr = (u64) (uintptr_t) &req_msg;
args[0].length = sizeof(req_msg);
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MUNMAP, 1, 0);
- err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc,
- &args[0]);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MUNMAP, 1, 0);
+ ioctl.inv.args = (__u64)args;
+
+ err = fastrpc_internal_invoke(fl, true, &ioctl);
if (!err) {
dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
spin_lock(&fl->lock);
@@ -1843,6 +1900,7 @@ static int fastrpc_req_munmap(struct fastrpc_user *fl, char __user *argp)
static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
{
struct fastrpc_invoke_args args[3] = { [0 ... 2] = { 0 } };
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_buf *buf = NULL;
struct fastrpc_mmap_req_msg req_msg;
struct fastrpc_mmap_rsp_msg rsp_msg;
@@ -1850,7 +1908,6 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
struct fastrpc_req_mmap req;
struct device *dev = fl->sctx->dev;
int err;
- u32 sc;
if (copy_from_user(&req, argp, sizeof(req)))
return -EFAULT;
@@ -1889,9 +1946,11 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
args[2].ptr = (u64) (uintptr_t) &rsp_msg;
args[2].length = sizeof(rsp_msg);
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MMAP, 2, 1);
- err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc,
- &args[0]);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MMAP, 2, 1);
+ ioctl.inv.args = (__u64)args;
+
+ err = fastrpc_internal_invoke(fl, true, &ioctl);
if (err) {
dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size);
goto err_invoke;
@@ -1943,10 +2002,10 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
static int fastrpc_req_mem_unmap_impl(struct fastrpc_user *fl, struct fastrpc_mem_unmap *req)
{
struct fastrpc_invoke_args args[1] = { [0] = { 0 } };
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_map *map = NULL, *iter, *m;
struct fastrpc_mem_unmap_req_msg req_msg = { 0 };
int err = 0;
- u32 sc;
struct device *dev = fl->sctx->dev;
spin_lock(&fl->lock);
@@ -1972,9 +2031,11 @@ static int fastrpc_req_mem_unmap_impl(struct fastrpc_user *fl, struct fastrpc_me
args[0].ptr = (u64) (uintptr_t) &req_msg;
args[0].length = sizeof(req_msg);
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_UNMAP, 1, 0);
- err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc,
- &args[0]);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_UNMAP, 1, 0);
+ ioctl.inv.args = (__u64)args;
+
+ err = fastrpc_internal_invoke(fl, true, &ioctl);
fastrpc_map_put(map);
if (err)
dev_err(dev, "unmmap\tpt fd = %d, 0x%09llx error\n", map->fd, map->raddr);
@@ -1995,6 +2056,7 @@ static int fastrpc_req_mem_unmap(struct fastrpc_user *fl, char __user *argp)
static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
{
struct fastrpc_invoke_args args[4] = { [0 ... 3] = { 0 } };
+ struct fastrpc_enhanced_invoke ioctl;
struct fastrpc_mem_map_req_msg req_msg = { 0 };
struct fastrpc_mmap_rsp_msg rsp_msg = { 0 };
struct fastrpc_mem_unmap req_unmap = { 0 };
@@ -2003,7 +2065,6 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
struct device *dev = fl->sctx->dev;
struct fastrpc_map *map = NULL;
int err;
- u32 sc;
if (copy_from_user(&req, argp, sizeof(req)))
return -EFAULT;
@@ -2039,8 +2100,11 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
args[3].ptr = (u64) (uintptr_t) &rsp_msg;
args[3].length = sizeof(rsp_msg);
- sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_MAP, 3, 1);
- err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, &args[0]);
+ ioctl.inv.handle = FASTRPC_INIT_HANDLE;
+ ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_MAP, 3, 1);
+ ioctl.inv.args = (__u64)args;
+
+ err = fastrpc_internal_invoke(fl, true, &ioctl);
if (err) {
dev_err(dev, "mem mmap error, fd %d, vaddr %llx, size %lld\n",
req.fd, req.vaddrin, map->size);
@@ -2080,6 +2144,9 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
case FASTRPC_IOCTL_INVOKE:
err = fastrpc_invoke(fl, argp);
break;
+ case FASTRPC_IOCTL_MULTIMODE_INVOKE:
+ err = fastrpc_multimode_invoke(fl, argp);
+ break;
case FASTRPC_IOCTL_INIT_ATTACH:
err = fastrpc_init_attach(fl, ROOT_PD);
break;
diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h
index f33d914..36694fb 100644
--- a/include/uapi/misc/fastrpc.h
+++ b/include/uapi/misc/fastrpc.h
@@ -16,6 +16,7 @@
#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)
+#define FASTRPC_IOCTL_MULTIMODE_INVOKE _IOWR('R', 12, struct fastrpc_ioctl_multimode_invoke)
#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)
/**
@@ -80,6 +81,30 @@ struct fastrpc_invoke {
__u64 args;
};
+struct fastrpc_enhanced_invoke {
+ struct fastrpc_invoke inv;
+ __u64 crc;
+ __u64 perf_kernel;
+ __u64 perf_dsp;
+ __u32 reserved[8];
+};
+
+struct fastrpc_ioctl_multimode_invoke {
+ __u32 req;
+ __u64 invparam;
+ __u64 size;
+ __u32 reserved[8];
+};
+
+enum fastrpc_multimode_invoke_type {
+ FASTRPC_INVOKE = 1,
+ FASTRPC_INVOKE_ENHANCED = 2,
+ FASTRPC_INVOKE_CONTROL = 3,
+ FASTRPC_INVOKE_DSPSIGNAL = 4,
+ FASTRPC_INVOKE_NOTIF = 5,
+ FASTRPC_INVOKE_MULTISESSION = 6,
+};
+
struct fastrpc_init_create {
__u32 filelen; /* elf file length */
__s32 filefd; /* fd for the file */
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/5] misc: fastrpc: Add CRC support for remote buffers
2023-08-31 16:28 [PATCH v1 0/5] Add multimode invoke request IOCTl support Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support Ekansh Gupta
@ 2023-08-31 16:28 ` Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 3/5] misc: fastrpc: Capture kernel and DSP performance counters Ekansh Gupta
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Ekansh Gupta @ 2023-08-31 16:28 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
CRC check for input and output argument helps in ensuring data
consistency over a remote call. If user intends to enable CRC check,
first local user CRC is calculated at user end and a CRC buffer is
passed to DSP to capture remote CRC values. DSP is expected to
write to the remote CRC buffer which is then compared at user level
with the local CRC values.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 04eaf6c..337ec1f 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -610,6 +610,7 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
/* Released in fastrpc_context_put() */
fastrpc_channel_ctx_get(cctx);
+ ctx->crc = (u32 *)(uintptr_t)invoke->crc;
ctx->sc = sc;
ctx->retval = -1;
ctx->pid = current->pid;
@@ -1063,6 +1064,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
struct fastrpc_invoke_buf *list;
struct fastrpc_phy_page *pages;
u64 *fdlist;
+ u32 *crclist;
int i, inbufs, outbufs, handles;
inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
@@ -1070,7 +1072,8 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
list = fastrpc_invoke_buf_start(rpra, ctx->nscalars);
pages = fastrpc_phy_page_start(list, ctx->nscalars);
- fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
+ fdlist = (u64 *)(pages + inbufs + outbufs + handles);
+ crclist = (u32 *)(fdlist + FASTRPC_MAX_FDLIST);
for (i = inbufs; i < ctx->nbufs; ++i) {
if (!ctx->maps[i]) {
@@ -1094,6 +1097,10 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
fastrpc_map_put(mmap);
}
+ if (ctx->crc && crclist && rpra) {
+ if (copy_to_user((void __user *)ctx->crc, crclist, FASTRPC_MAX_CRCLIST * sizeof(u32)))
+ return -EFAULT;
+ }
return 0;
}
@@ -1706,6 +1713,7 @@ static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp)
switch (invoke.req) {
case FASTRPC_INVOKE:
+ case FASTRPC_INVOKE_ENHANCED:
/* nscalars is truncated here to max supported value */
if (copy_from_user(&einv, (void __user *)(uintptr_t)invoke.invparam,
invoke.size))
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 3/5] misc: fastrpc: Capture kernel and DSP performance counters
2023-08-31 16:28 [PATCH v1 0/5] Add multimode invoke request IOCTl support Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 2/5] misc: fastrpc: Add CRC support for remote buffers Ekansh Gupta
@ 2023-08-31 16:28 ` Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank Ekansh Gupta
4 siblings, 0 replies; 9+ messages in thread
From: Ekansh Gupta @ 2023-08-31 16:28 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
Add support to capture kernel performance counters for different
kernel level operations. These counters collects the information
for remote call and copies the information to a buffer shared
by user.
Collection of DSP performance counters is also added as part of
this change. DSP updates the performance information in the
metadata which is then copied to a buffer passed by the user.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 140 +++++++++++++++++++++++++++++++++++++++++---
include/uapi/misc/fastrpc.h | 14 +++++
2 files changed, 146 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 337ec1f..f8c1c381 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -18,6 +18,7 @@
#include <linux/rpmsg.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
+#include <linux/delay.h>
#include <linux/firmware/qcom/qcom_scm.h>
#include <uapi/misc/fastrpc.h>
#include <linux/of_reserved_mem.h>
@@ -32,6 +33,8 @@
#define FASTRPC_ALIGN 128
#define FASTRPC_MAX_FDLIST 16
#define FASTRPC_MAX_CRCLIST 64
+#define FASTRPC_KERNEL_PERF_LIST (PERF_KEY_MAX)
+#define FASTRPC_DSP_PERF_LIST 12
#define FASTRPC_PHYS(p) ((p) & 0xffffffff)
#define FASTRPC_CTX_MAX (256)
#define FASTRPC_INIT_HANDLE 1
@@ -104,6 +107,27 @@
#define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
+#define PERF_END ((void)0)
+
+#define PERF(enb, cnt, ff) \
+ {\
+ struct timespec64 startT = {0};\
+ uint64_t *counter = cnt;\
+ if (enb && counter) {\
+ ktime_get_real_ts64(&startT);\
+ } \
+ ff ;\
+ if (enb && counter) {\
+ *counter += getnstimediff(&startT);\
+ } \
+ }
+
+#define GET_COUNTER(perf_ptr, offset) \
+ (perf_ptr != NULL ?\
+ (((offset >= 0) && (offset < PERF_KEY_MAX)) ?\
+ (uint64_t *)(perf_ptr + offset)\
+ : (uint64_t *)NULL) : (uint64_t *)NULL)
+
static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp",
"sdsp", "cdsp"};
struct fastrpc_phy_page {
@@ -227,6 +251,19 @@ struct fastrpc_map {
struct kref refcount;
};
+struct fastrpc_perf {
+ u64 count;
+ u64 flush;
+ u64 map;
+ u64 copy;
+ u64 link;
+ u64 getargs;
+ u64 putargs;
+ u64 invargs;
+ u64 invoke;
+ u64 tid;
+};
+
struct fastrpc_invoke_ctx {
int nscalars;
int nbufs;
@@ -235,6 +272,8 @@ struct fastrpc_invoke_ctx {
int tgid;
u32 sc;
u32 *crc;
+ u64 *perf_kernel;
+ u64 *perf_dsp;
u64 ctxid;
u64 msg_sz;
struct kref refcount;
@@ -249,6 +288,7 @@ struct fastrpc_invoke_ctx {
struct fastrpc_invoke_args *args;
struct fastrpc_buf_overlap *olaps;
struct fastrpc_channel_ctx *cctx;
+ struct fastrpc_perf *perf;
};
struct fastrpc_session_ctx {
@@ -298,6 +338,7 @@ struct fastrpc_user {
struct fastrpc_session_ctx *sctx;
struct fastrpc_buf *init_mem;
+ u32 profile;
int tgid;
int pd;
bool is_secure_dev;
@@ -307,6 +348,17 @@ struct fastrpc_user {
struct mutex mutex;
};
+static inline int64_t getnstimediff(struct timespec64 *start)
+{
+ int64_t ns;
+ struct timespec64 ts, b;
+
+ ktime_get_real_ts64(&ts);
+ b = timespec64_sub(ts, *start);
+ ns = timespec64_to_ns(&b);
+ return ns;
+}
+
static void fastrpc_free_map(struct kref *ref)
{
struct fastrpc_map *map;
@@ -492,6 +544,9 @@ static void fastrpc_context_free(struct kref *ref)
if (ctx->buf)
fastrpc_buf_free(ctx->buf);
+ if (ctx->fl->profile)
+ kfree(ctx->perf);
+
spin_lock_irqsave(&cctx->lock, flags);
idr_remove(&cctx->ctx_idr, ctx->ctxid >> 4);
spin_unlock_irqrestore(&cctx->lock, flags);
@@ -611,6 +666,14 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
fastrpc_channel_ctx_get(cctx);
ctx->crc = (u32 *)(uintptr_t)invoke->crc;
+ ctx->perf_dsp = (u64 *)(uintptr_t)invoke->perf_dsp;
+ ctx->perf_kernel = (u64 *)(uintptr_t)invoke->perf_kernel;
+ if (ctx->fl->profile) {
+ ctx->perf = kzalloc(sizeof(*(ctx->perf)), GFP_KERNEL);
+ if (!ctx->perf)
+ return ERR_PTR(-ENOMEM);
+ ctx->perf->tid = ctx->fl->tgid;
+ }
ctx->sc = sc;
ctx->retval = -1;
ctx->pid = current->pid;
@@ -872,7 +935,8 @@ static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
sizeof(struct fastrpc_invoke_buf) +
sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
sizeof(u64) * FASTRPC_MAX_FDLIST +
- sizeof(u32) * FASTRPC_MAX_CRCLIST;
+ sizeof(u32) * FASTRPC_MAX_CRCLIST +
+ sizeof(u32) + sizeof(u64) * FASTRPC_DSP_PERF_LIST;
return size;
}
@@ -939,16 +1003,22 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
int inbufs, i, oix, err = 0;
u64 len, rlen, pkt_size;
u64 pg_start, pg_end;
+ u64 *perf_counter = NULL;
uintptr_t args;
int metalen;
+ if (ctx->fl->profile)
+ perf_counter = (u64 *)ctx->perf + PERF_COUNT;
+
inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
metalen = fastrpc_get_meta_size(ctx);
pkt_size = fastrpc_get_payload_size(ctx, metalen);
+ PERF(ctx->fl->profile, GET_COUNTER(perf_counter, PERF_MAP),
err = fastrpc_create_maps(ctx);
if (err)
return err;
+ PERF_END);
ctx->msg_sz = pkt_size;
@@ -980,6 +1050,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
if (ctx->maps[i]) {
struct vm_area_struct *vma = NULL;
+ PERF(ctx->fl->profile, GET_COUNTER(perf_counter, PERF_MAP),
rpra[i].buf.pv = (u64) ctx->args[i].ptr;
pages[i].addr = ctx->maps[i]->phys;
@@ -994,9 +1065,9 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
pg_end = ((ctx->args[i].ptr + len - 1) & PAGE_MASK) >>
PAGE_SHIFT;
pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE;
-
+ PERF_END);
} else {
-
+ PERF(ctx->fl->profile, GET_COUNTER(perf_counter, PERF_COPY),
if (ctx->olaps[oix].offset == 0) {
rlen -= ALIGN(args, FASTRPC_ALIGN) - args;
args = ALIGN(args, FASTRPC_ALIGN);
@@ -1018,12 +1089,14 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE;
args = args + mlen;
rlen -= mlen;
+ PERF_END);
}
if (i < inbufs && !ctx->maps[i]) {
void *dst = (void *)(uintptr_t)rpra[i].buf.pv;
void *src = (void *)(uintptr_t)ctx->args[i].ptr;
+ PERF(ctx->fl->profile, GET_COUNTER(perf_counter, PERF_COPY),
if (!kernel) {
if (copy_from_user(dst, (void __user *)src,
len)) {
@@ -1033,6 +1106,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
} else {
memcpy(dst, src, len);
}
+ PERF_END);
}
}
@@ -1063,9 +1137,9 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
struct fastrpc_map *mmap = NULL;
struct fastrpc_invoke_buf *list;
struct fastrpc_phy_page *pages;
- u64 *fdlist;
- u32 *crclist;
- int i, inbufs, outbufs, handles;
+ u64 *fdlist, *perf_dsp_list;
+ u32 *crclist, *poll;
+ int i, inbufs, outbufs, handles, perferr;
inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
@@ -1074,6 +1148,8 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
pages = fastrpc_phy_page_start(list, ctx->nscalars);
fdlist = (u64 *)(pages + inbufs + outbufs + handles);
crclist = (u32 *)(fdlist + FASTRPC_MAX_FDLIST);
+ poll = (u32 *)(crclist + FASTRPC_MAX_CRCLIST);
+ perf_dsp_list = (u64 *)(poll + 1);
for (i = inbufs; i < ctx->nbufs; ++i) {
if (!ctx->maps[i]) {
@@ -1098,8 +1174,16 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
}
if (ctx->crc && crclist && rpra) {
- if (copy_to_user((void __user *)ctx->crc, crclist, FASTRPC_MAX_CRCLIST * sizeof(u32)))
+ if (copy_to_user((void __user *)ctx->crc, crclist,
+ FASTRPC_MAX_CRCLIST * sizeof(u32))) {
return -EFAULT;
+ }
+ }
+ if (ctx->perf_dsp && perf_dsp_list) {
+ perferr = copy_to_user((void __user *)ctx->perf_dsp,
+ perf_dsp_list, FASTRPC_DSP_PERF_LIST * sizeof(u64));
+ if (perferr)
+ dev_info(fl->sctx->dev, "Warning: failed to copy perf data %d\n", perferr);
}
return 0;
}
@@ -1136,6 +1220,20 @@ static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
}
+static void fastrpc_update_invoke_count(u32 handle, u64 *perf_counter,
+ struct timespec64 *invoket)
+{
+ u64 *invcount, *count;
+
+ invcount = GET_COUNTER(perf_counter, PERF_INVOKE);
+ if (invcount)
+ *invcount += getnstimediff(invoket);
+
+ count = GET_COUNTER(perf_counter, PERF_COUNT);
+ if (count)
+ *count += 1;
+}
+
static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
struct fastrpc_enhanced_invoke *invoke)
{
@@ -1143,7 +1241,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
struct fastrpc_buf *buf, *b;
struct fastrpc_invoke *inv = &invoke->inv;
u32 handle, sc;
- int err = 0;
+ u64 *perf_counter = NULL;
+ int err = 0, perferr = 0;
+ struct timespec64 invoket = {0};
+
+ if (fl->profile)
+ ktime_get_real_ts64(&invoket);
if (!fl->sctx)
return -EINVAL;
@@ -1162,18 +1265,24 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (IS_ERR(ctx))
return PTR_ERR(ctx);
+ if (fl->profile)
+ perf_counter = (u64 *)ctx->perf + PERF_COUNT;
+ PERF(fl->profile, GET_COUNTER(perf_counter, PERF_GETARGS),
if (ctx->nscalars) {
err = fastrpc_get_args(kernel, ctx);
if (err)
goto bail;
}
+ PERF_END);
/* make sure that all CPU memory writes are seen by DSP */
dma_wmb();
+ PERF(fl->profile, GET_COUNTER(perf_counter, PERF_LINK),
/* Send invoke buffer to remote dsp */
err = fastrpc_invoke_send(fl->sctx, ctx, kernel, handle);
if (err)
goto bail;
+ PERF_END);
if (kernel) {
if (!wait_for_completion_timeout(&ctx->work, 10 * HZ))
@@ -1193,10 +1302,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (ctx->nscalars) {
/* make sure that all memory writes by DSP are seen by CPU */
dma_rmb();
+ PERF(fl->profile, GET_COUNTER(perf_counter, PERF_PUTARGS),
/* populate all the output buffers with results */
err = fastrpc_put_args(ctx, kernel);
if (err)
goto bail;
+ PERF_END);
}
bail:
@@ -1213,6 +1324,15 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
list_del(&buf->node);
list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps);
}
+ } else if (ctx) {
+ if (fl->profile && !err)
+ fastrpc_update_invoke_count(handle, perf_counter, &invoket);
+ if (fl->profile && ctx->perf && ctx->perf_kernel) {
+ perferr = copy_to_user((void __user *)ctx->perf_kernel,
+ ctx->perf, FASTRPC_KERNEL_PERF_LIST * sizeof(u64));
+ if (perferr)
+ dev_info(fl->sctx->dev, "Warning: failed to copy perf data %d\n", perferr);
+ }
}
if (err)
@@ -1706,6 +1826,7 @@ static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp)
struct fastrpc_invoke_args *args = NULL;
struct fastrpc_ioctl_multimode_invoke invoke;
u32 nscalars;
+ u64 *perf_kernel;
int err;
if (copy_from_user(&invoke, argp, sizeof(invoke)))
@@ -1729,6 +1850,9 @@ static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp)
return -EFAULT;
}
}
+ perf_kernel = (u64 *)(uintptr_t)einv.perf_kernel;
+ if (perf_kernel)
+ fl->profile = true;
einv.inv.args = (__u64)args;
err = fastrpc_internal_invoke(fl, false, &einv);
kfree(args);
diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h
index 36694fb..c64cf6a 100644
--- a/include/uapi/misc/fastrpc.h
+++ b/include/uapi/misc/fastrpc.h
@@ -165,4 +165,18 @@ struct fastrpc_ioctl_capability {
__u32 reserved[4];
};
+enum fastrpc_perfkeys {
+ PERF_COUNT = 0,
+ PERF_RESERVED1 = 1,
+ PERF_MAP = 2,
+ PERF_COPY = 3,
+ PERF_LINK = 4,
+ PERF_GETARGS = 5,
+ PERF_PUTARGS = 6,
+ PERF_RESERVED2 = 7,
+ PERF_INVOKE = 8,
+ PERF_RESERVED3 = 9,
+ PERF_KEY_MAX = 10,
+};
+
#endif /* __QCOM_FASTRPC_H__ */
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted
2023-08-31 16:28 [PATCH v1 0/5] Add multimode invoke request IOCTl support Ekansh Gupta
` (2 preceding siblings ...)
2023-08-31 16:28 ` [PATCH v1 3/5] misc: fastrpc: Capture kernel and DSP performance counters Ekansh Gupta
@ 2023-08-31 16:28 ` Ekansh Gupta
2023-09-01 1:49 ` kernel test robot
2023-08-31 16:28 ` [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank Ekansh Gupta
4 siblings, 1 reply; 9+ messages in thread
From: Ekansh Gupta @ 2023-08-31 16:28 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
For any remote call, driver sends a message to DSP using RPMSG
framework. After message is sent, there is a wait on a completion
object at driver which is completed when DSP response is received.
There is a possibility that a signal is received while waiting
causing the wait function to return -ERESTARTSYS. In this case
the context should be saved and it should get restored for the
next invocation for the thread.
Adding changes to support saving and restoring of interrupted
fastrpc contexts.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 72 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index f8c1c381..1b26718 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -332,6 +332,7 @@ struct fastrpc_user {
struct list_head user;
struct list_head maps;
struct list_head pending;
+ struct list_head interrupted;
struct list_head mmaps;
struct fastrpc_channel_ctx *cctx;
@@ -711,6 +712,40 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
return ERR_PTR(ret);
}
+static struct fastrpc_invoke_ctx *fastrpc_context_restore_interrupted(
+ struct fastrpc_user *fl, struct fastrpc_invoke *inv)
+{
+ struct fastrpc_invoke_ctx *ctx = NULL, *ictx = NULL, *n;
+
+ spin_lock(&fl->lock);
+ list_for_each_entry_safe(ictx, n, &fl->interrupted, node) {
+ if (ictx->pid == current->pid) {
+ if (inv->sc != ictx->sc || ictx->fl != fl) {
+ dev_err(ictx->fl->sctx->dev,
+ "interrupted sc (0x%x) or fl (%pK) does not match with invoke sc (0x%x) or fl (%pK)\n",
+ ictx->sc, ictx->fl, inv->sc, fl);
+ spin_unlock(&fl->lock);
+ return ERR_PTR(-EINVAL);
+ }
+ ctx = ictx;
+ list_del(&ctx->node);
+ list_add_tail(&ctx->node, &fl->pending);
+ break;
+ }
+ }
+ spin_unlock(&fl->lock);
+ return ctx;
+}
+
+static void fastrpc_context_save_interrupted(
+ struct fastrpc_invoke_ctx *ctx)
+{
+ spin_lock(&ctx->fl->lock);
+ list_del(&ctx->node);
+ list_add_tail(&ctx->node, &ctx->fl->interrupted);
+ spin_unlock(&ctx->fl->lock);
+}
+
static struct sg_table *
fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
enum dma_data_direction dir)
@@ -1261,6 +1296,14 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
return -EPERM;
}
+ if (!kernel) {
+ ctx = fastrpc_context_restore_interrupted(fl, inv);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+ if (ctx)
+ goto wait;
+ }
+
ctx = fastrpc_context_alloc(fl, kernel, sc, invoke);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
@@ -1284,6 +1327,7 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
goto bail;
PERF_END);
+wait:
if (kernel) {
if (!wait_for_completion_timeout(&ctx->work, 10 * HZ))
err = -ETIMEDOUT;
@@ -1320,6 +1364,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
}
if (err == -ERESTARTSYS) {
+ if (ctx)
+ fastrpc_context_save_interrupted(ctx);
+
list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
list_del(&buf->node);
list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps);
@@ -1620,6 +1667,25 @@ static void fastrpc_session_free(struct fastrpc_channel_ctx *cctx,
spin_unlock_irqrestore(&cctx->lock, flags);
}
+static void fastrpc_context_list_free(struct fastrpc_user *fl)
+{
+ struct fastrpc_invoke_ctx *ctx, *n;
+
+ list_for_each_entry_safe(ctx, n, &fl->interrupted, node) {
+ spin_lock(&fl->lock);
+ list_del(&ctx->node);
+ spin_unlock(&fl->lock);
+ fastrpc_context_put(ctx);
+ }
+
+ list_for_each_entry_safe(ctx, n, &fl->pending, node) {
+ spin_lock(&fl->lock);
+ list_del(&ctx->node);
+ spin_unlock(&fl->lock);
+ fastrpc_context_put(ctx);
+ }
+}
+
static int fastrpc_release_current_dsp_process(struct fastrpc_user *fl)
{
struct fastrpc_invoke_args args[1];
@@ -1656,10 +1722,7 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
if (fl->init_mem)
fastrpc_buf_free(fl->init_mem);
- list_for_each_entry_safe(ctx, n, &fl->pending, node) {
- list_del(&ctx->node);
- fastrpc_context_put(ctx);
- }
+ fastrpc_context_list_free(fl);
list_for_each_entry_safe(map, m, &fl->maps, node)
fastrpc_map_put(map);
@@ -1700,6 +1763,7 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
spin_lock_init(&fl->lock);
mutex_init(&fl->mutex);
INIT_LIST_HEAD(&fl->pending);
+ INIT_LIST_HEAD(&fl->interrupted);
INIT_LIST_HEAD(&fl->maps);
INIT_LIST_HEAD(&fl->mmaps);
INIT_LIST_HEAD(&fl->user);
@@ -2555,6 +2619,10 @@ static void fastrpc_notify_users(struct fastrpc_user *user)
ctx->retval = -EPIPE;
complete(&ctx->work);
}
+ list_for_each_entry(ctx, &user->interrupted, node) {
+ ctx->retval = -EPIPE;
+ complete(&ctx->work);
+ }
spin_unlock(&user->lock);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank
2023-08-31 16:28 [PATCH v1 0/5] Add multimode invoke request IOCTl support Ekansh Gupta
` (3 preceding siblings ...)
2023-08-31 16:28 ` [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted Ekansh Gupta
@ 2023-08-31 16:28 ` Ekansh Gupta
2023-09-01 6:31 ` kernel test robot
4 siblings, 1 reply; 9+ messages in thread
From: Ekansh Gupta @ 2023-08-31 16:28 UTC (permalink / raw)
To: srinivas.kandagatla, linux-arm-msm
Cc: Ekansh Gupta, ekangupt, gregkh, linux-kernel, fastrpc.upstream
Context banks could be set as a shared one using a DT propery
"qcom,nsessions". The property takes the number of session to
be created of the context bank. This change provides a control
mechanism for user to use shared context banks for light weight
processes. The session is set as shared while its creation and if
a user requests for shared context bank, the same will be allocated
during process initialization.
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 121 +++++++++++++++++++++++++++++++++----------------
1 file changed, 82 insertions(+), 39 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 1b26718..6ac1403 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -296,6 +296,7 @@ struct fastrpc_session_ctx {
int sid;
bool used;
bool valid;
+ bool sharedcb;
};
struct fastrpc_channel_ctx {
@@ -343,12 +344,22 @@ struct fastrpc_user {
int tgid;
int pd;
bool is_secure_dev;
+ bool sharedcb;
/* Lock for lists */
spinlock_t lock;
/* lock for allocations */
struct mutex mutex;
};
+struct fastrpc_ctrl_smmu {
+ u32 sharedcb; /* Set to SMMU share context bank */
+};
+
+struct fastrpc_internal_control {
+ u32 req;
+ struct fastrpc_ctrl_smmu smmu;
+};
+
static inline int64_t getnstimediff(struct timespec64 *start)
{
int64_t ns;
@@ -850,6 +861,37 @@ static const struct dma_buf_ops fastrpc_dma_buf_ops = {
.release = fastrpc_release,
};
+static struct fastrpc_session_ctx *fastrpc_session_alloc(
+ struct fastrpc_channel_ctx *cctx, bool sharedcb)
+{
+ struct fastrpc_session_ctx *session = NULL;
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&cctx->lock, flags);
+ for (i = 0; i < cctx->sesscount; i++) {
+ if (!cctx->session[i].used && cctx->session[i].valid &&
+ cctx->session[i].sharedcb == sharedcb) {
+ cctx->session[i].used = true;
+ session = &cctx->session[i];
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&cctx->lock, flags);
+
+ return session;
+}
+
+static void fastrpc_session_free(struct fastrpc_channel_ctx *cctx,
+ struct fastrpc_session_ctx *session)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&cctx->lock, flags);
+ session->used = false;
+ spin_unlock_irqrestore(&cctx->lock, flags);
+}
+
static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
u64 len, u32 attr, struct fastrpc_map **ppmap)
{
@@ -1446,6 +1488,10 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
goto err_name;
}
+ fl->sctx = fastrpc_session_alloc(fl->cctx, fl->sharedcb);
+ if (!fl->sctx)
+ return -EBUSY;
+
if (!fl->cctx->remote_heap) {
err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
&fl->cctx->remote_heap);
@@ -1563,6 +1609,10 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
goto err;
}
+ fl->sctx = fastrpc_session_alloc(fl->cctx, fl->sharedcb);
+ if (!fl->sctx)
+ return -EBUSY;
+
inbuf.pgid = fl->tgid;
inbuf.namelen = strlen(current->comm) + 1;
inbuf.filelen = init.filelen;
@@ -1637,36 +1687,6 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
return err;
}
-static struct fastrpc_session_ctx *fastrpc_session_alloc(
- struct fastrpc_channel_ctx *cctx)
-{
- struct fastrpc_session_ctx *session = NULL;
- unsigned long flags;
- int i;
-
- spin_lock_irqsave(&cctx->lock, flags);
- for (i = 0; i < cctx->sesscount; i++) {
- if (!cctx->session[i].used && cctx->session[i].valid) {
- cctx->session[i].used = true;
- session = &cctx->session[i];
- break;
- }
- }
- spin_unlock_irqrestore(&cctx->lock, flags);
-
- return session;
-}
-
-static void fastrpc_session_free(struct fastrpc_channel_ctx *cctx,
- struct fastrpc_session_ctx *session)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&cctx->lock, flags);
- session->used = false;
- spin_unlock_irqrestore(&cctx->lock, flags);
-}
-
static void fastrpc_context_list_free(struct fastrpc_user *fl)
{
struct fastrpc_invoke_ctx *ctx, *n;
@@ -1771,15 +1791,6 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
fl->cctx = cctx;
fl->is_secure_dev = fdevice->secure;
- fl->sctx = fastrpc_session_alloc(cctx);
- if (!fl->sctx) {
- dev_err(&cctx->rpdev->dev, "No session available\n");
- mutex_destroy(&fl->mutex);
- kfree(fl);
-
- return -EBUSY;
- }
-
spin_lock_irqsave(&cctx->lock, flags);
list_add_tail(&fl->user, &cctx->users);
spin_unlock_irqrestore(&cctx->lock, flags);
@@ -1838,6 +1849,10 @@ static int fastrpc_init_attach(struct fastrpc_user *fl, int pd)
struct fastrpc_enhanced_invoke ioctl;
int tgid = fl->tgid;
+ fl->sctx = fastrpc_session_alloc(fl->cctx, fl->sharedcb);
+ if (!fl->sctx)
+ return -EBUSY;
+
args[0].ptr = (u64)(uintptr_t) &tgid;
args[0].length = sizeof(tgid);
args[0].fd = -1;
@@ -1884,11 +1899,32 @@ static int fastrpc_invoke(struct fastrpc_user *fl, char __user *argp)
return err;
}
+static int fastrpc_internal_control(struct fastrpc_user *fl,
+ struct fastrpc_internal_control *cp)
+{
+ int err = 0;
+
+ if (!fl)
+ return -EBADF;
+ if (!cp)
+ return -EINVAL;
+
+ case FASTRPC_CONTROL_SMMU:
+ fl->sharedcb = cp->smmu.sharedcb;
+ break;
+ default:
+ err = -EBADRQC;
+ break;
+ }
+ return err;
+}
+
static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp)
{
struct fastrpc_enhanced_invoke einv;
struct fastrpc_invoke_args *args = NULL;
struct fastrpc_ioctl_multimode_invoke invoke;
+ struct fastrpc_internal_control cp = {0};
u32 nscalars;
u64 *perf_kernel;
int err;
@@ -1921,6 +1957,12 @@ static int fastrpc_multimode_invoke(struct fastrpc_user *fl, char __user *argp)
err = fastrpc_internal_invoke(fl, false, &einv);
kfree(args);
break;
+ case FASTRPC_INVOKE_CONTROL:
+ if (copy_from_user(&cp, (void __user *)(uintptr_t)invoke.invparam, sizeof(cp)))
+ return -EFAULT;
+
+ err = fastrpc_internal_control(fl, &cp);
+ break;
default:
err = -ENOTTY;
break;
@@ -2421,6 +2463,7 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
if (sessions > 0) {
struct fastrpc_session_ctx *dup_sess;
+ sess->sharedcb = true;
for (i = 1; i < sessions; i++) {
if (cctx->sesscount >= FASTRPC_MAX_SESSIONS)
break;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support
2023-08-31 16:28 ` [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support Ekansh Gupta
@ 2023-08-31 21:26 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2023-08-31 21:26 UTC (permalink / raw)
To: Ekansh Gupta, srinivas.kandagatla, linux-arm-msm
Cc: oe-kbuild-all, Ekansh Gupta, ekangupt, gregkh, linux-kernel,
fastrpc.upstream
Hi Ekansh,
kernel test robot noticed the following build warnings:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.5 next-20230831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ekansh-Gupta/misc-fastrpc-Add-fastrpc-multimode-invoke-request-support/20230901-002929
base: char-misc/char-misc-testing
patch link: https://lore.kernel.org/r/1693499292-19083-2-git-send-email-quic_ekangupt%40quicinc.com
patch subject: [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230901/202309010543.Xc8XI7oZ-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230901/202309010543.Xc8XI7oZ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309010543.Xc8XI7oZ-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/misc/fastrpc.c: In function 'fastrpc_context_alloc':
>> drivers/misc/fastrpc.c:607:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
607 | ctx->args = (struct fastrpc_invoke_args *)invoke->inv.args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_create_static_process':
>> drivers/misc/fastrpc.c:1320:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1320 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_create_process':
drivers/misc/fastrpc.c:1453:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1453 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_release_current_dsp_process':
drivers/misc/fastrpc.c:1517:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1517 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_attach':
drivers/misc/fastrpc.c:1665:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1665 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_invoke':
drivers/misc/fastrpc.c:1696:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1696 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_multimode_invoke':
drivers/misc/fastrpc.c:1732:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1732 | einv.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_get_info_from_dsp':
drivers/misc/fastrpc.c:1762:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1762 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_munmap_impl':
drivers/misc/fastrpc.c:1865:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1865 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mmap':
drivers/misc/fastrpc.c:1963:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1963 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mem_unmap_impl':
drivers/misc/fastrpc.c:2044:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2044 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mem_map':
drivers/misc/fastrpc.c:2113:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2113 | ioctl.inv.args = (__u64)args;
| ^
vim +607 drivers/misc/fastrpc.c
573
574 static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
575 struct fastrpc_user *user, u32 kernel, u32 sc,
576 struct fastrpc_enhanced_invoke *invoke)
577 {
578 struct fastrpc_channel_ctx *cctx = user->cctx;
579 struct fastrpc_invoke_ctx *ctx = NULL;
580 unsigned long flags;
581 int ret;
582
583 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
584 if (!ctx)
585 return ERR_PTR(-ENOMEM);
586
587 INIT_LIST_HEAD(&ctx->node);
588 ctx->fl = user;
589 ctx->nscalars = REMOTE_SCALARS_LENGTH(sc);
590 ctx->nbufs = REMOTE_SCALARS_INBUFS(sc) +
591 REMOTE_SCALARS_OUTBUFS(sc);
592
593 if (ctx->nscalars) {
594 ctx->maps = kcalloc(ctx->nscalars,
595 sizeof(*ctx->maps), GFP_KERNEL);
596 if (!ctx->maps) {
597 kfree(ctx);
598 return ERR_PTR(-ENOMEM);
599 }
600 ctx->olaps = kcalloc(ctx->nscalars,
601 sizeof(*ctx->olaps), GFP_KERNEL);
602 if (!ctx->olaps) {
603 kfree(ctx->maps);
604 kfree(ctx);
605 return ERR_PTR(-ENOMEM);
606 }
> 607 ctx->args = (struct fastrpc_invoke_args *)invoke->inv.args;
608 fastrpc_get_buff_overlaps(ctx);
609 }
610
611 /* Released in fastrpc_context_put() */
612 fastrpc_channel_ctx_get(cctx);
613
614 ctx->sc = sc;
615 ctx->retval = -1;
616 ctx->pid = current->pid;
617 ctx->tgid = user->tgid;
618 ctx->cctx = cctx;
619 init_completion(&ctx->work);
620 INIT_WORK(&ctx->put_work, fastrpc_context_put_wq);
621
622 spin_lock(&user->lock);
623 list_add_tail(&ctx->node, &user->pending);
624 spin_unlock(&user->lock);
625
626 spin_lock_irqsave(&cctx->lock, flags);
627 ret = idr_alloc_cyclic(&cctx->ctx_idr, ctx, 1,
628 FASTRPC_CTX_MAX, GFP_ATOMIC);
629 if (ret < 0) {
630 spin_unlock_irqrestore(&cctx->lock, flags);
631 goto err_idr;
632 }
633 ctx->ctxid = ret << 4;
634 spin_unlock_irqrestore(&cctx->lock, flags);
635
636 kref_init(&ctx->refcount);
637
638 return ctx;
639 err_idr:
640 spin_lock(&user->lock);
641 list_del(&ctx->node);
642 spin_unlock(&user->lock);
643 fastrpc_channel_ctx_put(cctx);
644 kfree(ctx->maps);
645 kfree(ctx->olaps);
646 kfree(ctx);
647
648 return ERR_PTR(ret);
649 }
650
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted
2023-08-31 16:28 ` [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted Ekansh Gupta
@ 2023-09-01 1:49 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2023-09-01 1:49 UTC (permalink / raw)
To: Ekansh Gupta, srinivas.kandagatla, linux-arm-msm
Cc: oe-kbuild-all, Ekansh Gupta, ekangupt, gregkh, linux-kernel,
fastrpc.upstream
Hi Ekansh,
kernel test robot noticed the following build warnings:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.5 next-20230831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ekansh-Gupta/misc-fastrpc-Add-fastrpc-multimode-invoke-request-support/20230901-002929
base: char-misc/char-misc-testing
patch link: https://lore.kernel.org/r/1693499292-19083-5-git-send-email-quic_ekangupt%40quicinc.com
patch subject: [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230901/202309010926.bLqVExVs-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230901/202309010926.bLqVExVs-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309010926.bLqVExVs-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/misc/fastrpc.c: In function 'fastrpc_context_alloc':
drivers/misc/fastrpc.c:663:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
663 | ctx->args = (struct fastrpc_invoke_args *)invoke->inv.args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_create_static_process':
drivers/misc/fastrpc.c:1494:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1494 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_create_process':
drivers/misc/fastrpc.c:1627:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1627 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_release_current_dsp_process':
drivers/misc/fastrpc.c:1710:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1710 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_device_release':
>> drivers/misc/fastrpc.c:1719:42: warning: unused variable 'n' [-Wunused-variable]
1719 | struct fastrpc_invoke_ctx *ctx, *n;
| ^
>> drivers/misc/fastrpc.c:1719:36: warning: unused variable 'ctx' [-Wunused-variable]
1719 | struct fastrpc_invoke_ctx *ctx, *n;
| ^~~
drivers/misc/fastrpc.c: In function 'fastrpc_init_attach':
drivers/misc/fastrpc.c:1856:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1856 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_invoke':
drivers/misc/fastrpc.c:1887:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1887 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_multimode_invoke':
drivers/misc/fastrpc.c:1928:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1928 | einv.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_get_info_from_dsp':
drivers/misc/fastrpc.c:1958:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1958 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_munmap_impl':
drivers/misc/fastrpc.c:2061:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2061 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mmap':
drivers/misc/fastrpc.c:2159:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2159 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mem_unmap_impl':
drivers/misc/fastrpc.c:2240:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2240 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mem_map':
drivers/misc/fastrpc.c:2309:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2309 | ioctl.inv.args = (__u64)args;
| ^
vim +/n +1719 drivers/misc/fastrpc.c
0871561055e666 Abel Vesa 2022-11-25 1530
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1531 static int fastrpc_init_create_process(struct fastrpc_user *fl,
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1532 char __user *argp)
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1533 {
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1534 struct fastrpc_init_create init;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1535 struct fastrpc_invoke_args *args;
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1536 struct fastrpc_enhanced_invoke ioctl;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1537 struct fastrpc_phy_page pages[1];
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1538 struct fastrpc_map *map = NULL;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1539 struct fastrpc_buf *imem = NULL;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1540 int memlen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1541 int err;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1542 struct {
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1543 int pgid;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1544 u32 namelen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1545 u32 filelen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1546 u32 pageslen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1547 u32 attrs;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1548 u32 siglen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1549 } inbuf;
7f1f481263c3ce Jeya R 2022-02-14 1550 bool unsigned_module = false;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1551
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1552 args = kcalloc(FASTRPC_CREATE_PROCESS_NARGS, sizeof(*args), GFP_KERNEL);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1553 if (!args)
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1554 return -ENOMEM;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1555
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1556 if (copy_from_user(&init, argp, sizeof(init))) {
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1557 err = -EFAULT;
b49f6d83e290f1 Thierry Escande 2019-03-07 1558 goto err;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1559 }
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1560
7f1f481263c3ce Jeya R 2022-02-14 1561 if (init.attrs & FASTRPC_MODE_UNSIGNED_MODULE)
7f1f481263c3ce Jeya R 2022-02-14 1562 unsigned_module = true;
7f1f481263c3ce Jeya R 2022-02-14 1563
7f1f481263c3ce Jeya R 2022-02-14 1564 if (is_session_rejected(fl, unsigned_module)) {
7f1f481263c3ce Jeya R 2022-02-14 1565 err = -ECONNREFUSED;
7f1f481263c3ce Jeya R 2022-02-14 1566 goto err;
7f1f481263c3ce Jeya R 2022-02-14 1567 }
7f1f481263c3ce Jeya R 2022-02-14 1568
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1569 if (init.filelen > INIT_FILELEN_MAX) {
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1570 err = -EINVAL;
b49f6d83e290f1 Thierry Escande 2019-03-07 1571 goto err;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1572 }
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1573
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1574 inbuf.pgid = fl->tgid;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1575 inbuf.namelen = strlen(current->comm) + 1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1576 inbuf.filelen = init.filelen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1577 inbuf.pageslen = 1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1578 inbuf.attrs = init.attrs;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1579 inbuf.siglen = init.siglen;
84195d206e1fbd Jonathan Marek 2020-09-08 1580 fl->pd = USER_PD;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1581
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1582 if (init.filelen && init.filefd) {
e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 1583 err = fastrpc_map_create(fl, init.filefd, init.filelen, 0, &map);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1584 if (err)
b49f6d83e290f1 Thierry Escande 2019-03-07 1585 goto err;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1586 }
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1587
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1588 memlen = ALIGN(max(INIT_FILELEN_MAX, (int)init.filelen * 4),
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1589 1024 * 1024);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1590 err = fastrpc_buf_alloc(fl, fl->sctx->dev, memlen,
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1591 &imem);
b49f6d83e290f1 Thierry Escande 2019-03-07 1592 if (err)
b49f6d83e290f1 Thierry Escande 2019-03-07 1593 goto err_alloc;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1594
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1595 fl->init_mem = imem;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1596 args[0].ptr = (u64)(uintptr_t)&inbuf;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1597 args[0].length = sizeof(inbuf);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1598 args[0].fd = -1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1599
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1600 args[1].ptr = (u64)(uintptr_t)current->comm;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1601 args[1].length = inbuf.namelen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1602 args[1].fd = -1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1603
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1604 args[2].ptr = (u64) init.file;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1605 args[2].length = inbuf.filelen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1606 args[2].fd = init.filefd;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1607
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1608 pages[0].addr = imem->phys;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1609 pages[0].size = imem->size;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1610
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1611 args[3].ptr = (u64)(uintptr_t) pages;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1612 args[3].length = 1 * sizeof(*pages);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1613 args[3].fd = -1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1614
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1615 args[4].ptr = (u64)(uintptr_t)&inbuf.attrs;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1616 args[4].length = sizeof(inbuf.attrs);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1617 args[4].fd = -1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1618
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1619 args[5].ptr = (u64)(uintptr_t) &inbuf.siglen;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1620 args[5].length = sizeof(inbuf.siglen);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1621 args[5].fd = -1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1622
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1623 ioctl.inv.handle = FASTRPC_INIT_HANDLE;
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1624 ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE, 4, 0);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1625 if (init.attrs)
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1626 ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_CREATE_ATTR, 4, 0);
db2e49fb9bf108 Ekansh Gupta 2023-08-31 @1627 ioctl.inv.args = (__u64)args;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1628
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1629 err = fastrpc_internal_invoke(fl, true, &ioctl);
b49f6d83e290f1 Thierry Escande 2019-03-07 1630 if (err)
b49f6d83e290f1 Thierry Escande 2019-03-07 1631 goto err_invoke;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1632
b49f6d83e290f1 Thierry Escande 2019-03-07 1633 kfree(args);
b49f6d83e290f1 Thierry Escande 2019-03-07 1634
b49f6d83e290f1 Thierry Escande 2019-03-07 1635 return 0;
b49f6d83e290f1 Thierry Escande 2019-03-07 1636
b49f6d83e290f1 Thierry Escande 2019-03-07 1637 err_invoke:
b49f6d83e290f1 Thierry Escande 2019-03-07 1638 fl->init_mem = NULL;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1639 fastrpc_buf_free(imem);
b49f6d83e290f1 Thierry Escande 2019-03-07 1640 err_alloc:
b49f6d83e290f1 Thierry Escande 2019-03-07 1641 fastrpc_map_put(map);
b49f6d83e290f1 Thierry Escande 2019-03-07 1642 err:
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1643 kfree(args);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1644
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1645 return err;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1646 }
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1647
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1648 static struct fastrpc_session_ctx *fastrpc_session_alloc(
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1649 struct fastrpc_channel_ctx *cctx)
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1650 {
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1651 struct fastrpc_session_ctx *session = NULL;
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1652 unsigned long flags;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1653 int i;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1654
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1655 spin_lock_irqsave(&cctx->lock, flags);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1656 for (i = 0; i < cctx->sesscount; i++) {
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1657 if (!cctx->session[i].used && cctx->session[i].valid) {
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1658 cctx->session[i].used = true;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1659 session = &cctx->session[i];
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1660 break;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1661 }
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1662 }
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1663 spin_unlock_irqrestore(&cctx->lock, flags);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1664
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1665 return session;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1666 }
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1667
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1668 static void fastrpc_session_free(struct fastrpc_channel_ctx *cctx,
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1669 struct fastrpc_session_ctx *session)
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1670 {
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1671 unsigned long flags;
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1672
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1673 spin_lock_irqsave(&cctx->lock, flags);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1674 session->used = false;
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1675 spin_unlock_irqrestore(&cctx->lock, flags);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1676 }
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1677
1d9e27a4779236 Ekansh Gupta 2023-08-31 1678 static void fastrpc_context_list_free(struct fastrpc_user *fl)
1d9e27a4779236 Ekansh Gupta 2023-08-31 1679 {
1d9e27a4779236 Ekansh Gupta 2023-08-31 1680 struct fastrpc_invoke_ctx *ctx, *n;
1d9e27a4779236 Ekansh Gupta 2023-08-31 1681
1d9e27a4779236 Ekansh Gupta 2023-08-31 1682 list_for_each_entry_safe(ctx, n, &fl->interrupted, node) {
1d9e27a4779236 Ekansh Gupta 2023-08-31 1683 spin_lock(&fl->lock);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1684 list_del(&ctx->node);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1685 spin_unlock(&fl->lock);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1686 fastrpc_context_put(ctx);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1687 }
1d9e27a4779236 Ekansh Gupta 2023-08-31 1688
1d9e27a4779236 Ekansh Gupta 2023-08-31 1689 list_for_each_entry_safe(ctx, n, &fl->pending, node) {
1d9e27a4779236 Ekansh Gupta 2023-08-31 1690 spin_lock(&fl->lock);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1691 list_del(&ctx->node);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1692 spin_unlock(&fl->lock);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1693 fastrpc_context_put(ctx);
1d9e27a4779236 Ekansh Gupta 2023-08-31 1694 }
1d9e27a4779236 Ekansh Gupta 2023-08-31 1695 }
1d9e27a4779236 Ekansh Gupta 2023-08-31 1696
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1697 static int fastrpc_release_current_dsp_process(struct fastrpc_user *fl)
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1698 {
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1699 struct fastrpc_invoke_args args[1];
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1700 struct fastrpc_enhanced_invoke ioctl;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1701 int tgid = 0;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1702
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1703 tgid = fl->tgid;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1704 args[0].ptr = (u64)(uintptr_t) &tgid;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1705 args[0].length = sizeof(tgid);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1706 args[0].fd = -1;
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1707
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1708 ioctl.inv.handle = FASTRPC_INIT_HANDLE;
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1709 ioctl.inv.sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_RELEASE, 1, 0);
db2e49fb9bf108 Ekansh Gupta 2023-08-31 @1710 ioctl.inv.args = (__u64)args;
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1711
db2e49fb9bf108 Ekansh Gupta 2023-08-31 1712 return fastrpc_internal_invoke(fl, true, &ioctl);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1713 }
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1714
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1715 static int fastrpc_device_release(struct inode *inode, struct file *file)
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1716 {
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1717 struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1718 struct fastrpc_channel_ctx *cctx = fl->cctx;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 @1719 struct fastrpc_invoke_ctx *ctx, *n;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1720 struct fastrpc_map *map, *m;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1721 struct fastrpc_buf *buf, *b;
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1722 unsigned long flags;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1723
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1724 fastrpc_release_current_dsp_process(fl);
d73f71c7c6ee15 Srinivas Kandagatla 2019-02-08 1725
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1726 spin_lock_irqsave(&cctx->lock, flags);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1727 list_del(&fl->user);
977e6c8d1d1806 Srinivas Kandagatla 2019-03-07 1728 spin_unlock_irqrestore(&cctx->lock, flags);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1729
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1730 if (fl->init_mem)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1731 fastrpc_buf_free(fl->init_mem);
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1732
1d9e27a4779236 Ekansh Gupta 2023-08-31 1733 fastrpc_context_list_free(fl);
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1734
5bb96c8f9268e2 Abel Vesa 2022-11-24 1735 list_for_each_entry_safe(map, m, &fl->maps, node)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1736 fastrpc_map_put(map);
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 1737
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1738 list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1739 list_del(&buf->node);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1740 fastrpc_buf_free(buf);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1741 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1742
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1743 fastrpc_session_free(cctx, fl->sctx);
278d56f970ae6e Bjorn Andersson 2019-08-29 1744 fastrpc_channel_ctx_put(cctx);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1745
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1746 mutex_destroy(&fl->mutex);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1747 kfree(fl);
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1748 file->private_data = NULL;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1749
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1750 return 0;
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1751 }
f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 1752
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank
2023-08-31 16:28 ` [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank Ekansh Gupta
@ 2023-09-01 6:31 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2023-09-01 6:31 UTC (permalink / raw)
To: Ekansh Gupta, srinivas.kandagatla, linux-arm-msm
Cc: oe-kbuild-all, Ekansh Gupta, ekangupt, gregkh, linux-kernel,
fastrpc.upstream
Hi Ekansh,
kernel test robot noticed the following build warnings:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.5 next-20230831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ekansh-Gupta/misc-fastrpc-Add-fastrpc-multimode-invoke-request-support/20230901-002929
base: char-misc/char-misc-testing
patch link: https://lore.kernel.org/r/1693499292-19083-6-git-send-email-quic_ekangupt%40quicinc.com
patch subject: [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230901/202309011446.SVM4HbHv-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230901/202309011446.SVM4HbHv-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309011446.SVM4HbHv-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/misc/fastrpc.c: In function 'fastrpc_context_alloc':
drivers/misc/fastrpc.c:674:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
674 | ctx->args = (struct fastrpc_invoke_args *)invoke->inv.args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_create_static_process':
drivers/misc/fastrpc.c:1540:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1540 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_init_create_process':
drivers/misc/fastrpc.c:1677:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1677 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_release_current_dsp_process':
drivers/misc/fastrpc.c:1730:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1730 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_device_release':
drivers/misc/fastrpc.c:1739:42: warning: unused variable 'n' [-Wunused-variable]
1739 | struct fastrpc_invoke_ctx *ctx, *n;
| ^
drivers/misc/fastrpc.c:1739:36: warning: unused variable 'ctx' [-Wunused-variable]
1739 | struct fastrpc_invoke_ctx *ctx, *n;
| ^~~
drivers/misc/fastrpc.c: In function 'fastrpc_init_attach':
drivers/misc/fastrpc.c:1871:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1871 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_invoke':
drivers/misc/fastrpc.c:1902:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1902 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_internal_control':
drivers/misc/fastrpc.c:1920:14: error: 'FASTRPC_CONTROL_SMMU' undeclared (first use in this function); did you mean 'FASTRPC_IOCTL_MMAP'?
1920 | case FASTRPC_CONTROL_SMMU:
| ^~~~~~~~~~~~~~~~~~~~
| FASTRPC_IOCTL_MMAP
drivers/misc/fastrpc.c:1920:14: note: each undeclared identifier is reported only once for each function it appears in
drivers/misc/fastrpc.c:1920:9: error: case label not within a switch statement
1920 | case FASTRPC_CONTROL_SMMU:
| ^~~~
drivers/misc/fastrpc.c:1922:17: error: break statement not within loop or switch
1922 | break;
| ^~~~~
drivers/misc/fastrpc.c:1923:9: error: 'default' label not within a switch statement
1923 | default:
| ^~~~~~~
drivers/misc/fastrpc.c:1925:17: error: break statement not within loop or switch
1925 | break;
| ^~~~~
>> drivers/misc/fastrpc.c:1913:13: warning: variable 'err' set but not used [-Wunused-but-set-variable]
1913 | int err = 0;
| ^~~
drivers/misc/fastrpc.c: At top level:
drivers/misc/fastrpc.c:1927:9: error: expected identifier or '(' before 'return'
1927 | return err;
| ^~~~~~
drivers/misc/fastrpc.c:1928:1: error: expected identifier or '(' before '}' token
1928 | }
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_multimode_invoke':
drivers/misc/fastrpc.c:1964:33: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1964 | einv.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_get_info_from_dsp':
drivers/misc/fastrpc.c:2000:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2000 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_munmap_impl':
drivers/misc/fastrpc.c:2103:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2103 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mmap':
drivers/misc/fastrpc.c:2201:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2201 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mem_unmap_impl':
drivers/misc/fastrpc.c:2282:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2282 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_req_mem_map':
drivers/misc/fastrpc.c:2351:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2351 | ioctl.inv.args = (__u64)args;
| ^
drivers/misc/fastrpc.c: In function 'fastrpc_internal_control':
drivers/misc/fastrpc.c:1926:9: error: control reaches end of non-void function [-Werror=return-type]
1926 | }
| ^
cc1: some warnings being treated as errors
vim +/err +1913 drivers/misc/fastrpc.c
1909
1910 static int fastrpc_internal_control(struct fastrpc_user *fl,
1911 struct fastrpc_internal_control *cp)
1912 {
> 1913 int err = 0;
1914
1915 if (!fl)
1916 return -EBADF;
1917 if (!cp)
1918 return -EINVAL;
1919
1920 case FASTRPC_CONTROL_SMMU:
1921 fl->sharedcb = cp->smmu.sharedcb;
> 1922 break;
1923 default:
1924 err = -EBADRQC;
1925 break;
1926 }
1927 return err;
1928 }
1929
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-09-01 6:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-31 16:28 [PATCH v1 0/5] Add multimode invoke request IOCTl support Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 1/5] misc: fastrpc: Add fastrpc multimode invoke request support Ekansh Gupta
2023-08-31 21:26 ` kernel test robot
2023-08-31 16:28 ` [PATCH v1 2/5] misc: fastrpc: Add CRC support for remote buffers Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 3/5] misc: fastrpc: Capture kernel and DSP performance counters Ekansh Gupta
2023-08-31 16:28 ` [PATCH v1 4/5] misc: fastrpc: Add support to save and restore interrupted Ekansh Gupta
2023-09-01 1:49 ` kernel test robot
2023-08-31 16:28 ` [PATCH v1 5/5] misc: fastrpc: Add support to allocate shared context bank Ekansh Gupta
2023-09-01 6:31 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.