All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Bader <stefan.bader@canonical.com>
To: Suravee Suthikulanit <suravee.suthikulpanit@amd.com>
Cc: JBeulich@suse.com, xiantao.zhang@intel.com, xen-devel@lists.xen.org
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	[thread overview]
Message-ID: <52037D30.1050103@canonical.com> (raw)
In-Reply-To: <52020656.6090501@canonical.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 5795 bytes --]

On 07.08.2013 10:33, Stefan Bader wrote:

>>
> I will give it a spin, but might not b before tomorrow.
> 
> -Stefan

So I went ahead and modified Suravee's patch according to what I think Jan was
suggesting. This seems to be working and preventing the messages without showing
any immediately visible problems.

-Stefan

---

From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
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 failed

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 <suravee.suthikulpanit@amd.com>
---
 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
===================================================================
--- 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 == DEV_TYPE_PCIe_BRIDGE)
+             || (pdev->type == DEV_TYPE_PCIe2PCI_BRIDGE)
+             || (pdev->type == DEV_TYPE_LEGACY_PCI_BRIDGE)
+             || (pdev->type == 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
===================================================================
--- xen-4.3.0.orig/xen/drivers/passthrough/pci.c	2013-08-08 09:34:30.572474632 +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 = 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
===================================================================
--- 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.564474633
+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_FUNC(devfn));
Index: xen-4.3.0/xen/include/xen/pci.h
===================================================================
--- xen-4.3.0.orig/xen/include/xen/pci.h	2013-08-08 09:34:30.572474632 +0200
+++ 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;


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: xen-amd-bridge.patch --]
[-- Type: text/x-diff; name="xen-amd-bridge.patch", Size: 5462 bytes --]

From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
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 failed

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 <suravee.suthikulpanit@amd.com>
---
 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
===================================================================
--- 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 == DEV_TYPE_PCIe_BRIDGE)
+             || (pdev->type == DEV_TYPE_PCIe2PCI_BRIDGE)
+             || (pdev->type == DEV_TYPE_LEGACY_PCI_BRIDGE)
+             || (pdev->type == 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
===================================================================
--- xen-4.3.0.orig/xen/drivers/passthrough/pci.c	2013-08-08 09:34:30.572474632 +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 = 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
===================================================================
--- 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.564474633 +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_FUNC(devfn));
Index: xen-4.3.0/xen/include/xen/pci.h
===================================================================
--- xen-4.3.0.orig/xen/include/xen/pci.h	2013-08-08 09:34:30.572474632 +0200
+++ 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;
 

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 899 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2013-08-08 11:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07  2:40 [PATCH 1/1] x86/AMD: Fix setup ssss:bb:dd:f for d0 failed suravee.suthikulpanit
2013-08-07  2:42 ` Suravee Suthikulanit
2013-08-07  8:33   ` Stefan Bader
2013-08-08 11:12     ` Stefan Bader [this message]
2013-08-08 11:49       ` Jan Beulich
2013-08-08 12:07         ` Stefan Bader
2013-08-08 12:29           ` Jan Beulich
2013-08-08 12:35             ` Stefan Bader
2013-08-07  7:33 ` Jan Beulich
2013-08-07 15:31   ` Suravee Suthikulanit
2013-08-07 15:42     ` Jan Beulich
2013-08-07 19:20       ` Suravee Suthikulanit
2013-08-08  6:38         ` Jan Beulich
2013-08-30  1:25           ` Suravee Suthikulpanit
2013-08-30  8:09             ` Jan Beulich
2013-08-31  0:03               ` Suravee Suthikulpanit
2013-08-07  9:34 ` Andrew Cooper
2013-08-07  9:57   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52037D30.1050103@canonical.com \
    --to=stefan.bader@canonical.com \
    --cc=JBeulich@suse.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xiantao.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.