* [PATCH v4] dmaengine: sh: rz-dmac: Add device_synchronize callback
@ 2022-07-22 8:44 Biju Das
2022-07-22 8:57 ` Geert Uytterhoeven
2022-07-26 12:58 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Biju Das @ 2022-07-22 8:44 UTC (permalink / raw)
To: Vinod Koul
Cc: Biju Das, Colin Ian King, Dan Carpenter, Lad Prabhakar, dmaengine,
Mark Brown, Geert Uytterhoeven, Chris Paterson, Biju Das,
linux-renesas-soc
Some on-chip peripheral modules(for eg:- rspi) on RZ/G2L SoC
use the same signal for both interrupt and DMA transfer requests.
The signal works as a DMA transfer request signal by setting
DMARS, and subsequent interrupt requests to the interrupt controller
are masked.
We can re-enable the interrupt by clearing the DMARS.
This patch adds device_synchronize callback for clearing
DMARS and thereby allowing DMA consumers to switch to
interrupt mode.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v3->v4:
* Increased delay_us 10->100us and timeout_us 1ms->100ms.
v2->v3:
* Fixed commit description
* Added check if the DMA operation has been completed or terminated,
and wait (sleep) if needed.
v1->v2:
* No change
---
drivers/dma/sh/rz-dmac.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index ee2872e7d64c..476847a4916b 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -12,6 +12,7 @@
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/interrupt.h>
+#include <linux/iopoll.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -630,6 +631,21 @@ static void rz_dmac_virt_desc_free(struct virt_dma_desc *vd)
*/
}
+static void rz_dmac_device_synchronize(struct dma_chan *chan)
+{
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
+ u32 chstat;
+ int ret;
+
+ ret = read_poll_timeout(rz_dmac_ch_readl, chstat, !(chstat & CHSTAT_EN),
+ 100, 100000, false, channel, CHSTAT, 1);
+ if (ret < 0)
+ dev_warn(dmac->dev, "DMA Timeout");
+
+ rz_dmac_set_dmars_register(dmac, channel->index, 0);
+}
+
/*
* -----------------------------------------------------------------------------
* IRQ handling
@@ -909,6 +925,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
engine->device_config = rz_dmac_config;
engine->device_terminate_all = rz_dmac_terminate_all;
engine->device_issue_pending = rz_dmac_issue_pending;
+ engine->device_synchronize = rz_dmac_device_synchronize;
engine->copy_align = DMAENGINE_ALIGN_1_BYTE;
dma_set_max_seg_size(engine->dev, U32_MAX);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v4] dmaengine: sh: rz-dmac: Add device_synchronize callback
2022-07-22 8:44 [PATCH v4] dmaengine: sh: rz-dmac: Add device_synchronize callback Biju Das
@ 2022-07-22 8:57 ` Geert Uytterhoeven
2022-07-26 12:58 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-07-22 8:57 UTC (permalink / raw)
To: Biju Das
Cc: Vinod Koul, Colin Ian King, Dan Carpenter, Lad Prabhakar,
dmaengine, Mark Brown, Chris Paterson, Biju Das, Linux-Renesas
On Fri, Jul 22, 2022 at 10:44 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> Some on-chip peripheral modules(for eg:- rspi) on RZ/G2L SoC
> use the same signal for both interrupt and DMA transfer requests.
> The signal works as a DMA transfer request signal by setting
> DMARS, and subsequent interrupt requests to the interrupt controller
> are masked.
>
> We can re-enable the interrupt by clearing the DMARS.
>
> This patch adds device_synchronize callback for clearing
> DMARS and thereby allowing DMA consumers to switch to
> interrupt mode.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v3->v4:
> * Increased delay_us 10->100us and timeout_us 1ms->100ms.
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] 3+ messages in thread* Re: [PATCH v4] dmaengine: sh: rz-dmac: Add device_synchronize callback
2022-07-22 8:44 [PATCH v4] dmaengine: sh: rz-dmac: Add device_synchronize callback Biju Das
2022-07-22 8:57 ` Geert Uytterhoeven
@ 2022-07-26 12:58 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2022-07-26 12:58 UTC (permalink / raw)
To: Biju Das
Cc: Colin Ian King, Dan Carpenter, Lad Prabhakar, dmaengine,
Mark Brown, Geert Uytterhoeven, Chris Paterson, Biju Das,
linux-renesas-soc
On 22-07-22, 09:44, Biju Das wrote:
> Some on-chip peripheral modules(for eg:- rspi) on RZ/G2L SoC
> use the same signal for both interrupt and DMA transfer requests.
> The signal works as a DMA transfer request signal by setting
> DMARS, and subsequent interrupt requests to the interrupt controller
> are masked.
>
> We can re-enable the interrupt by clearing the DMARS.
>
> This patch adds device_synchronize callback for clearing
> DMARS and thereby allowing DMA consumers to switch to
> interrupt mode.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-26 12:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-22 8:44 [PATCH v4] dmaengine: sh: rz-dmac: Add device_synchronize callback Biju Das
2022-07-22 8:57 ` Geert Uytterhoeven
2022-07-26 12:58 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox