Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: fastrpc: copy to user only for non-DMA-BUF heap buffers

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>

authored by

Jeya R and committed by
Greg Kroah-Hartman
847afd7b 304b0ba0

+10 -8
+10 -8
drivers/misc/fastrpc.c
··· 890 890 inbufs = REMOTE_SCALARS_INBUFS(ctx->sc); 891 891 892 892 for (i = inbufs; i < ctx->nbufs; ++i) { 893 - void *src = (void *)(uintptr_t)rpra[i].pv; 894 - void *dst = (void *)(uintptr_t)ctx->args[i].ptr; 895 - u64 len = rpra[i].len; 893 + if (!ctx->maps[i]) { 894 + void *src = (void *)(uintptr_t)rpra[i].pv; 895 + void *dst = (void *)(uintptr_t)ctx->args[i].ptr; 896 + u64 len = rpra[i].len; 896 897 897 - if (!kernel) { 898 - if (copy_to_user((void __user *)dst, src, len)) 899 - return -EFAULT; 900 - } else { 901 - memcpy(dst, src, len); 898 + if (!kernel) { 899 + if (copy_to_user((void __user *)dst, src, len)) 900 + return -EFAULT; 901 + } else { 902 + memcpy(dst, src, len); 903 + } 902 904 } 903 905 } 904 906