Re: [PATCH v6 05/18] dmaengine: sh: rz-dmac: Add helper to compute the lmdesc address

From: Tommaso Merciai

Date: Thu May 28 2026 - 09:54:15 EST


On Tue, May 26, 2026 at 11:46:57AM +0300, Claudiu Beznea wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
>
> 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.
>

Tested-by: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>

Kind Regards,
Tommaso

> Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> Tested-by: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
> ---
>
> Changes in v6:
> - updated patch description
> - collected tags
>
> Changes in v5:
> - none
>
> Changes in v4:
> - none
>
> Changes in v3:
> - none, this patch is new
>
> 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 40ddf534c094..c48858b68dee 100644
> --- a/drivers/dma/sh/rz-dmac.c
> +++ b/drivers/dma/sh/rz-dmac.c
> @@ -259,6 +259,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;
> @@ -284,9 +290,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
>