Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754837Ab2BFLg0 (ORCPT ); Mon, 6 Feb 2012 06:36:26 -0500 Received: from mga09.intel.com ([134.134.136.24]:10535 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754589Ab2BFLgZ (ORCPT ); Mon, 6 Feb 2012 06:36:25 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,352,1309762800"; d="scan'208";a="104482662" Subject: Re: [PATCH v3] dmaengine: Add support for MEMCPY for imx-dma. From: Vinod Koul To: Javier Martin Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dan.j.williams@intel.com, s.hauer@pengutronix.de In-Reply-To: <1328006840-7345-1-git-send-email-javier.martin@vista-silicon.com> References: <1328006840-7345-1-git-send-email-javier.martin@vista-silicon.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 06 Feb 2012 17:08:14 +0530 Message-ID: <1328528294.26182.80.camel@vkoul-udesk3> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3638 Lines: 98 On Tue, 2012-01-31 at 11:47 +0100, Javier Martin wrote: > MEMCPY transfers allow DMA copies from memory to > memory. This patch has been tested with dmatest > device driver. > > Signed-off-by: Javier Martin > --- > drivers/dma/imx-dma.c | 36 +++++++++++++++++++++++++++++++++++- > 1 files changed, 35 insertions(+), 1 deletions(-) > > diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c > index 3296a73..9aa6e85 100644 > --- a/drivers/dma/imx-dma.c > +++ b/drivers/dma/imx-dma.c > @@ -196,7 +196,8 @@ static int imxdma_alloc_chan_resources(struct dma_chan *chan) > struct imxdma_channel *imxdmac = to_imxdma_chan(chan); > struct imx_dma_data *data = chan->private; > > - imxdmac->dma_request = data->dma_request; > + if (data != NULL) > + imxdmac->dma_request = data->dma_request; if you support memcopy then why should it _always_ require private pointer? > > dma_async_tx_descriptor_init(&imxdmac->desc, chan); > imxdmac->desc.tx_submit = imxdma_tx_submit; > @@ -328,6 +329,36 @@ static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic( > return &imxdmac->desc; > } > > +static struct dma_async_tx_descriptor *imxdma_prep_dma_memcpy( > + struct dma_chan *chan, dma_addr_t dest, > + dma_addr_t src, size_t len, unsigned long flags) > +{ > + struct imxdma_channel *imxdmac = to_imxdma_chan(chan); > + struct imxdma_engine *imxdma = imxdmac->imxdma; > + int ret; > + > + dev_dbg(imxdma->dev, "%s channel: %d src=0x%x dst=0x%x len=%d\n", > + __func__, imxdmac->channel, src, dest, len); > + > + if (imxdmac->status == DMA_IN_PROGRESS) > + return NULL; thats not right, you should be able to prepare descriptors even if dmac is busy. Prepare != start > + imxdmac->status = DMA_IN_PROGRESS; > + > + ret = imx_dma_config_channel(imxdmac->imxdma_channel, > + IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, > + IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, > + 0, 0); > + if (ret) > + return NULL; > + > + ret = imx_dma_setup_single(imxdmac->imxdma_channel, src, len, > + dest, DMA_MODE_WRITE); > + if (ret) > + return NULL; > + > + return &imxdmac->desc; > +} > + > static void imxdma_issue_pending(struct dma_chan *chan) > { > struct imxdma_channel *imxdmac = to_imxdma_chan(chan); > @@ -349,6 +380,7 @@ static int __init imxdma_probe(struct platform_device *pdev) > > dma_cap_set(DMA_SLAVE, imxdma->dma_device.cap_mask); > dma_cap_set(DMA_CYCLIC, imxdma->dma_device.cap_mask); > + dma_cap_set(DMA_MEMCPY, imxdma->dma_device.cap_mask); > > /* Initialize channel parameters */ > for (i = 0; i < MAX_DMA_CHANNELS; i++) { > @@ -382,11 +414,13 @@ static int __init imxdma_probe(struct platform_device *pdev) > imxdma->dma_device.device_tx_status = imxdma_tx_status; > imxdma->dma_device.device_prep_slave_sg = imxdma_prep_slave_sg; > imxdma->dma_device.device_prep_dma_cyclic = imxdma_prep_dma_cyclic; > + imxdma->dma_device.device_prep_dma_memcpy = imxdma_prep_dma_memcpy; > imxdma->dma_device.device_control = imxdma_control; > imxdma->dma_device.device_issue_pending = imxdma_issue_pending; > > platform_set_drvdata(pdev, imxdma); > > + imxdma->dma_device.copy_align = 2; /* 2^2 = 4 bytes alignment */ what is this magic number? > imxdma->dma_device.dev->dma_parms = &imxdma->dma_parms; > dma_set_max_seg_size(imxdma->dma_device.dev, 0xffffff); > -- ~Vinod -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/