Skip to content

Commit

Permalink
dma: edma: Setup parameters to DMA MAX_NR_SG at a time
Browse files Browse the repository at this point in the history
Changes are made here for configuring existing parameters to support
DMA'ing them out in batches as needed.

Also allocate as many as slots as needed by the SG list, but not more
than MAX_NR_SG. Then these slots will be reused accordingly.
For ex, if MAX_NR_SG=10, and number of SG entries is 40, still only
10 slots will be allocated to DMA the entire SG list of size 40.

Also enable TC interrupts for slots that are a last in a current
iteration, or that fall on a MAX_NR_SG boundary.

Signed-off-by: Joel Fernandes <joelf@ti.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  • Loading branch information
Joel Fernandes authored and Vinod Koul committed Sep 4, 2013
1 parent bd12763 commit 6fbe24d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions drivers/dma/edma.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
enum dma_slave_buswidth dev_width;
u32 burst;
struct scatterlist *sg;
int i;
int acnt, bcnt, ccnt, src, dst, cidx;
int src_bidx, dst_bidx, src_cidx, dst_cidx;
int i, nslots;

if (unlikely(!echan || !sgl || !sg_len))
return NULL;
Expand Down Expand Up @@ -262,8 +262,10 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(

edesc->pset_nr = sg_len;

for_each_sg(sgl, sg, sg_len, i) {
/* Allocate a PaRAM slot, if needed */
/* Allocate a PaRAM slot, if needed */
nslots = min_t(unsigned, MAX_NR_SG, sg_len);

for (i = 0; i < nslots; i++) {
if (echan->slot[i] < 0) {
echan->slot[i] =
edma_alloc_slot(EDMA_CTLR(echan->ch_num),
Expand All @@ -273,6 +275,10 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
return NULL;
}
}
}

/* Configure PaRAM sets for each SG */
for_each_sg(sgl, sg, sg_len, i) {

acnt = dev_width;

Expand Down Expand Up @@ -330,6 +336,12 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
/* Configure A or AB synchronized transfers */
if (edesc->absync)
edesc->pset[i].opt |= SYNCDIM;

/* If this is the last in a current SG set of transactions,
enable interrupts so that next set is processed */
if (!((i+1) % MAX_NR_SG))
edesc->pset[i].opt |= TCINTEN;

/* If this is the last set, enable completion interrupt flag */
if (i == sg_len - 1)
edesc->pset[i].opt |= TCINTEN;
Expand Down

0 comments on commit 6fbe24d

Please sign in to comment.