stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 08/10] spi: mxic: Fix the transmit path
       [not found] <20211008162228.1753083-1-miquel.raynal@bootlin.com>
@ 2021-10-08 16:22 ` Miquel Raynal
       [not found]   ` <OF11A0CCB6.4C81ABAD-ON4825876D.00256D6A-4825876D.00256F7A@LocalDomain>
  0 siblings, 1 reply; 2+ messages in thread
From: Miquel Raynal @ 2021-10-08 16:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus, linux-mtd
  Cc: Rob Herring, Mark Brown, Xiangsheng Hou, Boris Brezillon,
	devicetree, linux-spi, linux-kernel, jaimeliao, juliensu,
	Thomas Petazzoni, Miquel Raynal, stable, Mason Yang

By working with external hardware ECC engines, we figured out that
Under certain circumstances, it is needed for the SPI controller to
check INT_TX_EMPTY and INT_RX_NOT_EMPTY in both receive and transmit
path (not only in the receive path). The delay penalty being
negligible, move this code in the common path.

Fixes: b942d80b0a39 ("spi: Add MXIC controller driver")
Cc: stable@vger.kernel.org
Suggested-by: Mason Yang <masonccyang@mxic.com.tw>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/spi/spi-mxic.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
index 96b418293bf2..4fb19e6f94b0 100644
--- a/drivers/spi/spi-mxic.c
+++ b/drivers/spi/spi-mxic.c
@@ -304,25 +304,21 @@ static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf,
 
 		writel(data, mxic->regs + TXD(nbytes % 4));
 
+		ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
+					 sts & INT_TX_EMPTY, 0, USEC_PER_SEC);
+		if (ret)
+			return ret;
+
+		ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
+					 sts & INT_RX_NOT_EMPTY, 0,
+					 USEC_PER_SEC);
+		if (ret)
+			return ret;
+
+		data = readl(mxic->regs + RXD);
 		if (rxbuf) {
-			ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
-						 sts & INT_TX_EMPTY, 0,
-						 USEC_PER_SEC);
-			if (ret)
-				return ret;
-
-			ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
-						 sts & INT_RX_NOT_EMPTY, 0,
-						 USEC_PER_SEC);
-			if (ret)
-				return ret;
-
-			data = readl(mxic->regs + RXD);
 			data >>= (8 * (4 - nbytes));
 			memcpy(rxbuf + pos, &data, nbytes);
-			WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
-		} else {
-			readl(mxic->regs + RXD);
 		}
 		WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
 
-- 
2.27.0


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

* Re: 回信: [RFC PATCH 08/10] spi: mxic: Fix the transmit path
       [not found]   ` <OF11A0CCB6.4C81ABAD-ON4825876D.00256D6A-4825876D.00256F7A@LocalDomain>
@ 2021-10-13  7:04     ` zhengxunli
  0 siblings, 0 replies; 2+ messages in thread
From: zhengxunli @ 2021-10-13  7:04 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Rob Herring, Mark Brown, Xiangsheng Hou, Boris Brezillon,
	devicetree, linux-kernel, jaimeliao, juliensu, Thomas Petazzoni,
	Miquel Raynal, stable, Mason Yang, Richard Weinberger,
	Vignesh Raghavendra, Tudor Ambarus, linux-mtd, linux-spi


> By working with external hardware ECC engines, we figured out that
> Under certain circumstances, it is needed for the SPI controller to
> check INT_TX_EMPTY and INT_RX_NOT_EMPTY in both receive and transmit
> path (not only in the receive path). The delay penalty being
> negligible, move this code in the common path.
> 
> Fixes: b942d80b0a39 ("spi: Add MXIC controller driver")
> Cc: stable@vger.kernel.org
> Suggested-by: Mason Yang <masonccyang@mxic.com.tw>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/spi/spi-mxic.c | 28 ++++++++++++----------------
>  1 file changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
> index 96b418293bf2..4fb19e6f94b0 100644
> --- a/drivers/spi/spi-mxic.c
> +++ b/drivers/spi/spi-mxic.c
> @@ -304,25 +304,21 @@ static int mxic_spi_data_xfer(struct mxic_spi 
> *mxic, const void *txbuf,
> 
>        writel(data, mxic->regs + TXD(nbytes % 4));
> 
> +      ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
> +                sts & INT_TX_EMPTY, 0, USEC_PER_SEC);
> +      if (ret)
> +         return ret;
> +
> +      ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
> +                sts & INT_RX_NOT_EMPTY, 0,
> +                USEC_PER_SEC);
> +      if (ret)
> +         return ret;
> +
> +      data = readl(mxic->regs + RXD);
>        if (rxbuf) {
> -         ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
> -                   sts & INT_TX_EMPTY, 0,
> -                   USEC_PER_SEC);
> -         if (ret)
> -            return ret;
> -
> -         ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
> -                   sts & INT_RX_NOT_EMPTY, 0,
> -                   USEC_PER_SEC);
> -         if (ret)
> -            return ret;
> -
> -         data = readl(mxic->regs + RXD);
>           data >>= (8 * (4 - nbytes));
>           memcpy(rxbuf + pos, &data, nbytes);
> -         WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
> -      } else {
> -         readl(mxic->regs + RXD);
>        }
>        WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
> 
> -- 
> 2.27.0
> 

Reviewed-by: Zhengxun Li <zhengxunli@mxic.com.tw>


CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information 
and/or personal data, which is protected by applicable laws. Please be 
reminded that duplication, disclosure, distribution, or use of this e-mail 
(and/or its attachments) or any part thereof is prohibited. If you receive 
this e-mail in error, please notify us immediately and delete this mail as 
well as its attachment(s) from your system. In addition, please be 
informed that collection, processing, and/or use of personal data is 
prohibited unless expressly permitted by personal data protection laws. 
Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================



============================================================================

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================


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

end of thread, other threads:[~2021-10-13  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20211008162228.1753083-1-miquel.raynal@bootlin.com>
2021-10-08 16:22 ` [RFC PATCH 08/10] spi: mxic: Fix the transmit path Miquel Raynal
     [not found]   ` <OF11A0CCB6.4C81ABAD-ON4825876D.00256D6A-4825876D.00256F7A@LocalDomain>
2021-10-13  7:04     ` 回信: " zhengxunli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).