Re: [PATCH 2/3] dma: edma: Add support for Cyclic DMA

2013-10-31 Thread Vinod Koul
On Thu, Oct 24, 2013 at 12:57:02PM -0500, Joel Fernandes wrote:
 Rebased on slave-dma/next branch and reapplied:
Looks like your MUA caused lines to get wrapped and patch is corrupt, can you
pls resend again using git-send email. I tried even the patch from
patchworks but that too failed!
 
 8---
 From: Joel Fernandes jo...@ti.com
 Subject: [PATCH v2] dma: edma: Add support for Cyclic DMA
 
 Using the PaRAM configuration function that we split for reuse by the
 different DMA types, we implement Cyclic DMA support.
 For the cyclic case, we pass different configuration parameters to this
 function, and handle all the Cyclic-specific functionality separately.
 
 Callbacks to the DMA users are handled using vchan_cyclic_callback in
 the virt-dma layer. Linking is handled the same way as the slave SG case
 except for the last slot where we link it back to the first one in a
 cyclic fashion.
 
 For continuity, we check for cases where no.of periods is great than the
 MAX number of slots the driver can allocate for a particular descriptor
 and error out on such cases.
 
 Signed-off-by: Joel Fernandes jo...@ti.com
 ---
  drivers/dma/edma.c | 159 
 ++---
  1 file changed, 151 insertions(+), 8 deletions(-)
 

   struct edma_chan *echan = data;
 @@ -464,24 +602,28 @@ static void edma_callback(unsigned ch_num, u16 
 ch_status,
 void *data)
This seems bad
   unsigned long flags;
   struct edmacc_param p;
 
 - /* Pause the channel */
 - edma_pause(echan-ch_num);
 + edesc = echan-edesc;
 +
 + /* Pause the channel for non-cyclic */
 + if (!edesc || (edesc  !edesc-cyclic))
 + edma_pause(echan-ch_num);
 
   switch (ch_status) {
   case DMA_COMPLETE:
   spin_lock_irqsave(echan-vchan.lock, flags);
 
 - edesc = echan-edesc;
   if (edesc) {
 - if (edesc-processed == edesc-pset_nr) {
 + if (edesc-cyclic) {
 + vchan_cyclic_callback(edesc-vdesc);
 + } else if (edesc-processed == edesc-pset_nr) {
   dev_dbg(dev, Transfer complete, stopping 
 channel %d\n, ch_num);
   edma_stop(echan-ch_num);
   vchan_cookie_complete(edesc-vdesc);
 + edma_execute(echan);
   } else {
   dev_dbg(dev, Intermediate transfer complete on 
 channel %d\n, ch_num);
 + edma_execute(echan);
   }
 -
 - edma_execute(echan);
   }
 
   spin_unlock_irqrestore(echan-vchan.lock, flags);
 @@ -677,6 +819,7 @@ static void edma_dma_init(struct edma_cc *ecc, struct
 dma_device *dma,
ditto and few other which checkpatch was not happy about!
 struct device *dev)
  {
   dma-device_prep_slave_sg = edma_prep_slave_sg;
 + dma-device_prep_dma_cyclic = edma_prep_dma_cyclic;
   dma-device_alloc_chan_resources = edma_alloc_chan_resources;
   dma-device_free_chan_resources = edma_free_chan_resources;
   dma-device_issue_pending = edma_issue_pending;
 -- 
 1.8.1.2
 

--
~Vinod
___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


Re: [PATCH 2/3] dma: edma: Add support for Cyclic DMA

2013-10-31 Thread Joel Fernandes
On 10/31/2013 09:10 AM, Vinod Koul wrote:
 On Thu, Oct 24, 2013 at 12:57:02PM -0500, Joel Fernandes wrote:
 Rebased on slave-dma/next branch and reapplied:
 Looks like your MUA caused lines to get wrapped and patch is corrupt, can you
 pls resend again using git-send email. I tried even the patch from
 patchworks but that too failed!

Oops my bad, I ran into wordwrap issues. thanks for pointing this out, fixed my
MUA and wont happen again!

Will rebase/resend through git-send-email

thanks,

-Joel

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


Re: [PATCH 2/3] dma: edma: Add support for Cyclic DMA

2013-10-24 Thread Vinod Koul
On Tue, Oct 22, 2013 at 10:30:43AM -0500, Joel Fernandes wrote:
 On 10/21/2013 01:53 AM, Vinod Koul wrote:
  On Mon, Sep 23, 2013 at 06:05:14PM -0500, Joel Fernandes wrote:
  +  nr_periods = (buf_len / period_len) + 1;
  ?
  
  consider the case of buf = period_len, above makes nr_period = 2.
  
  Or buf len 100, period len 50, makes nr_period = 3
  
  Both doesnt seem right to me?
 
 I guess that variable name is misleading.
 
 nr_periods is actually the total no.of slots needed to process the request. 
 Its
 value is 1 greater than the total number of periods.
Okay sounds good to me. I tried applying below but looks like it fails as I have
already applied, 1  3. Can you pls rebase this resend

--
~Vinod
___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


Re: [PATCH 2/3] dma: edma: Add support for Cyclic DMA

2013-10-21 Thread Vinod Koul
On Mon, Sep 23, 2013 at 06:05:14PM -0500, Joel Fernandes wrote:
 
 @@ -449,6 +455,138 @@ static struct dma_async_tx_descriptor 
 *edma_prep_slave_sg(
   return vchan_tx_prep(echan-vchan, edesc-vdesc, tx_flags);
  }
  
 +static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
 + struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
 + size_t period_len, enum dma_transfer_direction direction,
 + unsigned long tx_flags, void *context)
 +{
 + struct edma_chan *echan = to_edma_chan(chan);
 + struct device *dev = chan-device-dev;
 + struct edma_desc *edesc;
 + dma_addr_t src_addr, dst_addr;
 + enum dma_slave_buswidth dev_width;
 + u32 burst;
 + int i, ret, nr_periods;
 +
 + if (unlikely(!echan || !buf_len || !period_len))
 + return NULL;
 +
 + if (direction == DMA_DEV_TO_MEM) {
 + src_addr = echan-cfg.src_addr;
 + dst_addr = buf_addr;
 + dev_width = echan-cfg.src_addr_width;
 + burst = echan-cfg.src_maxburst;
 + } else if (direction == DMA_MEM_TO_DEV) {
 + src_addr = buf_addr;
 + dst_addr = echan-cfg.dst_addr;
 + dev_width = echan-cfg.dst_addr_width;
 + burst = echan-cfg.dst_maxburst;
 + } else {
 + dev_err(dev, %s: bad direction?\n, __func__);
 + return NULL;
 + }
 +
 + if (dev_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) {
 + dev_err(dev, Undefined slave buswidth\n);
 + return NULL;
 + }
 +
 + if (unlikely(buf_len % period_len)) {
 + dev_err(dev, Period should be multiple of Buffer length\n);
 + return NULL;
 + }
 +
 + nr_periods = (buf_len / period_len) + 1;
?

consider the case of buf = period_len, above makes nr_period = 2.

Or buf len 100, period len 50, makes nr_period = 3

Both doesnt seem right to me?

--
~Vinod
___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source