i915 dma_map_sg return value

Volker Vogelhuber v.vogelhuber at digitalendoscopy.de
Tue May 5 00:42:44 PDT 2015

The documentation of the DMA-API writes the following about

"The implementation is free to merge several consecutive sglist entries
into one (e.g. if DMA mapping is done with PAGE_SIZE granularity, any
consecutive sglist entries can be merged into one provided the first one
ends and the second one starts on a page boundary - in fact this is a huge
advantage for cards which either cannot do scatter-gather or have very
limited number of scatter-gather entries) and returns the actual number
of sg entries it mapped them to."

I wonder why the return value of dma_map_sg is not returned in any way
from i915_gem_map_dma_buf. It only uses the return value for error
Can one be sure that in case of the i915 the nents value of the scatter
gather table is always equal to the value returned by dma_map_sg?
I'm asking because I want to use the sg table returned by
i915_gem_map_dma_buf in my own kernel module and iterate over it
using for_each_sg. And the example in the documentation of the DMA-API
uses the return value of dma_map_sg when calling for_each_sg and not
nents and it explicitly mentions:

"Then you should loop count times (note: this can be less than nents times)"


More information about the dri-devel mailing list