Skip to content

Commit

Permalink
dmaengine: Move icg helpers to global header
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  • Loading branch information
Maxime Ripard authored and Vinod Koul committed Jun 12, 2015
1 parent 6007ccb commit 87d001e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
46 changes: 4 additions & 42 deletions drivers/dma/at_xdmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions include/linux/dmaengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,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
Expand Down

0 comments on commit 87d001e

Please sign in to comment.