* [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements
@ 2026-11-26 15:21 Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 01/27] dmaengine: sh: rz-dmac: Avoid format-overflow warning Claudiu Beznea
` (27 more replies)
0 siblings, 28 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Hi,
This series backports cyclic DMA, runtime PM and suspend to RAM
along with preparatory and cleanup patches.
I tried to limit the number of patches per series. Please let me know
if this needs to be further improved and will consider it for the
future sumissions.
Thank you,
Claudiu
Biju Das (1):
dmaengine: sh: rz-dmac: Add device_tx_status() callback
Claudiu Beznea (21):
dmaengine: sh: rz-dmac: Protect the driver specific lists
dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock
dmaengine: sh: rz-dmac: Drop read of CHCTRL register
dmaengine: sh: rz-dmac: Drop goto instruction and label
dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call
dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks
dmaengine: sh: rz-dmac: Move interrupt request after everything is set
up
dmaengine: sh: rz-dmac: Fix incorrect NULL check for
list_first_entry()
dmaengine: sh: rz-dmac: Use list_first_entry_or_null()
dmaengine: sh: rz-dmac: Use rz_dmac_disable_hw()
dmaengine: sh: rz-dmac: Add helper to compute the lmdesc address
dmaengine: sh: rz-dmac: Save the start LM descriptor
dmaengine: sh: rz-dmac: Add helper to check if the channel is enabled
dmaengine: sh: rz-dmac: Add helper to check if the channel is paused
dmaengine: sh: rz-dmac: Use virt-dma APIs for channel descriptor
processing
dmaengine: sh: rz-dmac: Refactor pause/resume code
dmaengine: sh: rz-dmac: Drop the update of channel->chctrl with
CHCTRL_SETEN
dmaengine: sh: rz-dmac: Add cyclic DMA support
dmaengine: sh: rz-dmac: Adjust rz_dmac_chan_get_residue() to return
error codes
dmaengine: sh: rz-dmac: Add runtime PM support
dmaengine: sh: rz-dmac: Add suspend to RAM support
Geert Uytterhoeven (1):
dmaengine: sh: rz-dmac: Make channel irq local
John Madieu (1):
dmaengine: sh: rz-dmac: Use rz_lmdesc_setup() to invalidate
descriptors
Lad Prabhakar (1):
dmaengine: sh: rz-dmac: Avoid format-overflow warning
Tommaso Merciai (1):
dmaengine: sh: rz-dmac: Fix off-by-one in residue lmdesc lookup
Wolfram Sang (1):
dmaengine: sh: rz-dmac: handle configs where one address is zero
drivers/dma/sh/rz-dmac.c | 927 +++++++++++++++++++++++++++++++--------
1 file changed, 747 insertions(+), 180 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 01/27] dmaengine: sh: rz-dmac: Avoid format-overflow warning
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 02/27] dmaengine: sh: rz-dmac: handle configs where one address is zero Claudiu Beznea
` (26 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
commit c4d6dcb3b6250ea546a952ad33382daf7cd32425 upstream.
The max channel count for RZ DMAC is 16, hence use u8 instead of unsigned
int and make the pdev_irqname string long enough to avoid the warning.
This fixes the below issue:
drivers/dma/sh/rz-dmac.c: In function ‘rz_dmac_probe’:
drivers/dma/sh/rz-dmac.c:770:34: warning: ‘%u’ directive writing between 1 and 10 bytes into a region of size 3 [-Wformat-overflow=]
770 | sprintf(pdev_irqname, "ch%u", index);
| ^~
In function ‘rz_dmac_chan_probe’,
inlined from ‘rz_dmac_probe’ at drivers/dma/sh/rz-dmac.c:910:9:
drivers/dma/sh/rz-dmac.c:770:31: note: directive argument in the range [0, 4294967294]
770 | sprintf(pdev_irqname, "ch%u", index);
| ^~~~~~
drivers/dma/sh/rz-dmac.c:770:9: note: ‘sprintf’ output between 4 and 13 bytes into a destination of size 5
770 | sprintf(pdev_irqname, "ch%u", index);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While at it use scnprintf() instead of sprintf() to make the code
more robust.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240110222717.193719-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 71c37d5e3227..18b12cba3a34 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -760,11 +760,11 @@ static struct dma_chan *rz_dmac_of_xlate(struct of_phandle_args *dma_spec,
static int rz_dmac_chan_probe(struct rz_dmac *dmac,
struct rz_dmac_chan *channel,
- unsigned int index)
+ u8 index)
{
struct platform_device *pdev = to_platform_device(dmac->dev);
struct rz_lmdesc *lmdesc;
- char pdev_irqname[5];
+ char pdev_irqname[6];
char *irqname;
int ret;
@@ -772,7 +772,7 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
channel->mid_rid = -EINVAL;
/* Request the channel interrupt. */
- sprintf(pdev_irqname, "ch%u", index);
+ scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index);
channel->irq = platform_get_irq_byname(pdev, pdev_irqname);
if (channel->irq < 0)
return channel->irq;
@@ -850,9 +850,9 @@ static int rz_dmac_probe(struct platform_device *pdev)
struct dma_device *engine;
struct rz_dmac *dmac;
int channel_num;
- unsigned int i;
int ret;
int irq;
+ u8 i;
dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL);
if (!dmac)
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 02/27] dmaengine: sh: rz-dmac: handle configs where one address is zero
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 01/27] dmaengine: sh: rz-dmac: Avoid format-overflow warning Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 03/27] dmaengine: sh: rz-dmac: Make channel irq local Claudiu Beznea
` (25 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit 6e9c5c8ef2820d18492d07172ac52f23ea8a54d9 upstream.
Configs like the ones coming from the MMC subsystem will have either
'src' or 'dst' zeroed, resulting in an unknown bus width. This will bail
out on the RZ DMA driver because of the sanity check for a valid bus
width. Reorder the code, so that the check will only be applied when the
corresponding address is non-zero.
Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://lore.kernel.org/r/20241007110200.43166-6-wsa+renesas@sang-engineering.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 18b12cba3a34..6cf60c11a355 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -606,22 +606,25 @@ static int rz_dmac_config(struct dma_chan *chan,
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
u32 val;
- channel->src_per_address = config->src_addr;
channel->dst_per_address = config->dst_addr;
-
- val = rz_dmac_ds_to_val_mapping(config->dst_addr_width);
- if (val == CHCFG_DS_INVALID)
- return -EINVAL;
-
channel->chcfg &= ~CHCFG_FILL_DDS_MASK;
- channel->chcfg |= FIELD_PREP(CHCFG_FILL_DDS_MASK, val);
+ if (channel->dst_per_address) {
+ val = rz_dmac_ds_to_val_mapping(config->dst_addr_width);
+ if (val == CHCFG_DS_INVALID)
+ return -EINVAL;
- val = rz_dmac_ds_to_val_mapping(config->src_addr_width);
- if (val == CHCFG_DS_INVALID)
- return -EINVAL;
+ channel->chcfg |= FIELD_PREP(CHCFG_FILL_DDS_MASK, val);
+ }
+ channel->src_per_address = config->src_addr;
channel->chcfg &= ~CHCFG_FILL_SDS_MASK;
- channel->chcfg |= FIELD_PREP(CHCFG_FILL_SDS_MASK, val);
+ if (channel->src_per_address) {
+ val = rz_dmac_ds_to_val_mapping(config->src_addr_width);
+ if (val == CHCFG_DS_INVALID)
+ return -EINVAL;
+
+ channel->chcfg |= FIELD_PREP(CHCFG_FILL_SDS_MASK, val);
+ }
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 03/27] dmaengine: sh: rz-dmac: Make channel irq local
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 01/27] dmaengine: sh: rz-dmac: Avoid format-overflow warning Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 02/27] dmaengine: sh: rz-dmac: handle configs where one address is zero Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 04/27] dmaengine: sh: rz-dmac: Protect the driver specific lists Claudiu Beznea
` (24 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Geert Uytterhoeven <geert+renesas@glider.be>
commit e0c51fd02f9cfab341907f6764d2f15c134eea55 upstream.
The channel IRQ is only used inside the function rz_dmac_chan_probe(),
so there is no need to store it in the rz_dmac_chan structure for later
use.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://patch.msgid.link/312c2e3349f4747e0bca861632bfc3592224b012.1767718556.git.geert+renesas@glider.be
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 6cf60c11a355..3115ff2ab595 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -64,7 +64,6 @@ struct rz_dmac_chan {
void __iomem *ch_base;
void __iomem *ch_cmn_base;
unsigned int index;
- int irq;
struct rz_dmac_desc *desc;
int descs_allocated;
@@ -769,29 +768,27 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
struct rz_lmdesc *lmdesc;
char pdev_irqname[6];
char *irqname;
- int ret;
+ int irq, ret;
channel->index = index;
channel->mid_rid = -EINVAL;
/* Request the channel interrupt. */
scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index);
- channel->irq = platform_get_irq_byname(pdev, pdev_irqname);
- if (channel->irq < 0)
- return channel->irq;
+ irq = platform_get_irq_byname(pdev, pdev_irqname);
+ if (irq < 0)
+ return irq;
irqname = devm_kasprintf(dmac->dev, GFP_KERNEL, "%s:%u",
dev_name(dmac->dev), index);
if (!irqname)
return -ENOMEM;
- ret = devm_request_threaded_irq(dmac->dev, channel->irq,
- rz_dmac_irq_handler,
+ ret = devm_request_threaded_irq(dmac->dev, irq, rz_dmac_irq_handler,
rz_dmac_irq_handler_thread, 0,
irqname, channel);
if (ret) {
- dev_err(dmac->dev, "failed to request IRQ %u (%d)\n",
- channel->irq, ret);
+ dev_err(dmac->dev, "failed to request IRQ %u (%d)\n", irq, ret);
return ret;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 04/27] dmaengine: sh: rz-dmac: Protect the driver specific lists
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (2 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 03/27] dmaengine: sh: rz-dmac: Make channel irq local Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 05/27] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock Claudiu Beznea
` (23 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
commit abb863e6213dc41a58ef8bb3289b7e77460dabf3 upstream.
The driver lists (ld_free, ld_queue) are used in
rz_dmac_free_chan_resources(), rz_dmac_terminate_all(),
rz_dmac_issue_pending(), and rz_dmac_irq_handler_thread(), all under
the virtual channel lock. Take the same lock in rz_dmac_prep_slave_sg()
and rz_dmac_prep_dma_memcpy() as well to avoid concurrency issues, since
these functions also check whether the lists are empty and update or
remove list entries.
Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
Cc: stable@vger.kernel.org
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260316133252.240348-2-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: replaced scoped_guard() with
spin_lock_irqsave()/spin_unlock_irqrestore()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 3115ff2ab595..70410def8181 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -10,6 +10,7 @@
*/
#include <linux/bitfield.h>
+#include <linux/cleanup.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/interrupt.h>
@@ -423,6 +424,7 @@ static int rz_dmac_alloc_chan_resources(struct dma_chan *chan)
if (!desc)
break;
+ /* No need to lock. This is called only for the 1st client. */
list_add_tail(&desc->node, &channel->ld_free);
channel->descs_allocated++;
}
@@ -474,12 +476,17 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
struct rz_dmac *dmac = to_rz_dmac(chan->device);
struct rz_dmac_desc *desc;
+ unsigned long lock_flags;
dev_dbg(dmac->dev, "%s channel: %d src=0x%pad dst=0x%pad len=%zu\n",
__func__, channel->index, &src, &dest, len);
- if (list_empty(&channel->ld_free))
+ spin_lock_irqsave(&channel->vc.lock, lock_flags);
+
+ if (list_empty(&channel->ld_free)) {
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
return NULL;
+ }
desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
@@ -490,6 +497,9 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
desc->direction = DMA_MEM_TO_MEM;
list_move_tail(channel->ld_free.next, &channel->ld_queue);
+
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
+
return vchan_tx_prep(&channel->vc, &desc->vd, flags);
}
@@ -501,12 +511,17 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
struct rz_dmac_desc *desc;
+ unsigned long lock_flags;
struct scatterlist *sg;
int dma_length = 0;
int i = 0;
- if (list_empty(&channel->ld_free))
+ spin_lock_irqsave(&channel->vc.lock, lock_flags);
+
+ if (list_empty(&channel->ld_free)) {
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
return NULL;
+ }
desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
@@ -526,6 +541,9 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
desc->dest = channel->dst_per_address;
list_move_tail(channel->ld_free.next, &channel->ld_queue);
+
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
+
return vchan_tx_prep(&channel->vc, &desc->vd, flags);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 05/27] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (3 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 04/27] dmaengine: sh: rz-dmac: Protect the driver specific lists Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 06/27] dmaengine: sh: rz-dmac: Drop read of CHCTRL register Claudiu Beznea
` (22 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
commit 89a8567d84bde88cb7cdbbac2ab2299c4f991490 upstream.
Both rz_dmac_disable_hw() and rz_dmac_irq_handle_channel() update the
CHCTRL register. To avoid concurrency issues when configuring
functionalities exposed by this registers, take the virtual channel lock.
All other CHCTRL updates were already protected by the same lock.
Previously, rz_dmac_disable_hw() disabled and re-enabled local IRQs, before
accessing CHCTRL registers but this does not ensure race-free access.
Remove the local IRQ disable/enable code as well.
Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
Cc: stable@vger.kernel.org
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260316133252.240348-3-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: replaced scoped_guard() with
spin_lock_irqsave()/spin_unlock_irqrestore()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 70410def8181..8f2baf32d338 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -285,13 +285,10 @@ static void rz_dmac_disable_hw(struct rz_dmac_chan *channel)
{
struct dma_chan *chan = &channel->vc.chan;
struct rz_dmac *dmac = to_rz_dmac(chan->device);
- unsigned long flags;
dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index);
- local_irq_save(flags);
rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
- local_irq_restore(flags);
}
static void rz_dmac_set_dmars_register(struct rz_dmac *dmac, int nr, u32 dmars)
@@ -555,8 +552,8 @@ static int rz_dmac_terminate_all(struct dma_chan *chan)
unsigned int i;
LIST_HEAD(head);
- rz_dmac_disable_hw(channel);
spin_lock_irqsave(&channel->vc.lock, flags);
+ rz_dmac_disable_hw(channel);
for (i = 0; i < DMAC_NR_LMDESC; i++)
lmdesc[i].header = 0;
@@ -681,13 +678,17 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel)
{
struct dma_chan *chan = &channel->vc.chan;
struct rz_dmac *dmac = to_rz_dmac(chan->device);
+ unsigned long flags;
u32 chstat, chctrl;
chstat = rz_dmac_ch_readl(channel, CHSTAT, 1);
if (chstat & CHSTAT_ER) {
dev_err(dmac->dev, "DMAC err CHSTAT_%d = %08X\n",
channel->index, chstat);
+
+ spin_lock_irqsave(&channel->vc.lock, flags);
rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
goto done;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 06/27] dmaengine: sh: rz-dmac: Drop read of CHCTRL register
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (4 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 05/27] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 07/27] dmaengine: sh: rz-dmac: Drop goto instruction and label Claudiu Beznea
` (21 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
commit be342fb7f2bb5f641419fef3109eaffd469b0d44 upstream.
The CHCTRL register has 11 bits that can be updated by software. The
documentation for all these bits states the following:
- A read operation results in 0 being read
- Writing zero does not affect the operation
All bits in the CHCTRL register accessible by software are set and clear
bits.
The documentation for the CLREND bit of CHCTRL states:
Setting this bit to 1 can clear the END bit of the CHSTAT_n/nS register.
Also, the DMA transfer end interrupt is cleared. An attempt to read this
bit results in 0 being read.
1: Clears the END bit.
0: Does not affect the operation.
Since writing zero to any bit in this register does not affect controller
operation and reads always return zero, there is no need to perform
read-modify-write accesses to set the CLREND bit. Drop the read of the
CHCTRL register.
Also, since setting the CLREND bit does not interact with other
functionalities exposed through this register and only clears the END
interrupt, there is no need to lock around this operation. Add a comment
to document this.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260316133252.240348-4-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_irq_handle_channel()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 8f2baf32d338..e0f8c4f462a8 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -679,7 +679,7 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel)
struct dma_chan *chan = &channel->vc.chan;
struct rz_dmac *dmac = to_rz_dmac(chan->device);
unsigned long flags;
- u32 chstat, chctrl;
+ u32 chstat;
chstat = rz_dmac_ch_readl(channel, CHSTAT, 1);
if (chstat & CHSTAT_ER) {
@@ -692,8 +692,11 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel)
goto done;
}
- chctrl = rz_dmac_ch_readl(channel, CHCTRL, 1);
- rz_dmac_ch_writel(channel, chctrl | CHCTRL_CLREND, CHCTRL, 1);
+ /*
+ * No need to lock. This just clears the END interrupt. Writing
+ * zeros to CHCTRL is just ignored by HW.
+ */
+ rz_dmac_ch_writel(channel, CHCTRL_CLREND, CHCTRL, 1);
done:
return;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 07/27] dmaengine: sh: rz-dmac: Drop goto instruction and label
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (5 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 06/27] dmaengine: sh: rz-dmac: Drop read of CHCTRL register Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 08/27] dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call Claudiu Beznea
` (20 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
commit 7badd294fc82629378b153327c57b8ba453688c7 upstream.
There is no need to jump to the done label, so return immediately.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260316133252.240348-5-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_irq_handle_channel()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index e0f8c4f462a8..5086e1e19200 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -689,7 +689,7 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel)
spin_lock_irqsave(&channel->vc.lock, flags);
rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
spin_unlock_irqrestore(&channel->vc.lock, flags);
- goto done;
+ return;
}
/*
@@ -697,8 +697,6 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel)
* zeros to CHCTRL is just ignored by HW.
*/
rz_dmac_ch_writel(channel, CHCTRL_CLREND, CHCTRL, 1);
-done:
- return;
}
static irqreturn_t rz_dmac_irq_handler(int irq, void *dev_id)
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 08/27] dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (6 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 07/27] dmaengine: sh: rz-dmac: Drop goto instruction and label Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 09/27] dmaengine: sh: rz-dmac: Use rz_lmdesc_setup() to invalidate descriptors Claudiu Beznea
` (19 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
commit be25945d0ca3ac736c448b530c47e854c82a0343 upstream.
rz_dmac_enable_hw() calls local_irq_save()/local_irq_restore(), but
this is not needed because the callers of rz_dmac_enable_hw() already
protect the critical section using
spin_lock_irqsave()/spin_lock_irqrestore().
Remove the local_irq_save()/local_irq_restore() calls.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260316133252.240348-6-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 5086e1e19200..a16828509ba5 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -254,15 +254,12 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
{
struct dma_chan *chan = &channel->vc.chan;
struct rz_dmac *dmac = to_rz_dmac(chan->device);
- unsigned long flags;
u32 nxla;
u32 chctrl;
u32 chstat;
dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index);
- local_irq_save(flags);
-
rz_dmac_lmdesc_recycle(channel);
nxla = channel->lmdesc.base_dma +
@@ -277,8 +274,6 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
rz_dmac_ch_writel(channel, CHCTRL_SWRST, CHCTRL, 1);
rz_dmac_ch_writel(channel, chctrl, CHCTRL, 1);
}
-
- local_irq_restore(flags);
}
static void rz_dmac_disable_hw(struct rz_dmac_chan *channel)
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 09/27] dmaengine: sh: rz-dmac: Use rz_lmdesc_setup() to invalidate descriptors
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (7 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 08/27] dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 10/27] dmaengine: sh: rz-dmac: Add device_tx_status() callback Claudiu Beznea
` (18 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: John Madieu <john.madieu.xa@bp.renesas.com>
commit bfaa60be647842cece968769f208e57fa5dee594 upstream.
rz_lmdesc_setup() invalidates DMA descriptors more comprehensively.
It resets the base, head, and tail pointers of the descriptor list and
clears the descriptor headers and their NXLA pointers. Use
rz_lmdesc_setup() instead of open-coding parts of its logic.
Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260316133252.240348-7-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index a16828509ba5..585c6c597de0 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -431,15 +431,12 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
struct rz_dmac *dmac = to_rz_dmac(chan->device);
- struct rz_lmdesc *lmdesc = channel->lmdesc.base;
struct rz_dmac_desc *desc, *_desc;
unsigned long flags;
- unsigned int i;
spin_lock_irqsave(&channel->vc.lock, flags);
- for (i = 0; i < DMAC_NR_LMDESC; i++)
- lmdesc[i].header = 0;
+ rz_lmdesc_setup(channel, channel->lmdesc.base);
rz_dmac_disable_hw(channel);
list_splice_tail_init(&channel->ld_active, &channel->ld_free);
@@ -542,15 +539,12 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
static int rz_dmac_terminate_all(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
- struct rz_lmdesc *lmdesc = channel->lmdesc.base;
unsigned long flags;
- unsigned int i;
LIST_HEAD(head);
spin_lock_irqsave(&channel->vc.lock, flags);
rz_dmac_disable_hw(channel);
- for (i = 0; i < DMAC_NR_LMDESC; i++)
- lmdesc[i].header = 0;
+ rz_lmdesc_setup(channel, channel->lmdesc.base);
list_splice_tail_init(&channel->ld_active, &channel->ld_free);
list_splice_tail_init(&channel->ld_queue, &channel->ld_free);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 10/27] dmaengine: sh: rz-dmac: Add device_tx_status() callback
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (8 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 09/27] dmaengine: sh: rz-dmac: Use rz_lmdesc_setup() to invalidate descriptors Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 11/27] dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks Claudiu Beznea
` (17 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 21323b118c16d287355e6497e1098ce1ca348bd6 upstream.
The RZ/G2L SCIFA driver uses dmaengine_prep_slave_sg() to enqueue DMA
transfers and implements a timeout mechanism on RX to handle cases where
a DMA transfer does not complete. The timeout is implemented using an
hrtimer.
In the hrtimer callback, dmaengine_tx_status() is called (along with
dmaengine_pause()) to retrieve the transfer residue and handle incomplete
DMA transfers.
Add support for the device_tx_status() callback.
Co-developed-by: Long Luu <long.luu.ur@renesas.com>
Signed-off-by: Long Luu <long.luu.ur@renesas.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Co-developed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260316133252.240348-8-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: replaced scoped_guard() with
spin_lock_irqsave()/spin_unlock_irqrestore()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 146 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 145 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 585c6c597de0..ed9fb1c6aeb3 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -109,10 +109,12 @@ struct rz_dmac {
* Registers
*/
+#define CRTB 0x0020
#define CHSTAT 0x0024
#define CHCTRL 0x0028
#define CHCFG 0x002c
#define NXLA 0x0038
+#define CRLA 0x003c
#define DCTRL 0x0000
@@ -658,6 +660,147 @@ static void rz_dmac_device_synchronize(struct dma_chan *chan)
rz_dmac_set_dmars_register(dmac, channel->index, 0);
}
+static struct rz_lmdesc *
+rz_dmac_get_next_lmdesc(struct rz_lmdesc *base, struct rz_lmdesc *lmdesc)
+{
+ struct rz_lmdesc *next = ++lmdesc;
+
+ if (next >= base + DMAC_NR_LMDESC)
+ next = base;
+
+ return next;
+}
+
+static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel, u32 crla)
+{
+ struct rz_lmdesc *lmdesc = channel->lmdesc.head;
+ struct dma_chan *chan = &channel->vc.chan;
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
+ u32 residue = 0, i = 0;
+
+ while (lmdesc->nxla != crla) {
+ lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ if (++i >= DMAC_NR_LMDESC)
+ return 0;
+ }
+
+ /* Calculate residue from next lmdesc to end of virtual desc */
+ while (lmdesc->chcfg & CHCFG_DEM) {
+ residue += lmdesc->tb;
+ lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ }
+
+ dev_dbg(dmac->dev, "%s: VD residue is %u\n", __func__, residue);
+
+ return residue;
+}
+
+static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
+ dma_cookie_t cookie)
+{
+ struct rz_dmac_desc *current_desc, *desc;
+ enum dma_status status;
+ u32 crla, crtb, i;
+
+ /* Get current processing virtual descriptor */
+ current_desc = list_first_entry(&channel->ld_active,
+ struct rz_dmac_desc, node);
+ if (!current_desc)
+ return 0;
+
+ /*
+ * If the cookie corresponds to a descriptor that has been completed
+ * there is no residue. The same check has already been performed by the
+ * caller but without holding the channel lock, so the descriptor could
+ * now be complete.
+ */
+ status = dma_cookie_status(&channel->vc.chan, cookie, NULL);
+ if (status == DMA_COMPLETE)
+ return 0;
+
+ /*
+ * If the cookie doesn't correspond to the currently processing virtual
+ * descriptor then the descriptor hasn't been processed yet, and the
+ * residue is equal to the full descriptor size. Also, a client driver
+ * is possible to call this function before rz_dmac_irq_handler_thread()
+ * runs. In this case, the running descriptor will be the next
+ * descriptor, and will appear in the done list. So, if the argument
+ * cookie matches the done list's cookie, we can assume the residue is
+ * zero.
+ */
+ if (cookie != current_desc->vd.tx.cookie) {
+ list_for_each_entry(desc, &channel->ld_free, node) {
+ if (cookie == desc->vd.tx.cookie)
+ return 0;
+ }
+
+ list_for_each_entry(desc, &channel->ld_queue, node) {
+ if (cookie == desc->vd.tx.cookie)
+ return desc->len;
+ }
+
+ list_for_each_entry(desc, &channel->ld_active, node) {
+ if (cookie == desc->vd.tx.cookie)
+ return desc->len;
+ }
+
+ /*
+ * No descriptor found for the cookie, there's thus no residue.
+ * This shouldn't happen if the calling driver passes a correct
+ * cookie value.
+ */
+ WARN(1, "No descriptor for cookie!");
+ return 0;
+ }
+
+ /*
+ * We need to read two registers. Make sure the hardware does not move
+ * to next lmdesc while reading the current lmdesc. Trying it 3 times
+ * should be enough: initial read, retry, retry for the paranoid.
+ */
+ for (i = 0; i < 3; i++) {
+ crla = rz_dmac_ch_readl(channel, CRLA, 1);
+ crtb = rz_dmac_ch_readl(channel, CRTB, 1);
+ /* Still the same? */
+ if (crla == rz_dmac_ch_readl(channel, CRLA, 1))
+ break;
+ }
+
+ WARN_ONCE(i >= 3, "residue might not be continuous!");
+
+ /*
+ * Calculate number of bytes transferred in processing virtual descriptor.
+ * One virtual descriptor can have many lmdesc.
+ */
+ return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, crla);
+}
+
+static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
+ dma_cookie_t cookie,
+ struct dma_tx_state *txstate)
+{
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ enum dma_status status;
+ unsigned long flags;
+ u32 residue;
+
+ status = dma_cookie_status(chan, cookie, txstate);
+ if (status == DMA_COMPLETE || !txstate)
+ return status;
+
+ spin_lock_irqsave(&channel->vc.lock, flags);
+ residue = rz_dmac_chan_get_residue(channel, cookie);
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
+
+ /* if there's no residue, the cookie is complete */
+ if (!residue)
+ return DMA_COMPLETE;
+
+ dma_set_residue(txstate, residue);
+
+ return status;
+}
+
/*
* -----------------------------------------------------------------------------
* IRQ handling
@@ -936,6 +1079,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
engine = &dmac->engine;
dma_cap_set(DMA_SLAVE, engine->cap_mask);
dma_cap_set(DMA_MEMCPY, engine->cap_mask);
+ engine->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_0_7_COMMON_BASE + DCTRL);
rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_8_15_COMMON_BASE + DCTRL);
@@ -943,7 +1087,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
engine->device_alloc_chan_resources = rz_dmac_alloc_chan_resources;
engine->device_free_chan_resources = rz_dmac_free_chan_resources;
- engine->device_tx_status = dma_cookie_status;
+ engine->device_tx_status = rz_dmac_tx_status;
engine->device_prep_slave_sg = rz_dmac_prep_slave_sg;
engine->device_prep_dma_memcpy = rz_dmac_prep_dma_memcpy;
engine->device_config = rz_dmac_config;
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 11/27] dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (9 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 10/27] dmaengine: sh: rz-dmac: Add device_tx_status() callback Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 12/27] dmaengine: sh: rz-dmac: Move interrupt request after everything is set up Claudiu Beznea
` (16 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
commit 44f991bd6e01bb6a3f78da98eafa6d2a72819a2f upstream.
The RZ/G2L SCIFA driver uses dmaengine_prep_slave_sg() to enqueue DMA
transfers and implements a timeout mechanism on RX to handle cases where
a DMA transfer does not complete. The timeout is implemented using an
hrtimer.
In the hrtimer callback, dmaengine_tx_status() is called (along with
dmaengine_pause()) to retrieve the transfer residue and handle incomplete
DMA transfers.
Add support for device_{pause, resume}() callbacks.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20260316133252.240348-9-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_tx_status() as a result of
switch to spin_lock_irqsave()/spin_unlock_irqrestore()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 46 +++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index ed9fb1c6aeb3..79d1ba71eb18 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -125,10 +125,12 @@ struct rz_dmac {
#define CHANNEL_8_15_COMMON_BASE 0x0700
#define CHSTAT_ER BIT(4)
+#define CHSTAT_SUS BIT(3)
#define CHSTAT_EN BIT(0)
#define CHCTRL_CLRINTMSK BIT(17)
#define CHCTRL_CLRSUS BIT(9)
+#define CHCTRL_SETSUS BIT(8)
#define CHCTRL_CLRTC BIT(6)
#define CHCTRL_CLREND BIT(5)
#define CHCTRL_CLRRQ BIT(4)
@@ -782,7 +784,7 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
enum dma_status status;
unsigned long flags;
- u32 residue;
+ u32 residue, val;
status = dma_cookie_status(chan, cookie, txstate);
if (status == DMA_COMPLETE || !txstate)
@@ -790,10 +792,14 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
spin_lock_irqsave(&channel->vc.lock, flags);
residue = rz_dmac_chan_get_residue(channel, cookie);
+
+ val = rz_dmac_ch_readl(channel, CHSTAT, 1);
+ if (val & CHSTAT_SUS)
+ status = DMA_PAUSED;
spin_unlock_irqrestore(&channel->vc.lock, flags);
- /* if there's no residue, the cookie is complete */
- if (!residue)
+ /* if there's no residue and no paused, the cookie is complete */
+ if (!residue && status != DMA_PAUSED)
return DMA_COMPLETE;
dma_set_residue(txstate, residue);
@@ -801,6 +807,38 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
return status;
}
+static int rz_dmac_device_pause(struct dma_chan *chan)
+{
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ u32 val;
+
+ guard(spinlock_irqsave)(&channel->vc.lock);
+
+ val = rz_dmac_ch_readl(channel, CHSTAT, 1);
+ if (!(val & CHSTAT_EN))
+ return 0;
+
+ rz_dmac_ch_writel(channel, CHCTRL_SETSUS, CHCTRL, 1);
+ return read_poll_timeout_atomic(rz_dmac_ch_readl, val,
+ (val & CHSTAT_SUS), 1, 1024,
+ false, channel, CHSTAT, 1);
+}
+
+static int rz_dmac_device_resume(struct dma_chan *chan)
+{
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ u32 val;
+
+ guard(spinlock_irqsave)(&channel->vc.lock);
+
+ /* Do not check CHSTAT_SUS but rely on HW capabilities. */
+
+ rz_dmac_ch_writel(channel, CHCTRL_CLRSUS, CHCTRL, 1);
+ return read_poll_timeout_atomic(rz_dmac_ch_readl, val,
+ !(val & CHSTAT_SUS), 1, 1024,
+ false, channel, CHSTAT, 1);
+}
+
/*
* -----------------------------------------------------------------------------
* IRQ handling
@@ -1094,6 +1132,8 @@ static int rz_dmac_probe(struct platform_device *pdev)
engine->device_terminate_all = rz_dmac_terminate_all;
engine->device_issue_pending = rz_dmac_issue_pending;
engine->device_synchronize = rz_dmac_device_synchronize;
+ engine->device_pause = rz_dmac_device_pause;
+ engine->device_resume = rz_dmac_device_resume;
engine->copy_align = DMAENGINE_ALIGN_1_BYTE;
dma_set_max_seg_size(engine->dev, U32_MAX);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 12/27] dmaengine: sh: rz-dmac: Move interrupt request after everything is set up
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (10 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 11/27] dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 13/27] dmaengine: sh: rz-dmac: Fix incorrect NULL check for list_first_entry() Claudiu Beznea
` (15 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 731712403ddb39d1a76a11abf339a0615bc85de7 upstream.
Once the interrupt is requested, the interrupt handler may run immediately.
Since the IRQ handler can access channel->ch_base, which is initialized
only after requesting the IRQ, this may lead to invalid memory access.
Likewise, the IRQ thread may access uninitialized data (the ld_free,
ld_queue, and ld_active lists), which may also lead to issues.
Request the interrupts only after everything is set up. To keep the error
path simpler, use dmam_alloc_coherent() instead of dma_alloc_coherent().
Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
Cc: stable@vger.kernel.org
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-2-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_probe() by moving the code in
charge or requesting the error IRQ after rz_dmac_chan_probe()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 92 ++++++++++++++++------------------------
1 file changed, 36 insertions(+), 56 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 79d1ba71eb18..61300845968f 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -963,25 +963,6 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
channel->index = index;
channel->mid_rid = -EINVAL;
- /* Request the channel interrupt. */
- scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index);
- irq = platform_get_irq_byname(pdev, pdev_irqname);
- if (irq < 0)
- return irq;
-
- irqname = devm_kasprintf(dmac->dev, GFP_KERNEL, "%s:%u",
- dev_name(dmac->dev), index);
- if (!irqname)
- return -ENOMEM;
-
- ret = devm_request_threaded_irq(dmac->dev, irq, rz_dmac_irq_handler,
- rz_dmac_irq_handler_thread, 0,
- irqname, channel);
- if (ret) {
- dev_err(dmac->dev, "failed to request IRQ %u (%d)\n", irq, ret);
- return ret;
- }
-
/* Set io base address for each channel */
if (index < 8) {
channel->ch_base = dmac->base + CHANNEL_0_7_OFFSET +
@@ -994,9 +975,9 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
}
/* Allocate descriptors */
- lmdesc = dma_alloc_coherent(&pdev->dev,
- sizeof(struct rz_lmdesc) * DMAC_NR_LMDESC,
- &channel->lmdesc.base_dma, GFP_KERNEL);
+ lmdesc = dmam_alloc_coherent(&pdev->dev,
+ sizeof(struct rz_lmdesc) * DMAC_NR_LMDESC,
+ &channel->lmdesc.base_dma, GFP_KERNEL);
if (!lmdesc) {
dev_err(&pdev->dev, "Can't allocate memory (lmdesc)\n");
return -ENOMEM;
@@ -1012,7 +993,24 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
INIT_LIST_HEAD(&channel->ld_free);
INIT_LIST_HEAD(&channel->ld_active);
- return 0;
+ /* Request the channel interrupt. */
+ scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index);
+ irq = platform_get_irq_byname(pdev, pdev_irqname);
+ if (irq < 0)
+ return irq;
+
+ irqname = devm_kasprintf(dmac->dev, GFP_KERNEL, "%s:%u",
+ dev_name(dmac->dev), index);
+ if (!irqname)
+ return -ENOMEM;
+
+ ret = devm_request_threaded_irq(dmac->dev, irq, rz_dmac_irq_handler,
+ rz_dmac_irq_handler_thread, 0,
+ irqname, channel);
+ if (ret)
+ dev_err(dmac->dev, "failed to request IRQ %u (%d)\n", irq, ret);
+
+ return ret;
}
static int rz_dmac_parse_of(struct device *dev, struct rz_dmac *dmac)
@@ -1039,7 +1037,6 @@ static int rz_dmac_probe(struct platform_device *pdev)
const char *irqname = "error";
struct dma_device *engine;
struct rz_dmac *dmac;
- int channel_num;
int ret;
int irq;
u8 i;
@@ -1069,19 +1066,6 @@ static int rz_dmac_probe(struct platform_device *pdev)
if (IS_ERR(dmac->ext_base))
return PTR_ERR(dmac->ext_base);
- /* Register interrupt handler for error */
- irq = platform_get_irq_byname(pdev, irqname);
- if (irq < 0)
- return irq;
-
- ret = devm_request_irq(&pdev->dev, irq, rz_dmac_irq_handler, 0,
- irqname, NULL);
- if (ret) {
- dev_err(&pdev->dev, "failed to request IRQ %u (%d)\n",
- irq, ret);
- return ret;
- }
-
/* Initialize the channels. */
INIT_LIST_HEAD(&dmac->engine.channels);
@@ -1107,6 +1091,21 @@ static int rz_dmac_probe(struct platform_device *pdev)
goto err;
}
+ /* Register interrupt handler for error */
+ irq = platform_get_irq_byname(pdev, irqname);
+ if (irq < 0) {
+ ret = irq;
+ goto err;
+ }
+
+ ret = devm_request_irq(&pdev->dev, irq, rz_dmac_irq_handler, 0,
+ irqname, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to request IRQ %u (%d)\n",
+ irq, ret);
+ goto err;
+ }
+
/* Register the DMAC as a DMA provider for DT. */
ret = of_dma_controller_register(pdev->dev.of_node, rz_dmac_of_xlate,
NULL);
@@ -1148,16 +1147,6 @@ static int rz_dmac_probe(struct platform_device *pdev)
dma_register_err:
of_dma_controller_free(pdev->dev.of_node);
err:
- channel_num = i ? i - 1 : 0;
- for (i = 0; i < channel_num; i++) {
- struct rz_dmac_chan *channel = &dmac->channels[i];
-
- dma_free_coherent(&pdev->dev,
- sizeof(struct rz_lmdesc) * DMAC_NR_LMDESC,
- channel->lmdesc.base,
- channel->lmdesc.base_dma);
- }
-
reset_control_assert(dmac->rstc);
err_pm_runtime_put:
pm_runtime_put(&pdev->dev);
@@ -1170,18 +1159,9 @@ static int rz_dmac_probe(struct platform_device *pdev)
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];
-
- dma_free_coherent(&pdev->dev,
- sizeof(struct rz_lmdesc) * DMAC_NR_LMDESC,
- channel->lmdesc.base,
- channel->lmdesc.base_dma);
- }
reset_control_assert(dmac->rstc);
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 13/27] dmaengine: sh: rz-dmac: Fix incorrect NULL check for list_first_entry()
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (11 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 12/27] dmaengine: sh: rz-dmac: Move interrupt request after everything is set up Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 14/27] dmaengine: sh: rz-dmac: Use list_first_entry_or_null() Claudiu Beznea
` (14 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 5fbf3a2a3b96ef5810e6e0fbc601f82067629bc5 upstream.
list_first_entry() does not return NULL when the list is empty,
making the existing NULL check invalid. Use list_first_entry_or_null()
instead.
Fixes: 21323b118c16 ("dmaengine: sh: rz-dmac: Add device_tx_status() callback")
Cc: stable@vger.kernel.org
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-3-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 61300845968f..83499f481821 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -705,8 +705,8 @@ static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
u32 crla, crtb, i;
/* Get current processing virtual descriptor */
- current_desc = list_first_entry(&channel->ld_active,
- struct rz_dmac_desc, node);
+ current_desc = list_first_entry_or_null(&channel->ld_active,
+ struct rz_dmac_desc, node);
if (!current_desc)
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 14/27] dmaengine: sh: rz-dmac: Use list_first_entry_or_null()
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (12 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 13/27] dmaengine: sh: rz-dmac: Fix incorrect NULL check for list_first_entry() Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 15/27] dmaengine: sh: rz-dmac: Use rz_dmac_disable_hw() Claudiu Beznea
` (13 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 89975baaa9ea2490b75d69842561a32ca888b7e5 upstream.
Use list_first_entry_or_null() instead of open-coding it with a
list_empty() check and list_first_entry(). This simplifies the code.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-4-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict as a result of previous commits dropping
scoped_guard()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 83499f481821..3fb00da4407f 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -476,13 +476,12 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
spin_lock_irqsave(&channel->vc.lock, lock_flags);
- if (list_empty(&channel->ld_free)) {
+ desc = list_first_entry_or_null(&channel->ld_free, struct rz_dmac_desc, node);
+ if (!desc) {
spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
return NULL;
}
- desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
-
desc->type = RZ_DMAC_DESC_MEMCPY;
desc->src = src;
desc->dest = dest;
@@ -511,7 +510,8 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
spin_lock_irqsave(&channel->vc.lock, lock_flags);
- if (list_empty(&channel->ld_free)) {
+ desc = list_first_entry_or_null(&channel->ld_free, struct rz_dmac_desc, node);
+ if (!desc) {
spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
return NULL;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 15/27] dmaengine: sh: rz-dmac: Use rz_dmac_disable_hw()
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (13 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 14/27] dmaengine: sh: rz-dmac: Use list_first_entry_or_null() Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 16/27] dmaengine: sh: rz-dmac: Add helper to compute the lmdesc address Claudiu Beznea
` (12 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 38d4d021228386b8e3fbef2bca5f1e91eacd4fe6 upstream.
Use rz_dmac_disable_hw() instead of open coding it. This unifies the
code and prepares it for the addition of suspend to RAM and cyclic DMA.
The rz_dmac_disable_hw() from rz_dmac_chan_probe() was moved after
vchan_init() as it initializes the channel->vc.chan.device used in
rz_dmac_disable_hw().
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-5-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_irq_handle_channel()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 3fb00da4407f..f44a1e66120f 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -857,7 +857,7 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_chan *channel)
channel->index, chstat);
spin_lock_irqsave(&channel->vc.lock, flags);
- rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
+ rz_dmac_disable_hw(channel);
spin_unlock_irqrestore(&channel->vc.lock, flags);
return;
}
@@ -984,15 +984,15 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
}
rz_lmdesc_setup(channel, lmdesc);
- /* Initialize register for each channel */
- rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1);
-
channel->vc.desc_free = rz_dmac_virt_desc_free;
vchan_init(&channel->vc, &dmac->engine);
INIT_LIST_HEAD(&channel->ld_queue);
INIT_LIST_HEAD(&channel->ld_free);
INIT_LIST_HEAD(&channel->ld_active);
+ /* Initialize register for each channel */
+ rz_dmac_disable_hw(channel);
+
/* Request the channel interrupt. */
scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index);
irq = platform_get_irq_byname(pdev, pdev_irqname);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 16/27] dmaengine: sh: rz-dmac: Add helper to compute the lmdesc address
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (14 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 15/27] dmaengine: sh: rz-dmac: Use rz_dmac_disable_hw() Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 17/27] dmaengine: sh: rz-dmac: Save the start LM descriptor Claudiu Beznea
` (11 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 32a69f1487819766d2084ed32b1350b18f971c10 upstream.
Add a the rz_dmac_lmdesc_addr() helper function to compute the lmdesc
address, to make the code easier to understand. The helper will be used in
subsequent patches.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-6-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index f44a1e66120f..02bd4ddf4765 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -241,6 +241,12 @@ static void rz_lmdesc_setup(struct rz_dmac_chan *channel,
* Descriptors preparation
*/
+static u32 rz_dmac_lmdesc_addr(struct rz_dmac_chan *channel, struct rz_lmdesc *lmdesc)
+{
+ return channel->lmdesc.base_dma +
+ (sizeof(struct rz_lmdesc) * (lmdesc - channel->lmdesc.base));
+}
+
static void rz_dmac_lmdesc_recycle(struct rz_dmac_chan *channel)
{
struct rz_lmdesc *lmdesc = channel->lmdesc.head;
@@ -266,9 +272,7 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
rz_dmac_lmdesc_recycle(channel);
- nxla = channel->lmdesc.base_dma +
- (sizeof(struct rz_lmdesc) * (channel->lmdesc.head -
- channel->lmdesc.base));
+ nxla = rz_dmac_lmdesc_addr(channel, channel->lmdesc.head);
chstat = rz_dmac_ch_readl(channel, CHSTAT, 1);
if (!(chstat & CHSTAT_EN)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 17/27] dmaengine: sh: rz-dmac: Save the start LM descriptor
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (15 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 16/27] dmaengine: sh: rz-dmac: Add helper to compute the lmdesc address Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 18/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is enabled Claudiu Beznea
` (10 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit e21aa306e82067457f2297ae56af4c91db86c59a upstream.
Save the start LM descriptor to avoid starting from the beginning of the
channel's LM descriptor list in rz_dmac_calculate_residue_bytes_in_vd().
This avoids unnecessary iterations.
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-7-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 02bd4ddf4765..50c46917d4e1 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -56,6 +56,7 @@ struct rz_dmac_desc {
/* For slave sg */
struct scatterlist *sg;
unsigned int sgcount;
+ struct rz_lmdesc *start_lmdesc;
};
#define to_rz_dmac_desc(d) container_of(d, struct rz_dmac_desc, vd)
@@ -315,6 +316,8 @@ static void rz_dmac_prepare_desc_for_memcpy(struct rz_dmac_chan *channel)
struct rz_dmac_desc *d = channel->desc;
u32 chcfg = CHCFG_MEM_COPY;
+ d->start_lmdesc = lmdesc;
+
/* prepare descriptor */
lmdesc->sa = d->src;
lmdesc->da = d->dest;
@@ -349,6 +352,7 @@ static void rz_dmac_prepare_descs_for_slave_sg(struct rz_dmac_chan *channel)
}
lmdesc = channel->lmdesc.tail;
+ d->start_lmdesc = lmdesc;
for (i = 0, sg = sgl; i < sg_len; i++, sg = sg_next(sg)) {
if (d->direction == DMA_DEV_TO_MEM) {
@@ -677,9 +681,10 @@ rz_dmac_get_next_lmdesc(struct rz_lmdesc *base, struct rz_lmdesc *lmdesc)
return next;
}
-static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel, u32 crla)
+static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel,
+ struct rz_dmac_desc *desc, u32 crla)
{
- struct rz_lmdesc *lmdesc = channel->lmdesc.head;
+ struct rz_lmdesc *lmdesc = desc->start_lmdesc;
struct dma_chan *chan = &channel->vc.chan;
struct rz_dmac *dmac = to_rz_dmac(chan->device);
u32 residue = 0, i = 0;
@@ -778,7 +783,7 @@ static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
* Calculate number of bytes transferred in processing virtual descriptor.
* One virtual descriptor can have many lmdesc.
*/
- return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, crla);
+ return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, current_desc, crla);
}
static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 18/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is enabled
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (16 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 17/27] dmaengine: sh: rz-dmac: Save the start LM descriptor Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 19/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is paused Claudiu Beznea
` (9 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 7a94c109a5def4f0f25705a82ed5870f794ff4ed upstream.
Add the rz_dmac_chan_is_enabled() helper to check if a channel is
enabled. This helper will be reused in subsequent patches.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-8-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 50c46917d4e1..5f7d53e43194 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -261,6 +261,13 @@ static void rz_dmac_lmdesc_recycle(struct rz_dmac_chan *channel)
channel->lmdesc.head = lmdesc;
}
+static bool rz_dmac_chan_is_enabled(struct rz_dmac_chan *channel)
+{
+ u32 val = rz_dmac_ch_readl(channel, CHSTAT, 1);
+
+ return !!(val & CHSTAT_EN);
+}
+
static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
{
struct dma_chan *chan = &channel->vc.chan;
@@ -823,8 +830,7 @@ static int rz_dmac_device_pause(struct dma_chan *chan)
guard(spinlock_irqsave)(&channel->vc.lock);
- val = rz_dmac_ch_readl(channel, CHSTAT, 1);
- if (!(val & CHSTAT_EN))
+ if (!rz_dmac_chan_is_enabled(channel))
return 0;
rz_dmac_ch_writel(channel, CHCTRL_SETSUS, CHCTRL, 1);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 19/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is paused
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (17 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 18/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is enabled Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 20/27] dmaengine: sh: rz-dmac: Use virt-dma APIs for channel descriptor processing Claudiu Beznea
` (8 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 1dddc864dfa844efaf36345eb58b121b2cdffa5f upstream.
Add the rz_dmac_chan_is_paused() helper to check if the channel is paused.
This helper will be reused in subsequent patches.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-9-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 5f7d53e43194..58c44f9d19ce 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -268,6 +268,13 @@ static bool rz_dmac_chan_is_enabled(struct rz_dmac_chan *channel)
return !!(val & CHSTAT_EN);
}
+static bool rz_dmac_chan_is_paused(struct rz_dmac_chan *channel)
+{
+ u32 val = rz_dmac_ch_readl(channel, CHSTAT, 1);
+
+ return !!(val & CHSTAT_SUS);
+}
+
static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
{
struct dma_chan *chan = &channel->vc.chan;
@@ -800,7 +807,7 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
enum dma_status status;
unsigned long flags;
- u32 residue, val;
+ u32 residue;
status = dma_cookie_status(chan, cookie, txstate);
if (status == DMA_COMPLETE || !txstate)
@@ -809,8 +816,7 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
spin_lock_irqsave(&channel->vc.lock, flags);
residue = rz_dmac_chan_get_residue(channel, cookie);
- val = rz_dmac_ch_readl(channel, CHSTAT, 1);
- if (val & CHSTAT_SUS)
+ if (rz_dmac_chan_is_paused(channel))
status = DMA_PAUSED;
spin_unlock_irqrestore(&channel->vc.lock, flags);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 20/27] dmaengine: sh: rz-dmac: Use virt-dma APIs for channel descriptor processing
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (18 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 19/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is paused Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 21/27] dmaengine: sh: rz-dmac: Refactor pause/resume code Claudiu Beznea
` (7 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit daa6d4617bee722e83f7d8584416e83b709c958a upstream.
The driver used a mix of virt-dma APIs and driver specific logic to
process descriptors. It maintained three internal queues: ld_free,
ld_queue, and ld_active as follows:
- ld_free: stores the descriptors pre-allocated at probe time
- ld_queue: stores descriptors after they are taken from ld_free and
prepared. At the same time, vchan_tx_prep() queues them to
vc->desc_allocated. The vc->desc_allocated list is then checked in
rz_dmac_issue_pending() and rz_dmac_irq_handler_thread() before
starting a new transfer via rz_dmac_xfer_desc(). In turn,
rz_dmac_xfer_desc() grabs the next descriptor from vc->desc_issued and
submits it for transfer
- ld_active: stores the descriptors currently being transferred
The interrupt handler moved a completed descriptor to ld_free before
invoking its completion callback. Once returned to ld_free, the
descriptor can be reused to prepare a new transfer. In theory, this
means the descriptor could be re-prepared before its completion
callback is called.
Commit fully back the driver by the virt-dma APIs. With this, only ld_free
need to be kept to track how many free descriptors are available. This
is now done as follows:
- the prepare stage removes the first descriptor from the ld_free and
prepares it
- the completion calls for it vc->desc_free() (rz_dmac_virt_desc_free())
which re-adds the descriptor at the end of ld_free
With this, the critical areas in prepare callbacks were minimized to only
getting the descriptor from the ld_free list.
Introduce struct rz_dmac_chan::desc to keep track of the currently
transferred descriptor. It is cleared in rz_dmac_terminate_all(),
referenced from rz_dmac_issue_pending() to determine whether a new transfer
can be started, and from rz_dmac_irq_handler_thread() once a descriptor has
completed. Finally, the rz_dmac_device_synchronize() was updated with
vchan_synchronize() call to ensure the terminated descriptor is freed and
the tasklet is killed.
With this, residue computation is also simplified, as it can now be
handled entirely through the virt-dma APIs.
The spin_lock/unlock operations from rz_dmac_irq_handler_thread() were
replaced by guard as the final code after rework is simpler this way.
As subsequent commits will set the Link End bit on the last descriptor
of a transfer, rz_dmac_enable_hw() is also adjusted as part of the full
conversion to virt-dma APIs. It no longer checks the channel enable
status itself; instead, its callers verify whether the channel is
enabled and whether the previous transfer has completed before starting
a new one.
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-10-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 207 ++++++++++++++-------------------------
1 file changed, 73 insertions(+), 134 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 58c44f9d19ce..f31dd1f80a10 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -77,8 +77,6 @@ struct rz_dmac_chan {
int mid_rid;
struct list_head ld_free;
- struct list_head ld_queue;
- struct list_head ld_active;
struct {
struct rz_lmdesc *base;
@@ -281,7 +279,6 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
struct rz_dmac *dmac = to_rz_dmac(chan->device);
u32 nxla;
u32 chctrl;
- u32 chstat;
dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index);
@@ -289,14 +286,11 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *channel)
nxla = rz_dmac_lmdesc_addr(channel, channel->lmdesc.head);
- chstat = rz_dmac_ch_readl(channel, CHSTAT, 1);
- if (!(chstat & CHSTAT_EN)) {
- chctrl = (channel->chctrl | CHCTRL_SETEN);
- rz_dmac_ch_writel(channel, nxla, NXLA, 1);
- rz_dmac_ch_writel(channel, channel->chcfg, CHCFG, 1);
- rz_dmac_ch_writel(channel, CHCTRL_SWRST, CHCTRL, 1);
- rz_dmac_ch_writel(channel, chctrl, CHCTRL, 1);
- }
+ chctrl = (channel->chctrl | CHCTRL_SETEN);
+ rz_dmac_ch_writel(channel, nxla, NXLA, 1);
+ rz_dmac_ch_writel(channel, channel->chcfg, CHCFG, 1);
+ rz_dmac_ch_writel(channel, CHCTRL_SWRST, CHCTRL, 1);
+ rz_dmac_ch_writel(channel, chctrl, CHCTRL, 1);
}
static void rz_dmac_disable_hw(struct rz_dmac_chan *channel)
@@ -397,18 +391,20 @@ static void rz_dmac_prepare_descs_for_slave_sg(struct rz_dmac_chan *channel)
channel->chctrl = CHCTRL_SETEN;
}
-static int rz_dmac_xfer_desc(struct rz_dmac_chan *chan)
+static void rz_dmac_xfer_desc(struct rz_dmac_chan *chan)
{
- struct rz_dmac_desc *d = chan->desc;
struct virt_dma_desc *vd;
vd = vchan_next_desc(&chan->vc);
- if (!vd)
- return 0;
+ if (!vd) {
+ chan->desc = NULL;
+ return;
+ }
list_del(&vd->node);
+ chan->desc = to_rz_dmac_desc(vd);
- switch (d->type) {
+ switch (chan->desc->type) {
case RZ_DMAC_DESC_MEMCPY:
rz_dmac_prepare_desc_for_memcpy(chan);
break;
@@ -416,14 +412,9 @@ static int rz_dmac_xfer_desc(struct rz_dmac_chan *chan)
case RZ_DMAC_DESC_SLAVE_SG:
rz_dmac_prepare_descs_for_slave_sg(chan);
break;
-
- default:
- return -EINVAL;
}
rz_dmac_enable_hw(chan);
-
- return 0;
}
/*
@@ -465,8 +456,6 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
rz_lmdesc_setup(channel, channel->lmdesc.base);
rz_dmac_disable_hw(channel);
- list_splice_tail_init(&channel->ld_active, &channel->ld_free);
- list_splice_tail_init(&channel->ld_queue, &channel->ld_free);
if (channel->mid_rid >= 0) {
clear_bit(channel->mid_rid, dmac->modules);
@@ -475,13 +464,19 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
spin_unlock_irqrestore(&channel->vc.lock, flags);
+ vchan_free_chan_resources(&channel->vc);
+
+ spin_lock_irqsave(&channel->vc.lock, flags);
+
list_for_each_entry_safe(desc, _desc, &channel->ld_free, node) {
+ list_del(&desc->node);
kfree(desc);
channel->descs_allocated--;
}
INIT_LIST_HEAD(&channel->ld_free);
- vchan_free_chan_resources(&channel->vc);
+
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
}
static struct dma_async_tx_descriptor *
@@ -504,16 +499,16 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
return NULL;
}
+ list_del(&desc->node);
+
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
+
desc->type = RZ_DMAC_DESC_MEMCPY;
desc->src = src;
desc->dest = dest;
desc->len = len;
desc->direction = DMA_MEM_TO_MEM;
- list_move_tail(channel->ld_free.next, &channel->ld_queue);
-
- spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
-
return vchan_tx_prep(&channel->vc, &desc->vd, flags);
}
@@ -538,7 +533,9 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return NULL;
}
- desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node);
+ list_del(&desc->node);
+
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
for_each_sg(sgl, sg, sg_len, i) {
dma_length += sg_dma_len(sg);
@@ -555,10 +552,6 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
else
desc->dest = channel->dst_per_address;
- list_move_tail(channel->ld_free.next, &channel->ld_queue);
-
- spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
-
return vchan_tx_prep(&channel->vc, &desc->vd, flags);
}
@@ -572,8 +565,11 @@ static int rz_dmac_terminate_all(struct dma_chan *chan)
rz_dmac_disable_hw(channel);
rz_lmdesc_setup(channel, channel->lmdesc.base);
- list_splice_tail_init(&channel->ld_active, &channel->ld_free);
- list_splice_tail_init(&channel->ld_queue, &channel->ld_free);
+ if (channel->desc) {
+ vchan_terminate_vdesc(&channel->desc->vd);
+ channel->desc = NULL;
+ }
+
vchan_get_all_descriptors(&channel->vc, &head);
spin_unlock_irqrestore(&channel->vc.lock, flags);
vchan_dma_desc_free_list(&channel->vc, &head);
@@ -584,25 +580,16 @@ static int rz_dmac_terminate_all(struct dma_chan *chan)
static void rz_dmac_issue_pending(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
- struct rz_dmac *dmac = to_rz_dmac(chan->device);
- struct rz_dmac_desc *desc;
unsigned long flags;
spin_lock_irqsave(&channel->vc.lock, flags);
- if (!list_empty(&channel->ld_queue)) {
- desc = list_first_entry(&channel->ld_queue,
- struct rz_dmac_desc, node);
- channel->desc = desc;
- if (vchan_issue_pending(&channel->vc)) {
- if (rz_dmac_xfer_desc(channel) < 0)
- dev_warn(dmac->dev, "ch: %d couldn't issue DMA xfer\n",
- channel->index);
- else
- list_move_tail(channel->ld_queue.next,
- &channel->ld_active);
- }
- }
+ /*
+ * Issue the descriptor. If another transfer is already in progress, the
+ * issued descriptor will be handled after the current transfer finishes.
+ */
+ if (vchan_issue_pending(&channel->vc) && !channel->desc)
+ rz_dmac_xfer_desc(channel);
spin_unlock_irqrestore(&channel->vc.lock, flags);
}
@@ -660,13 +647,13 @@ static int rz_dmac_config(struct dma_chan *chan,
static void rz_dmac_virt_desc_free(struct virt_dma_desc *vd)
{
- /*
- * Place holder
- * Descriptor allocation is done during alloc_chan_resources and
- * get freed during free_chan_resources.
- * list is used to manage the descriptors and avoid any memory
- * allocation/free during DMA read/write.
- */
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(vd->tx.chan);
+ struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
+ struct rz_dmac_desc *desc = to_rz_dmac_desc(vd);
+
+ guard(spinlock_irqsave)(&vc->lock);
+
+ list_add_tail(&desc->node, &channel->ld_free);
}
static void rz_dmac_device_synchronize(struct dma_chan *chan)
@@ -676,6 +663,8 @@ static void rz_dmac_device_synchronize(struct dma_chan *chan)
u32 chstat;
int ret;
+ vchan_synchronize(&channel->vc);
+
ret = read_poll_timeout(rz_dmac_ch_readl, chstat, !(chstat & CHSTAT_EN),
100, 100000, false, channel, CHSTAT, 1);
if (ret < 0)
@@ -723,58 +712,22 @@ static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel,
static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
dma_cookie_t cookie)
{
- struct rz_dmac_desc *current_desc, *desc;
- enum dma_status status;
+ struct rz_dmac_desc *desc = NULL;
+ struct virt_dma_desc *vd;
u32 crla, crtb, i;
- /* Get current processing virtual descriptor */
- current_desc = list_first_entry_or_null(&channel->ld_active,
- struct rz_dmac_desc, node);
- if (!current_desc)
- return 0;
-
- /*
- * If the cookie corresponds to a descriptor that has been completed
- * there is no residue. The same check has already been performed by the
- * caller but without holding the channel lock, so the descriptor could
- * now be complete.
- */
- status = dma_cookie_status(&channel->vc.chan, cookie, NULL);
- if (status == DMA_COMPLETE)
- return 0;
-
- /*
- * If the cookie doesn't correspond to the currently processing virtual
- * descriptor then the descriptor hasn't been processed yet, and the
- * residue is equal to the full descriptor size. Also, a client driver
- * is possible to call this function before rz_dmac_irq_handler_thread()
- * runs. In this case, the running descriptor will be the next
- * descriptor, and will appear in the done list. So, if the argument
- * cookie matches the done list's cookie, we can assume the residue is
- * zero.
- */
- if (cookie != current_desc->vd.tx.cookie) {
- list_for_each_entry(desc, &channel->ld_free, node) {
- if (cookie == desc->vd.tx.cookie)
- return 0;
- }
-
- list_for_each_entry(desc, &channel->ld_queue, node) {
- if (cookie == desc->vd.tx.cookie)
- return desc->len;
- }
-
- list_for_each_entry(desc, &channel->ld_active, node) {
- if (cookie == desc->vd.tx.cookie)
- return desc->len;
- }
+ vd = vchan_find_desc(&channel->vc, cookie);
+ if (vd) {
+ /* Descriptor has been issued but not yet processed. */
+ desc = to_rz_dmac_desc(vd);
+ return desc->len;
+ } else if (channel->desc && channel->desc->vd.tx.cookie == cookie) {
+ /* Descriptor is currently processed. */
+ desc = channel->desc;
+ }
- /*
- * No descriptor found for the cookie, there's thus no residue.
- * This shouldn't happen if the calling driver passes a correct
- * cookie value.
- */
- WARN(1, "No descriptor for cookie!");
+ if (!desc) {
+ /* Descriptor was not found. May be already completed by now. */
return 0;
}
@@ -797,7 +750,7 @@ static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
* Calculate number of bytes transferred in processing virtual descriptor.
* One virtual descriptor can have many lmdesc.
*/
- return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, current_desc, crla);
+ return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, desc, crla);
}
static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
@@ -809,21 +762,19 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
unsigned long flags;
u32 residue;
+ spin_lock_irqsave(&channel->vc.lock, flags);
status = dma_cookie_status(chan, cookie, txstate);
- if (status == DMA_COMPLETE || !txstate)
+ if (status == DMA_COMPLETE || !txstate) {
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
return status;
+ }
- spin_lock_irqsave(&channel->vc.lock, flags);
residue = rz_dmac_chan_get_residue(channel, cookie);
- if (rz_dmac_chan_is_paused(channel))
+ if (status == DMA_IN_PROGRESS && rz_dmac_chan_is_paused(channel))
status = DMA_PAUSED;
spin_unlock_irqrestore(&channel->vc.lock, flags);
- /* if there's no residue and no paused, the cookie is complete */
- if (!residue && status != DMA_PAUSED)
- return DMA_COMPLETE;
-
dma_set_residue(txstate, residue);
return status;
@@ -905,28 +856,18 @@ static irqreturn_t rz_dmac_irq_handler(int irq, void *dev_id)
static irqreturn_t rz_dmac_irq_handler_thread(int irq, void *dev_id)
{
struct rz_dmac_chan *channel = dev_id;
- struct rz_dmac_desc *desc = NULL;
- unsigned long flags;
+ struct rz_dmac_desc *desc;
- spin_lock_irqsave(&channel->vc.lock, flags);
+ guard(spinlock_irqsave)(&channel->vc.lock);
- if (list_empty(&channel->ld_active)) {
- /* Someone might have called terminate all */
- goto out;
- }
+ desc = channel->desc;
+ if (!desc)
+ return IRQ_HANDLED;
- desc = list_first_entry(&channel->ld_active, struct rz_dmac_desc, node);
vchan_cookie_complete(&desc->vd);
- list_move_tail(channel->ld_active.next, &channel->ld_free);
- if (!list_empty(&channel->ld_queue)) {
- desc = list_first_entry(&channel->ld_queue, struct rz_dmac_desc,
- node);
- channel->desc = desc;
- if (rz_dmac_xfer_desc(channel) == 0)
- list_move_tail(channel->ld_queue.next, &channel->ld_active);
- }
-out:
- spin_unlock_irqrestore(&channel->vc.lock, flags);
+ channel->desc = NULL;
+
+ rz_dmac_xfer_desc(channel);
return IRQ_HANDLED;
}
@@ -1007,9 +948,7 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
channel->vc.desc_free = rz_dmac_virt_desc_free;
vchan_init(&channel->vc, &dmac->engine);
- INIT_LIST_HEAD(&channel->ld_queue);
INIT_LIST_HEAD(&channel->ld_free);
- INIT_LIST_HEAD(&channel->ld_active);
/* Initialize register for each channel */
rz_dmac_disable_hw(channel);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 21/27] dmaengine: sh: rz-dmac: Refactor pause/resume code
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (19 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 20/27] dmaengine: sh: rz-dmac: Use virt-dma APIs for channel descriptor processing Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 22/27] dmaengine: sh: rz-dmac: Drop the update of channel->chctrl with CHCTRL_SETEN Claudiu Beznea
` (6 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit dc86e47ca9b1021e258c366a5a9aa15d71c814a5 upstream.
Subsequent patches will add suspend/resume and cyclic DMA support to the
rz-dmac driver. This support needs to work on SoCs where power to most
components (including DMA) is turned off during system suspend. For this,
some channels (for example cyclic ones) may need to be paused and resumed
manually by the DMA driver during system suspend/resume.
Refactor the pause/resume support so the same code can be reused in the
system suspend/resume path.
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-11-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 73 ++++++++++++++++++++++++++++++++++------
1 file changed, 62 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index f31dd1f80a10..aa29601d3c0a 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -16,6 +16,7 @@
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/list.h>
+#include <linux/lockdep.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_dma.h>
@@ -61,6 +62,14 @@ struct rz_dmac_desc {
#define to_rz_dmac_desc(d) container_of(d, struct rz_dmac_desc, vd)
+/**
+ * enum rz_dmac_chan_status: RZ DMAC channel status
+ * @RZ_DMAC_CHAN_STATUS_PAUSED: Channel is paused though DMA engine callbacks
+ */
+enum rz_dmac_chan_status {
+ RZ_DMAC_CHAN_STATUS_PAUSED,
+};
+
struct rz_dmac_chan {
struct virt_dma_chan vc;
void __iomem *ch_base;
@@ -72,6 +81,8 @@ struct rz_dmac_chan {
dma_addr_t src_per_address;
dma_addr_t dst_per_address;
+ unsigned long status;
+
u32 chcfg;
u32 chctrl;
int mid_rid;
@@ -462,6 +473,8 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
channel->mid_rid = -EINVAL;
}
+ channel->status = 0;
+
spin_unlock_irqrestore(&channel->vc.lock, flags);
vchan_free_chan_resources(&channel->vc);
@@ -571,6 +584,9 @@ static int rz_dmac_terminate_all(struct dma_chan *chan)
}
vchan_get_all_descriptors(&channel->vc, &head);
+
+ channel->status = 0;
+
spin_unlock_irqrestore(&channel->vc.lock, flags);
vchan_dma_desc_free_list(&channel->vc, &head);
@@ -780,35 +796,70 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
return status;
}
-static int rz_dmac_device_pause(struct dma_chan *chan)
+static int rz_dmac_device_pause_set(struct rz_dmac_chan *channel,
+ unsigned long set_bitmask)
{
- struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ int ret = 0;
u32 val;
- guard(spinlock_irqsave)(&channel->vc.lock);
+ lockdep_assert_held(&channel->vc.lock);
if (!rz_dmac_chan_is_enabled(channel))
return 0;
+ if (rz_dmac_chan_is_paused(channel))
+ goto set_bit;
+
rz_dmac_ch_writel(channel, CHCTRL_SETSUS, CHCTRL, 1);
- return read_poll_timeout_atomic(rz_dmac_ch_readl, val,
- (val & CHSTAT_SUS), 1, 1024,
- false, channel, CHSTAT, 1);
+ ret = read_poll_timeout_atomic(rz_dmac_ch_readl, val,
+ (val & CHSTAT_SUS), 1, 1024, false,
+ channel, CHSTAT, 1);
+
+set_bit:
+ channel->status |= set_bitmask;
+
+ return ret;
}
-static int rz_dmac_device_resume(struct dma_chan *chan)
+static int rz_dmac_device_pause(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
- u32 val;
guard(spinlock_irqsave)(&channel->vc.lock);
+ return rz_dmac_device_pause_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED));
+}
+
+static int rz_dmac_device_resume_set(struct rz_dmac_chan *channel,
+ unsigned long clear_bitmask)
+{
+ int ret = 0;
+ u32 val;
+
+ lockdep_assert_held(&channel->vc.lock);
+
/* Do not check CHSTAT_SUS but rely on HW capabilities. */
rz_dmac_ch_writel(channel, CHCTRL_CLRSUS, CHCTRL, 1);
- return read_poll_timeout_atomic(rz_dmac_ch_readl, val,
- !(val & CHSTAT_SUS), 1, 1024,
- false, channel, CHSTAT, 1);
+ ret = read_poll_timeout_atomic(rz_dmac_ch_readl, val,
+ !(val & CHSTAT_SUS), 1, 1024, false,
+ channel, CHSTAT, 1);
+
+ channel->status &= ~clear_bitmask;
+
+ return ret;
+}
+
+static int rz_dmac_device_resume(struct dma_chan *chan)
+{
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+
+ guard(spinlock_irqsave)(&channel->vc.lock);
+
+ if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED)))
+ return 0;
+
+ return rz_dmac_device_resume_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED));
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 22/27] dmaengine: sh: rz-dmac: Drop the update of channel->chctrl with CHCTRL_SETEN
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (20 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 21/27] dmaengine: sh: rz-dmac: Refactor pause/resume code Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 23/27] dmaengine: sh: rz-dmac: Add cyclic DMA support Claudiu Beznea
` (5 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit e8baee1d1cddc8e2be7bc362d6dc3fcb2021e873 upstream.
The CHCTRL_SETEN bit is explicitly set in rz_dmac_enable_hw(). Updating
struct rz_dmac_chan::chctrl with this bit in
rz_dmac_prepare_desc_for_memcpy() and rz_dmac_prepare_descs_for_slave_sg()
is unnecessary in the current code base. Moreover, it conflicts with the
configuration sequence that will be used for cyclic DMA channels during
suspend to RAM. Cyclic DMA support will be introduced in subsequent
commits.
This is a preparatory commit for cyclic DMA suspend to RAM support.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-12-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_prepare_descs_for_slave_sg()
by dropping rz_dmac_set_dma_req_no() (which is unavailable in v5.10 CIP)]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index aa29601d3c0a..55654588f0b2 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -349,7 +349,7 @@ static void rz_dmac_prepare_desc_for_memcpy(struct rz_dmac_chan *channel)
rz_dmac_set_dmars_register(dmac, channel->index, 0);
channel->chcfg = chcfg;
- channel->chctrl = CHCTRL_STG | CHCTRL_SETEN;
+ channel->chctrl = CHCTRL_STG;
}
static void rz_dmac_prepare_descs_for_slave_sg(struct rz_dmac_chan *channel)
@@ -399,7 +399,7 @@ static void rz_dmac_prepare_descs_for_slave_sg(struct rz_dmac_chan *channel)
channel->lmdesc.tail = lmdesc;
rz_dmac_set_dmars_register(dmac, channel->index, channel->mid_rid);
- channel->chctrl = CHCTRL_SETEN;
+ channel->chctrl = 0;
}
static void rz_dmac_xfer_desc(struct rz_dmac_chan *chan)
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 23/27] dmaengine: sh: rz-dmac: Add cyclic DMA support
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (21 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 22/27] dmaengine: sh: rz-dmac: Drop the update of channel->chctrl with CHCTRL_SETEN Claudiu Beznea
@ 2026-11-26 15:21 ` Claudiu Beznea
2026-11-26 15:22 ` [PATCH 5.10.y-cip 24/27] dmaengine: sh: rz-dmac: Adjust rz_dmac_chan_get_residue() to return error codes Claudiu Beznea
` (4 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:21 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 172bfb57481c65fcc94ebcae3a730f6df2f953d4 upstream.
Add cyclic DMA support to the RZ DMAC driver. A per-channel status bit is
introduced to mark cyclic channels and is set during the DMA prepare
callback. The IRQ handler checks this status bit and calls
vchan_cyclic_callback() accordingly.
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-13-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea:
- in rz_dmac_prepare_descs_for_cyclic() moved the declaration of i
iterator outside of for block
- replaced rz_dmac_set_dma_req_no() with rz_dmac_set_dmars_register()
- replaced scoped_guard() with spin_lock_irqsave()/spin_unlock_irqrestore()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 141 +++++++++++++++++++++++++++++++++++++--
1 file changed, 135 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 55654588f0b2..968754752401 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -33,6 +33,7 @@
enum rz_dmac_prep_type {
RZ_DMAC_DESC_MEMCPY,
RZ_DMAC_DESC_SLAVE_SG,
+ RZ_DMAC_DESC_CYCLIC,
};
struct rz_lmdesc {
@@ -65,9 +66,11 @@ struct rz_dmac_desc {
/**
* enum rz_dmac_chan_status: RZ DMAC channel status
* @RZ_DMAC_CHAN_STATUS_PAUSED: Channel is paused though DMA engine callbacks
+ * @RZ_DMAC_CHAN_STATUS_CYCLIC: Channel is cyclic
*/
enum rz_dmac_chan_status {
RZ_DMAC_CHAN_STATUS_PAUSED,
+ RZ_DMAC_CHAN_STATUS_CYCLIC,
};
struct rz_dmac_chan {
@@ -176,6 +179,7 @@ struct rz_dmac {
/* LINK MODE DESCRIPTOR */
#define HEADER_LV BIT(0)
+#define HEADER_WBD BIT(2)
#define RZ_DMAC_MAX_CHAN_DESCRIPTORS 16
#define RZ_DMAC_MAX_CHANNELS 16
@@ -402,6 +406,57 @@ static void rz_dmac_prepare_descs_for_slave_sg(struct rz_dmac_chan *channel)
channel->chctrl = 0;
}
+static void rz_dmac_prepare_descs_for_cyclic(struct rz_dmac_chan *channel)
+{
+ struct dma_chan *chan = &channel->vc.chan;
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
+ struct rz_dmac_desc *d = channel->desc;
+ size_t period_len = d->sgcount, i;
+ struct rz_lmdesc *lmdesc;
+ size_t buf_len = d->len;
+ size_t periods = buf_len / period_len;
+
+ lockdep_assert_held(&channel->vc.lock);
+
+ channel->chcfg |= CHCFG_SEL(channel->index) | CHCFG_DMS;
+
+ if (d->direction == DMA_DEV_TO_MEM) {
+ channel->chcfg |= CHCFG_SAD;
+ channel->chcfg &= ~CHCFG_REQD;
+ } else {
+ channel->chcfg |= CHCFG_DAD | CHCFG_REQD;
+ }
+
+ lmdesc = channel->lmdesc.tail;
+ d->start_lmdesc = lmdesc;
+
+ for (i = 0; i < periods; i++) {
+ if (d->direction == DMA_DEV_TO_MEM) {
+ lmdesc->sa = d->src;
+ lmdesc->da = d->dest + (i * period_len);
+ } else {
+ lmdesc->sa = d->src + (i * period_len);
+ lmdesc->da = d->dest;
+ }
+
+ lmdesc->tb = period_len;
+ lmdesc->chitvl = 0;
+ lmdesc->chext = 0;
+ lmdesc->chcfg = channel->chcfg;
+ lmdesc->header = HEADER_LV | HEADER_WBD;
+
+ if (i == periods - 1)
+ lmdesc->nxla = rz_dmac_lmdesc_addr(channel, d->start_lmdesc);
+
+ if (++lmdesc >= (channel->lmdesc.base + DMAC_NR_LMDESC))
+ lmdesc = channel->lmdesc.base;
+ }
+
+ channel->lmdesc.tail = lmdesc;
+
+ rz_dmac_set_dmars_register(dmac, channel->index, channel->mid_rid);
+}
+
static void rz_dmac_xfer_desc(struct rz_dmac_chan *chan)
{
struct virt_dma_desc *vd;
@@ -423,6 +478,10 @@ static void rz_dmac_xfer_desc(struct rz_dmac_chan *chan)
case RZ_DMAC_DESC_SLAVE_SG:
rz_dmac_prepare_descs_for_slave_sg(chan);
break;
+
+ case RZ_DMAC_DESC_CYCLIC:
+ rz_dmac_prepare_descs_for_cyclic(chan);
+ break;
}
rz_dmac_enable_hw(chan);
@@ -568,6 +627,60 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return vchan_tx_prep(&channel->vc, &desc->vd, flags);
}
+static struct dma_async_tx_descriptor *
+rz_dmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
+ size_t buf_len, size_t period_len,
+ enum dma_transfer_direction direction,
+ unsigned long flags)
+{
+ struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac_desc *desc;
+ unsigned long lock_flags;
+ size_t periods;
+
+ if (!is_slave_direction(direction))
+ return NULL;
+
+ if (!period_len || !buf_len)
+ return NULL;
+
+ periods = buf_len / period_len;
+ if (!periods || periods > DMAC_NR_LMDESC)
+ return NULL;
+
+ spin_lock_irqsave(&channel->vc.lock, lock_flags);
+ if (channel->status & BIT(RZ_DMAC_CHAN_STATUS_CYCLIC)) {
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
+ return NULL;
+ }
+
+ desc = list_first_entry_or_null(&channel->ld_free, struct rz_dmac_desc, node);
+ if (!desc) {
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
+ return NULL;
+ }
+
+ list_del(&desc->node);
+
+ channel->status |= BIT(RZ_DMAC_CHAN_STATUS_CYCLIC);
+ spin_unlock_irqrestore(&channel->vc.lock, lock_flags);
+
+ desc->type = RZ_DMAC_DESC_CYCLIC;
+ desc->sgcount = period_len;
+ desc->len = buf_len;
+ desc->direction = direction;
+
+ if (direction == DMA_DEV_TO_MEM) {
+ desc->src = channel->src_per_address;
+ desc->dest = buf_addr;
+ } else {
+ desc->src = buf_addr;
+ desc->dest = channel->dst_per_address;
+ }
+
+ return vchan_tx_prep(&channel->vc, &desc->vd, flags);
+}
+
static int rz_dmac_terminate_all(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
@@ -715,9 +828,18 @@ static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel,
}
/* Calculate residue from next lmdesc to end of virtual desc */
- while (lmdesc->chcfg & CHCFG_DEM) {
- residue += lmdesc->tb;
- lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ if (channel->status & BIT(RZ_DMAC_CHAN_STATUS_CYCLIC)) {
+ u32 start_lmdesc_addr = rz_dmac_lmdesc_addr(channel, desc->start_lmdesc);
+
+ while (lmdesc->nxla != start_lmdesc_addr) {
+ residue += lmdesc->tb;
+ lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ }
+ } else {
+ while (lmdesc->chcfg & CHCFG_DEM) {
+ residue += lmdesc->tb;
+ lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ }
}
dev_dbg(dmac->dev, "%s: VD residue is %u\n", __func__, residue);
@@ -915,10 +1037,14 @@ static irqreturn_t rz_dmac_irq_handler_thread(int irq, void *dev_id)
if (!desc)
return IRQ_HANDLED;
- vchan_cookie_complete(&desc->vd);
- channel->desc = NULL;
+ if (channel->status & BIT(RZ_DMAC_CHAN_STATUS_CYCLIC)) {
+ vchan_cyclic_callback(&desc->vd);
+ } else {
+ vchan_cookie_complete(&desc->vd);
+ channel->desc = NULL;
- rz_dmac_xfer_desc(channel);
+ rz_dmac_xfer_desc(channel);
+ }
return IRQ_HANDLED;
}
@@ -1127,6 +1253,8 @@ static int rz_dmac_probe(struct platform_device *pdev)
engine = &dmac->engine;
dma_cap_set(DMA_SLAVE, engine->cap_mask);
dma_cap_set(DMA_MEMCPY, engine->cap_mask);
+ dma_cap_set(DMA_CYCLIC, engine->cap_mask);
+ engine->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
engine->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_0_7_COMMON_BASE + DCTRL);
rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_8_15_COMMON_BASE + DCTRL);
@@ -1138,6 +1266,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
engine->device_tx_status = rz_dmac_tx_status;
engine->device_prep_slave_sg = rz_dmac_prep_slave_sg;
engine->device_prep_dma_memcpy = rz_dmac_prep_dma_memcpy;
+ engine->device_prep_dma_cyclic = rz_dmac_prep_dma_cyclic;
engine->device_config = rz_dmac_config;
engine->device_terminate_all = rz_dmac_terminate_all;
engine->device_issue_pending = rz_dmac_issue_pending;
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 24/27] dmaengine: sh: rz-dmac: Adjust rz_dmac_chan_get_residue() to return error codes
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (22 preceding siblings ...)
2026-11-26 15:21 ` [PATCH 5.10.y-cip 23/27] dmaengine: sh: rz-dmac: Add cyclic DMA support Claudiu Beznea
@ 2026-11-26 15:22 ` Claudiu Beznea
2026-11-26 15:22 ` [PATCH 5.10.y-cip 25/27] dmaengine: sh: rz-dmac: Add runtime PM support Claudiu Beznea
` (3 subsequent siblings)
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:22 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 16ba40151b1e6a52b28296a2173457bc6c31f022 upstream.
Adjust rz_dmac_chan_get_residue() to return error codes on failure and
provide the residue to callers through the residue parameter. This
prepares the code for the addition of runtime PM support.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-14-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea: fixed conflict in rz_dmac_tx_status()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 968754752401..d5181f21538b 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -847,8 +847,8 @@ static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel,
return residue;
}
-static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
- dma_cookie_t cookie)
+static int rz_dmac_chan_get_residue(struct device *dev, struct rz_dmac_chan *channel,
+ dma_cookie_t cookie, u32 *residue)
{
struct rz_dmac_desc *desc = NULL;
struct virt_dma_desc *vd;
@@ -858,7 +858,8 @@ static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
if (vd) {
/* Descriptor has been issued but not yet processed. */
desc = to_rz_dmac_desc(vd);
- return desc->len;
+ *residue = desc->len;
+ return 0;
} else if (channel->desc && channel->desc->vd.tx.cookie == cookie) {
/* Descriptor is currently processed. */
desc = channel->desc;
@@ -866,6 +867,7 @@ static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
if (!desc) {
/* Descriptor was not found. May be already completed by now. */
+ *residue = 0;
return 0;
}
@@ -888,7 +890,9 @@ static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel,
* Calculate number of bytes transferred in processing virtual descriptor.
* One virtual descriptor can have many lmdesc.
*/
- return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, desc, crla);
+ *residue = crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, desc, crla);
+
+ return 0;
}
static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
@@ -896,9 +900,11 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
struct dma_tx_state *txstate)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
enum dma_status status;
unsigned long flags;
u32 residue;
+ int ret;
spin_lock_irqsave(&channel->vc.lock, flags);
status = dma_cookie_status(chan, cookie, txstate);
@@ -907,7 +913,11 @@ static enum dma_status rz_dmac_tx_status(struct dma_chan *chan,
return status;
}
- residue = rz_dmac_chan_get_residue(channel, cookie);
+ ret = rz_dmac_chan_get_residue(dmac->dev, channel, cookie, &residue);
+ if (ret) {
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
+ return DMA_ERROR;
+ }
if (status == DMA_IN_PROGRESS && rz_dmac_chan_is_paused(channel))
status = DMA_PAUSED;
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 25/27] dmaengine: sh: rz-dmac: Add runtime PM support
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (23 preceding siblings ...)
2026-11-26 15:22 ` [PATCH 5.10.y-cip 24/27] dmaengine: sh: rz-dmac: Adjust rz_dmac_chan_get_residue() to return error codes Claudiu Beznea
@ 2026-11-26 15:22 ` Claudiu Beznea
2026-12-01 11:53 ` Pavel Machek
2026-11-26 15:22 ` [PATCH 5.10.y-cip 26/27] dmaengine: sh: rz-dmac: Add suspend to RAM support Claudiu Beznea
` (2 subsequent siblings)
27 siblings, 1 reply; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:22 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit 7c27a4d54d48d0774518390e4ce6cf3309aac141 upstream.
Protect the driver exposed APIs with runtime PM suspend/resume calls
before accessing HW registers. As the current driver leaves runtime PM
enabled in probe, the purpose of the changes in this patch is to avoid
accessing HW registers after a failed system suspend leaves the runtime
PM state of the device improperly reinitialized.
In that case, the driver remains bound to the device, the APIs are still
exposed, and any access to HW registers without runtime resuming the
device may lead to synchronous aborts.
To avoid leaking resources in case of runtime PM failures, save the error
code returned by PM_RUNTIME_ACQUIRE_ERR() in rz_dmac_terminate_all() and
return it only at the end of the function to allow the cleanup code to
run. A similar approach is used in rz_dmac_free_chan_resources().
Because some exposed APIs (e.g. ->device_terminate_all()) may be called
from atomic context according to the documentation, mark the DMA device as
pm_runtime_irq_safe().
This patch prepares the driver for suspend-to-RAM support.
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-15-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea:
- PM_RUNTIME_ACQUIRE_IF_ENABLED()/PM_RUNTIME_ACQUIRE_ERR()
with the equivalent open-coded pm_runtime_resume_and_get()/
pm_runtime_put()
- replace guard() with spin_lock_irqsave()/spin_unlock_irqrestore() in
rz_dmac_device_pause() and rz_dmac_device_resume()]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 86 ++++++++++++++++++++++++++++++++++++----
1 file changed, 78 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index d5181f21538b..5b6d08fdade1 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -520,12 +520,21 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
struct rz_dmac *dmac = to_rz_dmac(chan->device);
struct rz_dmac_desc *desc, *_desc;
unsigned long flags;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret) {
+ dev_err(dmac->dev, "RPM resume failed for channel %s, ret=%d\n!",
+ dma_chan_name(chan), ret);
+ }
spin_lock_irqsave(&channel->vc.lock, flags);
rz_lmdesc_setup(channel, channel->lmdesc.base);
- rz_dmac_disable_hw(channel);
+ /* Skip touching HW if RPM resume failed. Let the cleanup do its jobs. */
+ if (!ret)
+ rz_dmac_disable_hw(channel);
if (channel->mid_rid >= 0) {
clear_bit(channel->mid_rid, dmac->modules);
@@ -549,6 +558,9 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
INIT_LIST_HEAD(&channel->ld_free);
spin_unlock_irqrestore(&channel->vc.lock, flags);
+
+ if (!ret)
+ pm_runtime_put(dmac->dev);
}
static struct dma_async_tx_descriptor *
@@ -684,11 +696,21 @@ rz_dmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
static int rz_dmac_terminate_all(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
unsigned long flags;
LIST_HEAD(head);
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret) {
+ dev_err(dmac->dev, "RPM resume failed for channel %s, ret=%d\n!",
+ dma_chan_name(chan), ret);
+ }
spin_lock_irqsave(&channel->vc.lock, flags);
- rz_dmac_disable_hw(channel);
+ /* Don't return if RPM failed. Let the cleanup do its jobs. */
+ if (!ret)
+ rz_dmac_disable_hw(channel);
rz_lmdesc_setup(channel, channel->lmdesc.base);
if (channel->desc) {
@@ -703,13 +725,22 @@ static int rz_dmac_terminate_all(struct dma_chan *chan)
spin_unlock_irqrestore(&channel->vc.lock, flags);
vchan_dma_desc_free_list(&channel->vc, &head);
- return 0;
+ if (!ret)
+ pm_runtime_put(dmac->dev);
+
+ return ret;
}
static void rz_dmac_issue_pending(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
unsigned long flags;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret)
+ return;
spin_lock_irqsave(&channel->vc.lock, flags);
@@ -721,6 +752,8 @@ static void rz_dmac_issue_pending(struct dma_chan *chan)
rz_dmac_xfer_desc(channel);
spin_unlock_irqrestore(&channel->vc.lock, flags);
+
+ pm_runtime_put(dmac->dev);
}
static u8 rz_dmac_ds_to_val_mapping(enum dma_slave_buswidth ds)
@@ -794,12 +827,18 @@ static void rz_dmac_device_synchronize(struct dma_chan *chan)
vchan_synchronize(&channel->vc);
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret)
+ return;
+
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);
+
+ pm_runtime_put(dmac->dev);
}
static struct rz_lmdesc *
@@ -853,6 +892,7 @@ static int rz_dmac_chan_get_residue(struct device *dev, struct rz_dmac_chan *cha
struct rz_dmac_desc *desc = NULL;
struct virt_dma_desc *vd;
u32 crla, crtb, i;
+ int ret;
vd = vchan_find_desc(&channel->vc, cookie);
if (vd) {
@@ -871,6 +911,10 @@ static int rz_dmac_chan_get_residue(struct device *dev, struct rz_dmac_chan *cha
return 0;
}
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret)
+ return ret;
+
/*
* We need to read two registers. Make sure the hardware does not move
* to next lmdesc while reading the current lmdesc. Trying it 3 times
@@ -892,6 +936,8 @@ static int rz_dmac_chan_get_residue(struct device *dev, struct rz_dmac_chan *cha
*/
*residue = crtb + rz_dmac_calculate_residue_bytes_in_vd(channel, desc, crla);
+ pm_runtime_put(dev);
+
return 0;
}
@@ -956,10 +1002,21 @@ static int rz_dmac_device_pause_set(struct rz_dmac_chan *channel,
static int rz_dmac_device_pause(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
+ unsigned long flags;
+ int ret;
- guard(spinlock_irqsave)(&channel->vc.lock);
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret)
+ return ret;
+
+ spin_lock_irqsave(&channel->vc.lock, flags);
+ ret = rz_dmac_device_pause_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED));
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
+
+ pm_runtime_put(dmac->dev);
- return rz_dmac_device_pause_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED));
+ return ret;
}
static int rz_dmac_device_resume_set(struct rz_dmac_chan *channel,
@@ -985,13 +1042,25 @@ static int rz_dmac_device_resume_set(struct rz_dmac_chan *channel,
static int rz_dmac_device_resume(struct dma_chan *chan)
{
struct rz_dmac_chan *channel = to_rz_dmac_chan(chan);
+ struct rz_dmac *dmac = to_rz_dmac(chan->device);
+ unsigned long flags;
+ int ret;
- guard(spinlock_irqsave)(&channel->vc.lock);
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret)
+ return ret;
+ spin_lock_irqsave(&channel->vc.lock, flags);
if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED)))
- return 0;
+ goto unlock;
+
+ ret = rz_dmac_device_resume_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED));
+unlock:
+ spin_unlock_irqrestore(&channel->vc.lock, flags);
+
+ pm_runtime_put(dmac->dev);
- return rz_dmac_device_resume_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED));
+ return ret;
}
/*
@@ -1221,6 +1290,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(dmac->rstc),
"failed to get resets\n");
+ pm_runtime_irq_safe(&pdev->dev);
pm_runtime_enable(&pdev->dev);
ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0) {
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 26/27] dmaengine: sh: rz-dmac: Add suspend to RAM support
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (24 preceding siblings ...)
2026-11-26 15:22 ` [PATCH 5.10.y-cip 25/27] dmaengine: sh: rz-dmac: Add runtime PM support Claudiu Beznea
@ 2026-11-26 15:22 ` Claudiu Beznea
2026-12-01 11:55 ` Pavel Machek
2026-11-26 15:22 ` [PATCH 5.10.y-cip 27/27] dmaengine: sh: rz-dmac: Fix off-by-one in residue lmdesc lookup Claudiu Beznea
2026-11-30 22:19 ` [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Pavel Machek
27 siblings, 1 reply; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:22 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
commit c13ce43e70719dead7009e7e708971ba1c447568 upstream.
The Renesas RZ/G3S SoC supports a power saving mode in which power to most
of the SoC components is turned off, including the DMA IP. Add suspend to
RAM support to save and restore the DMA IP registers.
Cyclic DMA channels require special handling. Since they can be paused and
resumed during system suspend/resume, the driver restores additional
registers for these channels during the system resume phase. If a channel
was not explicitly paused during suspend, the driver ensures that it is
paused and resumed as part of the system suspend/resume flow.
Tested-by: John Madieu <john.madieu.xa@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/20260526084710.3491480-16-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[claudiu.beznea:
- dropped rz_dmac_{v,t}2h_info, rz_dmac_generic_info since these are
not applicable to v5.10 CIP
- replace rz_dmac_set_dma_req_no() with rz_dmac_set_dmars_register()
since the former is NA in v5.10 CIP
- in rz_dmac_suspend_recover(): replaced PM_RUNTIME_ACQUIRE_IF_ENABLED()/
PM_RUNTIME_ACQUIRE_ERR() in rz_dmac_suspend_recover() with the
equivalent open-coded pm_runtime_resume_and_get()/pm_runtime_put
- in rz_dmac_suspend(), rz_dmac_suspend_recover(), rz_dmac_resume():
moved the declaration of i iterator outside of for block
- dropped static keyword in front of DEFINE_SIMPLE_DEV_PM_OPS() since the
macro already includes the static declaration]
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
drivers/dma/sh/rz-dmac.c | 184 +++++++++++++++++++++++++++++++++++++--
1 file changed, 179 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 5b6d08fdade1..f2ec90e3f52a 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -67,10 +67,12 @@ struct rz_dmac_desc {
* enum rz_dmac_chan_status: RZ DMAC channel status
* @RZ_DMAC_CHAN_STATUS_PAUSED: Channel is paused though DMA engine callbacks
* @RZ_DMAC_CHAN_STATUS_CYCLIC: Channel is cyclic
+ * @RZ_DMAC_CHAN_STATUS_PAUSED_INTERNAL: Channel is paused through driver internal logic
*/
enum rz_dmac_chan_status {
RZ_DMAC_CHAN_STATUS_PAUSED,
RZ_DMAC_CHAN_STATUS_CYCLIC,
+ RZ_DMAC_CHAN_STATUS_PAUSED_INTERNAL,
};
struct rz_dmac_chan {
@@ -90,6 +92,10 @@ struct rz_dmac_chan {
u32 chctrl;
int mid_rid;
+ struct {
+ u32 nxla;
+ } pm_state;
+
struct list_head ld_free;
struct {
@@ -1019,20 +1025,57 @@ static int rz_dmac_device_pause(struct dma_chan *chan)
return ret;
}
+static int rz_dmac_device_pause_internal(struct rz_dmac_chan *channel)
+{
+ lockdep_assert_held(&channel->vc.lock);
+
+ /* Skip channels explicitly paused by consummers or disabled. */
+ if (channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED) ||
+ !rz_dmac_chan_is_enabled(channel))
+ return 0;
+
+ return rz_dmac_device_pause_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED_INTERNAL));
+}
+
static int rz_dmac_device_resume_set(struct rz_dmac_chan *channel,
unsigned long clear_bitmask)
{
- int ret = 0;
u32 val;
+ int ret;
lockdep_assert_held(&channel->vc.lock);
- /* Do not check CHSTAT_SUS but rely on HW capabilities. */
+ /*
+ * We can be:
+ *
+ * 1/ after the channel was paused by a consummer and now it
+ * needs to be resummed
+ * 2/ after the channel was paused internally (as a result of
+ * a system suspend with power loss or not)
+ * 3/ after the channel was paused by a consummer, the system
+ * went through a system suspend (with power loss or not)
+ * and the consummer wants to resume the channel
+ *
+ * To cover all the above cases we set both CLRSUS and SETEN.
+ *
+ * In case 1/ setting SETEN while the channel is still enabled
+ * is harmless for the controller.
+ *
+ * In case 2/ the channel is disabled when calling this function
+ * and setting CLRSUS is harmless for the controller as the
+ * channel is disabled anyway.
+ *
+ * In case 3/ the channel is disabled/enabled if the system
+ * went though a suspend with power loss/or not and setting
+ * CLRSUS/SETEN is harmless for the controller as the channel
+ * is enabled/disabled anyway.
+ */
+
+ rz_dmac_ch_writel(channel, CHCTRL_CLRSUS | CHCTRL_SETEN, CHCTRL, 1);
- rz_dmac_ch_writel(channel, CHCTRL_CLRSUS, CHCTRL, 1);
ret = read_poll_timeout_atomic(rz_dmac_ch_readl, val,
- !(val & CHSTAT_SUS), 1, 1024, false,
- channel, CHSTAT, 1);
+ ((val & (CHSTAT_SUS | CHSTAT_EN)) == CHSTAT_EN),
+ 1, 1024, false, channel, CHSTAT, 1);
channel->status &= ~clear_bitmask;
@@ -1063,6 +1106,16 @@ static int rz_dmac_device_resume(struct dma_chan *chan)
return ret;
}
+static int rz_dmac_device_resume_internal(struct rz_dmac_chan *channel)
+{
+ lockdep_assert_held(&channel->vc.lock);
+
+ if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED_INTERNAL)))
+ return 0;
+
+ return rz_dmac_device_resume_set(channel, BIT(RZ_DMAC_CHAN_STATUS_PAUSED_INTERNAL));
+}
+
/*
* -----------------------------------------------------------------------------
* IRQ handling
@@ -1389,6 +1442,126 @@ static int rz_dmac_remove(struct platform_device *pdev)
return 0;
}
+static void rz_dmac_suspend_recover(struct rz_dmac *dmac)
+{
+ unsigned int i;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dmac->dev);
+ if (ret)
+ return;
+
+ for (i = 0; i < dmac->n_channels; i++) {
+ struct rz_dmac_chan *channel = &dmac->channels[i];
+
+ guard(spinlock_irqsave)(&channel->vc.lock);
+
+ if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_CYCLIC)))
+ continue;
+
+ rz_dmac_device_resume_internal(channel);
+ }
+
+ pm_runtime_put(dmac->dev);
+}
+
+static int rz_dmac_suspend(struct device *dev)
+{
+ struct rz_dmac *dmac = dev_get_drvdata(dev);
+ unsigned int i;
+ int ret = 0;
+
+ for (i = 0; i < dmac->n_channels; i++) {
+ struct rz_dmac_chan *channel = &dmac->channels[i];
+
+ guard(spinlock_irqsave)(&channel->vc.lock);
+
+ if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_CYCLIC)))
+ continue;
+
+ ret = rz_dmac_device_pause_internal(channel);
+ if (ret) {
+ dev_err(dev, "Failed to suspend channel %s\n",
+ dma_chan_name(&channel->vc.chan));
+ break;
+ }
+
+ channel->pm_state.nxla = rz_dmac_ch_readl(channel, NXLA, 1);
+ }
+
+ if (ret)
+ goto suspend_recover;
+
+ ret = reset_control_assert(dmac->rstc);
+ if (ret)
+ goto suspend_recover;
+
+ ret = pm_runtime_put_sync(dev);
+ if (ret < 0)
+ goto reset_deassert;
+
+ return 0;
+
+reset_deassert:
+ reset_control_deassert(dmac->rstc);
+suspend_recover:
+ rz_dmac_suspend_recover(dmac);
+ return ret;
+}
+
+static int rz_dmac_resume(struct device *dev)
+{
+ struct rz_dmac *dmac = dev_get_drvdata(dev);
+ int errors = 0, ret;
+ unsigned int i;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret)
+ return ret;
+
+ ret = reset_control_deassert(dmac->rstc);
+ if (ret) {
+ /*
+ * Do not put runtime PM here and keep the same state as in
+ * probe. As subsequent suspend/resume cycles may follow, leave
+ * the runtime PM as is, here, to avoid imbalances.
+ */
+ return ret;
+ }
+
+ rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_0_7_COMMON_BASE + DCTRL);
+ rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_8_15_COMMON_BASE + DCTRL);
+
+ for (i = 0; i < dmac->n_channels; i++) {
+ struct rz_dmac_chan *channel = &dmac->channels[i];
+
+ guard(spinlock_irqsave)(&channel->vc.lock);
+
+ rz_dmac_disable_hw(&dmac->channels[i]);
+
+ if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_CYCLIC)))
+ continue;
+
+ rz_dmac_set_dmars_register(dmac, channel->index, channel->mid_rid);
+
+ rz_dmac_ch_writel(channel, channel->pm_state.nxla, NXLA, 1);
+ rz_dmac_ch_writel(channel, channel->chcfg, CHCFG, 1);
+ rz_dmac_ch_writel(channel, CHCTRL_SWRST, CHCTRL, 1);
+ rz_dmac_ch_writel(channel, channel->chctrl, CHCTRL, 1);
+
+ ret = rz_dmac_device_resume_internal(channel);
+ if (ret) {
+ errors = ret;
+ dev_err(dev, "Failed to resume channel %s, ret=%d\n",
+ dma_chan_name(&channel->vc.chan), ret);
+ }
+ }
+
+ return errors ? : 0;
+}
+
+DEFINE_SIMPLE_DEV_PM_OPS(rz_dmac_pm_ops, rz_dmac_suspend, rz_dmac_resume);
+
static const struct of_device_id of_rz_dmac_match[] = {
{ .compatible = "renesas,rz-dmac", },
{ /* Sentinel */ }
@@ -1399,6 +1572,7 @@ static struct platform_driver rz_dmac_driver = {
.driver = {
.name = "rz-dmac",
.of_match_table = of_rz_dmac_match,
+ .pm = pm_ptr(&rz_dmac_pm_ops),
},
.probe = rz_dmac_probe,
.remove = rz_dmac_remove,
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH 5.10.y-cip 27/27] dmaengine: sh: rz-dmac: Fix off-by-one in residue lmdesc lookup
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (25 preceding siblings ...)
2026-11-26 15:22 ` [PATCH 5.10.y-cip 26/27] dmaengine: sh: rz-dmac: Add suspend to RAM support Claudiu Beznea
@ 2026-11-26 15:22 ` Claudiu Beznea
2026-11-30 22:19 ` [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Pavel Machek
27 siblings, 0 replies; 31+ messages in thread
From: Claudiu Beznea @ 2026-11-26 15:22 UTC (permalink / raw)
To: nobuhiro.iwamatsu.x90, pavel; +Cc: cip-dev
From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
commit 9db8e502b34bc1df8078abd0169a4fa0624de3bb upstream.
lmdesc->nxla is the address of the next descriptor, so comparing it
against CRLA, which is the address of the current descriptor,
finds the descriptor before the active one, not the active one.
The residue loops below then summed one lmdesc too many on top of
that.
Compare each descriptor's own address to CRLA instead, and add tb
after advancing to the next lmdesc.
Fixes: 21323b118c16 ("dmaengine: sh: rz-dmac: Add device_tx_status() callback")
Fixes: 172bfb57481c ("dmaengine: sh: rz-dmac: Add cyclic DMA support")
Cc: stable@vger.kernel.org
Suggested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260922092037.224884-1-claudiu.beznea@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
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 f2ec90e3f52a..5d5109510110 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -866,7 +866,7 @@ static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel,
struct rz_dmac *dmac = to_rz_dmac(chan->device);
u32 residue = 0, i = 0;
- while (lmdesc->nxla != crla) {
+ while (rz_dmac_lmdesc_addr(channel, lmdesc) != crla) {
lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
if (++i >= DMAC_NR_LMDESC)
return 0;
@@ -877,13 +877,13 @@ static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *channel,
u32 start_lmdesc_addr = rz_dmac_lmdesc_addr(channel, desc->start_lmdesc);
while (lmdesc->nxla != start_lmdesc_addr) {
- residue += lmdesc->tb;
lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ residue += lmdesc->tb;
}
} else {
while (lmdesc->chcfg & CHCFG_DEM) {
- residue += lmdesc->tb;
lmdesc = rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc);
+ residue += lmdesc->tb;
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
` (26 preceding siblings ...)
2026-11-26 15:22 ` [PATCH 5.10.y-cip 27/27] dmaengine: sh: rz-dmac: Fix off-by-one in residue lmdesc lookup Claudiu Beznea
@ 2026-11-30 22:19 ` Pavel Machek
27 siblings, 0 replies; 31+ messages in thread
From: Pavel Machek @ 2026-11-30 22:19 UTC (permalink / raw)
To: Claudiu Beznea; +Cc: nobuhiro.iwamatsu.x90, pavel, cip-dev
[-- Attachment #1: Type: text/plain, Size: 534 bytes --]
Hi!
> This series backports cyclic DMA, runtime PM and suspend to RAM
> along with preparatory and cleanup patches.
>
> I tried to limit the number of patches per series. Please let me know
> if this needs to be further improved and will consider it for the
> future sumissions.
This looks okay to me.
Reviewed-by: Pavel Machek <pavel@nabladev.com>
I can apply the series if it passes testing and there are no other
comments.
Best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 5.10.y-cip 25/27] dmaengine: sh: rz-dmac: Add runtime PM support
2026-11-26 15:22 ` [PATCH 5.10.y-cip 25/27] dmaengine: sh: rz-dmac: Add runtime PM support Claudiu Beznea
@ 2026-12-01 11:53 ` Pavel Machek
0 siblings, 0 replies; 31+ messages in thread
From: Pavel Machek @ 2026-12-01 11:53 UTC (permalink / raw)
To: Claudiu Beznea; +Cc: nobuhiro.iwamatsu.x90, pavel, cip-dev
[-- Attachment #1: Type: text/plain, Size: 2014 bytes --]
Hi!
> Protect the driver exposed APIs with runtime PM suspend/resume calls
> before accessing HW registers. As the current driver leaves runtime PM
> enabled in probe, the purpose of the changes in this patch is to avoid
> accessing HW registers after a failed system suspend leaves the runtime
> PM state of the device improperly reinitialized.
>
> In that case, the driver remains bound to the device, the APIs are still
> exposed, and any access to HW registers without runtime resuming the
> device may lead to synchronous aborts.
>
> To avoid leaking resources in case of runtime PM failures, save the error
> code returned by PM_RUNTIME_ACQUIRE_ERR() in rz_dmac_terminate_all() and
> return it only at the end of the function to allow the cleanup code to
> run. A similar approach is used in rz_dmac_free_chan_resources().
>
> Because some exposed APIs (e.g. ->device_terminate_all()) may be called
> from atomic context according to the documentation, mark the DMA device as
> pm_runtime_irq_safe().
>
> This patch prepares the driver for suspend-to-RAM support.
> diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
> index d5181f21538b..5b6d08fdade1 100644
> --- a/drivers/dma/sh/rz-dmac.c
> +++ b/drivers/dma/sh/rz-dmac.c
> @@ -520,12 +520,21 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan)
> struct rz_dmac *dmac = to_rz_dmac(chan->device);
> struct rz_dmac_desc *desc, *_desc;
> unsigned long flags;
> + int ret;
> +
> + ret = pm_runtime_resume_and_get(dmac->dev);
> + if (ret) {
> + dev_err(dmac->dev, "RPM resume failed for channel %s, ret=%d\n!",
> + dma_chan_name(chan), ret);
> + }
Ok, so we failed to power up the hardware... why are we continuing?
> rz_lmdesc_setup(channel, channel->lmdesc.base);
>
> - rz_dmac_disable_hw(channel);
> + /* Skip touching HW if RPM resume failed. Let the cleanup do its jobs. */
> + if (!ret)
There is extra space after "/*".
Best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 5.10.y-cip 26/27] dmaengine: sh: rz-dmac: Add suspend to RAM support
2026-11-26 15:22 ` [PATCH 5.10.y-cip 26/27] dmaengine: sh: rz-dmac: Add suspend to RAM support Claudiu Beznea
@ 2026-12-01 11:55 ` Pavel Machek
0 siblings, 0 replies; 31+ messages in thread
From: Pavel Machek @ 2026-12-01 11:55 UTC (permalink / raw)
To: Claudiu Beznea; +Cc: nobuhiro.iwamatsu.x90, pavel, cip-dev
[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]
Hi!
> commit c13ce43e70719dead7009e7e708971ba1c447568 upstream.
>
> The Renesas RZ/G3S SoC supports a power saving mode in which power to most
> of the SoC components is turned off, including the DMA IP. Add suspend to
> RAM support to save and restore the DMA IP registers.
>
> Cyclic DMA channels require special handling. Since they can be paused and
> resumed during system suspend/resume, the driver restores additional
> registers for these channels during the system resume phase. If a channel
> was not explicitly paused during suspend, the driver ensures that it is
> paused and resumed as part of the system suspend/resume flow.
> diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
> index 5b6d08fdade1..f2ec90e3f52a 100644
> --- a/drivers/dma/sh/rz-dmac.c
> +++ b/drivers/dma/sh/rz-dmac.c
...
> + if (ret) {
> + errors = ret;
> + dev_err(dev, "Failed to resume channel %s, ret=%d\n",
> + dma_chan_name(&channel->vc.chan), ret);
> + }
> + }
> +
> + return errors ? : 0;
> +}
> +
This is complicated way of saying "return errors", AFAICT. Eventually
cleaning it up in mainline would be nice.
Best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2026-12-01 11:55 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 15:21 [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 01/27] dmaengine: sh: rz-dmac: Avoid format-overflow warning Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 02/27] dmaengine: sh: rz-dmac: handle configs where one address is zero Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 03/27] dmaengine: sh: rz-dmac: Make channel irq local Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 04/27] dmaengine: sh: rz-dmac: Protect the driver specific lists Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 05/27] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 06/27] dmaengine: sh: rz-dmac: Drop read of CHCTRL register Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 07/27] dmaengine: sh: rz-dmac: Drop goto instruction and label Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 08/27] dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 09/27] dmaengine: sh: rz-dmac: Use rz_lmdesc_setup() to invalidate descriptors Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 10/27] dmaengine: sh: rz-dmac: Add device_tx_status() callback Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 11/27] dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 12/27] dmaengine: sh: rz-dmac: Move interrupt request after everything is set up Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 13/27] dmaengine: sh: rz-dmac: Fix incorrect NULL check for list_first_entry() Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 14/27] dmaengine: sh: rz-dmac: Use list_first_entry_or_null() Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 15/27] dmaengine: sh: rz-dmac: Use rz_dmac_disable_hw() Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 16/27] dmaengine: sh: rz-dmac: Add helper to compute the lmdesc address Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 17/27] dmaengine: sh: rz-dmac: Save the start LM descriptor Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 18/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is enabled Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 19/27] dmaengine: sh: rz-dmac: Add helper to check if the channel is paused Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 20/27] dmaengine: sh: rz-dmac: Use virt-dma APIs for channel descriptor processing Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 21/27] dmaengine: sh: rz-dmac: Refactor pause/resume code Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 22/27] dmaengine: sh: rz-dmac: Drop the update of channel->chctrl with CHCTRL_SETEN Claudiu Beznea
2026-11-26 15:21 ` [PATCH 5.10.y-cip 23/27] dmaengine: sh: rz-dmac: Add cyclic DMA support Claudiu Beznea
2026-11-26 15:22 ` [PATCH 5.10.y-cip 24/27] dmaengine: sh: rz-dmac: Adjust rz_dmac_chan_get_residue() to return error codes Claudiu Beznea
2026-11-26 15:22 ` [PATCH 5.10.y-cip 25/27] dmaengine: sh: rz-dmac: Add runtime PM support Claudiu Beznea
2026-12-01 11:53 ` Pavel Machek
2026-11-26 15:22 ` [PATCH 5.10.y-cip 26/27] dmaengine: sh: rz-dmac: Add suspend to RAM support Claudiu Beznea
2026-12-01 11:55 ` Pavel Machek
2026-11-26 15:22 ` [PATCH 5.10.y-cip 27/27] dmaengine: sh: rz-dmac: Fix off-by-one in residue lmdesc lookup Claudiu Beznea
2026-11-30 22:19 ` [PATCH 5.10.y-cip 00/27] Renesas: Backport DMA fixes and improvements Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox