]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
misc: fastrpc: copy to user only for non-DMA-BUF heap buffers
authorJeya R <jeyr@codeaurora.org>
Thu, 23 Sep 2021 08:37:52 +0000 (14:07 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Oct 2021 14:11:03 +0000 (16:11 +0200)
fastrpc_put_args is copying all the output buffers to user. For large
number of output context buffers, this might cause performance
degradation. Copying is not needed for DMA-BUF heap buffers.

Signed-off-by: Jeya R <jeyr@codeaurora.org>
Link: https://lore.kernel.org/r/1632386272-18139-1-git-send-email-jeyr@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/fastrpc.c

index bd7811e3f76190c727115dbf3aef345f8e176601..e0d0c894c5fde7ce3ee5e9e550c7e951d8ba8e8b 100644 (file)
@@ -890,15 +890,17 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
        inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
 
        for (i = inbufs; i < ctx->nbufs; ++i) {
-               void *src = (void *)(uintptr_t)rpra[i].pv;
-               void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
-               u64 len = rpra[i].len;
+               if (!ctx->maps[i]) {
+                       void *src = (void *)(uintptr_t)rpra[i].pv;
+                       void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
+                       u64 len = rpra[i].len;
 
-               if (!kernel) {
-                       if (copy_to_user((void __user *)dst, src, len))
-                               return -EFAULT;
-               } else {
-                       memcpy(dst, src, len);
+                       if (!kernel) {
+                               if (copy_to_user((void __user *)dst, src, len))
+                                       return -EFAULT;
+                       } else {
+                               memcpy(dst, src, len);
+                       }
                }
        }