linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: rockchip: turn down tx dma bursts
@ 2019-04-12 10:53 Emil Renner Berthing
  2019-05-08 10:33 ` Applied "spi: rockchip: turn down tx dma bursts" to the spi tree Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Emil Renner Berthing @ 2019-04-12 10:53 UTC (permalink / raw)
  To: linux-spi
  Cc: linux-rockchip, linux-arm-kernel, linux-kernel, Mark Brown,
	Heiko Stuebner, Vicente Bergas, Robin Murphy,
	Emil Renner Berthing

This fixes tx and bi-directional dma transfers on rk3399-gru-kevin.

It seems the SPI fifo must have room for 2 bursts when the dma_tx_req
signal is generated or it might skip some words. This in turn makes
the rx dma channel never complete for bi-directional transfers.

Fix it by setting tx burst length to fifo_len / 4 and the dma
watermark to fifo_len / 2.

However the rk3399 TRM says (sic):
"DMAC support incrementing-address burst and fixed-address burst. But in
the case of access SPI and UART at byte or halfword size, DMAC only
support fixed-address burst and the address must be aligned to word."

So this relies on fifo_len being a multiple of 16 such that the
burst length (= fifo_len / 4) is a multiple of 4 and the addresses
will be word-aligned.

Fixes: dcfc861d24ec ("spi: rockchip: adjust dma watermark and burstlen")
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
---
 drivers/spi/spi-rockchip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 3912526ead66..19f6a76f1c07 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -425,7 +425,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
 			.direction = DMA_MEM_TO_DEV,
 			.dst_addr = rs->dma_addr_tx,
 			.dst_addr_width = rs->n_bytes,
-			.dst_maxburst = rs->fifo_len / 2,
+			.dst_maxburst = rs->fifo_len / 4,
 		};
 
 		dmaengine_slave_config(master->dma_tx, &txconf);
@@ -526,7 +526,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 	else
 		writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);
 
-	writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_DMATDLR);
+	writel_relaxed(rs->fifo_len / 2, rs->regs + ROCKCHIP_SPI_DMATDLR);
 	writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR);
 	writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR);
 
-- 
2.21.0


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

* Applied "spi: rockchip: turn down tx dma bursts" to the spi tree
  2019-04-12 10:53 [PATCH] spi: rockchip: turn down tx dma bursts Emil Renner Berthing
@ 2019-05-08 10:33 ` Mark Brown
  2019-06-05 19:36   ` Emil Renner Berthing
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2019-05-08 10:33 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Heiko Stuebner, linux-arm-kernel, linux-kernel, linux-rockchip,
	linux-spi, Mark Brown, Robin Murphy, Vicente Bergas

The patch

   spi: rockchip: turn down tx dma bursts

has been applied to the spi tree at

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

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

From 47300728fb213486a830565d2af49da967c9d16a Mon Sep 17 00:00:00 2001
From: Emil Renner Berthing <kernel@esmil.dk>
Date: Fri, 12 Apr 2019 12:53:20 +0200
Subject: [PATCH] spi: rockchip: turn down tx dma bursts

This fixes tx and bi-directional dma transfers on rk3399-gru-kevin.

It seems the SPI fifo must have room for 2 bursts when the dma_tx_req
signal is generated or it might skip some words. This in turn makes
the rx dma channel never complete for bi-directional transfers.

Fix it by setting tx burst length to fifo_len / 4 and the dma
watermark to fifo_len / 2.

However the rk3399 TRM says (sic):
"DMAC support incrementing-address burst and fixed-address burst. But in
the case of access SPI and UART at byte or halfword size, DMAC only
support fixed-address burst and the address must be aligned to word."

So this relies on fifo_len being a multiple of 16 such that the
burst length (= fifo_len / 4) is a multiple of 4 and the addresses
will be word-aligned.

Fixes: dcfc861d24ec ("spi: rockchip: adjust dma watermark and burstlen")
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-rockchip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 3912526ead66..19f6a76f1c07 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -425,7 +425,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
 			.direction = DMA_MEM_TO_DEV,
 			.dst_addr = rs->dma_addr_tx,
 			.dst_addr_width = rs->n_bytes,
-			.dst_maxburst = rs->fifo_len / 2,
+			.dst_maxburst = rs->fifo_len / 4,
 		};
 
 		dmaengine_slave_config(master->dma_tx, &txconf);
@@ -526,7 +526,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 	else
 		writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR);
 
-	writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_DMATDLR);
+	writel_relaxed(rs->fifo_len / 2, rs->regs + ROCKCHIP_SPI_DMATDLR);
 	writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR);
 	writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR);
 
-- 
2.20.1


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

* Re: Applied "spi: rockchip: turn down tx dma bursts" to the spi tree
  2019-05-08 10:33 ` Applied "spi: rockchip: turn down tx dma bursts" to the spi tree Mark Brown
@ 2019-06-05 19:36   ` Emil Renner Berthing
  2019-06-05 19:55     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Emil Renner Berthing @ 2019-06-05 19:36 UTC (permalink / raw)
  To: Mark Brown
  Cc: Heiko Stuebner, linux-arm-kernel, Linux Kernel Mailing List,
	open list:ARM/Rockchip SoC...,
	linux-spi, Robin Murphy, Vicente Bergas

Hi Mark

On Wed, 8 May 2019 at 12:34, Mark Brown <broonie@kernel.org> wrote:
>
> The patch
>
>    spi: rockchip: turn down tx dma bursts
>
> has been applied to the spi tree at
>
>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
>
> 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.

I've tried looking in the for-next and for-5.x branches here, and I
can't seem to find this patch.
Am I missing something?

It fixes a problem introduced in 4.19, so it'd be nice if it could
make it to stable trees eventually.

/Emil

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

* Re: Applied "spi: rockchip: turn down tx dma bursts" to the spi tree
  2019-06-05 19:36   ` Emil Renner Berthing
@ 2019-06-05 19:55     ` Mark Brown
  2019-06-05 20:14       ` Emil Renner Berthing
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2019-06-05 19:55 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Heiko Stuebner, linux-arm-kernel, Linux Kernel Mailing List,
	open list:ARM/Rockchip SoC...,
	linux-spi, Robin Murphy, Vicente Bergas

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

On Wed, Jun 05, 2019 at 09:36:44PM +0200, Emil Renner Berthing wrote:
> On Wed, 8 May 2019 at 12:34, Mark Brown <broonie@kernel.org> wrote:

> >    spi: rockchip: turn down tx dma bursts

> I've tried looking in the for-next and for-5.x branches here, and I
> can't seem to find this patch.
> Am I missing something?

> It fixes a problem introduced in 4.19, so it'd be nice if it could
> make it to stable trees eventually.

47300728fb213486a830565d2af49da967c9d16a is in my tree.  When it reaches
Linus' tree send a request to Greg for it to be backported if none of
the stable automation picks it up.

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

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

* Re: Applied "spi: rockchip: turn down tx dma bursts" to the spi tree
  2019-06-05 19:55     ` Mark Brown
@ 2019-06-05 20:14       ` Emil Renner Berthing
  0 siblings, 0 replies; 5+ messages in thread
From: Emil Renner Berthing @ 2019-06-05 20:14 UTC (permalink / raw)
  To: Mark Brown
  Cc: Heiko Stuebner, linux-arm-kernel, Linux Kernel Mailing List,
	open list:ARM/Rockchip SoC...,
	linux-spi, Robin Murphy, Vicente Bergas

On Wed, 5 Jun 2019 at 21:55, Mark Brown <broonie@kernel.org> wrote:
>
> On Wed, Jun 05, 2019 at 09:36:44PM +0200, Emil Renner Berthing wrote:
> > On Wed, 8 May 2019 at 12:34, Mark Brown <broonie@kernel.org> wrote:
>
> > >    spi: rockchip: turn down tx dma bursts
>
> > I've tried looking in the for-next and for-5.x branches here, and I
> > can't seem to find this patch.
> > Am I missing something?
>
> > It fixes a problem introduced in 4.19, so it'd be nice if it could
> > make it to stable trees eventually.
>
> 47300728fb213486a830565d2af49da967c9d16a is in my tree.  When it reaches
> Linus' tree send a request to Greg for it to be backported if none of
> the stable automation picks it up.

You're absolutely right, sorry about the noise.

Thanks.
/Emil

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

end of thread, other threads:[~2019-06-05 20:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 10:53 [PATCH] spi: rockchip: turn down tx dma bursts Emil Renner Berthing
2019-05-08 10:33 ` Applied "spi: rockchip: turn down tx dma bursts" to the spi tree Mark Brown
2019-06-05 19:36   ` Emil Renner Berthing
2019-06-05 19:55     ` Mark Brown
2019-06-05 20:14       ` Emil Renner Berthing

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