On Wed, Apr 13, 2016 at 09:52:00PM +0300, Adam Morrison wrote:
> @@ -3738,7 +3743,16 @@ static void intel_unmap_sg(struct device *dev, struct 
> scatterlist *sglist,
>                          int nelems, enum dma_data_direction dir,
>                          struct dma_attrs *attrs)
>  {
> -     intel_unmap(dev, sglist[0].dma_address);
> +     dma_addr_t startaddr = sglist[0].dma_address - sglist[0].offset;
> +     unsigned long nrpages = 0;
> +     struct scatterlist *sg;
> +     int i;
> +
> +     for_each_sg(sglist, sg, nelems, i) {
> +             nrpages += aligned_nrpages(sg->offset, sg->length);
> +     }
> +
> +     intel_unmap(dev, startaddr, nrpages << VTD_PAGE_SHIFT);
>  }

I'm uncomfortmable with the .dma_address, .length. There are macros for
these, sg_dma_address/sg_dma_len. For .offset, are we sure it's always
valid in .unmap_sg? Better use sg_dma_address/sg_dma_len and align them
to get the pages.

Thanks,
Shaohua
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to