All of lore.kernel.org
 help / color / mirror / Atom feed
From: vinod.koul@intel.com (Vinod Koul)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/5] dma: mxs-dma: Report correct residue for cyclic DMA
Date: Wed, 13 Nov 2013 15:32:42 +0530	[thread overview]
Message-ID: <20131113100242.GU8834@intel.com> (raw)
In-Reply-To: <1383032869-12863-3-git-send-email-mpa@pengutronix.de>

On Tue, Oct 29, 2013 at 08:47:46AM +0100, Markus Pargmann wrote:
> Use the channel's buffer address register to calculate correct residue
> value for tx_status.
> 
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
>  drivers/dma/mxs-dma.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index 1d1b6e9..083e7f1 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -58,6 +58,8 @@
>  	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x050 : 0x110) + (n) * 0x70)
>  #define HW_APBHX_CHn_SEMA(d, n) \
>  	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70)
> +#define HW_APBHX_CHn_BAR(d, n) \
> +	(((dma_is_apbh(d) && apbh_is_old(d)) ? 0x070 : 0x130) + (n) * 0x70)
>  
>  /*
>   * ccw bits definitions
> @@ -623,8 +625,24 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan,
>  			dma_cookie_t cookie, struct dma_tx_state *txstate)
>  {
>  	struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
> +	struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma;
> +	u32 residue = 0;
> +
> +	if (mxs_chan->status == DMA_IN_PROGRESS &&
> +			mxs_chan->flags & MXS_DMA_SG_LOOP) {
> +		struct mxs_dma_ccw *last_ccw;
> +		u32 bar;
> +
> +		last_ccw = &mxs_chan->ccw[mxs_chan->desc_count - 1];
> +		residue = last_ccw->xfer_bytes + last_ccw->bufaddr;
> +
> +		bar = readl(mxs_dma->base +
> +				HW_APBHX_CHn_BAR(mxs_dma, chan->chan_id));
> +		residue -= bar;
> +	}
>  
> -	dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie, 0);
> +	dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie,
> +			residue);
>  
>  	return mxs_chan->status;
This will work for your driver where we have artficial restriction on allowing
only 1 descriptor to be submitted at any point of time. I winder what made that
restriction?

--
~Vinod

  reply	other threads:[~2013-11-13 10:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29  7:47 [PATCH v5 0/5] dma: mxs-dma bugfixes and cleanup Markus Pargmann
2013-10-29  7:47 ` [PATCH v5 1/5] dma: mxs-dma: Cleanup interrupt handler Markus Pargmann
2013-10-29  7:47 ` [PATCH v5 2/5] dma: mxs-dma: Report correct residue for cyclic DMA Markus Pargmann
2013-11-13 10:02   ` Vinod Koul [this message]
2013-10-29  7:47 ` [PATCH v5 3/5] dma: mxs-dma: Fix channel reset hardware bug Markus Pargmann
2013-10-29  7:47 ` [PATCH v5 4/5] dma: mxs-dma: Update state after channel reset Markus Pargmann
2013-10-29  7:47 ` [PATCH v5 5/5] dma: mxs-dma: Use semaphores for cyclic DMA Markus Pargmann
2013-11-13 10:12 ` [PATCH v5 0/5] dma: mxs-dma bugfixes and cleanup 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=20131113100242.GU8834@intel.com \
    --to=vinod.koul@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.