lkml.org 
[lkml]   [2013]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] dw_dmac: return proper residue value
On Mon, Jan 21, 2013 at 11:00:44AM +0200, Andy Shevchenko wrote:
> Currently the driver returns full length of the active descriptor which is
> wrong. We have to go throught the active descriptor and sum up the length of
> unsent children in the chain along with the actual data in the DMA channel
why do you mean by children here?
> registers.
>
> The cyclic case is not handled by this patch due to len field in the descriptor
> structure is left untouched by the original code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/dma/dw_dmac.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 92 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
> index d1b9ba2..4325c68 100644
> --- a/drivers/dma/dw_dmac.c
> +++ b/drivers/dma/dw_dmac.c
> @@ -941,6 +941,97 @@ err_desc_get:
> return NULL;
> }
>
> +/* --------------------- Calculate residue ---------------------------- */
> +
> +static inline size_t dwc_get_rest(struct dw_dma_chan *dwc, struct dw_desc *desc)
> +{
> + enum dma_transfer_direction direction = dwc->direction;
> +
> + if (direction == DMA_MEM_TO_DEV || direction == DMA_MEM_TO_MEM)
> + return desc->len - (channel_readl(dwc, SAR) - desc->lli.sar);
> + else if (direction == DMA_DEV_TO_MEM)
> + return desc->len - (channel_readl(dwc, DAR) - desc->lli.dar);
> +
> + return 0;
hmmm, why not use BLOCK_TS value. That way you dont need to look at direction
and along with burst can easily calculate residue...

--
~Vinod


\
 
 \ /
  Last update: 2013-01-21 11:01    [W:0.072 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site