LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   'nents' argument of dma_unmap_sg? (https://www.linuxquestions.org/questions/linux-kernel-70/nents-argument-of-dma_unmap_sg-4175621964/)

bonezuk 01-19-2018 05:13 AM

'nents' argument of dma_unmap_sg?
 
Hi

I'm maintaining a driver for the 4.4 branch which makes use of a mapped scatterlist using

count = dma_map_sg(device, sglist, nents, direction);

In the DMA-API-HOWTO.txt documentation (at line 647) is the statement: "The 'nents' argument to the dma_unmap_sg call must be the _same_ one you passed into the dma_map_sg call, it should _NOT_ be the 'count' value _returned_ from the dma_map_sg call."

Thus I would expect to unmap the scatterlist by calling

dma_unmap_sg(device, sglist, nents, direction);

However, in looking at drivers/media/v4l2-core/videobuf-dma-sg.c as a reference example the call to dma_unmap_sg in the videobuf_dma_unmap function uses the number of entries returned by the dma_map_sg call. i.e. It is going against the statement in the DMA-API-HOWTO.txt. That is:

dma_unmap_sg(device, sglist, count, direction);

So my question is which one is the correct use or this a mistake in the documentation? In my implementation I use 'count' as when I used 'nents' I got context page faults on the call to unmapping the memory.

Cheers for any help,

Stuart MacLean

AwesomeMachine 01-19-2018 10:51 PM

Hi bonezuk,

Welcome to LQ!

I would say the second one is correct.

thellstrom 04-25-2018 08:24 AM

Bonezuk,

I vaguely remember hitting the same problem. What architecture are you on and are you using an IOMMU?
Thanks,

Thomas


All times are GMT -5. The time now is 02:42 PM.