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: Thu, 08 Aug 2013 13:12:48 +0200 Message-ID: <52037D30.1050103@canonical.com> References: <1375843208-3165-1-git-send-email-suravee.suthikulpanit@amd.com> <5201B42B.2090602@amd.com> <52020656.6090501@canonical.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7025362806856082431==" Return-path: In-Reply-To: <52020656.6090501@canonical.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: JBeulich@suse.com, xiantao.zhang@intel.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============7025362806856082431== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig0B6EE981AAC310FB4F92C89A" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig0B6EE981AAC310FB4F92C89A Content-Type: multipart/mixed; boundary="------------020808090007010801090804" This is a multi-part message in MIME format. --------------020808090007010801090804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 07.08.2013 10:33, Stefan Bader wrote: >> > I will give it a spin, but might not b before tomorrow. >=20 > -Stefan So I went ahead and modified Suravee's patch according to what I think Ja= n was suggesting. This seems to be working and preventing the messages without = showing any immediately visible problems. -Stefan --- From: Suravee Suthikulpanit Date: Tue, 6 Aug 2013 21:40:08 -0500 Subject: [Xen-devel] [PATCH 1/1] x86/AMD: Fix setup ssss:bb:dd:f for d0 f= ailed 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(-) Index: xen-4.3.0/xen/drivers/passthrough/amd/pci_amd_iommu.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/drivers/passthrough/amd/pci_amd_iommu.c 2013-08-08= 09:34:30.572474632 +0200 +++ xen-4.3.0/xen/drivers/passthrough/amd/pci_amd_iommu.c 2013-08-08 10:04:55.056397984 +0200 @@ -175,9 +175,20 @@ static int __init amd_iommu_setup_dom0_d if ( unlikely(!iommu) ) { + /* 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 bridge %04x:%02x:%02x.%u (type %x)= \n", + pdev->seg, PCI_BUS(bdf), PCI_SLOT(bdf), PCI_FUNC= (bdf), + pdev->type); + return 0; + } AMD_IOMMU_DEBUG("No iommu for device %04x:%02x:%02x.%u\n", pdev->seg, pdev->bus, - PCI_SLOT(devfn), PCI_FUNC(devfn)); + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); return -ENODEV; } Index: xen-4.3.0/xen/drivers/passthrough/pci.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/drivers/passthrough/pci.c 2013-08-08 09:34:30.5724= 74632 +0200 +++ xen-4.3.0/xen/drivers/passthrough/pci.c 2013-08-08 10:02:34.472403890= +0200 @@ -189,9 +189,6 @@ static struct pci_dev *alloc_pdev(struct 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 break; case DEV_TYPE_PCI: + case DEV_TYPE_PCI_HOST_BRIDGE: + case DEV_TYPE_PCIe_BRIDGE: break; default: @@ -691,7 +690,8 @@ void pci_release_devices(struct domain * spin_unlock(&pcidevs_lock); } -#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_PCI_HOST_BRIDGE 0x0600 +#define PCI_CLASS_BRIDGE_PCI 0x0604 enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) { @@ -715,6 +715,9 @@ enum pdev_type pdev_type(u16 seg, u8 bus } return DEV_TYPE_PCIe_BRIDGE; + case PCI_CLASS_PCI_HOST_BRIDGE: + return DEV_TYPE_PCI_HOST_BRIDGE; + case 0x0000: case 0xffff: return DEV_TYPE_PCI_UNKNOWN; } Index: xen-4.3.0/xen/drivers/passthrough/vtd/iommu.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/drivers/passthrough/vtd/iommu.c 2013-08-08 09:34:30.572474632 +0200 +++ xen-4.3.0/xen/drivers/passthrough/vtd/iommu.c 2013-08-08 09:34:30.564= 474633 +0200 @@ -1447,6 +1447,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, @@ -1576,6 +1577,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_FU= NC(devfn)); Index: xen-4.3.0/xen/include/xen/pci.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/include/xen/pci.h 2013-08-08 09:34:30.572474632 +0= 200 +++ xen-4.3.0/xen/include/xen/pci.h 2013-08-08 09:34:30.564474633 +0200 @@ -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; --------------020808090007010801090804 Content-Type: text/x-diff; name="xen-amd-bridge.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-amd-bridge.patch" From: Suravee Suthikulpanit Date: Tue, 6 Aug 2013 21:40:08 -0500 Subject: [Xen-devel] [PATCH 1/1] x86/AMD: Fix setup ssss:bb:dd:f for d0 f= ailed 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.=20 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(-) Index: xen-4.3.0/xen/drivers/passthrough/amd/pci_amd_iommu.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/drivers/passthrough/amd/pci_amd_iommu.c 2013-08-08= 09:34:30.572474632 +0200 +++ xen-4.3.0/xen/drivers/passthrough/amd/pci_amd_iommu.c 2013-08-08 10:0= 4:55.056397984 +0200 @@ -175,9 +175,20 @@ static int __init amd_iommu_setup_dom0_d =20 if ( unlikely(!iommu) ) { + /* 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 bridge %04x:%02x:%02x.%u (type %x)= \n", + pdev->seg, PCI_BUS(bdf), PCI_SLOT(bdf), PCI_FUNC= (bdf), + pdev->type); + return 0; + } AMD_IOMMU_DEBUG("No iommu for device %04x:%02x:%02x.%u\n", pdev->seg, pdev->bus, - PCI_SLOT(devfn), PCI_FUNC(devfn)); + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); return -ENODEV; } =20 Index: xen-4.3.0/xen/drivers/passthrough/pci.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/drivers/passthrough/pci.c 2013-08-08 09:34:30.5724= 74632 +0200 +++ xen-4.3.0/xen/drivers/passthrough/pci.c 2013-08-08 10:02:34.472403890= +0200 @@ -189,9 +189,6 @@ static struct pci_dev *alloc_pdev(struct u16 cap; u8 sec_bus, sub_bus; =20 - 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 break; =20 case DEV_TYPE_PCI: + case DEV_TYPE_PCI_HOST_BRIDGE: + case DEV_TYPE_PCIe_BRIDGE: break; =20 default: @@ -691,7 +690,8 @@ void pci_release_devices(struct domain * spin_unlock(&pcidevs_lock); } =20 -#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_PCI_HOST_BRIDGE 0x0600 +#define PCI_CLASS_BRIDGE_PCI 0x0604 =20 enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) { @@ -715,6 +715,9 @@ enum pdev_type pdev_type(u16 seg, u8 bus } return DEV_TYPE_PCIe_BRIDGE; =20 + case PCI_CLASS_PCI_HOST_BRIDGE: + return DEV_TYPE_PCI_HOST_BRIDGE; + case 0x0000: case 0xffff: return DEV_TYPE_PCI_UNKNOWN; } Index: xen-4.3.0/xen/drivers/passthrough/vtd/iommu.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/drivers/passthrough/vtd/iommu.c 2013-08-08 09:34:3= 0.572474632 +0200 +++ xen-4.3.0/xen/drivers/passthrough/vtd/iommu.c 2013-08-08 09:34:30.564= 474633 +0200 @@ -1447,6 +1447,7 @@ static int domain_context_mapping( break; =20 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, @@ -1576,6 +1577,7 @@ static int domain_context_unmap( break; =20 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_FU= NC(devfn)); Index: xen-4.3.0/xen/include/xen/pci.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- xen-4.3.0.orig/xen/include/xen/pci.h 2013-08-08 09:34:30.572474632 +0= 200 +++ xen-4.3.0/xen/include/xen/pci.h 2013-08-08 09:34:30.564474633 +0200 @@ -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 --------------020808090007010801090804-- --------------enig0B6EE981AAC310FB4F92C89A 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/ iQIcBAEBCgAGBQJSA30wAAoJEOhnXe7L7s6jsBIQANphqRctBJ9KqanIGENtaU9w WeU7rOgcgU4L2sMOor9Og2ImfSdqrU0vALJNDkEJevbU248BmJWx0vV8bw8Ylvhn aoskX5hWLp9ewqGwi5JDAfImOHzmjvbE85n7C+sGCgEEPwl2rvYNI38KHR0R53UH 0UNp5/cpcM0r5DUuXgao62cJL0b1WqLhwG1Js3EZjDldkxVm7aRRWLaRZRcoe6+Q Ppjm3Pgp6mqTF4jnIvKFGURXJqrqlBBLhxt/9pFEa/+r66pORzERGdrP9UdUzuRy e20ubNKqi4t2ouWEyGg9n3H/NnYoJ0RrU3Rrg7nPEDJU6rJazavQ3PGrIQRsj01O vTIN9dIPdzEemL8HxvaBVw2iSpvfKTZdsDto7vG07vaNPc1O8Cfl3p7bgV97+qRA 88GcUmC8SPlDyaB1yedE1ECGl3RS6ZBVKJZHbCPmOnrHc6B/T+3gvWVcGV8v8UFu F0DU/gFnPojJ9Ta77+4k7rF4j6I6jXJlwuTuO+KVfIaTSvLhe7AC8rS3U7LHQAzb tnz+cR7jlKzL/0Xj+11CECOBqyn6q9a5ueKyAnBjoBkshumpe/ZPJ3hCCo+q0KDh zY2+GmAQHOv2Y7USB55U01Ysio7evW8oTr0ZzM/6yV47Io3oNLkM/jGB3/wPM0Vk 28bPaIHtWoYCjtxdsdqj =IRkl -----END PGP SIGNATURE----- --------------enig0B6EE981AAC310FB4F92C89A-- --===============7025362806856082431== 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 --===============7025362806856082431==--