Thread (31 messages) 31 messages, 3 authors, 2015-06-18

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

From: Boris Brezillon <hidden>
Date: 2015-06-18 09:33:48
Also in: linux-arm-kernel, linux-devicetree, lkml

Hi Russel,

On Thu, 18 Jun 2015 10:04:00 +0100
Russell King - ARM Linux [off-list ref] wrote:
On Wed, Jun 17, 2015 at 05:50:01PM +0800, Herbert Xu wrote:
quoted
On Wed, Jun 17, 2015 at 09:45:33AM +0200, Boris Brezillon wrote:
quoted
+	ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents,
+			 DMA_TO_DEVICE);
+	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.
Yes, I realized that, and I never used the value returned by
dma_map_sg() to walk the scatterlist anyway: I was using the sg_next()
and sg->length value (which I replaced by sg_dma_len() in v7 as
suggested by Herbert).
So the ->src_nents assignment to dma_map_sg() return value was just a
silly mistake caused by an uncareful read of the DMA-API-HOWTO.

Am I missing something else ?

Best Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help