Re: [PATCH v6 05/14] crypto: marvell/CESA: add TDMA support

From: Russell King - ARM Linux
Date: Thu Jun 18 2015 - 05:04:40 EST

On Wed, Jun 17, 2015 at 05:50:01PM +0800, Herbert Xu wrote:
> On Wed, Jun 17, 2015 at 09:45:33AM +0200, Boris Brezillon wrote:
> >
> > + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents,
> > + if (!ret)
> > + return -ENOMEM;
> > +
> > + creq->src_nents = ret;
> DMA-API-HOWTO says that you must retain the original nents and
> use it when you call dma_unmap_sg. So I'm afraid one more repost
> is needed :)

It's worse than that... You're right on that point, but there's an
additional point.

If dma_map_sg() coalesces scatterlist entries, then ret will be smaller
than src_nents, and ret indicates how many scatterlist entries to be
walked during DMA - you should not use src_nents for that. I couldn't
see where the driver used that information. In fact, the driver seems
to be capable of walking more than src_nents/ret numbers of scatterlist
entries: it just keeps going with sg_next() until it hits the end of
the allocated scatterlist.

FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at