Re: [PATCH crypto 2/2] crypto: safexcel - Map AEAD buffers with accurate DMA directions

From: Herbert Xu

Date: Fri Oct 16 2026 - 05:23:02 EST


On Tue, Sep 15, 2026 at 01:32:12PM +0200, Ralf Lici wrote:
>
> @@ -748,8 +833,17 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
> return -EINVAL;
> }
> if (sreq->nr_src > 0) {
> - src_mapped = dma_map_sg(priv->dev, src, sreq->nr_src,
> - DMA_BIDIRECTIONAL);
> + if (ctx->aead)
> + src_mapped =
> + safexcel_map_aead(priv->dev, src,
> + sreq->nr_src,
> + sreq->output_offset,
> + sreq->output_len,
> + true);
> + else
> + src_mapped = dma_map_sg(priv->dev, src,
> + sreq->nr_src,
> + DMA_BIDIRECTIONAL);

This path doesn't actualy matter because BIDIRECTIONAL is safe
even if you use it unnecessarily.

> @@ -775,8 +869,17 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
> }
>
> if (sreq->nr_dst > 0) {
> - dst_mapped = dma_map_sg(priv->dev, dst, sreq->nr_dst,
> - DMA_FROM_DEVICE);

So this is the really buggy path. Why don't you just change it to
BIDRECTIONAL, perhaps with a comment referring to the assoc data?

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt