linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: dw-axi-dmac: Fix RMW on channel suspend register
@ 2022-06-27  9:09 Emil Renner Berthing
  2022-07-01 11:48 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Emil Renner Berthing @ 2022-06-27  9:09 UTC (permalink / raw)
  To: Eugeniy Paltsev, dmaengine
  Cc: Emil Renner Berthing, Vinod Koul, Andy Shevchenko, Pandith N,
	Michael Zhu, linux-kernel, Samin Guo

From: Emil Renner Berthing <kernel@esmil.dk>

When the DMA is configured for more than 8 channels the bits controlling
suspend moves to another register. However when adding support for this
the new register would be completely overwritten in one case and
overwritten with values from the old register in another case.

Found by comparing the parallel implementation of more than 8 channel
support for the StarFive JH7100 SoC by Samin.

Fixes: 824351668a41 ("dmaengine: dw-axi-dmac: support DMAX_NUM_CHANNELS > 8")
Co-developed-by: Samin Guo <samin.guo@starfivetech.com>
Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index e9c9bcb1f5c2..c741da02b67e 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1164,8 +1164,9 @@ static int dma_chan_pause(struct dma_chan *dchan)
 			BIT(chan->id) << DMAC_CHAN_SUSP_WE_SHIFT;
 		axi_dma_iowrite32(chan->chip, DMAC_CHEN, val);
 	} else {
-		val = BIT(chan->id) << DMAC_CHAN_SUSP2_SHIFT |
-		      BIT(chan->id) << DMAC_CHAN_SUSP2_WE_SHIFT;
+		val = axi_dma_ioread32(chan->chip, DMAC_CHSUSPREG);
+		val |= BIT(chan->id) << DMAC_CHAN_SUSP2_SHIFT |
+			BIT(chan->id) << DMAC_CHAN_SUSP2_WE_SHIFT;
 		axi_dma_iowrite32(chan->chip, DMAC_CHSUSPREG, val);
 	}
 
@@ -1190,12 +1191,13 @@ static inline void axi_chan_resume(struct axi_dma_chan *chan)
 {
 	u32 val;
 
-	val = axi_dma_ioread32(chan->chip, DMAC_CHEN);
 	if (chan->chip->dw->hdata->reg_map_8_channels) {
+		val = axi_dma_ioread32(chan->chip, DMAC_CHEN);
 		val &= ~(BIT(chan->id) << DMAC_CHAN_SUSP_SHIFT);
 		val |=  (BIT(chan->id) << DMAC_CHAN_SUSP_WE_SHIFT);
 		axi_dma_iowrite32(chan->chip, DMAC_CHEN, val);
 	} else {
+		val = axi_dma_ioread32(chan->chip, DMAC_CHSUSPREG);
 		val &= ~(BIT(chan->id) << DMAC_CHAN_SUSP2_SHIFT);
 		val |=  (BIT(chan->id) << DMAC_CHAN_SUSP2_WE_SHIFT);
 		axi_dma_iowrite32(chan->chip, DMAC_CHSUSPREG, val);
-- 
2.36.1


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

* Re: [PATCH] dmaengine: dw-axi-dmac: Fix RMW on channel suspend register
  2022-06-27  9:09 [PATCH] dmaengine: dw-axi-dmac: Fix RMW on channel suspend register Emil Renner Berthing
@ 2022-07-01 11:48 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2022-07-01 11:48 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Eugeniy Paltsev, dmaengine, Emil Renner Berthing,
	Andy Shevchenko, Pandith N, Michael Zhu, linux-kernel, Samin Guo

On 27-06-22, 11:09, Emil Renner Berthing wrote:
> From: Emil Renner Berthing <kernel@esmil.dk>
> 
> When the DMA is configured for more than 8 channels the bits controlling
> suspend moves to another register. However when adding support for this
> the new register would be completely overwritten in one case and
> overwritten with values from the old register in another case.
> 
> Found by comparing the parallel implementation of more than 8 channel
> support for the StarFive JH7100 SoC by Samin.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2022-07-01 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27  9:09 [PATCH] dmaengine: dw-axi-dmac: Fix RMW on channel suspend register Emil Renner Berthing
2022-07-01 11:48 ` Vinod Koul

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