All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>,
	"Horia Geantă" <horia.geanta@nxp.com>,
	"Kim Phillips" <kim.phillips@arm.com>,
	linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] crypto: talitos - Fix sparse warnings
Date: Sat, 03 Oct 2020 19:15:53 +0200	[thread overview]
Message-ID: <20201003191553.Horde.qhVjpQA-iJND7COibFfWZQ7@messagerie.c-s.fr> (raw)
In-Reply-To: <20201002124341.GA1587@gondor.apana.org.au>


Quoting Herbert Xu <herbert@gondor.apana.org.au>:

> On Fri, Oct 02, 2020 at 10:42:23PM +1000, Herbert Xu wrote:
>>
>> I don't think that's a valid optimisation unless it's backed up
>> with real numbers.
>
> Also it only matters on little-endian as they're no-ops on big-endian.
> If I'm right then this driver never even worked on little-endian.
>

The following changes fix the sparse warnings with less churn:

---
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 7c547352a862..992d58a4dbf1 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -460,7 +460,7 @@ DEF_TALITOS2_DONE(ch1_3, TALITOS2_ISR_CH_1_3_DONE)
  /*
   * locate current (offending) descriptor
   */
-static u32 current_desc_hdr(struct device *dev, int ch)
+static __be32 current_desc_hdr(struct device *dev, int ch)
  {
  	struct talitos_private *priv = dev_get_drvdata(dev);
  	int tail, iter;
@@ -478,7 +478,7 @@ static u32 current_desc_hdr(struct device *dev, int ch)

  	iter = tail;
  	while (priv->chan[ch].fifo[iter].dma_desc != cur_desc &&
-	       priv->chan[ch].fifo[iter].desc->next_desc != cur_desc) {
+	       priv->chan[ch].fifo[iter].desc->next_desc != cpu_to_be32(cur_desc)) {
  		iter = (iter + 1) & (priv->fifo_len - 1);
  		if (iter == tail) {
  			dev_err(dev, "couldn't locate current descriptor\n");
@@ -486,7 +486,7 @@ static u32 current_desc_hdr(struct device *dev, int ch)
  		}
  	}

-	if (priv->chan[ch].fifo[iter].desc->next_desc == cur_desc) {
+	if (priv->chan[ch].fifo[iter].desc->next_desc == cpu_to_be32(cur_desc)) {
  		struct talitos_edesc *edesc;

  		edesc = container_of(priv->chan[ch].fifo[iter].desc,
@@ -501,13 +501,13 @@ static u32 current_desc_hdr(struct device *dev, int ch)
  /*
   * user diagnostics; report root cause of error based on execution  
unit status
   */
-static void report_eu_error(struct device *dev, int ch, u32 desc_hdr)
+static void report_eu_error(struct device *dev, int ch, __be32 desc_hdr)
  {
  	struct talitos_private *priv = dev_get_drvdata(dev);
  	int i;

  	if (!desc_hdr)
-		desc_hdr = in_be32(priv->chan[ch].reg + TALITOS_DESCBUF);
+		desc_hdr = cpu_to_be32(in_be32(priv->chan[ch].reg + TALITOS_DESCBUF));

  	switch (desc_hdr & DESC_HDR_SEL0_MASK) {
  	case DESC_HDR_SEL0_AFEU:
---
Christophe

WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linuxppc-dev@ozlabs.org, "Kim Phillips" <kim.phillips@arm.com>,
	"Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>,
	"Horia Geantă" <horia.geanta@nxp.com>
Subject: Re: [PATCH] crypto: talitos - Fix sparse warnings
Date: Sat, 03 Oct 2020 19:15:53 +0200	[thread overview]
Message-ID: <20201003191553.Horde.qhVjpQA-iJND7COibFfWZQ7@messagerie.c-s.fr> (raw)
In-Reply-To: <20201002124341.GA1587@gondor.apana.org.au>


Quoting Herbert Xu <herbert@gondor.apana.org.au>:

> On Fri, Oct 02, 2020 at 10:42:23PM +1000, Herbert Xu wrote:
>>
>> I don't think that's a valid optimisation unless it's backed up
>> with real numbers.
>
> Also it only matters on little-endian as they're no-ops on big-endian.
> If I'm right then this driver never even worked on little-endian.
>

The following changes fix the sparse warnings with less churn:

---
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 7c547352a862..992d58a4dbf1 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -460,7 +460,7 @@ DEF_TALITOS2_DONE(ch1_3, TALITOS2_ISR_CH_1_3_DONE)
  /*
   * locate current (offending) descriptor
   */
-static u32 current_desc_hdr(struct device *dev, int ch)
+static __be32 current_desc_hdr(struct device *dev, int ch)
  {
  	struct talitos_private *priv = dev_get_drvdata(dev);
  	int tail, iter;
@@ -478,7 +478,7 @@ static u32 current_desc_hdr(struct device *dev, int ch)

  	iter = tail;
  	while (priv->chan[ch].fifo[iter].dma_desc != cur_desc &&
-	       priv->chan[ch].fifo[iter].desc->next_desc != cur_desc) {
+	       priv->chan[ch].fifo[iter].desc->next_desc != cpu_to_be32(cur_desc)) {
  		iter = (iter + 1) & (priv->fifo_len - 1);
  		if (iter == tail) {
  			dev_err(dev, "couldn't locate current descriptor\n");
@@ -486,7 +486,7 @@ static u32 current_desc_hdr(struct device *dev, int ch)
  		}
  	}

-	if (priv->chan[ch].fifo[iter].desc->next_desc == cur_desc) {
+	if (priv->chan[ch].fifo[iter].desc->next_desc == cpu_to_be32(cur_desc)) {
  		struct talitos_edesc *edesc;

  		edesc = container_of(priv->chan[ch].fifo[iter].desc,
@@ -501,13 +501,13 @@ static u32 current_desc_hdr(struct device *dev, int ch)
  /*
   * user diagnostics; report root cause of error based on execution  
unit status
   */
-static void report_eu_error(struct device *dev, int ch, u32 desc_hdr)
+static void report_eu_error(struct device *dev, int ch, __be32 desc_hdr)
  {
  	struct talitos_private *priv = dev_get_drvdata(dev);
  	int i;

  	if (!desc_hdr)
-		desc_hdr = in_be32(priv->chan[ch].reg + TALITOS_DESCBUF);
+		desc_hdr = cpu_to_be32(in_be32(priv->chan[ch].reg + TALITOS_DESCBUF));

  	switch (desc_hdr & DESC_HDR_SEL0_MASK) {
  	case DESC_HDR_SEL0_AFEU:
---
Christophe

  reply	other threads:[~2020-10-03 17:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 11:52 [PATCH] crypto: talitos - Fix sparse warnings Herbert Xu
2020-10-02 12:40 ` Christophe Leroy
2020-10-02 12:42   ` Herbert Xu
2020-10-02 12:43     ` Herbert Xu
2020-10-03 17:15       ` Christophe Leroy [this message]
2020-10-03 17:15         ` Christophe Leroy
2020-10-07  6:50         ` Herbert Xu
2020-10-07  6:50           ` Herbert Xu
2020-10-08  9:50           ` Christophe Leroy
2020-10-08  9:50             ` Christophe Leroy

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=20201003191553.Horde.qhVjpQA-iJND7COibFfWZQ7@messagerie.c-s.fr \
    --to=christophe.leroy@csgroup.eu \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=kim.phillips@arm.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.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 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.