[PATCH] ARM: add PrimeCell generic DMA to MMCI/PL180 v10

Russell King - ARM Linux linux at arm.linux.org.uk
Thu Aug 12 10:30:02 EDT 2010


On Thu, Aug 12, 2010 at 03:58:08PM +0200, Linus Walleij wrote:
> 2010/8/11 Rabin Vincent <rabin at rab.in>:
> >> +     sglen = dma_map_sg(mmc_dev(host->mmc), data->sg,
> >> +                        data->sg_len, direction);
> >> +     if (sglen != data->sg_len)
> >> +             goto unmap_exit;
> >
> > sglen < data->sg_len is not an error condition.
> 
> In arch/arm/mm/dma-mapping.c
> dma_map_sg() returns 0 on a mapping error, and the same as
> passed in the third parameter on success.

Rabin is right - dma_map_sg() is allowed to return fewer entries than
was passed as it is allowed to coalesce entries together.  Please don't
use the implementation as a source of how things should behave, instead
read the documentation in Documentation/DMA-API.txt:

        int
        dma_map_sg(struct device *dev, struct scatterlist *sg,
                int nents, enum dma_data_direction direction)

Returns: the number of physical segments mapped (this may be shorter
than <nents> passed in if some elements of the scatter/gather list are
physically or virtually adjacent and an IOMMU maps them with a single
entry).




More information about the linux-arm-kernel mailing list