Skip to content

Commit 0aa0ac3

Browse files
committed
FROMLIST: misc: fastrpc: Move fdlist to invoke context structure
The fdlist is currently part of the meta buffer, computed during put_args. This leads to code duplication when preparing and reading critical meta buffer contents used by the FastRPC driver. Move fdlist to the invoke context structure to improve maintainability and reduce redundancy. This centralizes its handling and simplifies meta buffer preparation and reading logic. Link: https://lore.kernel.org/all/20260215182136.3995111-2-ekansh.gupta@oss.qualcomm.com/ Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
1 parent 6de23f8 commit 0aa0ac3

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

drivers/misc/fastrpc.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ struct fastrpc_invoke_ctx {
233233
int pid;
234234
int client_id;
235235
u32 sc;
236+
u64 *fdlist;
236237
u32 *crc;
237238
u64 ctxid;
238239
u64 msg_sz;
@@ -1016,6 +1017,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
10161017
rpra = ctx->buf->virt;
10171018
list = fastrpc_invoke_buf_start(rpra, ctx->nscalars);
10181019
pages = fastrpc_phy_page_start(list, ctx->nscalars);
1020+
ctx->fdlist = (u64 *)(pages + ctx->nscalars);
10191021
args = (uintptr_t)ctx->buf->virt + metalen;
10201022
rlen = pkt_size - metalen;
10211023
ctx->rpra = rpra;
@@ -1118,18 +1120,10 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
11181120
union fastrpc_remote_arg *rpra = ctx->rpra;
11191121
struct fastrpc_user *fl = ctx->fl;
11201122
struct fastrpc_map *mmap = NULL;
1121-
struct fastrpc_invoke_buf *list;
1122-
struct fastrpc_phy_page *pages;
1123-
u64 *fdlist;
1124-
int i, inbufs, outbufs, handles;
1123+
int i, inbufs;
11251124
int ret = 0;
11261125

11271126
inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
1128-
outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
1129-
handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
1130-
list = fastrpc_invoke_buf_start(rpra, ctx->nscalars);
1131-
pages = fastrpc_phy_page_start(list, ctx->nscalars);
1132-
fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
11331127

11341128
for (i = inbufs; i < ctx->nbufs; ++i) {
11351129
if (!ctx->maps[i]) {
@@ -1151,9 +1145,9 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
11511145
cleanup_fdlist:
11521146
/* Clean up fdlist which is updated by DSP */
11531147
for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
1154-
if (!fdlist[i])
1148+
if (!ctx->fdlist[i])
11551149
break;
1156-
if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap))
1150+
if (!fastrpc_map_lookup(fl, (int)ctx->fdlist[i], &mmap))
11571151
fastrpc_map_put(mmap);
11581152
}
11591153

0 commit comments

Comments
 (0)