Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Antoine Tenart <atenart@kernel.org>
To: Peter Harliman Liem <pliem@maxlinear.com>, herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, linux-lgm-soc@maxlinear.com,
	Peter Harliman Liem <pliem@maxlinear.com>
Subject: Re: [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero
Date: Tue, 06 Sep 2022 16:00:53 +0200	[thread overview]
Message-ID: <166247285388.3585.6290053542530090542@kwain> (raw)
In-Reply-To: <de6de430fd9bbc2d38ff2d5a1ce89983421b9dda.1662432407.git.pliem@maxlinear.com>

Quoting Peter Harliman Liem (2022-09-06 04:51:49)
> From commit d03c54419274 ("dma-mapping: disallow .map_sg
> operations from returning zero on error"), dma_map_sg()
> produces warning if size is 0. This results in visible
> warnings if crypto length is zero.
> To avoid that, we avoid calling dma_map_sg if size is zero.
> 
> Fixes: d03c54419274 ("dma-mapping: disallow .map_sg operations from returning zero on error")

You can't reference the commit above, it's not introducing the issue but
the warning itself. The actual commit introducing the below logic should
be referenced.

Alternatively since the warning was introduced latter than the logic and
this is not a huge issue, you might resend it w/o the Fixes tag as well.

> Signed-off-by: Peter Harliman Liem <pliem@maxlinear.com>

With the Fixes: tag fixed,

Acked-by: Antoine Tenart <atenart@kernel.org>

Thanks!

> ---
> v2:
>  Add fixes tag
> 
>  drivers/crypto/inside-secure/safexcel_cipher.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c
> index d68ef16650d4..3775497775e0 100644
> --- a/drivers/crypto/inside-secure/safexcel_cipher.c
> +++ b/drivers/crypto/inside-secure/safexcel_cipher.c
> @@ -737,14 +737,17 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
>                                 max(totlen_src, totlen_dst));
>                         return -EINVAL;
>                 }
> -               dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL);
> +               if (sreq->nr_src > 0)
> +                       dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONAL);
>         } else {
>                 if (unlikely(totlen_src && (sreq->nr_src <= 0))) {
>                         dev_err(priv->dev, "Source buffer not large enough (need %d bytes)!",
>                                 totlen_src);
>                         return -EINVAL;
>                 }
> -               dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE);
> +
> +               if (sreq->nr_src > 0)
> +                       dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE);
>  
>                 if (unlikely(totlen_dst && (sreq->nr_dst <= 0))) {
>                         dev_err(priv->dev, "Dest buffer not large enough (need %d bytes)!",
> @@ -753,7 +756,9 @@ static int safexcel_send_req(struct crypto_async_request *base, int ring,
>                                      DMA_TO_DEVICE);
>                         return -EINVAL;
>                 }
> -               dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE);
> +
> +               if (sreq->nr_dst > 0)
> +                       dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE);
>         }
>  
>         memcpy(ctx->base.ctxr->data, ctx->key, ctx->key_len);
> -- 
> 2.17.1
> 

  parent reply	other threads:[~2022-09-06 15:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06  2:51 [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero Peter Harliman Liem
2022-09-06  2:51 ` [PATCH v2 2/2] crypto: inside-secure - Select CRYPTO_AES config Peter Harliman Liem
2022-09-06 14:05   ` Antoine Tenart
2022-09-07  6:46     ` Peter Harliman Liem
2022-09-07  8:48       ` Antoine Tenart
2022-09-23  2:39         ` Peter Harliman Liem
2022-09-06 14:00 ` Antoine Tenart [this message]
2022-09-07  6:43   ` [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero Peter Harliman Liem
2022-09-07  6:52 ` Herbert Xu
2022-09-23  2:35   ` Peter Harliman Liem

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=166247285388.3585.6290053542530090542@kwain \
    --to=atenart@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-lgm-soc@maxlinear.com \
    --cc=pliem@maxlinear.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