Skip to content

Commit

Permalink
misc: fastrpc: Free DMA handles for RPC calls with no arguments
Browse files Browse the repository at this point in the history
commit 2064843 upstream.

The FDs for DMA handles to be freed is updated in fdlist by DSP over
a remote call. This holds true even for remote calls with no
arguments. To handle this, get_args and put_args are needed to
be called for remote calls with no arguments also as fdlist
is allocated in get_args and FDs updated in fdlist is freed
in put_args.

Fixes: 8f6c1d8 ("misc: fastrpc: Add fdlist implementation")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231013122007.174464-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
quic-ekangupt authored and gregkh committed Nov 2, 2023
1 parent 1e8851b commit 7737e93
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions drivers/misc/fastrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
}
}

/* Clean up fdlist which is updated by DSP */
for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
if (!fdlist[i])
break;
Expand Down Expand Up @@ -1100,11 +1101,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (IS_ERR(ctx))
return PTR_ERR(ctx);

if (ctx->nscalars) {
err = fastrpc_get_args(kernel, ctx);
if (err)
goto bail;
}
err = fastrpc_get_args(kernel, ctx);
if (err)
goto bail;

/* make sure that all CPU memory writes are seen by DSP */
dma_wmb();
Expand All @@ -1128,14 +1127,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (err)
goto bail;

if (ctx->nscalars) {
/* make sure that all memory writes by DSP are seen by CPU */
dma_rmb();
/* populate all the output buffers with results */
err = fastrpc_put_args(ctx, kernel);
if (err)
goto bail;
}
/* make sure that all memory writes by DSP are seen by CPU */
dma_rmb();
/* populate all the output buffers with results */
err = fastrpc_put_args(ctx, kernel);
if (err)
goto bail;

bail:
if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
Expand Down

0 comments on commit 7737e93

Please sign in to comment.