linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: mediatek: fix fifo rx mode
@ 2021-07-06 12:16 Frank Wunderlich
  2021-07-12 10:45 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Wunderlich @ 2021-07-06 12:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: Peter Hess, Matthias Brugger, Leilk Liu, linux-spi,
	linux-arm-kernel, linux-mediatek, linux-kernel, Frank Wunderlich

From: Peter Hess <peter.hess@ph-home.de>

In FIFO mode were two problems:
- RX mode was never handled and
- in this case the tx_buf pointer was NULL and caused an exception

fix this by handling RX mode in mtk_spi_fifo_transfer

Fixes: a568231f4632 ("spi: mediatek: Add spi bus for Mediatek MT8173")
Signed-off-by: Peter Hess <peter.hess@ph-home.de>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
 drivers/spi/spi-mt65xx.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 976f73b9e299..8d5fa7f1e506 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -427,13 +427,23 @@ static int mtk_spi_fifo_transfer(struct spi_master *master,
 	mtk_spi_setup_packet(master);
 
 	cnt = xfer->len / 4;
-	iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt);
+	if (xfer->tx_buf)
+		iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt);
+
+	if (xfer->rx_buf)
+		ioread32_rep(mdata->base + SPI_RX_DATA_REG, xfer->rx_buf, cnt);
 
 	remainder = xfer->len % 4;
 	if (remainder > 0) {
 		reg_val = 0;
-		memcpy(&reg_val, xfer->tx_buf + (cnt * 4), remainder);
-		writel(reg_val, mdata->base + SPI_TX_DATA_REG);
+		if (xfer->tx_buf) {
+			memcpy(&reg_val, xfer->tx_buf + (cnt * 4), remainder);
+			writel(reg_val, mdata->base + SPI_TX_DATA_REG);
+		}
+		if (xfer->rx_buf) {
+			reg_val = readl(mdata->base + SPI_RX_DATA_REG);
+			memcpy(xfer->rx_buf + (cnt * 4), &reg_val, remainder);
+		}
 	}
 
 	mtk_spi_enable_transfer(master);
-- 
2.25.1


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

* Re: [PATCH] spi: mediatek: fix fifo rx mode
  2021-07-06 12:16 [PATCH] spi: mediatek: fix fifo rx mode Frank Wunderlich
@ 2021-07-12 10:45 ` Mark Brown
  2021-07-23 13:46   ` Frank Wunderlich
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2021-07-12 10:45 UTC (permalink / raw)
  To: Frank Wunderlich
  Cc: Mark Brown, linux-arm-kernel, Leilk Liu, linux-kernel,
	Matthias Brugger, Peter Hess, linux-mediatek, Frank Wunderlich,
	linux-spi

On Tue, 6 Jul 2021 14:16:09 +0200, Frank Wunderlich wrote:
> In FIFO mode were two problems:
> - RX mode was never handled and
> - in this case the tx_buf pointer was NULL and caused an exception
> 
> fix this by handling RX mode in mtk_spi_fifo_transfer

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: mediatek: fix fifo rx mode
      commit: 3a70dd2d050331ee4cf5ad9d5c0a32d83ead9a43

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

* Re: [PATCH] spi: mediatek: fix fifo rx mode
  2021-07-12 10:45 ` Mark Brown
@ 2021-07-23 13:46   ` Frank Wunderlich
  2021-07-23 13:52     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Wunderlich @ 2021-07-23 13:46 UTC (permalink / raw)
  To: linux-mediatek, Mark Brown, Frank Wunderlich
  Cc: linux-arm-kernel, Leilk Liu, linux-kernel, Matthias Brugger,
	Peter Hess, linux-spi

Hi

Can we add stable-tag i've missed to fix older kernel versions or inform greg to add patch to at least 5.4/5.10?

Regards Frank

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

* Re: [PATCH] spi: mediatek: fix fifo rx mode
  2021-07-23 13:46   ` Frank Wunderlich
@ 2021-07-23 13:52     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-07-23 13:52 UTC (permalink / raw)
  To: Frank Wunderlich
  Cc: linux-mediatek, Frank Wunderlich, linux-arm-kernel, Leilk Liu,
	linux-kernel, Matthias Brugger, Peter Hess, linux-spi

[-- Attachment #1: Type: text/plain, Size: 746 bytes --]

On Fri, Jul 23, 2021 at 03:46:02PM +0200, Frank Wunderlich wrote:

> Can we add stable-tag i've missed to fix older kernel versions or
> inform greg to add patch to at least 5.4/5.10?

Let the stable people know once it's in mainline (IIRC it is already) -
there's a good chance they'll pick it up anyway based on the commit log.

Please don't top post, reply in line with needed context.  This allows
readers to readily follow the flow of conversation and understand what
you are talking about and also helps ensure that everything in the
discussion is being addressed.

Please fix your mail client to word wrap within paragraphs at something
substantially less than 80 columns.  Doing this makes your messages much
easier to read and reply to.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2021-07-23 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 12:16 [PATCH] spi: mediatek: fix fifo rx mode Frank Wunderlich
2021-07-12 10:45 ` Mark Brown
2021-07-23 13:46   ` Frank Wunderlich
2021-07-23 13:52     ` Mark Brown

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).