Re: [PATCH 6/6] scatterlist: use sg_phys()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 7, 2015 at 9:15 AM, Christoph Hellwig <hch@xxxxxx> wrote:
> From: Dan Williams <dan.j.williams@xxxxxxxxx>
>
> Coccinelle cleanup to replace open coded sg to physical address
> translations.  This is in preparation for introducing scatterlists that
> reference __pfn_t.
>
> // sg_phys.cocci: convert usage page_to_phys(sg_page(sg)) to sg_phys(sg)
> // usage: make coccicheck COCCI=sg_phys.cocci MODE=patch
>
> virtual patch
> virtual report
> virtual org
>
> @@
> struct scatterlist *sg;
> @@
>
> - page_to_phys(sg_page(sg)) + sg->offset
> + sg_phys(sg)
>
> @@
> struct scatterlist *sg;
> @@
>
> - page_to_phys(sg_page(sg))
> + sg_phys(sg) - sg->offset

So this ends up being an awkward conversion, a better one is:

- page_to_phys(sg_page(sg))
+ sg_phys(sg) & PAGE_MASK

[..]
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 5852df8..e0faecc 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -2098,7 +2098,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
>                         sg_res = aligned_nrpages(sg->offset, sg->length);
>                         sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset;
>                         sg->dma_length = sg->length;
> -                       pteval = page_to_phys(sg_page(sg)) | prot;
> +                       pteval = (sg_phys(sg) - sg->offset) | prot;

For example here, as Joerg pointed out.

[1]: https://lkml.org/lkml/2015/6/10/230
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux