[v2 rebased 1/2] dma: mmp_pdma: add support for residue reporting

Russell King - ARM Linux linux at arm.linux.org.uk
Wed Aug 14 08:46:43 EDT 2013


On Wed, Aug 14, 2013 at 02:25:20PM +0200, Daniel Mack wrote:
> In order to report the channel's residue, we have to memorize the first
> dma buffer position when the channel is configured.

This is actually broken, and I'm surprised that Vinod even suggested it.

Think about what happens with a scatter-gather list where the addresses
of each element really are scattered in memory.  Let's say that the
N'th element is at a lower address than the first element, and we're on
that N'th element.  What happens when curr is less than chan->start_addr
here:

> +static unsigned int mmp_pdma_residue(struct mmp_pdma_chan *chan)
> +{
> +	u32 curr, done;
> +
> +	if (chan->dir == DMA_DEV_TO_MEM)
> +		curr = readl(chan->phy->base + DTADR(chan->phy->idx));
> +	else
> +		curr = readl(chan->phy->base + DSADR(chan->phy->idx));
> +
> +	done = curr - chan->start_addr;
> +
> +	return chan->total_len - done;
> +}



More information about the linux-arm-kernel mailing list