From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH v4 18/21] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk Date: Mon, 28 Apr 2014 15:46:23 +0100 Message-ID: <535E69BF.6080502@linaro.org> References: <1398172475-27873-1-git-send-email-julien.grall@linaro.org> <1398172475-27873-19-git-send-email-julien.grall@linaro.org> <1398694180.29700.126.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WempC-00072Y-OM for xen-devel@lists.xenproject.org; Mon, 28 Apr 2014 14:46:30 +0000 Received: by mail-ee0-f42.google.com with SMTP id d17so4956004eek.15 for ; Mon, 28 Apr 2014 07:46:25 -0700 (PDT) In-Reply-To: <1398694180.29700.126.camel@kazak.uk.xensource.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: Ian Campbell Cc: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org On 04/28/2014 03:09 PM, Ian Campbell wrote: >> xen/arch/arm/p2m.c | 24 ++++++++++++++++++------ >> xen/drivers/passthrough/iommu.c | 11 +++++++++++ >> xen/include/xen/iommu.h | 5 +++++ >> 3 files changed, 34 insertions(+), 6 deletions(-) >> >> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c >> index 21219de..996d2bd 100644 >> --- a/xen/arch/arm/p2m.c >> +++ b/xen/arch/arm/p2m.c >> @@ -274,6 +274,18 @@ enum p2m_operation { >> CACHEFLUSH, >> }; >> >> +static void unmap_coherent_domain_page(struct domain *d, const void *va) >> +{ >> + /* Some IOMMU doesn't support coherent PT walk. When the p2m is > > "don't support" > >> + * shared with the CPU, Xen has to make sure that the PT changes have >> + * reached the memory >> + */ >> + if ( need_iommu(d) && !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK) ) >> + clean_xen_dcache_va_range(va, PAGE_SIZE); > > This is a fairly large hammer when you might only have touched a few > bytes, if any, in the page. > > Wouldn't it be better to do this is write_pte, or just after the calls > to write_pte? I didn't think that the cache flush on a page was divided in small chunks. > iommu_has_feature has a lot of callbacks -- worth calling once in > apply_p2m_changes? I will create a write_pte_coherent helpers which will take in parameter a boolean to know if we need to flush the cache or not. Regards, -- Julien Grall