All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhantao Tang" <zhantao.tang@windriver.com>
To: bruce.ashfield@gmail.com
Cc: yocto@yoctoproject.org
Subject: [PATCH] drivers: dspi: fsl: fix dspi transfer hang issue
Date: Fri,  4 Jun 2021 13:41:22 +0800	[thread overview]
Message-ID: <20210604054122.2732003-2-zhantao.tang@windriver.com> (raw)
In-Reply-To: <20210604054122.2732003-1-zhantao.tang@windriver.com>

On NXP S32G RDB2, there is an sja1110 switch, which can be accessed
using dspi interface, but if users use the following commands to test
the switch, the board will hang there.

	$ echo 30 > /sys/class/gpio/export
	$ echo out > /sys/class/gpio/gpio30/direction
	$ echo 0 > /sys/class/gpio/gpio30/value
	$ echo -n -e '\x02\x00\x00\x00\x00\x00\x00\x00' | spi-pipe -d /dev/spidev5.1 -b 4 | hexdump -C

The reason is that, the dspi driver wrongly sets the HALT flag in
the register, and the while loop will run forever, so the board hang
there. This patch is to fix this issue.

Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
---
 drivers/spi/spi-fsl-dspi.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 063cf4a60ed3..c20cce466bf7 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -965,10 +965,8 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr,
 		dspi->progress = 0;
 
 		regmap_update_bits(dspi->regmap, SPI_MCR,
-				SPI_MCR_HALT, SPI_MCR_HALT);
-		while (regmap_read(dspi->regmap, SPI_SR, &val) >= 0 &&
-				val & SPI_SR_TXRXS)
-			;
+				   SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF,
+				   SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF);
 
 		spi_take_timestamp_pre(dspi->ctlr, dspi->cur_transfer,
 				       dspi->progress, !dspi->irq);
@@ -987,10 +985,6 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr,
 				} while (status == -EINPROGRESS);
 			}
 		}
-		regmap_update_bits(dspi->regmap, SPI_MCR,
-				SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF |
-				SPI_MCR_HALT,
-				SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF);
 		if (status)
 			break;
 
-- 
2.25.1


  reply	other threads:[~2021-06-04  5:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04  5:41 [linux-yocto] [linux-yocto v5.10/standard/nxp-sdk-5.4/nxp-s32g2xx]: drivers: dspi: fsl: fix dspi transfer hang issue Zhantao Tang
2021-06-04  5:41 ` Zhantao Tang [this message]
2021-06-07  3:06 ` Bruce Ashfield
2021-06-08  2:20   ` Zhantao Tang

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=20210604054122.2732003-2-zhantao.tang@windriver.com \
    --to=zhantao.tang@windriver.com \
    --cc=bruce.ashfield@gmail.com \
    --cc=yocto@yoctoproject.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.