From mboxrd@z Thu Jan 1 00:00:00 1970 From: Weidong Han Subject: Re: [PATCH] VT-d: fix device assignment failure (regression from Xen c/s 19805:2f1fa2215e60) Date: Wed, 03 Nov 2010 08:54:15 +0800 Message-ID: <4CD0B2B7.4040908@intel.com> References: <4CCFD41E0200007800020359@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4CCFD41E0200007800020359@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Jan Beulich wrote: > If the device at :00.0 is the device the mapping operation was > initiated for, trying to map it a second time will fail, and hence > this second mapping attempt must be prevented (as was done prior to > said c/s). > > Once at it, simplify the code a little, too. > > Signed-off-by: Jan Beulich > > --- a/xen/drivers/passthrough/vtd/iommu.c > +++ b/xen/drivers/passthrough/vtd/iommu.c > @@ -1371,23 +1371,16 @@ static int domain_context_mapping(struct > if ( find_upstream_bridge(&bus, &devfn, &secbus) < 1 ) > break; > > - /* PCIe to PCI/PCIx bridge */ > - if ( pdev_type(bus, devfn) == DEV_TYPE_PCIe2PCI_BRIDGE ) > - { > - ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); > - if ( ret ) > - return ret; > + ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); > > - /* > - * Devices behind PCIe-to-PCI/PCIx bridge may generate > - * different requester-id. It may originate from devfn=0 > - * on the secondary bus behind the bridge. Map that id > - * as well. > - */ > + /* > + * Devices behind PCIe-to-PCI/PCIx bridge may generate different > + * requester-id. It may originate from devfn=0 on the secondary bus > + * behind the bridge. Map that id as well if we didn't already. > + */ > + if ( !ret && pdev_type(bus, devfn) == DEV_TYPE_PCIe2PCI_BRIDGE && > + (secbus != pdev->bus || pdev->devfn != 0) ) > ret = domain_context_mapping_one(domain, drhd->iommu, secbus, 0); > - } > - else /* Legacy PCI bridge */ > - ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); > > break; > > > > Acked-by: Weidong Han >