From patchwork Tue Mar 6 22:36:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 145039 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 99FEFB7492 for ; Wed, 7 Mar 2012 09:39:45 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1S52zw-0004GU-1x; Tue, 06 Mar 2012 22:36:48 +0000 Received: from [2002:4e20:1eda::1] (helo=caramon.arm.linux.org.uk) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1S52zp-0004CW-SN for linux-arm-kernel@lists.infradead.org; Tue, 06 Mar 2012 22:36:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Date:Sender:Message-Id:Content-Type:MIME-Version:Cc:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Cc:Cc:To:From:References:In-Reply-To; bh=vJGUMu76CGm9tdI5ujQM3dxdaoGBHMY+eNrmD73RH4c=; b=XQfGkbN5esfS8kFFLRx8mZEsIC9pcEoiO2b/JJl1pFkB93R/N4plyKNTg66gpNM9pe7FWXyQbzels9rcA/ImwdLmTBE9yY9X46MVrTYnbxlYCLHiIeTncn9KWdrgNnkv7P9gMZ4SyVPnDbfe71BhVLOjctd20+Fn6Y469WPsIKg=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:48545 helo=rmk-PC.arm.linux.org.uk) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1S52zd-0002P1-8V; Tue, 06 Mar 2012 22:36:29 +0000 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1S52zb-0002NE-La; Tue, 06 Mar 2012 22:36:27 +0000 In-Reply-To: <20120306223321.GD15201@n2100.arm.linux.org.uk> References: <20120306223321.GD15201@n2100.arm.linux.org.uk> From: Russell King - ARM Linux To: Dan Williams , Vinod Koul Subject: [PATCH 9/9] dmaengine: ensure all DMA engine drivers initialize their cookies MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 06 Mar 2012 22:36:27 +0000 X-MIME-Error: demime acl condition: double headers (content-type, content-disposition or content-transfer-encoding) X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS Cc: linuxppc-dev@lists.ozlabs.org, Li Yang , Stephen Warren , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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 --- drivers/dma/fsldma.c | 1 + drivers/dma/imx-dma.c | 1 + drivers/dma/imx-sdma.c | 1 + drivers/dma/ioat/dma.c | 1 + drivers/dma/iop-adma.c | 1 + drivers/dma/mv_xor.c | 1 + drivers/dma/mxs-dma.c | 1 + drivers/dma/ppc4xx/adma.c | 1 + drivers/dma/shdma.c | 1 + 9 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index 2f6c806..7d7384b 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c @@ -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); diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index ba317e6..4e14f51 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c @@ -348,6 +348,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 */ diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 4406be2..0be36a4 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1356,6 +1356,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; /* diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index 97e100c..31493d8 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c @@ -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); diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c index 4370b10..1f3a703 100644 --- a/drivers/dma/iop-adma.c +++ b/drivers/dma/iop-adma.c @@ -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)) { diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index 486353e..fa5d55f 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c @@ -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); diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index 5f3492e..a2267f9 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c @@ -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); diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c index 9752062..ced9882 100644 --- a/drivers/dma/ppc4xx/adma.c +++ b/drivers/dma/ppc4xx/adma.c @@ -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); diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c index 50510ef..5c40886 100644 --- a/drivers/dma/shdma.c +++ b/drivers/dma/shdma.c @@ -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;