RE: [PATCH v2 5/5] dmaengine: sh: rz-dmac: rz_dmac_prepare_descs_for_slave_sg() improvements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> Sent: Wednesday, April 5, 2023 3:09 PM
> To: Vinod Koul <vkoul@xxxxxxxxxx>
> Cc: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>; Geert Uytterhoeven
> <geert+renesas@xxxxxxxxx>; Prabhakar Mahadev Lad <prabhakar.mahadev-
> lad.rj@xxxxxxxxxxxxxx>; dmaengine@xxxxxxxxxxxxxxx; linux-renesas-
> soc@xxxxxxxxxxxxxxx
> Subject: [PATCH v2 5/5] dmaengine: sh: rz-dmac:
> rz_dmac_prepare_descs_for_slave_sg() improvements
> 
> Some code improvements for rz_dmac_prepare_descs_for_slave_sg().
> 
> Replace the loop for->for_each_sg and drop the variables sgl and sg_len.
> Also improve the logic for assigning lmdesc->chcfg and lmdesc->header and
> lastly, add lmdesc assignment along with the declaration.
> 
> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> ---
> v2:
>  * New patch.
> ---
>  drivers/dma/sh/rz-dmac.c | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index
> 153893045932..c6150d7ae8a7 100644
> --- a/drivers/dma/sh/rz-dmac.c
> +++ b/drivers/dma/sh/rz-dmac.c
> @@ -342,12 +342,12 @@ static void rz_dmac_prepare_desc_for_memcpy(struct
> rz_dmac_chan *channel)
> 
>  static void rz_dmac_prepare_descs_for_slave_sg(struct rz_dmac_chan
> *channel)  {
> +	struct rz_lmdesc *lmdesc = channel->lmdesc.tail;
>  	struct dma_chan *chan = &channel->vc.chan;
>  	struct rz_dmac *dmac = to_rz_dmac(chan->device);
>  	struct rz_dmac_desc *d = channel->desc;
> -	struct scatterlist *sg, *sgl = d->sg;
> -	struct rz_lmdesc *lmdesc;
> -	unsigned int i, sg_len = d->sgcount;
> +	struct scatterlist *sg;
> +	unsigned int i;
> 
>  	channel->chcfg |= CHCFG_SEL(channel->index) | CHCFG_DEM | CHCFG_DMS;
> 
> @@ -358,9 +358,7 @@ static void rz_dmac_prepare_descs_for_slave_sg(struct
> rz_dmac_chan *channel)
>  		channel->chcfg |= CHCFG_DAD | CHCFG_REQD;
>  	}
> 
> -	lmdesc = channel->lmdesc.tail;
> -
> -	for (i = 0, sg = sgl; i < sg_len; i++, sg = sg_next(sg)) {
> +	for_each_sg(d->sg, sg, d->sgcount, i) {
>  		if (d->direction == DMA_DEV_TO_MEM) {
>  			lmdesc->sa = channel->src_per_address;
>  			lmdesc->da = sg_dma_address(sg);
> @@ -372,13 +370,11 @@ static void rz_dmac_prepare_descs_for_slave_sg(struct
> rz_dmac_chan *channel)
>  		lmdesc->tb = sg_dma_len(sg);
>  		lmdesc->chitvl = 0;
>  		lmdesc->chext = 0;
> -		if (i == (sg_len - 1)) {
> -			lmdesc->chcfg = (channel->chcfg & ~CHCFG_DEM);
> -			lmdesc->header = HEADER_LV;
> -		} else {
> -			lmdesc->chcfg = channel->chcfg;
> -			lmdesc->header = HEADER_LV;
> -		}
> +		lmdesc->chcfg = channel->chcfg;
> +		lmdesc->header = HEADER_LV;
> +		if (i == (d->sgcount - 1))
> +			lmdesc->chcfg &= ~CHCFG_DEM;

To match with previous code flow,

lmdesc->header = HEADER_LV; should be after lmdesc->chcfg &= ~CHCFG_DEM;

I will change this in next version.

Cheers,
Biju




> +
>  		if (++lmdesc >= (channel->lmdesc.base + DMAC_NR_LMDESC))
>  			lmdesc = channel->lmdesc.base;
>  	}
> --
> 2.25.1





[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux