From: Stefano Stabellini Subject: Re: [PATCH 3/4] xen/arm: introduce XENMEM_cache_flush Date: Thu, 2 Oct 2014 13:59:25 +0100 Message-ID: References: <1412244158-12124-3-git-send-email-stefano.stabellini@eu.citrix.com> <542D5457020000780003BE7B@mail.emea.novell.com> <542D57D3020000780003BF2C@mail.emea.novell.com> <542D5D12020000780003BF98@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZg1C-0003zm-7z for xen-devel@lists.xenproject.org; Thu, 02 Oct 2014 13:02:06 +0000 In-Reply-To: <542D5D12020000780003BF98@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: julien.grall@citrix.com, xen-devel , Ian.Campbell@citrix.com, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thu, 2 Oct 2014, Jan Beulich wrote: > >>> On 02.10.14 at 13:57, wrote: > > On Thu, 2 Oct 2014, Jan Beulich wrote: > >> But again I don't see why Dom0 can't track state for the mappings > >> it establishes - after all, a grant-ref would be the most natural > >> thing to pass in here. > > > > I agree it would be more natural to pass the grant-ref, but if Linux > > knew the grant-ref it wouldn't need the hypercall: it would also know > > the pfn and could just perform the flush on the pseudo-physical address. > > > > See drivers/xen/swiotlb-xen.c: the dma_map_ops api only gives us an mfn > > at unmap time. Maintaining an mfn_to_pfn (or to grant_ref) tree with > > multiple entries per mfn is expensive. The tree would need to be global: > > maintained for every grant map/unmap operation, that nowadays happen > > extremely often with netfront/netback. In addition the lookup is not > > very fast either. We would also need to take a lock to be able to handle > > the multiple grants for the same page scenario. > > I don't follow: The first thing xen_unmap_single() does is get > the physical address for the passed in DMA one. On ARM that would just return the mfn again, because Linux doesn't track mfn to pfn anymore. > Furthermore, if only SWIOTLB code is of concern, It is not: the swiotlb-xen functions are called in all cases but the swiotlb internal buffer is only used as slow path when strictly necessary. See for example xen_swiotlb_map_page: if (dma_capable(dev, dev_addr, size) && !range_straddles_page_boundary(phys, size) && !swiotlb_force) { this check triggers the fast path. > then this is limited > size, and hence you could have a xen_io_tlb_nslabs-element array > tracking whatever additional information you may need for each of the > slabs. > > Jan >