public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup
@ 2023-11-14 14:51 Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback Kory Maincent
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent, Manivannan Sadhasivam

This patch series fix the support of dw-edma HDMA NATIVE IP.
I can only test it in remote HDMA IP setup with single dma transfer, but
with these fixes it works properly.

Few fixes has also been added for eDMA version. Similarly to HDMA I have
tested only eDMA in remote setup.

Changes in v2:
- Update comments and fix typos.
- Removed patches that tackle hypothetical bug and then were not pertinent.
- Add the similar HDMA race condition in remote setup fix to eDMA IP driver.

Changes in v3:
- Fix comment style.
- Split a patch in two to differ bug fix and simple harmless typo.

Changes in v4:
- Update patch git commit message.
- Link to v3: https://lore.kernel.org/r/20231011-b4-feature_hdma_mainline-v3-0-24ee0c979c6f@bootlin.com

Changes in v5:
- No change
- Rebase to mainline 6.7-rc1
- Link to v4: https://lore.kernel.org/r/20231011-b4-feature_hdma_mainline-v4-0-43d417b93138@bootlin.com

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
Kory Maincent (6):
      dmaengine: dw-edma: Fix the ch_count hdma callback
      dmaengine: dw-edma: Fix wrong interrupt bit set
      dmaengine: dw-edma: Typo fix
      dmaengine: dw-edma: Add HDMA remote interrupt configuration
      dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup
      dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup

 drivers/dma/dw-edma/dw-edma-v0-core.c | 17 +++++++++++++++
 drivers/dma/dw-edma/dw-hdma-v0-core.c | 39 +++++++++++++++++++++++------------
 drivers/dma/dw-edma/dw-hdma-v0-regs.h |  2 +-
 3 files changed, 44 insertions(+), 14 deletions(-)
---
base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86
change-id: 20231011-b4-feature_hdma_mainline-b6c57f8e3b5d

Best regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


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

