mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ludovic Desroches <ludovic.desroches@atmel.com>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Vinod Koul <vinod.koul@intel.com>, <dmaengine@vger.kernel.org>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Ludovic Desroches <ludovic.desroches@atmel.com>,
	Thomas Petazzoni <thomas@free-electrons.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/2] dmaengine: Move icg helpers to global header
Date: Mon, 1 Jun 2015 10:14:01 +0200	[thread overview]
Message-ID: <20150601081401.GG25118@odux.rfo.atmel.com> (raw)
In-Reply-To: <1432735313-481-2-git-send-email-maxime.ripard@free-electrons.com>

On Wed, May 27, 2015 at 04:01:52PM +0200, Maxime Ripard wrote:
> Now that we can have ICGs set for both the source and destination (using
> the icg field of struct data_chunk) or for only the source or the
> destination (using the dst_icg or src_icg respectively), and that these
> fields can be ignored depending on other parameters (src_inc, src_sgl,
> etc.), the logic to get the actual ICG value can be quite tricky.
> 
> The XDMAC driver was already implementing it, but since we will need it in
> other drivers, we can move it to the main header file.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>

> ---
>  drivers/dma/at_xdmac.c    | 46 ++++------------------------------------------
>  include/linux/dmaengine.h | 27 +++++++++++++++++++++++++++
>  2 files changed, 31 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index 9b602a67d40d..80e46e571bdd 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -862,20 +862,8 @@ at_xdmac_interleaved_queue_desc(struct dma_chan *chan,
>  
>  	desc->lld.mbr_sa = src;
>  	desc->lld.mbr_da = dst;
> -
> -	if (xt->src_inc && xt->src_sgl) {
> -		if (chunk->src_icg)
> -			desc->lld.mbr_sus = chunk->src_icg;
> -		else
> -			desc->lld.mbr_sus = chunk->icg;
> -	}
> -
> -	if (xt->dst_inc && xt->dst_sgl) {
> -		if (chunk->dst_icg)
> -			desc->lld.mbr_dus = chunk->dst_icg;
> -		else
> -			desc->lld.mbr_dus = chunk->icg;
> -	}
> +	desc->lld.mbr_sus = dmaengine_get_src_icg(xt, chunk);
> +	desc->lld.mbr_dus = dmaengine_get_dst_icg(xt, chunk);
>  
>  	desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV3
>  		| AT_XDMAC_MBR_UBC_NDEN
> @@ -895,32 +883,6 @@ at_xdmac_interleaved_queue_desc(struct dma_chan *chan,
>  	return desc;
>  }
>  
> -static size_t at_xdmac_get_icg(bool inc, bool sgl, size_t icg, size_t dir_icg)
> -{
> -	if (inc) {
> -		if (dir_icg)
> -			return dir_icg;
> -		else if (sgl)
> -			return icg;
> -	}
> -
> -	return 0;
> -}
> -
> -static size_t at_xdmac_get_dst_icg(struct dma_interleaved_template *xt,
> -				   struct data_chunk *chunk)
> -{
> -	return at_xdmac_get_icg(xt->dst_inc, xt->dst_sgl,
> -				chunk->icg, chunk->dst_icg);
> -}
> -
> -static size_t at_xdmac_get_src_icg(struct dma_interleaved_template *xt,
> -				   struct data_chunk *chunk)
> -{
> -	return at_xdmac_get_icg(xt->src_inc, xt->src_sgl,
> -				chunk->icg, chunk->src_icg);
> -}
> -
>  static struct dma_async_tx_descriptor *
>  at_xdmac_prep_interleaved(struct dma_chan *chan,
>  			  struct dma_interleaved_template *xt,
> @@ -950,8 +912,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
>  
>  		chunk = xt->sgl + i;
>  
> -		dst_icg = at_xdmac_get_dst_icg(xt, chunk);
> -		src_icg = at_xdmac_get_src_icg(xt, chunk);
> +		dst_icg = dmaengine_get_dst_icg(xt, chunk);
> +		src_icg = dmaengine_get_src_icg(xt, chunk);
>  
>  		src_skip = chunk->size + src_icg;
>  		dst_skip = chunk->size + dst_icg;
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 8faf6a2dd9d8..43a9a397b2d7 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -899,6 +899,33 @@ static inline int dma_maxpq(struct dma_device *dma, enum dma_ctrl_flags flags)
>  	BUG();
>  }
>  
> +static inline size_t dmaengine_get_icg(bool inc, bool sgl, size_t icg,
> +				      size_t dir_icg)
> +{
> +	if (inc) {
> +		if (dir_icg)
> +			return dir_icg;
> +		else if (sgl)
> +			return icg;
> +	}
> +
> +	return 0;
> +}
> +
> +static inline size_t dmaengine_get_dst_icg(struct dma_interleaved_template *xt,
> +					   struct data_chunk *chunk)
> +{
> +	return dmaengine_get_icg(xt->dst_inc, xt->dst_sgl,
> +				 chunk->icg, chunk->dst_icg);
> +}
> +
> +static inline size_t dmaengine_get_src_icg(struct dma_interleaved_template *xt,
> +					   struct data_chunk *chunk)
> +{
> +	return dmaengine_get_icg(xt->src_inc, xt->src_sgl,
> +				 chunk->icg, chunk->src_icg);
> +}
> +
>  /* --- public DMA engine API --- */
>  
>  #ifdef CONFIG_DMA_ENGINE
> -- 
> 2.4.1
> 

  reply	other threads:[~2015-06-01  8:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 14:01 [PATCH 0/2] dmaengine: hdmac: Implement interleaved transfers support Maxime Ripard
2015-05-27 14:01 ` [PATCH 1/2] dmaengine: Move icg helpers to global header Maxime Ripard
2015-06-01  8:14   ` Ludovic Desroches [this message]
2015-05-27 14:01 ` [PATCH 2/2] dmaengine: hdmac: Implement interleaved transfers Maxime Ripard
2015-06-01  8:32   ` Ludovic Desroches
2015-06-02  9:19     ` Maxime Ripard
2015-06-12 12:44 ` [PATCH 0/2] dmaengine: hdmac: Implement interleaved transfers support Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150601081401.GG25118@odux.rfo.atmel.com \
    --to=ludovic.desroches@atmel.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=thomas@free-electrons.com \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®