All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Joel Fernandes <joelf@ti.com>
Cc: Matt Porter <matt@ohporter.com>, Mark Brown <broonie@linaro.org>,
	Russell King <linux@arm.linux.org.uk>, Dan Williams <djbw@fb.com>,
	Jyri Sarha <jsarha@ti.com>, Lars Peter-Clausen <lars@metafoo.de>,
	Linux OMAP List <linux-omap@vger.kernel.org>,
	Linux ARM Kernel List <linux-arm-kernel@lists.infradead.org>,
	Linux DaVinci Kernel List
	<davinci-linux-open-source@linux.davincidsp.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH 2/3] dma: edma: Add support for Cyclic DMA
Date: Mon, 21 Oct 2013 12:23:19 +0530	[thread overview]
Message-ID: <20131021065319.GM14013@intel.com> (raw)
In-Reply-To: <1379977515-3794-3-git-send-email-joelf@ti.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: vinod.koul@intel.com (Vinod Koul)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] dma: edma: Add support for Cyclic DMA
Date: Mon, 21 Oct 2013 12:23:19 +0530	[thread overview]
Message-ID: <20131021065319.GM14013@intel.com> (raw)
In-Reply-To: <1379977515-3794-3-git-send-email-joelf@ti.com>

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

  reply	other threads:[~2013-10-21  6:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23 23:05 [PATCH 0/3] dma: edma: Add cyclic DMA support Joel Fernandes
2013-09-23 23:05 ` Joel Fernandes
2013-09-23 23:05 ` Joel Fernandes
     [not found] ` <1379977515-3794-1-git-send-email-joelf-l0cyMroinI0@public.gmane.org>
2013-09-23 23:05   ` [PATCH 1/3] dma: edma: Split out PaRAM set calculations into its own function Joel Fernandes
2013-09-23 23:05     ` Joel Fernandes
2013-09-23 23:05     ` Joel Fernandes
2013-10-21  7:26     ` Vinod Koul
2013-10-21  7:26       ` Vinod Koul
2013-09-23 23:05   ` [PATCH 2/3] dma: edma: Add support for Cyclic DMA Joel Fernandes
2013-09-23 23:05     ` Joel Fernandes
2013-09-23 23:05     ` Joel Fernandes
2013-10-21  6:53     ` Vinod Koul [this message]
2013-10-21  6:53       ` Vinod Koul
     [not found]       ` <20131021065319.GM14013-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-10-22 15:30         ` Joel Fernandes
2013-10-22 15:30           ` Joel Fernandes
2013-10-22 15:30           ` Joel Fernandes
2013-10-24 16:38           ` Vinod Koul
2013-10-24 16:38             ` Vinod Koul
     [not found]             ` <20131024163829.GA21230-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-10-24 17:57               ` Joel Fernandes
2013-10-24 17:57                 ` Joel Fernandes
2013-10-24 17:57                 ` Joel Fernandes
2013-10-31 14:10                 ` Vinod Koul
2013-10-31 14:10                   ` Vinod Koul
     [not found]                   ` <20131031141012.GJ18788-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-10-31 16:03                     ` Joel Fernandes
2013-10-31 16:03                       ` Joel Fernandes
2013-10-31 16:03                       ` Joel Fernandes
2013-09-23 23:05   ` [PATCH 3/3] dma: edma: Increase maximum SG limit to 20 Joel Fernandes
2013-09-23 23:05     ` Joel Fernandes
2013-09-23 23:05     ` Joel Fernandes
2013-10-21  7:26     ` Vinod Koul
2013-10-21  7:26       ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131021065319.GM14013@intel.com \
    --to=vinod.koul@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@linaro.org \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=djbw@fb.com \
    --cc=joelf@ti.com \
    --cc=jsarha@ti.com \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=matt@ohporter.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.