From: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Corentin Labbe <clabbe.montjoie@gmail.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Andre Przywara <andre.przywara@arm.com>,
linux-crypto@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: sun8i-ce: Fix `dma_unmap_sg()` nents value
Date: Mon, 23 Jun 2025 13:42:15 +0300 [thread overview]
Message-ID: <0b963009-85fe-473a-a65b-6b427bee98c5@gmail.com> (raw)
In-Reply-To: <20250623091009.65436-2-fourier.thomas@gmail.com>
Hi Thomas,
On 6/23/25 12:10 PM, Thomas Fourier wrote:
> The `dma_unmap_sg()` functions should be called with the same nents as the
> `dma_map_sg()`, not the value the map function returned.
>
This should already be fixed by:
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git/commit/?id=b6cd3cfb5afe49952f8f6be947aeeca9ba0faebb
The sg nents are saved to request context during prepare() and then used
in unprepare().
Thanks,
Ovidiu
> Fixes: 0605fa0f7826 ("crypto: sun8i-ce - split into prepare/run/unprepare")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> index f9cf00d690e2..ce9d071f5693 100644
> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> @@ -326,8 +326,8 @@ static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
> struct sun8i_ce_flow *chan;
> struct ce_task *cet;
> unsigned int ivsize, offset;
> - int nr_sgs = rctx->nr_sgs;
> - int nr_sgd = rctx->nr_sgd;
> + int ns = sg_nents_for_len(areq->src, areq->cryptlen);
> + int nd = sg_nents_for_len(areq->dst, areq->cryptlen);
> int flow;
>
> flow = rctx->flow;
> @@ -336,11 +336,11 @@ static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
> ivsize = crypto_skcipher_ivsize(tfm);
>
> if (areq->src == areq->dst) {
> - dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_BIDIRECTIONAL);
> + dma_unmap_sg(ce->dev, areq->src, ns, DMA_BIDIRECTIONAL);
> } else {
> - if (nr_sgs > 0)
> - dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_TO_DEVICE);
> - dma_unmap_sg(ce->dev, areq->dst, nr_sgd, DMA_FROM_DEVICE);
> + if (rctx->nr_sgs > 0)
> + dma_unmap_sg(ce->dev, areq->src, ns, DMA_TO_DEVICE);
> + dma_unmap_sg(ce->dev, areq->dst, nd, DMA_FROM_DEVICE);
> }
>
> if (areq->iv && ivsize > 0) {
prev parent reply other threads:[~2025-06-23 10:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 9:10 Thomas Fourier
2025-06-23 10:42 ` Ovidiu Panait [this message]
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=0b963009-85fe-473a-a65b-6b427bee98c5@gmail.com \
--to=ovidiu.panait.oss@gmail.com \
--cc=andre.przywara@arm.com \
--cc=clabbe.montjoie@gmail.com \
--cc=davem@davemloft.net \
--cc=fourier.thomas@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=samuel@sholland.org \
--cc=wens@csie.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®