public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@mind.be>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, linux-omap@vger.kernel.org,
	Lokesh Vutla <lokeshvutla@ti.com>,
	Tero Kristo <kristo@kernel.org>,
	Francis Le Bourse <francis.lebourse@sfr.fr>
Subject: [PATCH 1/2] crypto: omap - Avoid redundant copy when using truncated sg list
Date: Wed, 11 Aug 2021 02:05:55 +0200	[thread overview]
Message-ID: <20210811000554.GB22095@cephalopod> (raw)
In-Reply-To: <20210811000333.GA22095@cephalopod>

omap_crypto_cleanup() currently copies data from sg to orig if either
copy flag is set.  However OMAP_CRYPTO_SG_COPIED means that sg refers
to the same pages as orig, truncated to len bytes.  There is no need
to copy in this case.

Only copy data if the OMAP_CRYPTO_DATA_COPIED flag is set.

Fixes: 74ed87e7e7f7 ("crypto: omap - add base support library for common ...")
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
This change was previously submitted as part of the patch at
https://patchwork.kernel.org/project/linux-crypto/patch/1522164573-12259-1-git-send-email-francis.lebourse@sfr.fr/ .
I couldn't find the full discussion of that in mailing list archives.

Ben.

 drivers/crypto/omap-crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/omap-crypto.c b/drivers/crypto/omap-crypto.c
index 31bdb1d76d11..a4cc6bf146ec 100644
--- a/drivers/crypto/omap-crypto.c
+++ b/drivers/crypto/omap-crypto.c
@@ -210,7 +210,7 @@ void omap_crypto_cleanup(struct scatterlist *sg, struct scatterlist *orig,
 	buf = sg_virt(sg);
 	pages = get_order(len);
 
-	if (orig && (flags & OMAP_CRYPTO_COPY_MASK))
+	if (orig && (flags & OMAP_CRYPTO_DATA_COPIED))
 		omap_crypto_copy_data(sg, orig, offset, len);
 
 	if (flags & OMAP_CRYPTO_DATA_COPIED)
-- 
2.20.1


  reply	other threads:[~2021-08-11  0:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  0:03 [PATCH 0/2] omap-crypto fixes Ben Hutchings
2021-08-11  0:05 ` Ben Hutchings [this message]
2021-08-11  0:06 ` [PATCH 2/2] crypto: omap - Fix inconsistent locking of device lists Ben Hutchings
2021-08-21  7:49 ` [PATCH 0/2] omap-crypto fixes Herbert Xu

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=20210811000554.GB22095@cephalopod \
    --to=ben.hutchings@mind.be \
    --cc=davem@davemloft.net \
    --cc=francis.lebourse@sfr.fr \
    --cc=herbert@gondor.apana.org.au \
    --cc=kristo@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox