All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeya R <jeyr@codeaurora.org>
To: linux-arm-msm@vger.kernel.org, srinivas.kandagatla@linaro.org
Cc: Jeya R <jeyr@codeaurora.org>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	fastrpc.upstream@qti.qualcomm.com
Subject: [PATCH] misc: fastrpc: copy to user only for non-DMA-BUF heap buffers
Date: Thu, 23 Sep 2021 14:07:52 +0530	[thread overview]
Message-ID: <1632386272-18139-1-git-send-email-jeyr@codeaurora.org> (raw)

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>
---
 drivers/misc/fastrpc.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index beda610..536eabf 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -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);
+			}
 		}
 	}
 
-- 
2.7.4


             reply	other threads:[~2021-09-23  8:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  8:37 Jeya R [this message]
2021-09-23  8:49 ` [PATCH] misc: fastrpc: copy to user only for non-DMA-BUF heap buffers Greg KH
2021-09-23 10:24   ` jeyr
2021-09-23 17:43     ` Greg KH
2021-09-24  6:25       ` jeyr
2021-09-24  6:55         ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1632386272-18139-1-git-send-email-jeyr@codeaurora.org \
    --to=jeyr@codeaurora.org \
    --cc=fastrpc.upstream@qti.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.