Re: [PATCH v2 08/11] swiotlb-xen: introduce phys_to_dma/dma_to_phys translations

From: Boris Ostrovsky
Date: Thu Jun 04 2020 - 13:48:43 EST


On 6/3/20 6:22 PM, Stefano Stabellini wrote:
>
> diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
> index 0a6cb67f0fc4..60ef07440905 100644
> --- a/drivers/xen/swiotlb-xen.c
> +++ b/drivers/xen/swiotlb-xen.c
> @@ -64,16 +64,16 @@ static inline dma_addr_t xen_phys_to_bus(struct device *dev, phys_addr_t paddr)


Weren't you going to rename this to xen_phys_to_dma()? (And the the one
below to xen_dma_to_phys())?


-boris


>
> dma |= paddr & ~XEN_PAGE_MASK;
>
> - return dma;
> + return phys_to_dma(dev, dma);
> }
>
> -static inline phys_addr_t xen_bus_to_phys(struct device *dev, dma_addr_t baddr)
> +static inline phys_addr_t xen_bus_to_phys(struct device *dev,
> + dma_addr_t dma_addr)
> {
> + phys_addr_t baddr = dma_to_phys(dev, dma_addr);
> unsigned long xen_pfn = bfn_to_pfn(XEN_PFN_DOWN(baddr));
> - dma_addr_t dma = (dma_addr_t)xen_pfn << XEN_PAGE_SHIFT;
> - phys_addr_t paddr = dma;
> -
> - paddr |= baddr & ~XEN_PAGE_MASK;
> + phys_addr_t paddr = (xen_pfn << XEN_PAGE_SHIFT) |
> + (baddr & ~XEN_PAGE_MASK);
>