All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: crypto4xx - Call dma_unmap_page when done
@ 2023-02-06  6:01 Herbert Xu
  2023-02-08 19:03 ` Christian Lamparter
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2023-02-06  6:01 UTC (permalink / raw)
  To: Linux Crypto Mailing List, Christian Lamparter; +Cc: James Hsiao

In crypto4xx_cipher_done, we should be unmapping the dst page, not
mapping it.

This was flagged by a sparse warning about the unused addr variable.
While we're at it, also fix a sparse warning regarding the unused
ctx variable in crypto4xx_ahash_done (by actually using it).

Fixes: 049359d65527 ("crypto: amcc - Add crypt4xx driver")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index 3a9d0ab41f32..17deef864dd2 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -523,7 +523,6 @@ static void crypto4xx_cipher_done(struct crypto4xx_device *dev,
 {
 	struct skcipher_request *req;
 	struct scatterlist *dst;
-	dma_addr_t addr;
 
 	req = skcipher_request_cast(pd_uinfo->async_req);
 
@@ -532,8 +531,8 @@ static void crypto4xx_cipher_done(struct crypto4xx_device *dev,
 					  req->cryptlen, req->dst);
 	} else {
 		dst = pd_uinfo->dest_va;
-		addr = dma_map_page(dev->core_dev->device, sg_page(dst),
-				    dst->offset, dst->length, DMA_FROM_DEVICE);
+		dma_unmap_page(dev->core_dev->device, pd->dest, dst->length,
+			       DMA_FROM_DEVICE);
 	}
 
 	if (pd_uinfo->sa_va->sa_command_0.bf.save_iv == SA_SAVE_IV) {
@@ -558,10 +557,9 @@ static void crypto4xx_ahash_done(struct crypto4xx_device *dev,
 	struct ahash_request *ahash_req;
 
 	ahash_req = ahash_request_cast(pd_uinfo->async_req);
-	ctx  = crypto_tfm_ctx(ahash_req->base.tfm);
+	ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(ahash_req));
 
-	crypto4xx_copy_digest_to_dst(ahash_req->result, pd_uinfo,
-				     crypto_tfm_ctx(ahash_req->base.tfm));
+	crypto4xx_copy_digest_to_dst(ahash_req->result, pd_uinfo, ctx);
 	crypto4xx_ret_sg_desc(dev, pd_uinfo);
 
 	if (pd_uinfo->state & PD_ENTRY_BUSY)
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: crypto4xx - Call dma_unmap_page when done
  2023-02-06  6:01 [PATCH] crypto: crypto4xx - Call dma_unmap_page when done Herbert Xu
@ 2023-02-08 19:03 ` Christian Lamparter
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Lamparter @ 2023-02-08 19:03 UTC (permalink / raw)
  To: Herbert Xu, Linux Crypto Mailing List

On 2/6/23 07:01, Herbert Xu wrote:
> In crypto4xx_cipher_done, we should be unmapping the dst page, not
> mapping it.
> 
> This was flagged by a sparse warning about the unused addr variable.
> While we're at it, also fix a sparse warning regarding the unused
> ctx variable in crypto4xx_ahash_done (by actually using it).
> 
> Fixes: 049359d65527 ("crypto: amcc - Add crypt4xx driver")
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Tested this on the MyBook Live. Internal cryptmgr_test pass with:

[    2.888784] alg: No test for stdrng (crypto4xx_rng)
[    7.519740] "cryptomgr_test" (102) uses obsolete ecb(arc4) skcipher
(but all crypto4xx entries in /proc/crypto say that the selftest pass)

as well as libkcapi kcapi-enc-test.sh passes.

The ahash portion is a bit "underused". Currently the driver doesn't
register any hashes (this is because in testing I found the getting
the crypto-hardware to do those is so much slower than letting the
CPU do these).

Anyway:

Tested-by: Christian Lamparter <chunkeey@gmail.com>

Thanks!


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-08 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-06  6:01 [PATCH] crypto: crypto4xx - Call dma_unmap_page when done Herbert Xu
2023-02-08 19:03 ` Christian Lamparter

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.