From: Kory Maincent <[email protected]>
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.
Kory Maincent (5):
dmaengine: dw-edma: Fix the ch_count hdma callback
dmaengine: dw-edma: Typos fixes
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 | 22 ++++++++++++++
drivers/dma/dw-edma/dw-hdma-v0-core.c | 43 +++++++++++++++++++--------
drivers/dma/dw-edma/dw-hdma-v0-regs.h | 2 +-
3 files changed, 53 insertions(+), 14 deletions(-)
--
2.25.1
From: Kory Maincent <[email protected]>
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")
Signed-off-by: Kory Maincent <[email protected]>
---
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
---
drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++------------
1 file changed, 5 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..3e78d4fd3955 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
@@ -65,18 +65,11 @@ 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
From: Kory Maincent <[email protected]>
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 <[email protected]>
Reviewed-by: Serge Semin <[email protected]>
---
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 0afafc683a9e..0cce1880cfdc 100644
--- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
+++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
@@ -236,6 +236,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
Hi Cai,
On Mon, Oct 02, 2023 at 03:17:45PM +0200, K?ry Maincent wrote:
> From: Kory Maincent <[email protected]>
>
> 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")
> Signed-off-by: Kory Maincent <[email protected]>
> ---
>
> See the following thread mail that talk about this issue:
> https://lore.kernel.org/lkml/20230607095832.6d6b1a73@kmaincent-XPS-13-7390/
Cai, do you have anything to add in regards to this change and to the
discussion available in the thread above? If no, I guess the solution
provided in this patch is the best we can currently come up with.
-Serge(y)
>
> Changes in v2:
> - Add comment
> ---
> drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++------------
> 1 file changed, 5 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..3e78d4fd3955 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> @@ -65,18 +65,11 @@ 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
>
On 02-10-23, 15:17, K?ry Maincent wrote:
> From: Kory Maincent <[email protected]>
>
> 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...?
>
> Kory Maincent (5):
> dmaengine: dw-edma: Fix the ch_count hdma callback
> dmaengine: dw-edma: Typos fixes
> 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 | 22 ++++++++++++++
> drivers/dma/dw-edma/dw-hdma-v0-core.c | 43 +++++++++++++++++++--------
> drivers/dma/dw-edma/dw-hdma-v0-regs.h | 2 +-
> 3 files changed, 53 insertions(+), 14 deletions(-)
>
> --
> 2.25.1
--
~Vinod
On Wed, 4 Oct 2023 12:51:54 +0530
Vinod Koul <[email protected]> wrote:
> On 02-10-23, 15:17, Köry Maincent wrote:
> > From: Kory Maincent <[email protected]>
> >
> > 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...?
Oops forget to add it to the cover letter, sorry.
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.
On Mon, Oct 02, 2023 at 03:17:45PM +0200, Köry Maincent wrote:
> From: Kory Maincent <[email protected]>
>
> 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")
> Signed-off-by: Kory Maincent <[email protected]>
One nitpick below. With that,
Acked-by: Manivannan Sadhasivam <[email protected]>
> ---
>
> 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
> ---
> drivers/dma/dw-edma/dw-hdma-v0-core.c | 17 +++++------------
> 1 file changed, 5 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..3e78d4fd3955 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> @@ -65,18 +65,11 @@ 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
Please use below style for multi line comment:
/*
* ...
*/
- Mani
> + * 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
>
--
மணிவண்ணன் சதாசிவம்
On Mon, Oct 02, 2023 at 03:17:47PM +0200, Köry Maincent wrote:
> From: Kory Maincent <[email protected]>
>
> 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 <[email protected]>
Acked-by: Manivannan Sadhasivam <[email protected]>
- Mani
> Reviewed-by: Serge Semin <[email protected]>
> ---
> 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 0afafc683a9e..0cce1880cfdc 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> @@ -236,6 +236,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
>
--
மணிவண்ணன் சதாசிவம்