* [PATCH v5 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback
  2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
@ 2023-11-14 14:51 ` Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set Kory Maincent
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent, Manivannan Sadhasivam

The current check of ch_en enabled to know the maximum number of available
hardware channels is wrong as it check the number of ch_en register set
but all of them are unset at probe. This register is set at the
dw_hdma_v0_core_start function which is run lately before a DMA transfer.

The HDMA IP have no way to know the number of hardware channels available
like the eDMA IP, then let set it to maximum channels and let the platform
set the right number of channels.

Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

See the following thread mail that talk about this issue:
https://lore.kernel.org/lkml/20230607095832.6d6b1a73@kmaincent-XPS-13-7390/

Changes in v2:
- Add comment

Changes in v3:
- Fix comment style.
---
 drivers/dma/dw-edma/dw-hdma-v0-core.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
index 00b735a0202a..1f4cb7db5475 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
@@ -65,18 +65,12 @@ static void dw_hdma_v0_core_off(struct dw_edma *dw)
 
 static u16 dw_hdma_v0_core_ch_count(struct dw_edma *dw, enum dw_edma_dir dir)
 {
-	u32 num_ch = 0;
-	int id;
-
-	for (id = 0; id < HDMA_V0_MAX_NR_CH; id++) {
-		if (GET_CH_32(dw, id, dir, ch_en) & BIT(0))
-			num_ch++;
-	}
-
-	if (num_ch > HDMA_V0_MAX_NR_CH)
-		num_ch = HDMA_V0_MAX_NR_CH;
-
-	return (u16)num_ch;
+	/*
+	 * The HDMA IP have no way to know the number of hardware channels
+	 * available, we set it to maximum channels and let the platform
+	 * set the right number of channels.
+	 */
+	return HDMA_V0_MAX_NR_CH;
 }
 
 static enum dma_status dw_hdma_v0_core_ch_status(struct dw_edma_chan *chan)

-- 
2.25.1


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

* [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set
  2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback Kory Maincent
@ 2023-11-14 14:51 ` Kory Maincent
  2023-11-17  7:48   ` Manivannan Sadhasivam
  2023-11-14 14:51 ` [PATCH v5 3/6] dmaengine: dw-edma: Typo fix Kory Maincent
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent

Fix "HDMA_V0_LOCAL_STOP_INT_EN" to "HDMA_V0_LOCAL_ABORT_INT_EN" as the STOP
bit is already set in the same line.

Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
---

Changes in v3:
- Split the patch in two to differ bug fix and simple harmless typo.
---
 drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
index 1f4cb7db5475..108f9127aaaa 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
@@ -236,7 +236,7 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
 		/* Interrupt enable&unmask - done, abort */
 		tmp = GET_CH_32(dw, chan->dir, chan->id, int_setup) |
 		      HDMA_V0_STOP_INT_MASK | HDMA_V0_ABORT_INT_MASK |
-		      HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_STOP_INT_EN;
+		      HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_ABORT_INT_EN;
 		SET_CH_32(dw, chan->dir, chan->id, int_setup, tmp);
 		/* Channel control */
 		SET_CH_32(dw, chan->dir, chan->id, control1, HDMA_V0_LINKLIST_EN);

-- 
2.25.1


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

* [PATCH v5 3/6] dmaengine: dw-edma: Typo fix
  2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set Kory Maincent
@ 2023-11-14 14:51 ` Kory Maincent
  2023-11-17  7:58   ` Manivannan Sadhasivam
  2023-11-14 14:51 ` [PATCH v5 4/6] dmaengine: dw-edma: Add HDMA remote interrupt configuration Kory Maincent
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent

Fix "HDMA_V0_REMOTEL_STOP_INT_EN" typo error

Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
---

Changes in v3:
- Split the patch in two to differ bug fix and simple harmless typo.
---
 drivers/dma/dw-edma/dw-hdma-v0-regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dw-edma/dw-hdma-v0-regs.h b/drivers/dma/dw-edma/dw-hdma-v0-regs.h
index a974abdf8aaf..eab5fd7177e5 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-regs.h
+++ b/drivers/dma/dw-edma/dw-hdma-v0-regs.h
@@ -15,7 +15,7 @@
 #define HDMA_V0_LOCAL_ABORT_INT_EN		BIT(6)
 #define HDMA_V0_REMOTE_ABORT_INT_EN		BIT(5)
 #define HDMA_V0_LOCAL_STOP_INT_EN		BIT(4)
-#define HDMA_V0_REMOTEL_STOP_INT_EN		BIT(3)
+#define HDMA_V0_REMOTE_STOP_INT_EN		BIT(3)
 #define HDMA_V0_ABORT_INT_MASK			BIT(2)
 #define HDMA_V0_STOP_INT_MASK			BIT(0)
 #define HDMA_V0_LINKLIST_EN			BIT(0)

-- 
2.25.1


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

* [PATCH v5 4/6] dmaengine: dw-edma: Add HDMA remote interrupt configuration
  2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
                   ` (2 preceding siblings ...)
  2023-11-14 14:51 ` [PATCH v5 3/6] dmaengine: dw-edma: Typo fix Kory Maincent
@ 2023-11-14 14:51 ` Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Kory Maincent
  2023-11-14 14:51 ` [PATCH v5 6/6] dmaengine: dw-edma: eDMA: " Kory Maincent
  5 siblings, 0 replies; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent, Manivannan Sadhasivam

Only the local interruption was configured, remote interrupt was left
behind. This patch fix it by setting stop and abort remote interrupts when
the DW_EDMA_CHIP_LOCAL flag is not set.

Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
index 108f9127aaaa..04b0bcb6ded9 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
@@ -237,6 +237,8 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
 		tmp = GET_CH_32(dw, chan->dir, chan->id, int_setup) |
 		      HDMA_V0_STOP_INT_MASK | HDMA_V0_ABORT_INT_MASK |
 		      HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_ABORT_INT_EN;
+		if (!(dw->chip->flags & DW_EDMA_CHIP_LOCAL))
+			tmp |= HDMA_V0_REMOTE_STOP_INT_EN | HDMA_V0_REMOTE_ABORT_INT_EN;
 		SET_CH_32(dw, chan->dir, chan->id, int_setup, tmp);
 		/* Channel control */
 		SET_CH_32(dw, chan->dir, chan->id, control1, HDMA_V0_LINKLIST_EN);

-- 
2.25.1


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

* [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup
  2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
                   ` (3 preceding siblings ...)
  2023-11-14 14:51 ` [PATCH v5 4/6] dmaengine: dw-edma: Add HDMA remote interrupt configuration Kory Maincent
@ 2023-11-14 14:51 ` Kory Maincent
  2023-11-17  8:07   ` Manivannan Sadhasivam
  2023-11-14 14:51 ` [PATCH v5 6/6] dmaengine: dw-edma: eDMA: " Kory Maincent
  5 siblings, 1 reply; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent

The Linked list element and pointer are not stored in the same memory as
the HDMA controller register. If the doorbell register is toggled before
the full write of the linked list a race condition error will occur.
In remote setup we can only use a readl to the memory to assure the full
write has occurred.

Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

Changes in v2:
- Move the sync read in a function.
- Add commments

Changes in v4:
- Update git commit message.
---
 drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
index 04b0bcb6ded9..13b6aec6a6de 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
@@ -222,6 +222,20 @@ static void dw_hdma_v0_core_write_chunk(struct dw_edma_chunk *chunk)
 	dw_hdma_v0_write_ll_link(chunk, i, control, chunk->ll_region.paddr);
 }
 
+static void dw_hdma_v0_sync_ll_data(struct dw_edma_chunk *chunk)
+{
+	/*
+	 * In case of remote HDMA engine setup, the DW PCIe RP/EP internals
+	 * configuration registers and Application memory are normally accessed
+	 * over different buses. Ensure LL-data reaches the memory before the
+	 * doorbell register is toggled by issuing the dummy-read from the remote
+	 * LL memory in a hope that the posted MRd TLP will return only after the
+	 * last MWr TLP is completed
+	 */
+	if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL))
+		readl(chunk->ll_region.vaddr.io);
+}
+
 static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
 {
 	struct dw_edma_chan *chan = chunk->chan;
@@ -252,6 +266,9 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
 	/* Set consumer cycle */
 	SET_CH_32(dw, chan->dir, chan->id, cycle_sync,
 		  HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT);
+
+	dw_hdma_v0_sync_ll_data(chunk);
+
 	/* Doorbell */
 	SET_CH_32(dw, chan->dir, chan->id, doorbell, HDMA_V0_DOORBELL_START);
 }

-- 
2.25.1


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

* [PATCH v5 6/6] dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup
  2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
                   ` (4 preceding siblings ...)
  2023-11-14 14:51 ` [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Kory Maincent
@ 2023-11-14 14:51 ` Kory Maincent
  2023-11-17  8:08   ` Manivannan Sadhasivam
  5 siblings, 1 reply; 11+ messages in thread
From: Kory Maincent @ 2023-11-14 14:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing
  Cc: Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina,
	Kory Maincent

The Linked list element and pointer are not stored in the same memory as
the eDMA controller register. If the doorbell register is toggled before
the full write of the linked list a race condition error will occur.
In remote setup we can only use a readl to the memory to assure the full
write has occurred.

Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

Changes in v2:
- New patch

Changes in v4:
- Update git commit message.
---
 drivers/dma/dw-edma/dw-edma-v0-core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c
index b38786f0ad79..6245b720fbfe 100644
--- a/drivers/dma/dw-edma/dw-edma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-edma-v0-core.c
@@ -346,6 +346,20 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk)
 	dw_edma_v0_write_ll_link(chunk, i, control, chunk->ll_region.paddr);
 }
 
+static void dw_edma_v0_sync_ll_data(struct dw_edma_chunk *chunk)
+{
+	/*
+	 * In case of remote eDMA engine setup, the DW PCIe RP/EP internals
+	 * configuration registers and Application memory are normally accessed
+	 * over different buses. Ensure LL-data reaches the memory before the
+	 * doorbell register is toggled by issuing the dummy-read from the remote
+	 * LL memory in a hope that the posted MRd TLP will return only after the
+	 * last MWr TLP is completed
+	 */
+	if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL))
+		readl(chunk->ll_region.vaddr.io);
+}
+
 static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
 {
 	struct dw_edma_chan *chan = chunk->chan;
@@ -412,6 +426,9 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
 		SET_CH_32(dw, chan->dir, chan->id, llp.msb,
 			  upper_32_bits(chunk->ll_region.paddr));
 	}
+
+	dw_edma_v0_sync_ll_data(chunk);
+
 	/* Doorbell */
 	SET_RW_32(dw, chan->dir, doorbell,
 		  FIELD_PREP(EDMA_V0_DOORBELL_CH_MASK, chan->id));

-- 
2.25.1


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

* Re: [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set
  2023-11-14 14:51 ` [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set Kory Maincent
@ 2023-11-17  7:48   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2023-11-17  7:48 UTC (permalink / raw)
  To: Kory Maincent
  Cc: Manivannan Sadhasivam, Gustavo Pimentel, Serge Semin, Vinod Koul,
	Cai Huoqing, Thomas Petazzoni, dmaengine, linux-kernel,
	Herve Codina

On Tue, Nov 14, 2023 at 03:51:55PM +0100, Kory Maincent wrote:

Subject should reflect HDMA:

"dmaengine: dw-edma: Fix wrong interrupt bit set for HDMA"

> Fix "HDMA_V0_LOCAL_STOP_INT_EN" to "HDMA_V0_LOCAL_ABORT_INT_EN" as the STOP
> bit is already set in the same line.
> 

How about:

"Instead of setting HDMA_V0_LOCAL_ABORT_INT_EN bit, HDMA_V0_LOCAL_STOP_INT_EN
bit got set twice, due to which the abort interrupt is not getting generated for
HDMA. Fix it by setting the correct interrupt enable bit."

> Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

With the above changes,

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> ---
> 
> Changes in v3:
> - Split the patch in two to differ bug fix and simple harmless typo.
> ---
>  drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> index 1f4cb7db5475..108f9127aaaa 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> @@ -236,7 +236,7 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
>  		/* Interrupt enable&unmask - done, abort */
>  		tmp = GET_CH_32(dw, chan->dir, chan->id, int_setup) |
>  		      HDMA_V0_STOP_INT_MASK | HDMA_V0_ABORT_INT_MASK |
> -		      HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_STOP_INT_EN;
> +		      HDMA_V0_LOCAL_STOP_INT_EN | HDMA_V0_LOCAL_ABORT_INT_EN;
>  		SET_CH_32(dw, chan->dir, chan->id, int_setup, tmp);
>  		/* Channel control */
>  		SET_CH_32(dw, chan->dir, chan->id, control1, HDMA_V0_LINKLIST_EN);
> 
> -- 
> 2.25.1
> 

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH v5 3/6] dmaengine: dw-edma: Typo fix
  2023-11-14 14:51 ` [PATCH v5 3/6] dmaengine: dw-edma: Typo fix Kory Maincent
@ 2023-11-17  7:58   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2023-11-17  7:58 UTC (permalink / raw)
  To: Kory Maincent
  Cc: Gustavo Pimentel, Serge Semin, Vinod Koul, Cai Huoqing,
	Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina

On Tue, Nov 14, 2023 at 03:51:56PM +0100, Kory Maincent wrote:

Please mention what typo it is in the subject.

> Fix "HDMA_V0_REMOTEL_STOP_INT_EN" typo error
> 
> Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

With that,

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> ---
> 
> Changes in v3:
> - Split the patch in two to differ bug fix and simple harmless typo.
> ---
>  drivers/dma/dw-edma/dw-hdma-v0-regs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/dw-edma/dw-hdma-v0-regs.h b/drivers/dma/dw-edma/dw-hdma-v0-regs.h
> index a974abdf8aaf..eab5fd7177e5 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-regs.h
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-regs.h
> @@ -15,7 +15,7 @@
>  #define HDMA_V0_LOCAL_ABORT_INT_EN		BIT(6)
>  #define HDMA_V0_REMOTE_ABORT_INT_EN		BIT(5)
>  #define HDMA_V0_LOCAL_STOP_INT_EN		BIT(4)
> -#define HDMA_V0_REMOTEL_STOP_INT_EN		BIT(3)
> +#define HDMA_V0_REMOTE_STOP_INT_EN		BIT(3)
>  #define HDMA_V0_ABORT_INT_MASK			BIT(2)
>  #define HDMA_V0_STOP_INT_MASK			BIT(0)
>  #define HDMA_V0_LINKLIST_EN			BIT(0)
> 
> -- 
> 2.25.1
> 

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup
  2023-11-14 14:51 ` [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Kory Maincent
@ 2023-11-17  8:07   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2023-11-17  8:07 UTC (permalink / raw)
  To: Kory Maincent
  Cc: Gustavo Pimentel, Serge Semin, Vinod Koul, Cai Huoqing,
	Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina

On Tue, Nov 14, 2023 at 03:51:58PM +0100, Kory Maincent wrote:
> The Linked list element and pointer are not stored in the same memory as
> the HDMA controller register. If the doorbell register is toggled before
> the full write of the linked list a race condition error will occur.
> In remote setup we can only use a readl to the memory to assure the full
> write has occurred.
> 
> Fixes: e74c39573d35 ("dmaengine: dw-edma: Add support for native HDMA")
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

Few nitpicks below. With those addressed,

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

> ---
> 
> Changes in v2:
> - Move the sync read in a function.
> - Add commments
> 
> Changes in v4:
> - Update git commit message.
> ---
>  drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> index 04b0bcb6ded9..13b6aec6a6de 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> @@ -222,6 +222,20 @@ static void dw_hdma_v0_core_write_chunk(struct dw_edma_chunk *chunk)
>  	dw_hdma_v0_write_ll_link(chunk, i, control, chunk->ll_region.paddr);
>  }
>  
> +static void dw_hdma_v0_sync_ll_data(struct dw_edma_chunk *chunk)
> +{
> +	/*
> +	 * In case of remote HDMA engine setup, the DW PCIe RP/EP internals

s/internals/internal

> +	 * configuration registers and Application memory are normally accessed

s/Application/application

> +	 * over different buses. Ensure LL-data reaches the memory before the
> +	 * doorbell register is toggled by issuing the dummy-read from the remote
> +	 * LL memory in a hope that the posted MRd TLP will return only after the

MRd TLP is not posted.

- Mani

> +	 * last MWr TLP is completed
> +	 */
> +	if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL))
> +		readl(chunk->ll_region.vaddr.io);
> +}
> +
>  static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
>  {
>  	struct dw_edma_chan *chan = chunk->chan;
> @@ -252,6 +266,9 @@ static void dw_hdma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
>  	/* Set consumer cycle */
>  	SET_CH_32(dw, chan->dir, chan->id, cycle_sync,
>  		  HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT);
> +
> +	dw_hdma_v0_sync_ll_data(chunk);
> +
>  	/* Doorbell */
>  	SET_CH_32(dw, chan->dir, chan->id, doorbell, HDMA_V0_DOORBELL_START);
>  }
> 
> -- 
> 2.25.1
> 

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH v5 6/6] dmaengine: dw-edma: eDMA: Add sync read before starting the DMA transfer in remote setup
  2023-11-14 14:51 ` [PATCH v5 6/6] dmaengine: dw-edma: eDMA: " Kory Maincent
@ 2023-11-17  8:08   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2023-11-17  8:08 UTC (permalink / raw)
  To: Kory Maincent
  Cc: Gustavo Pimentel, Serge Semin, Vinod Koul, Cai Huoqing,
	Thomas Petazzoni, dmaengine, linux-kernel, Herve Codina

On Tue, Nov 14, 2023 at 03:51:59PM +0100, Kory Maincent wrote:
> The Linked list element and pointer are not stored in the same memory as
> the eDMA controller register. If the doorbell register is toggled before
> the full write of the linked list a race condition error will occur.
> In remote setup we can only use a readl to the memory to assure the full
> write has occurred.
> 
> Fixes: 7e4b8a4fbe2c ("dmaengine: Add Synopsys eDMA IP version 0 support")
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>

Same comment as patch 5/6. With that addressed,

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
> 
> Changes in v2:
> - New patch
> 
> Changes in v4:
> - Update git commit message.
> ---
>  drivers/dma/dw-edma/dw-edma-v0-core.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c
> index b38786f0ad79..6245b720fbfe 100644
> --- a/drivers/dma/dw-edma/dw-edma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c
> @@ -346,6 +346,20 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk)
>  	dw_edma_v0_write_ll_link(chunk, i, control, chunk->ll_region.paddr);
>  }
>  
> +static void dw_edma_v0_sync_ll_data(struct dw_edma_chunk *chunk)
> +{
> +	/*
> +	 * In case of remote eDMA engine setup, the DW PCIe RP/EP internals
> +	 * configuration registers and Application memory are normally accessed
> +	 * over different buses. Ensure LL-data reaches the memory before the
> +	 * doorbell register is toggled by issuing the dummy-read from the remote
> +	 * LL memory in a hope that the posted MRd TLP will return only after the
> +	 * last MWr TLP is completed
> +	 */
> +	if (!(chunk->chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL))
> +		readl(chunk->ll_region.vaddr.io);
> +}
> +
>  static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
>  {
>  	struct dw_edma_chan *chan = chunk->chan;
> @@ -412,6 +426,9 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
>  		SET_CH_32(dw, chan->dir, chan->id, llp.msb,
>  			  upper_32_bits(chunk->ll_region.paddr));
>  	}
> +
> +	dw_edma_v0_sync_ll_data(chunk);
> +
>  	/* Doorbell */
>  	SET_RW_32(dw, chan->dir, doorbell,
>  		  FIELD_PREP(EDMA_V0_DOORBELL_CH_MASK, chan->id));
> 
> -- 
> 2.25.1
> 

