From: "Jan Beulich" Subject: Re: [PATCH v2 14/21] xen/passthrough: Introduce iommu_construct Date: Fri, 01 Aug 2014 09:55:19 +0100 Message-ID: <53DB72170200007800028517@mail.emea.novell.com> References: <1406818852-31856-1-git-send-email-julien.grall@linaro.org> <1406818852-31856-15-git-send-email-julien.grall@linaro.org> 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 1XD8cT-00042r-Pb for xen-devel@lists.xenproject.org; Fri, 01 Aug 2014 08:55:21 +0000 In-Reply-To: <1406818852-31856-15-git-send-email-julien.grall@linaro.org> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: xen-devel@lists.xenproject.org, stefano.stabellini@citrix.com, ian.campbell@citrix.com, tim@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 31.07.14 at 17:00, wrote: > +int iommu_construct(struct domain *d) > +{ > + int rc = 0; > + > + /* > + * The caller should check we effectively need to set up the IOMMMU > + * for this domain. > + */ > + ASSERT(need_iommu(d) <= 0); > + > + if ( need_iommu(d) > 0 ) > + return 0; Either ASSERT() or if() (and in the latter case there's be no need for the callers to check unless they need the check for other purposes). > + > + if ( !iommu_use_hap_pt(d) ) > + { > + rc = arch_iommu_populate_page_table(d); > + if ( rc ) > + return rc; > + } > + > + d->need_iommu = 1; This wasn't removed from the caller - an oversight? > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -1342,14 +1342,10 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) > > if ( need_iommu(d) <= 0 ) > { > - if ( !iommu_use_hap_pt(d) ) > - { > - rc = arch_iommu_populate_page_table(d); > - if ( rc ) > - { > - spin_unlock(&pcidevs_lock); > - return rc; > - } > + rc = iommu_construct(d); > + if ( rc ) { Coding style. Jan