Commit 20648430 authored by Ekansh Gupta's avatar Ekansh Gupta Committed by Greg Kroah-Hartman

misc: fastrpc: Free DMA handles for RPC calls with no arguments

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: 8f6c1d8c ("misc: fastrpc: Add fdlist implementation")
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarEkansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231013122007.174464-3-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1c29d801
...@@ -1091,6 +1091,7 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx, ...@@ -1091,6 +1091,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++) { for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
if (!fdlist[i]) if (!fdlist[i])
break; break;
...@@ -1157,11 +1158,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, ...@@ -1157,11 +1158,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (IS_ERR(ctx)) if (IS_ERR(ctx))
return PTR_ERR(ctx); return PTR_ERR(ctx);
if (ctx->nscalars) { err = fastrpc_get_args(kernel, ctx);
err = fastrpc_get_args(kernel, ctx); if (err)
if (err) goto bail;
goto bail;
}
/* make sure that all CPU memory writes are seen by DSP */ /* make sure that all CPU memory writes are seen by DSP */
dma_wmb(); dma_wmb();
...@@ -1185,14 +1184,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, ...@@ -1185,14 +1184,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (err) if (err)
goto bail; goto bail;
if (ctx->nscalars) { /* make sure that all memory writes by DSP are seen by CPU */
/* make sure that all memory writes by DSP are seen by CPU */ dma_rmb();
dma_rmb(); /* populate all the output buffers with results */
/* populate all the output buffers with results */ err = fastrpc_put_args(ctx, kernel);
err = fastrpc_put_args(ctx, kernel); if (err)
if (err) goto bail;
goto bail;
}
bail: bail:
if (err != -ERESTARTSYS && err != -ETIMEDOUT) { if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment