Skip to content

Commit 8f6c1d8

Browse files
Vamsi Krishna Gattupalligregkh
authored andcommitted
misc: fastrpc: Add fdlist implementation
Add fdlist implementation to support dma handles. fdlist is populated by DSP if any map is no longer used and it is freed during put_args. Signed-off-by: Vamsi Krishna Gattupalli <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 54f7c85 commit 8f6c1d8

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

drivers/misc/fastrpc.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ static void fastrpc_map_get(struct fastrpc_map *map)
320320
kref_get(&map->refcount);
321321
}
322322

323-
static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
323+
324+
static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
324325
struct fastrpc_map **ppmap)
325326
{
326327
struct fastrpc_map *map = NULL;
327328

328329
mutex_lock(&fl->mutex);
329330
list_for_each_entry(map, &fl->maps, node) {
330331
if (map->fd == fd) {
331-
fastrpc_map_get(map);
332332
*ppmap = map;
333333
mutex_unlock(&fl->mutex);
334334
return 0;
@@ -339,6 +339,17 @@ static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
339339
return -ENOENT;
340340
}
341341

342+
static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
343+
struct fastrpc_map **ppmap)
344+
{
345+
int ret = fastrpc_map_lookup(fl, fd, ppmap);
346+
347+
if (!ret)
348+
fastrpc_map_get(*ppmap);
349+
350+
return ret;
351+
}
352+
342353
static void fastrpc_buf_free(struct fastrpc_buf *buf)
343354
{
344355
dma_free_coherent(buf->dev, buf->size, buf->virt,
@@ -411,7 +422,7 @@ static void fastrpc_context_free(struct kref *ref)
411422
ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
412423
cctx = ctx->cctx;
413424

414-
for (i = 0; i < ctx->nscalars; i++)
425+
for (i = 0; i < ctx->nbufs; i++)
415426
fastrpc_map_put(ctx->maps[i]);
416427

417428
if (ctx->buf)
@@ -969,9 +980,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
969980
u32 kernel)
970981
{
971982
struct fastrpc_remote_arg *rpra = ctx->rpra;
972-
int i, inbufs;
983+
struct fastrpc_user *fl = ctx->fl;
984+
struct fastrpc_map *mmap = NULL;
985+
struct fastrpc_invoke_buf *list;
986+
struct fastrpc_phy_page *pages;
987+
u64 *fdlist;
988+
int i, inbufs, outbufs, handles;
973989

974990
inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
991+
outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
992+
handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
993+
list = fastrpc_invoke_buf_start(rpra, ctx->nscalars);
994+
pages = fastrpc_phy_page_start(list, ctx->nscalars);
995+
fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
975996

976997
for (i = inbufs; i < ctx->nbufs; ++i) {
977998
if (!ctx->maps[i]) {
@@ -988,6 +1009,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
9881009
}
9891010
}
9901011

1012+
for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
1013+
if (!fdlist[i])
1014+
break;
1015+
if (!fastrpc_map_lookup(fl, (int)fdlist[i], &mmap))
1016+
fastrpc_map_put(mmap);
1017+
}
1018+
9911019
return 0;
9921020
}
9931021

0 commit comments

Comments
 (0)