All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] crypto: ccree - Remove a useless dma_supported() call
@ 2022-07-20 13:28 Christophe JAILLET
  2022-07-20 15:31 ` Gilad Ben-Yossef
  2022-07-29 10:35 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-07-20 13:28 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S. Miller
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
	Christoph Hellwig, linux-crypto

There is no point in calling dma_supported() before calling
dma_set_coherent_mask(). This function already calls dma_supported() and
returns an error (-EIO) if it fails.

So remove the superfluous dma_supported() call.

Moreover, setting a larger DMA mask will never fail when setting a smaller
one will succeed, so the whole "while" loop can be removed as well. (see
[1])

While at it, fix the name of the function reported in a dev_err().

[1]: https://lore.kernel.org/all/YteQ6Vx2C03UtCkG@infradead.org/

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/crypto/ccree/cc_driver.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 7d1bee86d581..cadead18b59e 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -372,17 +372,10 @@ static int init_cc_resources(struct platform_device *plat_dev)
 		dev->dma_mask = &dev->coherent_dma_mask;
 
 	dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
-	while (dma_mask > 0x7fffffffUL) {
-		if (dma_supported(dev, dma_mask)) {
-			rc = dma_set_coherent_mask(dev, dma_mask);
-			if (!rc)
-				break;
-		}
-		dma_mask >>= 1;
-	}
-
+	rc = dma_set_coherent_mask(dev, dma_mask);
 	if (rc) {
-		dev_err(dev, "Failed in dma_set_mask, mask=%llx\n", dma_mask);
+		dev_err(dev, "Failed in dma_set_coherent_mask, mask=%llx\n",
+			dma_mask);
 		return rc;
 	}
 
-- 
2.34.1


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

* Re: [PATCH v2] crypto: ccree - Remove a useless dma_supported() call
  2022-07-20 13:28 [PATCH v2] crypto: ccree - Remove a useless dma_supported() call Christophe JAILLET
@ 2022-07-20 15:31 ` Gilad Ben-Yossef
  2022-07-29 10:35 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Gilad Ben-Yossef @ 2022-07-20 15:31 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Herbert Xu, David S. Miller, Linux kernel mailing list,
	kernel-janitors, Christoph Hellwig, Linux Crypto Mailing List

Hi,


On Wed, Jul 20, 2022 at 4:29 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> There is no point in calling dma_supported() before calling
> dma_set_coherent_mask(). This function already calls dma_supported() and
> returns an error (-EIO) if it fails.
>
> So remove the superfluous dma_supported() call.
>
> Moreover, setting a larger DMA mask will never fail when setting a smaller
> one will succeed, so the whole "while" loop can be removed as well. (see
> [1])
>
> While at it, fix the name of the function reported in a dev_err().
>
> [1]: https://lore.kernel.org/all/YteQ6Vx2C03UtCkG@infradead.org/
>
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/crypto/ccree/cc_driver.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)

Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>

Thank you,
Gilad

>
> diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
> index 7d1bee86d581..cadead18b59e 100644
> --- a/drivers/crypto/ccree/cc_driver.c
> +++ b/drivers/crypto/ccree/cc_driver.c
> @@ -372,17 +372,10 @@ static int init_cc_resources(struct platform_device *plat_dev)
>                 dev->dma_mask = &dev->coherent_dma_mask;
>
>         dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN);
> -       while (dma_mask > 0x7fffffffUL) {
> -               if (dma_supported(dev, dma_mask)) {
> -                       rc = dma_set_coherent_mask(dev, dma_mask);
> -                       if (!rc)
> -                               break;
> -               }
> -               dma_mask >>= 1;
> -       }
> -
> +       rc = dma_set_coherent_mask(dev, dma_mask);
>         if (rc) {
> -               dev_err(dev, "Failed in dma_set_mask, mask=%llx\n", dma_mask);
> +               dev_err(dev, "Failed in dma_set_coherent_mask, mask=%llx\n",
> +                       dma_mask);
>                 return rc;
>         }
>
> --
> 2.34.1
>


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

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

* Re: [PATCH v2] crypto: ccree - Remove a useless dma_supported() call
  2022-07-20 13:28 [PATCH v2] crypto: ccree - Remove a useless dma_supported() call Christophe JAILLET
  2022-07-20 15:31 ` Gilad Ben-Yossef
@ 2022-07-29 10:35 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2022-07-29 10:35 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Gilad Ben-Yossef, David S. Miller, linux-kernel, kernel-janitors,
	Christoph Hellwig, linux-crypto

On Wed, Jul 20, 2022 at 03:28:44PM +0200, Christophe JAILLET wrote:
> There is no point in calling dma_supported() before calling
> dma_set_coherent_mask(). This function already calls dma_supported() and
> returns an error (-EIO) if it fails.
> 
> So remove the superfluous dma_supported() call.
> 
> Moreover, setting a larger DMA mask will never fail when setting a smaller
> one will succeed, so the whole "while" loop can be removed as well. (see
> [1])
> 
> While at it, fix the name of the function reported in a dev_err().
> 
> [1]: https://lore.kernel.org/all/YteQ6Vx2C03UtCkG@infradead.org/
> 
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/crypto/ccree/cc_driver.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)

Patch applied.  Thanks.
-- 
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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-29 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 13:28 [PATCH v2] crypto: ccree - Remove a useless dma_supported() call Christophe JAILLET
2022-07-20 15:31 ` Gilad Ben-Yossef
2022-07-29 10:35 ` Herbert Xu

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.