linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] RZ/G2L DMA fix/improvements
@ 2023-07-06 11:21 Biju Das
  2023-07-06 11:21 ` [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove() Biju Das
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Biju Das @ 2023-07-06 11:21 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Biju Das, Geert Uytterhoeven, Lad Prabhakar, Hien Huynh,
	dmaengine, linux-renesas-soc

This patch series aims to fix/improve RZ/DMAC driver.

The improvement patch is related to fix cleanup order in probe/remove().
and fixes patch is related to wrong SDS/DDS settings, when we change/update
the DMA bus width several times.

v2->v3:
 * Added bitfield.h header file and replaced CHCFG_FILL_{SDS,DDS}
   macros with FIELD_PREP.
 * Updated commit header 'dma: rz-dmac'->'dmaengine: sh: rz-dmac'.
v1->v2:
 * Update patch header and description.

Biju Das (1):
  dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()

Hien Huynh (1):
  dmaengine: sh: rz-dmac: Fix destination and source data size setting

 drivers/dma/sh/rz-dmac.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

-- 
2.25.1


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

* [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()
  2023-07-06 11:21 [PATCH v3 0/2] RZ/G2L DMA fix/improvements Biju Das
@ 2023-07-06 11:21 ` Biju Das
  2023-07-07 15:41   ` Pavel Machek
  2023-07-10 13:30   ` Geert Uytterhoeven
  2023-07-06 11:21 ` [PATCH v3 2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting Biju Das
  2023-07-11 16:43 ` [PATCH v3 0/2] RZ/G2L DMA fix/improvements Vinod Koul
  2 siblings, 2 replies; 7+ messages in thread
From: Biju Das @ 2023-07-06 11:21 UTC (permalink / raw)
  To: Vinod Koul, Philipp Zabel
  Cc: Biju Das, Geert Uytterhoeven, Hien Huynh, Lad Prabhakar,
	dmaengine, linux-renesas-soc, Pavel Machek

We usually do cleanup in reverse order of init. Currently, in the
case of error, this is not followed in rz_dmac_probe(), and similar
case for remove().

This patch improves error handling in probe() and cleanup in
reverse order of init in the remove().

Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2->v3:
 No change.
v1->v2:
 * Fixed typo in patch header
 * Updated patch description.
---
 drivers/dma/sh/rz-dmac.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 9479f29692d3..229f642fde6b 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -947,7 +947,6 @@ static int rz_dmac_probe(struct platform_device *pdev)
 dma_register_err:
 	of_dma_controller_free(pdev->dev.of_node);
 err:
-	reset_control_assert(dmac->rstc);
 	channel_num = i ? i - 1 : 0;
 	for (i = 0; i < channel_num; i++) {
 		struct rz_dmac_chan *channel = &dmac->channels[i];
@@ -958,6 +957,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
 				  channel->lmdesc.base_dma);
 	}
 
+	reset_control_assert(dmac->rstc);
 err_pm_runtime_put:
 	pm_runtime_put(&pdev->dev);
 err_pm_disable:
@@ -971,6 +971,8 @@ static int rz_dmac_remove(struct platform_device *pdev)
 	struct rz_dmac *dmac = platform_get_drvdata(pdev);
 	unsigned int i;
 
+	dma_async_device_unregister(&dmac->engine);
+	of_dma_controller_free(pdev->dev.of_node);
 	for (i = 0; i < dmac->n_channels; i++) {
 		struct rz_dmac_chan *channel = &dmac->channels[i];
 
@@ -979,8 +981,6 @@ static int rz_dmac_remove(struct platform_device *pdev)
 				  channel->lmdesc.base,
 				  channel->lmdesc.base_dma);
 	}
-	of_dma_controller_free(pdev->dev.of_node);
-	dma_async_device_unregister(&dmac->engine);
 	reset_control_assert(dmac->rstc);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-- 
2.25.1


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

* [PATCH v3 2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting
  2023-07-06 11:21 [PATCH v3 0/2] RZ/G2L DMA fix/improvements Biju Das
  2023-07-06 11:21 ` [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove() Biju Das
@ 2023-07-06 11:21 ` Biju Das
  2023-07-10 13:36   ` Geert Uytterhoeven
  2023-07-11 16:43 ` [PATCH v3 0/2] RZ/G2L DMA fix/improvements Vinod Koul
  2 siblings, 1 reply; 7+ messages in thread
From: Biju Das @ 2023-07-06 11:21 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Hien Huynh, Biju Das, Geert Uytterhoeven, Lad Prabhakar,
	dmaengine, linux-renesas-soc, stable

From: Hien Huynh <hien.huynh.px@renesas.com>

Before setting DDS and SDS values, we need to clear its value first
otherwise, we get incorrect results when we change/update the DMA bus
width several times due to the 'OR' expression.

Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
Cc: stable@kernel.org
Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2->v3:
 * Added bitfield.h header file and replaced CHCFG_FILL_{SDS,DDS}
   macros with FIELD_PREP.
 * Updated commit header 'dma: rz-dmac'->'dmaengine: sh: rz-dmac'.
v1->v2:
 * Updated patch header.
---
 drivers/dma/sh/rz-dmac.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 229f642fde6b..f777addda8ba 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -9,6 +9,7 @@
  * Copyright 2012 Javier Martin, Vista Silicon <javier.martin@vista-silicon.com>
  */
 
+#include <linux/bitfield.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
 #include <linux/interrupt.h>
@@ -145,8 +146,8 @@ struct rz_dmac {
 #define CHCFG_REQD			BIT(3)
 #define CHCFG_SEL(bits)			((bits) & 0x07)
 #define CHCFG_MEM_COPY			(0x80400008)
-#define CHCFG_FILL_DDS(a)		(((a) << 16) & GENMASK(19, 16))
-#define CHCFG_FILL_SDS(a)		(((a) << 12) & GENMASK(15, 12))
+#define CHCFG_FILL_DDS_MASK		GENMASK(19, 16)
+#define CHCFG_FILL_SDS_MASK		GENMASK(15, 12)
 #define CHCFG_FILL_TM(a)		(((a) & BIT(5)) << 22)
 #define CHCFG_FILL_AM(a)		(((a) & GENMASK(4, 2)) << 6)
 #define CHCFG_FILL_LVL(a)		(((a) & BIT(1)) << 5)
@@ -607,13 +608,15 @@ static int rz_dmac_config(struct dma_chan *chan,
 	if (val == CHCFG_DS_INVALID)
 		return -EINVAL;
 
-	channel->chcfg |= CHCFG_FILL_DDS(val);
+	channel->chcfg &= ~CHCFG_FILL_DDS_MASK;
+	channel->chcfg |= FIELD_PREP(CHCFG_FILL_DDS_MASK, val);
 
 	val = rz_dmac_ds_to_val_mapping(config->src_addr_width);
 	if (val == CHCFG_DS_INVALID)
 		return -EINVAL;
 
-	channel->chcfg |= CHCFG_FILL_SDS(val);
+	channel->chcfg &= ~CHCFG_FILL_SDS_MASK;
+	channel->chcfg |= FIELD_PREP(CHCFG_FILL_SDS_MASK, val);
 
 	return 0;
 }
-- 
2.25.1


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

* Re: [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()
  2023-07-06 11:21 ` [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove() Biju Das
@ 2023-07-07 15:41   ` Pavel Machek
  2023-07-10 13:30   ` Geert Uytterhoeven
  1 sibling, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2023-07-07 15:41 UTC (permalink / raw)
  To: Biju Das
  Cc: Vinod Koul, Philipp Zabel, Geert Uytterhoeven, Hien Huynh,
	Lad Prabhakar, dmaengine, linux-renesas-soc, Pavel Machek

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

Hi!

> We usually do cleanup in reverse order of init. Currently, in the
> case of error, this is not followed in rz_dmac_probe(), and similar
> case for remove().
> 
> This patch improves error handling in probe() and cleanup in
> reverse order of init in the remove().

Thanks for doing this.

Reviewed-by: Pavel Machek <pavel@denx.de>

BR,
								Pavel
-- 
DENX Software Engineering GmbH,        Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

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

* Re: [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()
  2023-07-06 11:21 ` [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove() Biju Das
  2023-07-07 15:41   ` Pavel Machek
@ 2023-07-10 13:30   ` Geert Uytterhoeven
  1 sibling, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2023-07-10 13:30 UTC (permalink / raw)
  To: Biju Das
  Cc: Vinod Koul, Philipp Zabel, Hien Huynh, Lad Prabhakar, dmaengine,
	linux-renesas-soc, Pavel Machek

On Thu, Jul 6, 2023 at 1:22 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> We usually do cleanup in reverse order of init. Currently, in the
> case of error, this is not followed in rz_dmac_probe(), and similar
> case for remove().
>
> This patch improves error handling in probe() and cleanup in
> reverse order of init in the remove().
>
> Reported-by: Pavel Machek <pavel@denx.de>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v2->v3:
>  No change.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting
  2023-07-06 11:21 ` [PATCH v3 2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting Biju Das
@ 2023-07-10 13:36   ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2023-07-10 13:36 UTC (permalink / raw)
  To: Biju Das
  Cc: Vinod Koul, Hien Huynh, Geert Uytterhoeven, Lad Prabhakar,
	dmaengine, linux-renesas-soc, stable

On Thu, Jul 6, 2023 at 1:22 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> From: Hien Huynh <hien.huynh.px@renesas.com>
>
> Before setting DDS and SDS values, we need to clear its value first
> otherwise, we get incorrect results when we change/update the DMA bus
> width several times due to the 'OR' expression.
>
> Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
> Cc: stable@kernel.org
> Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v2->v3:
>  * Added bitfield.h header file and replaced CHCFG_FILL_{SDS,DDS}
>    macros with FIELD_PREP.
>  * Updated commit header 'dma: rz-dmac'->'dmaengine: sh: rz-dmac'.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 0/2] RZ/G2L DMA fix/improvements
  2023-07-06 11:21 [PATCH v3 0/2] RZ/G2L DMA fix/improvements Biju Das
  2023-07-06 11:21 ` [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove() Biju Das
  2023-07-06 11:21 ` [PATCH v3 2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting Biju Das
@ 2023-07-11 16:43 ` Vinod Koul
  2 siblings, 0 replies; 7+ messages in thread
From: Vinod Koul @ 2023-07-11 16:43 UTC (permalink / raw)
  To: Biju Das
  Cc: Geert Uytterhoeven, Lad Prabhakar, Hien Huynh, dmaengine,
	linux-renesas-soc


On Thu, 06 Jul 2023 12:21:48 +0100, Biju Das wrote:
> This patch series aims to fix/improve RZ/DMAC driver.
> 
> The improvement patch is related to fix cleanup order in probe/remove().
> and fixes patch is related to wrong SDS/DDS settings, when we change/update
> the DMA bus width several times.
> 
> v2->v3:
>  * Added bitfield.h header file and replaced CHCFG_FILL_{SDS,DDS}
>    macros with FIELD_PREP.
>  * Updated commit header 'dma: rz-dmac'->'dmaengine: sh: rz-dmac'.
> v1->v2:
>  * Update patch header and description.
> 
> [...]

Applied, thanks!

[1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()
      commit: d8fb35d80914846d25833a35acb211e59ee36046
[2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting
      commit: 48f745e247ac05dc23b0ffee189c6faba183a9d7

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2023-07-11 16:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 11:21 [PATCH v3 0/2] RZ/G2L DMA fix/improvements Biju Das
2023-07-06 11:21 ` [PATCH v3 1/2] dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove() Biju Das
2023-07-07 15:41   ` Pavel Machek
2023-07-10 13:30   ` Geert Uytterhoeven
2023-07-06 11:21 ` [PATCH v3 2/2] dmaengine: sh: rz-dmac: Fix destination and source data size setting Biju Das
2023-07-10 13:36   ` Geert Uytterhoeven
2023-07-11 16:43 ` [PATCH v3 0/2] RZ/G2L DMA fix/improvements 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).