From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Bader Subject: Re: [PATCH 1/1] x86/AMD: Fix setup ssss:bb:dd:f for d0 failed Date: Wed, 07 Aug 2013 09:33:26 +0100 Message-ID: <52020656.6090501@canonical.com> References: <1375843208-3165-1-git-send-email-suravee.suthikulpanit@amd.com> <5201B42B.2090602@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7071004020959115126==" Return-path: In-Reply-To: <5201B42B.2090602@amd.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: Suravee Suthikulanit Cc: xiantao.zhang@intel.com, JBeulich@suse.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============7071004020959115126== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigCF8B78643B9874EE81FD6DFD" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigCF8B78643B9874EE81FD6DFD Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 07.08.2013 03:42, Suravee Suthikulanit wrote: > Also CC Stefan. >=20 > Suravee >=20 > On 8/6/2013 9:40 PM, suravee.suthikulpanit@amd.com wrote: >> From: Suravee Suthikulpanit >> >> The host bridge device (i.e. 0x18 for AMD) does not >> require IOMMU, and therefore is not included in the IVRS. >> The current logic tries to map all PCI devices to an IOMMU. >> In this case, "xl dmesg" shows the following message on AMD sytem. >> >> (XEN) setup 0000:00:18.0 for d0 failed (-19) >> (XEN) setup 0000:00:18.1 for d0 failed (-19) >> (XEN) setup 0000:00:18.2 for d0 failed (-19) >> (XEN) setup 0000:00:18.3 for d0 failed (-19) >> (XEN) setup 0000:00:18.4 for d0 failed (-19) >> (XEN) setup 0000:00:18.5 for d0 failed (-19) >> >> This patch add new device type (i.e. DEV_TYPE_PCI_HOST_BRIDGE) which >> is corresponded to PCI class code 0x06 and sub-class 0x00. Then, it >> use this new type to filter when trying to map device to IOMMU. >> >> Signed-off-by: Suravee Suthikulpanit >> --- >> xen/drivers/passthrough/amd/pci_amd_iommu.c | 20 +++++++++++++----= >> xen/drivers/passthrough/pci.c | 31 ++++++++++++++++-= ---------- >> xen/drivers/passthrough/vtd/iommu.c | 2 ++ >> xen/include/xen/pci.h | 1 + >> 4 files changed, 38 insertions(+), 16 deletions(-) >> >> diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c >> b/xen/drivers/passthrough/amd/pci_amd_iommu.c >> index 9684ae8..0bb954a 100644 >> --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c >> +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c >> @@ -175,10 +175,22 @@ static int __init amd_iommu_setup_dom0_device(u8= devfn, >> struct pci_dev *pdev) >> if ( unlikely(!iommu) ) >> { >> - AMD_IOMMU_DEBUG("No iommu for device %04x:%02x:%02x.%u\n", >> - pdev->seg, pdev->bus, >> - PCI_SLOT(devfn), PCI_FUNC(devfn)); >> - return -ENODEV; >> + /* Filter the bridge devices */ >> + if ( (pdev->type =3D=3D DEV_TYPE_PCIe_BRIDGE) >> + || (pdev->type =3D=3D DEV_TYPE_PCIe2PCI_BRIDGE) >> + || (pdev->type =3D=3D DEV_TYPE_LEGACY_PCI_BRIDGE) >> + || (pdev->type =3D=3D DEV_TYPE_PCI_HOST_BRIDGE) ) >> + { >> + AMD_IOMMU_DEBUG("Skipping device %04x:%02x:%02x.%u (type = %x)\n", >> + pdev->seg, PCI_BUS(bdf), PCI_SLOT(bdf), PCI_F= UNC(bdf), >> + pdev->type); >> + return 0; >> + } else { >> + AMD_IOMMU_DEBUG("No iommu for device %04x:%02x:%02x.%u\n"= , >> + pdev->seg, pdev->bus, >> + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); >> + return -ENODEV; >> + } >> } >> amd_iommu_setup_domain_device(pdev->domain, iommu, devfn, pdev= ); >> diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/p= ci.c >> index f2756c9..0b94fc4 100644 >> --- a/xen/drivers/passthrough/pci.c >> +++ b/xen/drivers/passthrough/pci.c >> @@ -189,9 +189,6 @@ static struct pci_dev *alloc_pdev(struct pci_seg *= pseg, u8 >> bus, u8 devfn) >> u16 cap; >> u8 sec_bus, sub_bus; >> - case DEV_TYPE_PCIe_BRIDGE: >> - break; >> - >> case DEV_TYPE_PCIe2PCI_BRIDGE: >> case DEV_TYPE_LEGACY_PCI_BRIDGE: >> sec_bus =3D pci_conf_read8(pseg->nr, bus, PCI_SLOT(devfn= ), >> @@ -239,6 +236,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *= pseg, u8 >> bus, u8 devfn) >> break; >> case DEV_TYPE_PCI: >> + case DEV_TYPE_PCI_HOST_BRIDGE: >> + case DEV_TYPE_PCIe_BRIDGE: >> break; >> default: >> @@ -691,35 +690,43 @@ void pci_release_devices(struct domain *d) >> spin_unlock(&pcidevs_lock); >> } >> -#define PCI_CLASS_BRIDGE_PCI 0x0604 >> +#define PCI_CLASS_HOST_PCI_BRIDGE 0x0600 >> +#define PCI_CLASS_PCI_PCI_BRIDGE 0x0604 >> enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) >> { >> - u16 class_device, creg; >> + u16 creg; >> u8 d =3D PCI_SLOT(devfn), f =3D PCI_FUNC(devfn); >> - int pos =3D pci_find_cap_offset(seg, bus, d, f, PCI_CAP_ID_EXP); >> + u16 class_device =3D pci_conf_read16(seg, bus, d, f, PCI_CLASS_DE= VICE); >> + int cap_offset =3D pci_find_cap_offset(seg, bus, d, f, PCI_CAP_ID= _EXP); >> - class_device =3D pci_conf_read16(seg, bus, d, f, PCI_CLASS_DEVI= CE); >> switch ( class_device ) >> { >> - case PCI_CLASS_BRIDGE_PCI: >> - if ( !pos ) >> + case PCI_CLASS_PCI_PCI_BRIDGE: >> + if ( !cap_offset ) >> return DEV_TYPE_LEGACY_PCI_BRIDGE; >> - creg =3D pci_conf_read16(seg, bus, d, f, pos + PCI_EXP_FLAGS)= ; >> + >> + creg =3D pci_conf_read16(seg, bus, d, f, cap_offset + PCI_EXP= _FLAGS); >> + >> switch ( (creg & PCI_EXP_FLAGS_TYPE) >> 4 ) >> { >> case PCI_EXP_TYPE_PCI_BRIDGE: >> return DEV_TYPE_PCIe2PCI_BRIDGE; >> case PCI_EXP_TYPE_PCIE_BRIDGE: >> return DEV_TYPE_PCI2PCIe_BRIDGE; >> + default: >> + return DEV_TYPE_PCIe_BRIDGE; >> } >> - return DEV_TYPE_PCIe_BRIDGE; >> + break; >> + >> + case PCI_CLASS_HOST_PCI_BRIDGE: >> + return DEV_TYPE_PCI_HOST_BRIDGE; >> case 0x0000: case 0xffff: >> return DEV_TYPE_PCI_UNKNOWN; >> } >> - return pos ? DEV_TYPE_PCIe_ENDPOINT : DEV_TYPE_PCI; >> + return cap_offset ? DEV_TYPE_PCIe_ENDPOINT : DEV_TYPE_PCI; >> } >> /* >> diff --git a/xen/drivers/passthrough/vtd/iommu.c >> b/xen/drivers/passthrough/vtd/iommu.c >> index 76f7b8e..046262c 100644 >> --- a/xen/drivers/passthrough/vtd/iommu.c >> +++ b/xen/drivers/passthrough/vtd/iommu.c >> @@ -1448,6 +1448,7 @@ static int domain_context_mapping( >> break; >> case DEV_TYPE_PCI: >> + case DEV_TYPE_PCI_HOST_BRIDGE: >> if ( iommu_verbose ) >> dprintk(VTDPREFIX, "d%d:PCI: map %04x:%02x:%02x.%u\n", >> domain->domain_id, seg, bus, >> @@ -1577,6 +1578,7 @@ static int domain_context_unmap( >> break; >> case DEV_TYPE_PCI: >> + case DEV_TYPE_PCI_HOST_BRIDGE: >> if ( iommu_verbose ) >> dprintk(VTDPREFIX, "d%d:PCI: unmap %04x:%02x:%02x.%u\n",= >> domain->domain_id, seg, bus, PCI_SLOT(devfn), >> PCI_FUNC(devfn)); >> diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h >> index ca72a99..2530491 100644 >> --- a/xen/include/xen/pci.h >> +++ b/xen/include/xen/pci.h >> @@ -73,6 +73,7 @@ struct pci_dev { >> DEV_TYPE_PCIe2PCI_BRIDGE, // PCIe-to-PCI/PCIx bridge >> DEV_TYPE_PCI2PCIe_BRIDGE, // PCI/PCIx-to-PCIe bridge >> DEV_TYPE_LEGACY_PCI_BRIDGE, // Legacy PCI bridge >> + DEV_TYPE_PCI_HOST_BRIDGE, // PCI Host bridge >> DEV_TYPE_PCI, >> } type; >> =20 >=20 >=20 I will give it a spin, but might not b before tomorrow. -Stefan --------------enigCF8B78643B9874EE81FD6DFD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQIcBAEBCgAGBQJSAgZWAAoJEOhnXe7L7s6jRkkQAKu2oMdGTQOlmj+LFr5Z9Ggr p5sYlvt14yLeL2dMD8KZXHs3qZ2ud+nSs8mDOU8gcFFotsG8XVnh2Iz8nkZTJxOA hKyX6led2xyl+/KLlp29aT1Q6Wallqd/ZlC+MayVOkE4HTOucA6R11/giOzMToCn hJMEfrhsxDak+5EeLSv5/MrvOZ8++8ZMZg8yuRSFMIgF8CWlFTmuBBpZISfbX428 bOA1U/ClE54rg3SDnZxImvflMgY6PaToxzu74O4RuGPXF3Wzc6tzr4gxi6xbLIhn yL81bvtZY/yuVHkKRclwBB3rvKEiztAt5IeLWVdyaocRdnxaNcTrj0rbA2JVhUiZ 4VMczy3gSQKwx91kGjqy8/dORPZtx8HZvewTsoR0OosDd6nj11OJERimZ2lFbXTt 994syWNGeErK0HfpuLGmfCuypu0nJhlDsJX0nyNBlr7Y6QRoZEOEM6uiVlkO7fRP wUfe/rsqUjwA7Un7JnOnGN0xWsWLZQXkj/XOyoybjkHqZs0BfQhNSmZed8PUtX+b zyMSFxU49c/+6aDOjQNmaLemVf4LQX/7gBDnFyTuaiUr+Ec6L3x23LQTkeJ/85MD 8dDkkw59YZgKljffDYe40lXEFIR0fNcRb8DF/kGa/wj3qEA7vKzZxcvyMpZPHYPQ VfaShyH/qa/JfkQpC1XH =LE6i -----END PGP SIGNATURE----- --------------enigCF8B78643B9874EE81FD6DFD-- --===============7071004020959115126== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============7071004020959115126==--