Skip to content

Commit f1ac572

Browse files
Alexandre BounineRohan Somvanshi
Alexandre Bounine
authored and
Rohan Somvanshi
committed
dmaengine: add context parameter to prep_slave_sg and prep_dma_cyclic
Add context parameter to device_prep_slave_sg() and device_prep_dma_cyclic() interfaces to allow passing client/target specific information associated with the data transfer. Modify all affected DMA engine drivers. Signed-off-by: Alexandre Bounine <[email protected]> Acked-by: Linus Walleij <[email protected]> Acked-by: Felipe Balbi <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Cherry-picked from mainline 185ecb5 Change-Id: Ief79d20f6e9d367ee2b530d08df72864fb16895a Signed-off-by: Laxman Dewangan <[email protected]> Reviewed-on: http://git-master/r/94464 Reviewed-by: Automatic_Commit_Validation_User
1 parent a9eb124 commit f1ac572

19 files changed

+106
-74
lines changed

drivers/dma/amba-pl08x.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_dma_memcpy(
13461346

13471347
static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
13481348
struct dma_chan *chan, struct scatterlist *sgl,
1349-
unsigned int sg_len, enum dma_data_direction direction,
1350-
unsigned long flags)
1349+
unsigned long flags, void *context)
13511350
{
13521351
struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
13531352
struct pl08x_driver_data *pl08x = plchan->host;

drivers/dma/at_hdmac.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,12 @@ atc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
633633
* @sg_len: number of entries in @scatterlist
634634
* @direction: DMA direction
635635
* @flags: tx descriptor status flags
636+
* @context: transaction context (ignored)
636637
*/
637638
static struct dma_async_tx_descriptor *
638639
atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
639-
unsigned int sg_len, enum dma_data_direction direction,
640-
unsigned long flags)
640+
unsigned int sg_len, enum dma_transfer_direction direction,
641+
unsigned long flags, void *context)
641642
{
642643
struct at_dma_chan *atchan = to_at_dma_chan(chan);
643644
struct at_dma_slave *atslave = chan->private;
@@ -834,10 +835,12 @@ atc_dma_cyclic_fill_desc(struct at_dma_slave *atslave, struct at_desc *desc,
834835
* @buf_len: total number of bytes for the entire buffer
835836
* @period_len: number of bytes for each period
836837
* @direction: transfer direction, to or from device
838+
* @context: transfer context (ignored)
837839
*/
838840
static struct dma_async_tx_descriptor *
839841
atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
840-
size_t period_len, enum dma_data_direction direction)
842+
size_t period_len, enum dma_transfer_direction direction,
843+
void *context)
841844
{
842845
struct at_dma_chan *atchan = to_at_dma_chan(chan);
843846
struct at_dma_slave *atslave = chan->private;

drivers/dma/coh901318.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,8 @@ coh901318_prep_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
10201020

10211021
static struct dma_async_tx_descriptor *
10221022
coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
1023-
unsigned int sg_len, enum dma_data_direction direction,
1024-
unsigned long flags)
1023+
unsigned int sg_len, enum dma_transfer_direction direction,
1024+
unsigned long flags, void *context)
10251025
{
10261026
struct coh901318_chan *cohc = to_coh901318_chan(chan);
10271027
struct coh901318_lli *lli;

drivers/dma/dw_dmac.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
716716

717717
static struct dma_async_tx_descriptor *
718718
dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
719-
unsigned int sg_len, enum dma_data_direction direction,
720-
unsigned long flags)
719+
unsigned int sg_len, enum dma_transfer_direction direction,
720+
unsigned long flags, void *context)
721721
{
722722
struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
723723
struct dw_dma_slave *dws = chan->private;

drivers/dma/ep93xx_dma.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -942,13 +942,14 @@ ep93xx_dma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest,
942942
* @sg_len: number of entries in @sgl
943943
* @dir: direction of tha DMA transfer
944944
* @flags: flags for the descriptor
945+
* @context: operation context (ignored)
945946
*
946947
* Returns a valid DMA descriptor or %NULL in case of failure.
947948
*/
948949
static struct dma_async_tx_descriptor *
949950
ep93xx_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
950-
unsigned int sg_len, enum dma_data_direction dir,
951-
unsigned long flags)
951+
unsigned int sg_len, enum dma_transfer_direction dir,
952+
unsigned long flags, void *context)
952953
{
953954
struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
954955
struct ep93xx_dma_desc *desc, *first;
@@ -1015,6 +1016,7 @@ ep93xx_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
10151016
* @buf_len: length of the buffer (in bytes)
10161017
* @period_len: lenght of a single period
10171018
* @dir: direction of the operation
1019+
* @context: operation context (ignored)
10181020
*
10191021
* Prepares a descriptor for cyclic DMA operation. This means that once the
10201022
* descriptor is submitted, we will be submitting in a @period_len sized
@@ -1027,7 +1029,7 @@ ep93xx_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
10271029
static struct dma_async_tx_descriptor *
10281030
ep93xx_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
10291031
size_t buf_len, size_t period_len,
1030-
enum dma_data_direction dir)
1032+
enum dma_transfer_direction dir, void *context)
10311033
{
10321034
struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan);
10331035
struct ep93xx_dma_desc *desc, *first;

drivers/dma/fsldma.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,16 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_sg(struct dma_chan *dchan,
759759
* @sg_len: number of entries in @scatterlist
760760
* @direction: DMA direction
761761
* @flags: DMAEngine flags
762+
* @context: transaction context (ignored)
762763
*
763764
* Prepare a set of descriptors for a DMA_SLAVE transaction. Following the
764765
* DMA_SLAVE API, this gets the device-specific information from the
765766
* chan->private variable.
766767
*/
767768
static struct dma_async_tx_descriptor *fsl_dma_prep_slave_sg(
768769
struct dma_chan *dchan, struct scatterlist *sgl, unsigned int sg_len,
769-
enum dma_data_direction direction, unsigned long flags)
770+
enum dma_transfer_direction direction, unsigned long flags,
771+
void *context)
770772
{
771773
/*
772774
* This operation is not supported on the Freescale DMA controller

drivers/dma/imx-dma.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ static void imxdma_free_chan_resources(struct dma_chan *chan)
201201

202202
static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
203203
struct dma_chan *chan, struct scatterlist *sgl,
204-
unsigned int sg_len, enum dma_data_direction direction,
205-
unsigned long flags)
204+
unsigned int sg_len, enum dma_transfer_direction direction,
205+
unsigned long flags, void *context)
206206
{
207207
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
208208
struct scatterlist *sg;
@@ -248,7 +248,8 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
248248

249249
static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic(
250250
struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
251-
size_t period_len, enum dma_data_direction direction)
251+
size_t period_len, enum dma_transfer_direction direction,
252+
void *context)
252253
{
253254
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
254255
struct imxdma_engine *imxdma = imxdmac->imxdma;

drivers/dma/imx-sdma.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
886886

887887
static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
888888
struct dma_chan *chan, struct scatterlist *sgl,
889-
unsigned int sg_len, enum dma_data_direction direction,
890-
unsigned long flags)
889+
unsigned int sg_len, enum dma_transfer_direction direction,
890+
unsigned long flags, void *context)
891891
{
892892
struct sdma_channel *sdmac = to_sdma_chan(chan);
893893
struct sdma_engine *sdma = sdmac->sdma;
@@ -983,7 +983,8 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
983983

984984
static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic(
985985
struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
986-
size_t period_len, enum dma_data_direction direction)
986+
size_t period_len, enum dma_transfer_direction direction,
987+
void *context)
987988
{
988989
struct sdma_channel *sdmac = to_sdma_chan(chan);
989990
struct sdma_engine *sdma = sdmac->sdma;
@@ -1094,12 +1095,8 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan,
10941095

10951096
last_used = chan->cookie;
10961097

1097-
<<<<<<< HEAD
1098-
dma_set_tx_state(txstate, sdmac->last_completed, last_used, 0);
1099-
=======
11001098
dma_set_tx_state(txstate, chan->completed_cookie, last_used,
11011099
sdmac->chn_count - sdmac->chn_real_count);
1102-
>>>>>>> 4d4e58d... dmaengine: move last completed cookie into generic dma_chan structure
11031100

11041101
return sdmac->status;
11051102
}

drivers/dma/intel_mid_dma.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,14 @@ static struct dma_async_tx_descriptor *intel_mid_dma_prep_memcpy(
708708
* @sg_len: length of sg txn
709709
* @direction: DMA transfer dirtn
710710
* @flags: DMA flags
711+
* @context: transfer context (ignored)
711712
*
712713
* Prepares LLI based periphral transfer
713714
*/
714715
static struct dma_async_tx_descriptor *intel_mid_dma_prep_slave_sg(
715716
struct dma_chan *chan, struct scatterlist *sgl,
716-
unsigned int sg_len, enum dma_data_direction direction,
717-
unsigned long flags)
717+
unsigned int sg_len, enum dma_transfer_direction direction,
718+
unsigned long flags, void *context)
718719
{
719720
struct intel_mid_dma_chan *midc = NULL;
720721
struct intel_mid_dma_slave *mids = NULL;
@@ -1093,12 +1094,8 @@ static int mid_setup_dma(struct pci_dev *pdev)
10931094
struct intel_mid_dma_chan *midch = &dma->ch[i];
10941095

10951096
midch->chan.device = &dma->common;
1096-
<<<<<<< HEAD
1097-
midch->chan.cookie = 1;
10981097
midch->chan.chan_id = i;
1099-
=======
11001098
dma_cookie_init(&midch->chan);
1101-
>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
11021099
midch->ch_id = dma->chan_base + i;
11031100
pr_debug("MDMA:Init CH %d, ID %d\n", i, midch->ch_id);
11041101

drivers/dma/ipu/ipu_idmac.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,8 @@ static void ipu_gc_tasklet(unsigned long arg)
13561356
/* Allocate and initialise a transfer descriptor. */
13571357
static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan,
13581358
struct scatterlist *sgl, unsigned int sg_len,
1359-
enum dma_data_direction direction, unsigned long tx_flags)
1359+
enum dma_transfer_direction direction, unsigned long tx_flags,
1360+
void *context)
13601361
{
13611362
struct idmac_channel *ichan = to_idmac_chan(chan);
13621363
struct idmac_tx_desc *desc = NULL;
@@ -1634,15 +1635,7 @@ static int __init ipu_idmac_init(struct ipu *ipu)
16341635
snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i);
16351636

16361637
dma_chan->device = &idmac->dma;
1637-
<<<<<<< HEAD
1638-
dma_chan->cookie = 1;
1639-
<<<<<<< HEAD
1640-
dma_chan->completed_cookie = -ENXIO;
1641-
=======
1642-
=======
16431638
dma_cookie_init(dma_chan);
1644-
>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
1645-
>>>>>>> 1e15982... dmaengine: consolidate initialization of cookies
16461639
dma_chan->chan_id = i;
16471640
list_add_tail(&dma_chan->device_node, &dma->channels);
16481641
}

drivers/dma/mxs-dma.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan)
363363

364364
static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(
365365
struct dma_chan *chan, struct scatterlist *sgl,
366-
unsigned int sg_len, enum dma_data_direction direction,
367-
unsigned long append)
366+
unsigned int sg_len, enum dma_transfer_direction direction,
367+
unsigned long append, void *context)
368368
{
369369
struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
370370
struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
@@ -458,7 +458,8 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(
458458

459459
static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic(
460460
struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
461-
size_t period_len, enum dma_data_direction direction)
461+
size_t period_len, enum dma_transfer_direction direction,
462+
void *context)
462463
{
463464
struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
464465
struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;

drivers/dma/pch_dma.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,8 @@ static void pd_issue_pending(struct dma_chan *chan)
587587

588588
static struct dma_async_tx_descriptor *pd_prep_slave_sg(struct dma_chan *chan,
589589
struct scatterlist *sgl, unsigned int sg_len,
590-
enum dma_data_direction direction, unsigned long flags)
590+
enum dma_transfer_direction direction, unsigned long flags,
591+
void *context)
591592
{
592593
struct pch_dma_chan *pd_chan = to_pd_chan(chan);
593594
struct pch_dma_slave *pd_slave = chan->private;
@@ -914,12 +915,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
914915
struct pch_dma_chan *pd_chan = &pd->channels[i];
915916

916917
pd_chan->chan.device = &pd->dma;
917-
<<<<<<< HEAD
918-
pd_chan->chan.cookie = 1;
919-
pd_chan->chan.chan_id = i;
920-
=======
921918
dma_cookie_init(&pd_chan->chan);
922-
>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
923919

924920
pd_chan->membase = &regs->desc[i];
925921

drivers/dma/pl330.c

+50-2
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,54 @@ static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len)
503503
return burst_len;
504504
}
505505

506+
static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic(
507+
struct dma_chan *chan, dma_addr_t dma_addr, size_t len,
508+
size_t period_len, enum dma_transfer_direction direction,
509+
void *context)
510+
{
511+
struct dma_pl330_desc *desc;
512+
struct dma_pl330_chan *pch = to_pchan(chan);
513+
dma_addr_t dst;
514+
dma_addr_t src;
515+
516+
desc = pl330_get_desc(pch);
517+
if (!desc) {
518+
dev_err(pch->dmac->pif.dev, "%s:%d Unable to fetch desc\n",
519+
__func__, __LINE__);
520+
return NULL;
521+
}
522+
523+
switch (direction) {
524+
case DMA_MEM_TO_DEV:
525+
desc->rqcfg.src_inc = 1;
526+
desc->rqcfg.dst_inc = 0;
527+
desc->req.rqtype = MEMTODEV;
528+
src = dma_addr;
529+
dst = pch->fifo_addr;
530+
break;
531+
case DMA_DEV_TO_MEM:
532+
desc->rqcfg.src_inc = 0;
533+
desc->rqcfg.dst_inc = 1;
534+
desc->req.rqtype = DEVTOMEM;
535+
src = pch->fifo_addr;
536+
dst = dma_addr;
537+
break;
538+
default:
539+
dev_err(pch->dmac->pif.dev, "%s:%d Invalid dma direction\n",
540+
__func__, __LINE__);
541+
return NULL;
542+
}
543+
544+
desc->rqcfg.brst_size = pch->burst_sz;
545+
desc->rqcfg.brst_len = 1;
546+
547+
pch->cyclic = true;
548+
549+
fill_px(&desc->px, dst, src, period_len);
550+
551+
return &desc->txd;
552+
}
553+
506554
static struct dma_async_tx_descriptor *
507555
pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
508556
dma_addr_t src, size_t len, unsigned long flags)
@@ -550,8 +598,8 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
550598

551599
static struct dma_async_tx_descriptor *
552600
pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
553-
unsigned int sg_len, enum dma_data_direction direction,
554-
unsigned long flg)
601+
unsigned int sg_len, enum dma_transfer_direction direction,
602+
unsigned long flg, void *context)
555603
{
556604
struct dma_pl330_desc *first, *desc = NULL;
557605
struct dma_pl330_chan *pch = to_pchan(chan);

drivers/dma/shdma.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_memcpy(
624624

625625
static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg(
626626
struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len,
627-
enum dma_data_direction direction, unsigned long flags)
627+
enum dma_transfer_direction direction, unsigned long flags,
628+
void *context)
628629
{
629630
struct sh_dmae_slave *param;
630631
struct sh_dmae_chan *sh_chan;

drivers/dma/sirf-dma.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ static struct dma_async_tx_descriptor *sirfsoc_dma_prep_interleaved(
488488
static struct dma_async_tx_descriptor *
489489
sirfsoc_dma_prep_cyclic(struct dma_chan *chan, dma_addr_t addr,
490490
size_t buf_len, size_t period_len,
491-
enum dma_transfer_direction direction)
491+
enum dma_transfer_direction direction, void *context)
492492
{
493493
struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan);
494494
struct sirfsoc_dma_desc *sdesc = NULL;

drivers/dma/ste_dma40.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -2097,8 +2097,9 @@ d40_prep_memcpy_sg(struct dma_chan *chan,
20972097
static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan,
20982098
struct scatterlist *sgl,
20992099
unsigned int sg_len,
2100-
enum dma_data_direction direction,
2101-
unsigned long dma_flags)
2100+
enum dma_transfer_direction direction,
2101+
unsigned long dma_flags,
2102+
void *context)
21022103
{
21032104
if (direction != DMA_FROM_DEVICE && direction != DMA_TO_DEVICE)
21042105
return NULL;
@@ -2109,7 +2110,7 @@ static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan,
21092110
static struct dma_async_tx_descriptor *
21102111
dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
21112112
size_t buf_len, size_t period_len,
2112-
enum dma_data_direction direction)
2113+
enum dma_transfer_direction direction, void *context)
21132114
{
21142115
unsigned int periods = buf_len / period_len;
21152116
struct dma_async_tx_descriptor *txd;

drivers/dma/timb_dma.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ static void td_issue_pending(struct dma_chan *chan)
546546

547547
static struct dma_async_tx_descriptor *td_prep_slave_sg(struct dma_chan *chan,
548548
struct scatterlist *sgl, unsigned int sg_len,
549-
enum dma_data_direction direction, unsigned long flags)
549+
enum dma_transfer_direction direction, unsigned long flags,
550+
void *context)
550551
{
551552
struct timb_dma_chan *td_chan =
552553
container_of(chan, struct timb_dma_chan, chan);
@@ -754,12 +755,8 @@ static int __devinit td_probe(struct platform_device *pdev)
754755
}
755756

756757
td_chan->chan.device = &td->dma;
757-
<<<<<<< HEAD
758-
td_chan->chan.cookie = 1;
759758
td_chan->chan.chan_id = i;
760-
=======
761759
dma_cookie_init(&td_chan->chan);
762-
>>>>>>> d3ee98cdc... dmaengine: consolidate initialization of cookies
763760
spin_lock_init(&td_chan->lock);
764761
INIT_LIST_HEAD(&td_chan->active_list);
765762
INIT_LIST_HEAD(&td_chan->queue);

0 commit comments

Comments
 (0)