From: "Jan Beulich" Subject: Re: VT-d device assignment may fail (regression from Xen c/s 19805:2f1fa2215e60) Date: Wed, 27 Oct 2010 12:34:44 +0100 Message-ID: <4CC82A74020000780001F6FC@vpn.id2.novell.com> References: <4CC17FE5020000780001E91F@vpn.id2.novell.com> <4CC7BBFC.8010802@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4CC7BBFC.8010802@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Weidong Han Cc: Yunhong Jiang , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org >>> On 27.10.10 at 07:43, Weidong Han wrote: > Jan Beulich wrote: >> The question now is whether some similar check should be restored, >> or whether pdev->domain should get updated earlier. This may >> =20 > I prefer to add the check. Like this (not tested yet, simplifying the code a little at once): --- 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; =20 - /* PCIe to PCI/PCIx bridge */ - if ( pdev_type(bus, devfn) =3D=3D DEV_TYPE_PCIe2PCI_BRIDGE ) - { - ret =3D domain_context_mapping_one(domain, drhd->iommu, bus, = devfn); - if ( ret ) - return ret; + ret =3D domain_context_mapping_one(domain, drhd->iommu, bus, = devfn); =20 - /* - * Devices behind PCIe-to-PCI/PCIx bridge may generate - * different requester-id. It may originate from devfn=3D0 - * 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=3D0 on the secondary = bus + * behind the bridge. Map that id as well if we didn't already. + */ + if ( !ret && pdev_type(bus, devfn) =3D=3D DEV_TYPE_PCIe2PCI_BRIDGE= && + (secbus !=3D pdev->bus || pdev->devfn !=3D 0) ) ret =3D domain_context_mapping_one(domain, drhd->iommu, = secbus, 0); - } - else /* Legacy PCI bridge */ - ret =3D domain_context_mapping_one(domain, drhd->iommu, bus, = devfn); =20 break; =20 Jan