[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 02/10] swiotlb-xen: remove start_dma_addr
On Fri, 22 May 2020, Julien Grall wrote: > On 22/05/2020 04:55, Stefano Stabellini wrote: > > On Thu, 21 May 2020, Julien Grall wrote: > > > Hi, > > > > > > On 21/05/2020 00:45, Stefano Stabellini wrote: > > > > From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx> > > > > > > > > It is not strictly needed. Call virt_to_phys on xen_io_tlb_start > > > > instead. It will be useful not to have a start_dma_addr around with the > > > > next patches. > > > > > > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx> > > > > --- > > > > drivers/xen/swiotlb-xen.c | 5 +---- > > > > 1 file changed, 1 insertion(+), 4 deletions(-) > > > > > > > > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c > > > > index a42129cba36e..b5e0492b07b9 100644 > > > > --- a/drivers/xen/swiotlb-xen.c > > > > +++ b/drivers/xen/swiotlb-xen.c > > > > @@ -52,8 +52,6 @@ static unsigned long xen_io_tlb_nslabs; > > > > * Quick lookup value of the bus address of the IOTLB. > > > > */ > > > > -static u64 start_dma_addr; > > > > - > > > > /* > > > > * Both of these functions should avoid XEN_PFN_PHYS because > > > > phys_addr_t > > > > * can be 32bit when dma_addr_t is 64bit leading to a loss in > > > > @@ -241,7 +239,6 @@ int __ref xen_swiotlb_init(int verbose, bool early) > > > > m_ret = XEN_SWIOTLB_EFIXUP; > > > > goto error; > > > > } > > > > - start_dma_addr = xen_virt_to_bus(xen_io_tlb_start); > > > > if (early) { > > > > if (swiotlb_init_with_tbl(xen_io_tlb_start, > > > > xen_io_tlb_nslabs, > > > > verbose)) > > > > @@ -389,7 +386,7 @@ static dma_addr_t xen_swiotlb_map_page(struct device > > > > *dev, struct page *page, > > > > */ > > > > trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force); > > > > - map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, > > > > + map = swiotlb_tbl_map_single(dev, > > > > virt_to_phys(xen_io_tlb_start), > > > > phys, > > > > > > xen_virt_to_bus() is implemented as xen_phys_to_bus(virt_to_phys()). Can > > > you > > > explain how the two are equivalent? > > > > They are not equivalent. Looking at what swiotlb_tbl_map_single expects, > > and also the implementation of swiotlb_init_with_tbl, I think > > virt_to_phys is actually the one we want. > > > > swiotlb_tbl_map_single compares the argument with __pa(tlb) which is > > __pa(xen_io_tlb_start) which is virt_to_phys(xen_io_tlb_start). > > I can't find such check in master. What is your baseline? Could you point to > the exact line of code? My base is b85051e755b0e9d6dd8f17ef1da083851b83287d, which is master from a couple of days back. xen_swiotlb_init calls swiotlb_init_with_tbl which takes a virt address as a parameter (xen_io_tlb_start), it gets converted to phys and stored in io_tlb_start as a physical address. Later, xen_swiotlb_map_page calls swiotlb_tbl_map_single passing a dma addr as parameter (tbl_dma_addr). tbl_dma_addr is used to calculate the right slot in the swiotlb buffer to use. (Strangely tbl_dma_addr is a dma_addr_t and it is not converted to phys_addr_t before doing operations... I think tbl_dma_addr should be a phys addr.) The comparison with io_tlb_start is done here: do { while (iommu_is_span_boundary(index, nslots, offset_slots, max_slots)) { index += stride; if (index >= io_tlb_nslabs) index = 0; if (index == wrap) goto not_found; } index is io_tlb_start and offset_slots is derived by tbl_dma_addr.
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |