This is a note to let you know that I've just added the patch titled misc: fastrpc: Free DMA handles for RPC calls with no arguments to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: misc-fastrpc-free-dma-handles-for-rpc-calls-with-no-arguments.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 206484303892a2a36c0c3414030ddfef658a4e70 Mon Sep 17 00:00:00 2001 From: Ekansh Gupta <quic_ekangupt@xxxxxxxxxxx> Date: Fri, 13 Oct 2023 13:20:05 +0100 Subject: misc: fastrpc: Free DMA handles for RPC calls with no arguments From: Ekansh Gupta <quic_ekangupt@xxxxxxxxxxx> commit 206484303892a2a36c0c3414030ddfef658a4e70 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: 8f6c1d8c4f0c ("misc: fastrpc: Add fdlist implementation") Cc: stable <stable@xxxxxxxxxx> Signed-off-by: Ekansh Gupta <quic_ekangupt@xxxxxxxxxxx> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> Link: https://lore.kernel.org/r/20231013122007.174464-3-srinivas.kandagatla@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/misc/fastrpc.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1036,6 +1036,7 @@ static int fastrpc_put_args(struct fastr } } + /* Clean up fdlist which is updated by DSP */ for (i = 0; i < FASTRPC_MAX_FDLIST; i++) { if (!fdlist[i]) break; @@ -1100,11 +1101,9 @@ static int fastrpc_internal_invoke(struc 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(); @@ -1128,14 +1127,12 @@ static int fastrpc_internal_invoke(struc 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) { Patches currently in stable-queue which might be from quic_ekangupt@xxxxxxxxxxx are queue-6.1/misc-fastrpc-reset-metadata-buffer-to-avoid-incorrect-free.patch queue-6.1/misc-fastrpc-unmap-only-if-buffer-is-unmapped-from-dsp.patch queue-6.1/misc-fastrpc-clean-buffers-on-remote-invocation-failures.patch queue-6.1/misc-fastrpc-free-dma-handles-for-rpc-calls-with-no-arguments.patch