dmaengine: ensure all DMA engine drivers initialize their cookies
authorRussell King - ARM Linux <linux@arm.linux.org.uk>
Tue, 6 Mar 2012 22:36:27 +0000 (22:36 +0000)
committerVinod Koul <vinod.koul@linux.intel.com>
Tue, 13 Mar 2012 06:07:42 +0000 (11:37 +0530)
Ensure all DMA engine drivers initialize their cookies in the same way,
so that they all behave in a similar fashion.  This means their first
issued cookie will be 2 rather than 1, and will increment to INT_MAX
before returning 1 and starting over.

In connection with this, Dan Williams said:
> Russell King wrote:
> > Secondly, some DMA engine drivers initialize the dma_chan cookie to 0,
> > others to 1.  Is there a reason for this, or are these all buggy?
>
> I know that ioat and iop-adma expect 0 to mean "I have cleaned up this
> descriptor and it is idle", and would break if zero was an in-flight
> cookie value.  The reserved usage of zero is an driver internal
> concern, but I have no problem formalizing it as a reserved value.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
[imx-sdma.c & mxs-dma.c]
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
drivers/dma/fsldma.c
drivers/dma/imx-dma.c
drivers/dma/imx-sdma.c
drivers/dma/ioat/dma.c
drivers/dma/iop-adma.c
drivers/dma/mv_xor.c
drivers/dma/mxs-dma.c
drivers/dma/ppc4xx/adma.c
drivers/dma/shdma.c

index 2f6c806126e2dd44a0d2b6c3936a32944571eec2..7d7384b3462138b7ad373447d650f1babd5bd309 100644 (file)
@@ -1292,6 +1292,7 @@ static int __devinit fsl_dma_chan_probe(struct fsldma_device *fdev,
        chan->idle = true;
 
        chan->common.device = &fdev->common;
+       dma_cookie_init(&chan->common);
 
        /* find the IRQ line, if it exists in the device tree */
        chan->irq = irq_of_parse_and_map(node, 0);
index 6731f1918c555de3f0ca127771bacabeb5612099..f0485c0a685adbc6d82ca6607fa038f531e14b56 100644 (file)
@@ -347,6 +347,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
                spin_lock_init(&imxdmac->lock);
 
                imxdmac->chan.device = &imxdma->dma_device;
+               dma_cookie_init(&imxdmac->chan);
                imxdmac->channel = i;
 
                /* Add the channel to the DMAC list */
index 981071ebd5c8bf3d23dd6f5234bf9f2105ef48c7..ccfc7c425c525b37227ed320ab9b35d5bc3acac7 100644 (file)
@@ -1355,6 +1355,7 @@ static int __init sdma_probe(struct platform_device *pdev)
                spin_lock_init(&sdmac->lock);
 
                sdmac->chan.device = &sdma->dma_device;
+               dma_cookie_init(&sdmac->chan);
                sdmac->channel = i;
 
                /*
index 97e100ce43ebebf73af12788c4145227532d7f67..31493d80e0e9dd0538546703317dbf60abe2247e 100644 (file)
@@ -109,6 +109,7 @@ void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *c
        chan->reg_base = device->reg_base + (0x80 * (idx + 1));
        spin_lock_init(&chan->cleanup_lock);
        chan->common.device = dma;
+       dma_cookie_init(&chan->common);
        list_add_tail(&chan->common.device_node, &dma->channels);
        device->idx[idx] = chan;
        init_timer(&chan->timer);
index 4370b1015f73e3b312377689e9510a45dac3118d..1f3a703ed0e0237d8c0ab9357e746db4e8428f56 100644 (file)
@@ -1545,6 +1545,7 @@ static int __devinit iop_adma_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&iop_chan->chain);
        INIT_LIST_HEAD(&iop_chan->all_slots);
        iop_chan->common.device = dma_dev;
+       dma_cookie_init(&iop_chan->common);
        list_add_tail(&iop_chan->common.device_node, &dma_dev->channels);
 
        if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) {
index 486353e60a0a2742eff7a94cb4f2b42f26e639a1..fa5d55fea46cc4829ba55b84a53cb42baafe81c9 100644 (file)
@@ -1193,6 +1193,7 @@ static int __devinit mv_xor_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&mv_chan->completed_slots);
        INIT_LIST_HEAD(&mv_chan->all_slots);
        mv_chan->common.device = dma_dev;
+       dma_cookie_init(&mv_chan->common);
 
        list_add_tail(&mv_chan->common.device_node, &dma_dev->channels);
 
index 5f3492e5d28f34494681b6d342fd482f302c88e6..a2267f9ab56887609ce6dc9d96985f3847dfa534 100644 (file)
@@ -618,6 +618,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 
                mxs_chan->mxs_dma = mxs_dma;
                mxs_chan->chan.device = &mxs_dma->dma_device;
+               dma_cookie_init(&mxs_chan->chan);
 
                tasklet_init(&mxs_chan->tasklet, mxs_dma_tasklet,
                             (unsigned long) mxs_chan);
index 975206257f6e5ab1e88ea5eca84e2d2687ad3814..ced98826684ae65da86539ab6fa4dad531503aa4 100644 (file)
@@ -4497,6 +4497,7 @@ static int __devinit ppc440spe_adma_probe(struct platform_device *ofdev)
        INIT_LIST_HEAD(&chan->all_slots);
        chan->device = adev;
        chan->common.device = &adev->common;
+       dma_cookie_init(&chan->common);
        list_add_tail(&chan->common.device_node, &adev->common.channels);
        tasklet_init(&chan->irq_tasklet, ppc440spe_adma_tasklet,
                     (unsigned long)chan);
index 50510ef7db72e5aa24afa2450b3b1f7a3837f5ef..5c4088603dd4645560098bb3f6e3eb25aeec2c66 100644 (file)
@@ -1089,6 +1089,7 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id,
 
        /* reference struct dma_device */
        new_sh_chan->common.device = &shdev->common;
+       dma_cookie_init(&new_sh_chan->common);
 
        new_sh_chan->dev = shdev->common.dev;
        new_sh_chan->id = id;