-- 
மணிவண்ணன் சதாசிவம்

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

end of thread, other threads:[~2023-11-17  8:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-14 14:51 [PATCH v5 0/6] Fix support of dw-edma HDMA NATIVE IP in remote setup Kory Maincent
2023-11-14 14:51 ` [PATCH v5 1/6] dmaengine: dw-edma: Fix the ch_count hdma callback Kory Maincent
2023-11-14 14:51 ` [PATCH v5 2/6] dmaengine: dw-edma: Fix wrong interrupt bit set Kory Maincent
2023-11-17  7:48   ` Manivannan Sadhasivam
2023-11-14 14:51 ` [PATCH v5 3/6] dmaengine: dw-edma: Typo fix Kory Maincent
2023-11-17  7:58   ` Manivannan Sadhasivam
2023-11-14 14:51 ` [PATCH v5 4/6] dmaengine: dw-edma: Add HDMA remote interrupt configuration Kory Maincent
2023-11-14 14:51 ` [PATCH v5 5/6] dmaengine: dw-edma: HDMA: Add sync read before starting the DMA transfer in remote setup Kory Maincent
2023-11-17  8:07   ` Manivannan Sadhasivam
2023-11-14 14:51 ` [PATCH v5 6/6] dmaengine: dw-edma: eDMA: " Kory Maincent
2023-11-17  8:08   ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox