Re: [PATCH v8 6/8] dmaengine: sh: rz-dmac: Add rz_dmac_invalidate_lmdesc()
From: Frank Li
Date: Wed Feb 25 2026 - 11:32:09 EST
On Tue, Jan 20, 2026 at 03:33:28PM +0200, Claudiu wrote:
> From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
>
> Add rz_dmac_invalidate_lmdesc() so that the same code can be shared
> between rz_dmac_terminate_all() and rz_dmac_free_chan_resources().
>
> Based on a patch in the BSP by Long Luu <long.luu.ur@xxxxxxxxxxx>.
>
> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> [claudiu.beznea: adjusted the commit description; defined the lmdesc
> inside the for block to have more compact code]
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
>
> Changes in v8:
> - none
>
> Changes in v7:
> - none
>
> Changes in v6:
> - none
>
> Changes in v5:
> - adjusted the commit description
> - defined the lmdesc inside the for block
>
> drivers/dma/sh/rz-dmac.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
> index 1d2b50d6273b..4602f8b7408a 100644
> --- a/drivers/dma/sh/rz-dmac.c
> +++ b/drivers/dma/sh/rz-dmac.c
> @@ -256,6 +256,13 @@ static void rz_lmdesc_setup(struct rz_dmac_chan *channel,
> * Descriptors preparation
> */
>
> +static void rz_dmac_invalidate_lmdesc(struct rz_dmac_chan *channel)
> +{
> + for (struct rz_lmdesc *lmdesc = channel->lmdesc.base;
> + lmdesc < channel->lmdesc.base + DMAC_NR_LMDESC; lmdesc++)
> + lmdesc->header = 0;
> +}
> +
> static void rz_dmac_lmdesc_recycle(struct rz_dmac_chan *channel)
> {
> struct rz_lmdesc *lmdesc = channel->lmdesc.head;
> @@ -461,15 +468,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_dmac_invalidate_lmdesc(channel);
>
> rz_dmac_disable_hw(channel);
> list_splice_tail_init(&channel->ld_active, &channel->ld_free);
> @@ -561,15 +565,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_dmac_invalidate_lmdesc(channel);
>
> list_splice_tail_init(&channel->ld_active, &channel->ld_free);
> list_splice_tail_init(&channel->ld_queue, &channel->ld_free);
> --
> 2.43.0
>