Skip to contentSkip to conversation

qemu:xen: implement isa bridge specific to IGD passthrough

PATCH In review Tiejun Chen 5 participants 38 messages Aug 21, 2014 – Nov 5, 2014

lore
Share & tools
lore
#0 lore raw

cover qemu:xen: implement isa bridge specific to IGD passthrough

This is a subset to support IGD passthrough with qemu/xen, and this should be based on

http://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg02166.html

We will register to create isa bridge specific to IGD passthrough.

----------------------------------------------------------------
Tiejun Chen (2):
hw:xen:xen_pt: register isa bridge specific to IGD passthrough xen:i386:pc_piix: create isa bridge specific to IGD passthrough

 hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
 hw/xen/xen_pt.c   | 21 +++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

Thanks
Tiejun

#1 lore raw

PATCH 1/2 hw:xen:xen_pt: register isa bridge specific to IGD passthrough

We need this instance to passthrough some config fields of PCH.

---
 hw/xen/xen_pt.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
hw/xen/xen_pt.c +21 -0
index c1bf357..bf72719 100644
@@ -829,3 +829,24 @@ static void xen_pci_passthrough_register_types(void)
 }
 
 type_init(xen_pci_passthrough_register_types)
+
+static void xen_igd_passthrough_isa_bridge_class_init(ObjectClass *klass,
+                                                      void *data)
+{
+    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+    k->class_id = PCI_CLASS_BRIDGE_ISA;
+};
+
+static TypeInfo xen_igd_passthrough_isa_bridge_info = {
+    .name           = "xen-igd-passthrough-isa-bridge",
+    .parent         = TYPE_PCI_DEVICE,
+    .class_init     = xen_igd_passthrough_isa_bridge_class_init,
+};
+
+static void xen_igd_passthrough_isa_bridge_register_types(void)
+{
+    type_register_static(&xen_igd_passthrough_isa_bridge_info);
+}
+
+type_init(xen_igd_passthrough_isa_bridge_register_types);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/2 xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the real vendor/device ids as the driver expect.

---
 hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +23 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
 #include "cpu.h"
 #include "qemu/error-report.h"
 #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
 #endif
 
 #define MAX_IDE_BUS 2
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
+        } else
+            fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+    }
+}
+
 static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
 {
     PCIBus *bus;
@@ -472,6 +493,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }
 }
 #endif
Signature · 1 line
1.9.1
#3 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 1 line · Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the

Currently

Quoted 1 line

real vendor/device ids as the driver expect.

Could you add a bit more description to this patch please? Explain the rationale, etc.

Quoted 21 lines
---
 hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +2 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
 #include "cpu.h"
 #include "qemu/error-report.h"
 #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
 #endif
 
 #define MAX_IDE_BUS 2

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 473

Quoted 10 lines
hw/i386/pc_piix.c +7 -0
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.

should

However I would remove the comment as it does not add anything extra to the function. It is pretty clear what it is doing.

What would help is if you said:

Must be fixed at 1f.0 because .. bla blah

Quoted 32 lines
hw/i386/pc_piix.c +14 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
+        } else
+            fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+    }
+}
+
 static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
 {
     PCIBus *bus;
@@ -472,6 +493,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }
 }
 #endif
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#4 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the

Currently

Fixed.

Quoted 5 lines
Quoted 2 lines

real vendor/device ids as the driver expect.

Could you add a bit more description to this patch please? Explain the rationale, etc.

So rephrase as follows:

xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Currently IGD drivers always need to access PCH by 1f.0, and identify PCH type with its own real vendor/device ids. This type value help driver initialize correctly.

Quoted 34 lines
Quoted 21 lines
---
  hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +2 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
  #include "cpu.h"
  #include "qemu/error-report.h"
  #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
  #endif
 
  #define MAX_IDE_BUS 2

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 473

Quoted 10 lines
hw/i386/pc_piix.c +7 -0
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
      }
  }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.

should

Quoted 6 lines

However I would remove the comment as it does not add anything extra to the function. It is pretty clear what it is doing.

What would help is if you said:

Must be fixed at 1f.0 because .. bla blah

Like the patch description, so what about this,

    /* Currently IGD drivers always need to access PCH by 1f.0, and
     * identify PCH type with its own real vendor/device ids.
     */

Thanks
Tiejun

Quoted 34 lines
Quoted 33 lines
hw/i386/pc_piix.c +14 -1
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
+        } else
+            fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+    }
+}
+
  static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
  {
      PCIBus *bus;
@@ -472,6 +493,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
      bus = pci_find_primary_bus();
      if (bus != NULL) {
          pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
      }
  }
  #endif
--

1.9.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#37 lore raw

Re: [Qemu-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Tiejun Chen
Quoted 30 lines · Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the real vendor/device ids as the driver expect.

---
 hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +6 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
 #include "cpu.h"
 #include "qemu/error-report.h"
 #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
 #endif
 
 #define MAX_IDE_BUS 2
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 480

Quoted 10 lines
hw/i386/pc_piix.c +10 -0
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);

No need to override vendor ID, it's intel anyway.

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 481

Quoted 1 line
hw/i386/pc_piix.c +1 -0
+            pci_config_set_device_id(dev->config, hdev.device_id);

Please don't do this directly.
Instead, add a property specifying device ID.
Xen can then set this property in Xen code.

Quoted 18 lines
hw/i386/pc_piix.c +6 -0
+        } else
+            fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+    }
+}
+
 static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
 {
     PCIBus *bus;
@@ -472,6 +493,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }
 }
 #endif
Signature · 1 line
1.9.1
#5 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Chen, Tiejun
Quoted 11 lines · Tiejun
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the

Currently

Fixed.

Quoted 3 lines
Quoted 2 lines

real vendor/device ids as the driver expect.

Quoted 8 lines
Quoted 2 lines

Could you add a bit more description to this patch please? Explain the rationale, etc.

So rephrase as follows:

xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Currently IGD drivers always need to access PCH by 1f.0,

OK

Quoted 3 lines

and
identify PCH type with its own real vendor/device ids. This type value help driver initialize correctly.

instead: PCH vendor/device id is used to identify the card.

Quoted 41 lines
Quoted 34 lines
Quoted 21 lines
---
 hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +2 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
 #include "cpu.h"
 #include "qemu/error-report.h"
 #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
 #endif
 
 #define MAX_IDE_BUS 2

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 473

Quoted 10 lines
hw/i386/pc_piix.c +7 -0
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.

should

Quoted 6 lines

However I would remove the comment as it does not add anything extra to the function. It is pretty clear what it is doing.

What would help is if you said:

Must be fixed at 1f.0 because .. bla blah

Quoted 18 lines

Like the patch description, so what about this,

    /* Currently IGD drivers always need to access PCH by 1f.0, and
     * identify PCH type with its own real vendor/device ids.
     */

Thanks
Tiejun

Quoted 9 lines
Quoted 9 lines
hw/i386/pc_piix.c +8 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
hw/i386/pc_piix.c +6 -1
+        } else
+            fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+    }
+}
+
 static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
 {
     PCIBus *bus;
@@ -472,6 +493,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }
 }
 #endif
--

1.9.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 21 lines · Michael S. Tsirkin
Quoted 11 lines · Tiejun
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the

Currently

Fixed.

Quoted 3 lines
Quoted 2 lines

real vendor/device ids as the driver expect.

Quoted 8 lines
Quoted 2 lines

Could you add a bit more description to this patch please? Explain the rationale, etc.

So rephrase as follows:

xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Currently IGD drivers always need to access PCH by 1f.0,

Quoted 7 lines

OK

Quoted 3 lines

and
identify PCH type with its own real vendor/device ids. This type value help driver initialize correctly.

instead: PCH vendor/device id is used to identify the card.

Okay.

Quoted 61 lines
Quoted 42 lines
Quoted 35 lines
Quoted 22 lines
---
  hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +2 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
  #include "cpu.h"
  #include "qemu/error-report.h"
  #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
  #endif
 
  #define MAX_IDE_BUS 2

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 473

Quoted 10 lines
hw/i386/pc_piix.c +7 -0
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState *machine)
      }
  }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.

should

Quoted 6 lines

However I would remove the comment as it does not add anything extra to the function. It is pretty clear what it is doing.

What would help is if you said:

Must be fixed at 1f.0 because .. bla blah

Quoted 18 lines

Like the patch description, so what about this,

     /* Currently IGD drivers always need to access PCH by 1f.0, and
      * identify PCH type with its own real vendor/device ids.
      */

Thanks
Tiejun

Quoted 9 lines
Quoted 9 lines
hw/i386/pc_piix.c +8 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f, 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#7 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 95 lines · Tiejun
Quoted 21 lines · Michael S. Tsirkin
Quoted 11 lines · Tiejun
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Tiejun Chen

Currenjly this ISA bridge should be fixed at 1f.0, and pass the

Currently

Fixed.

Quoted 3 lines
Quoted 2 lines

real vendor/device ids as the driver expect.

Quoted 8 lines
Quoted 2 lines

Could you add a bit more description to this patch please? Explain the rationale, etc.

So rephrase as follows:

xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Currently IGD drivers always need to access PCH by 1f.0,

Quoted 7 lines

OK

Quoted 3 lines

and
identify PCH type with its own real vendor/device ids. This type value help driver initialize correctly.

instead: PCH vendor/device id is used to identify the card.

Okay.

Quoted 63 lines
Quoted 62 lines
Quoted 36 lines
Quoted 23 lines
---
  hw/i386/pc_piix.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/pc_piix.c +2 -1
index 7710724..b131fa3 100644
@@ -50,7 +50,8 @@
  #include "cpu.h"
  #include "qemu/error-report.h"
  #ifdef CONFIG_XEN
-#  include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/hvm_info_table.h>
+#include <hw/xen/xen-host-pci-device.h>
  #endif
 
  #define MAX_IDE_BUS 2
@@ -463,6 +464,26 @@ static void pc_xen_hvm_init(MachineState
 *machine)

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState · line 474

Quoted 10 lines
hw/i386/pc_piix.c +7 -0
      }
  }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    XenHostPCIDevice hdev;
+    int r = 0;
+
+    /* This shoudl be fixed at 1f.0 then pass vendor/device ids.

should

Quoted 6 lines

However I would remove the comment as it does not add anything extra to the function. It is pretty clear what it is doing.

What would help is if you said:

Must be fixed at 1f.0 because .. bla blah

Like the patch description, so what about this,

     /* Currently IGD drivers always need to access PCH by 1f.0, and
      * identify PCH type with its own real vendor/device ids.
      */

Thanks
Tiejun

Quoted 10 lines
Quoted 10 lines
hw/i386/pc_piix.c +8 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,
 0), 0);
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 7 lines
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Michael,

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#8 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
Quoted 9 lines

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 481

Quoted 9 lines
hw/i386/pc_piix.c +5 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,

0), 0);

hw/i386/pc_piix.c +3 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Quoted 6 lines
Quoted 3 lines

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Michael,

Ping.

Thanks
Tiejun

Quoted 17 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#9 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 18 lines · Tiejun
Quoted 18 lines
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
(quoted diff) +5 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,

0), 0);

(quoted diff) +3 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

Quoted 18 lines
Quoted 15 lines

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#10 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 32 lines · Tiejun
Quoted 18 lines · Tiejun
Quoted 18 lines
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
(quoted diff) +5 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,

0), 0);

(quoted diff) +3 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there. Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH combos, as I don't think they're generally mixed across generations, though SNB and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

the problem with these tables is they are hard to keep up to date as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Quoted 18 lines
Quoted 18 lines
Quoted 15 lines

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#11 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 48 lines · Michael S. Tsirkin
Quoted 32 lines · Tiejun
Quoted 18 lines · Tiejun
Quoted 18 lines
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
(quoted diff) +5 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,

0), 0);

(quoted diff) +3 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there. Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 7 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH combos, as I don't think they're generally mixed across generations, though SNB and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Quoted 2 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 21 lines
Quoted 20 lines
Quoted 20 lines
Quoted 17 lines

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#12 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 66 lines · Tiejun
Quoted 48 lines · Michael S. Tsirkin
Quoted 32 lines · Tiejun
Quoted 18 lines · Tiejun
Quoted 18 lines
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
(quoted diff) +5 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,

0), 0);

(quoted diff) +3 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there. Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 7 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH combos, as I don't think they're generally mixed across generations, though SNB and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 39 lines
Quoted 2 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 21 lines
Quoted 20 lines
Quoted 20 lines
Quoted 17 lines

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#13 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 73 lines · Michael S. Tsirkin
Quoted 72 lines · Tiejun
Quoted 48 lines · Michael S. Tsirkin
Quoted 32 lines · Tiejun
Quoted 18 lines · Tiejun
Quoted 18 lines
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
(quoted diff) +5 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0, PCI_DEVFN(0x1f,

0), 0);

(quoted diff) +3 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config, hdev.vendor_id);
+            pci_config_set_device_id(dev->config, hdev.device_id);
Quoted 3 lines

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there. Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 7 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH combos, as I don't think they're generally mixed across generations, though SNB and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

Quoted 5 lines
Quoted 2 lines

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Thanks
Tiejun

Quoted 42 lines
Quoted 40 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 21 lines
Quoted 20 lines
Quoted 20 lines
Quoted 17 lines

Thanks
Tiejun

Quoted 8 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in passthrough case?

Thanks
Tiejun

#14 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
(quoted diff) +6 -0
+     */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+    if (dev) {
+        r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,

0), 0);

(quoted diff) +2 -0
+        if (!r) {
+            pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 20 lines
Quoted 20 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

Quoted 5 lines
Quoted 2 lines

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 7 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#15 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 105 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 20 lines
Quoted 20 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

Quoted 5 lines
Quoted 2 lines

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 7 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Quoted 3 lines

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

Point is it won't be, since future devices will not need this hack. So we just need the table for the existing ones, build it once and forget about it.

Quoted 1 line

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

That's one.
But a more important one is security: we don't want QEMU to poke at any new files in the host if we can help it, otherwise all distros have to change their LSM policies to allow this. In particular when using kvm with VFIO, QEMU does not poke at /sys/bus/pci/ at all anymore, and let's keep it that way.

Quoted 48 lines
Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#16 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 125 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, September 02, 2014 11:27 PM
To: Kay, Allen M
Cc: Chen, Tiejun; [email protected]; qemu- [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 66 lines · Allen M
Quoted 66 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix:
create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific

GPU/PCH

Quoted 5 lines
Quoted 5 lines

combos,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

as I don't think they're generally mixed across generations,
though

SNB

Quoted 1 line
Quoted 1 line
Quoted 1 line

and IVB did have compatible sockets, so there is the

possibility of

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

mixing CPT and PPT PCHs, but those are register identical as

far as the

Quoted 26 lines
Quoted 26 lines
Quoted 18 lines
Quoted 18 lines
Quoted 2 lines

graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

Quoted 5 lines
Quoted 2 lines

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Agreed.

Quoted 7 lines
Quoted 5 lines

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

If I understand this correctly, the only difference is instead of reading PCH

DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

I agree the downside of doing this is the reverse mapping table may be

hard to maintain.

Point is it won't be, since future devices will not need this hack. So we just need the table for the existing ones, build it once and forget about it.

Agree.

Quoted 11 lines
Quoted 1 line

What is the advantage of doing this instead of having QEMU reading it from

the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

That's one.
But a more important one is security: we don't want QEMU to poke at any new files in the host if we can help it, otherwise all distros have to change their LSM policies to allow this. In particular when using kvm with VFIO, QEMU does not poke at /sys/bus/pci/ at all anymore, and let's keep it that way.

OK. I now see this is from KVM support perspective. Thanks for the explanation.

Quoted 50 lines
Quoted 50 lines
Quoted 26 lines

Thanks
Tiejun

Quoted 23 lines
Quoted 23 lines
Quoted 4 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 22 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Thanks
Tiejun

Quoted 3 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#17 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Kay, Allen M
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
    uint16_t gpu_device_id;
    uint16_t pch_device_id;
} XenIGDDeviceIDInfo;

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.
*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
    /* HSW Classic */
    {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
    {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
    {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
    {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
    {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
    /* HSW ULT */
    {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
    {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
    {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
    {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
    {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
    {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
    /* HSW CRW */
    {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
    {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
    /* HSW Server */
    {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
    /* HSW SRVR */
    {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
    /* BSW */
    {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
    {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
    {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
    {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
    {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
    {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
    {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
    {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
    {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
    {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
    {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void
*opaque,
const
char *name,
Error
**errp)

{
    uint32_t value = 0;
    XenHostPCIDevice hdev;
    int r = 0, num;

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        value = hdev.device_id;

        num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
        for (r = 0; r < num; r++)
            if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                value = xen_igd_combo_id_infos[r].pch_device_id;
    }

    visit_type_uint32(v, &value, name, errp);
}

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj) {
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#18 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 187 lines · Tiejun
Quoted 102 lines · Allen M
Quoted 102 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix:
create
isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+
"xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

as I don't think they're generally mixed across generations,
though

SNB

Quoted 27 lines
Quoted 16 lines
Quoted 6 lines

and IVB did have compatible sockets, so there is the
possibility of
mixing CPT and PPT PCHs, but those are register identical as
far as the
graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 7 lines
Quoted 7 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can
do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
     uint16_t gpu_device_id;
     uint16_t pch_device_id;
} XenIGDDeviceIDInfo;

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.
*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
     /* HSW Classic */
     {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
     {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
     {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
     {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
     {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
     /* HSW ULT */
     {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
     {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
     {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
     {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
     {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
     {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
     /* HSW CRW */
     {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
     {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
     /* HSW Server */
     {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
     /* HSW SRVR */
     {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
     /* BSW */
     {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
     {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
     {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
     {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
     {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
     {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
     {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
     {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
     {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
     {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
     {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void
*opaque,
const
char *name,
Error
**errp)

Quoted 10 lines
{
     uint32_t value = 0;
     XenHostPCIDevice hdev;
     int r = 0, num;

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         value = hdev.device_id;

         num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);

Sorry for this one typo:

sizeof(xen_igd_combo_id_infos)/sizeof(xen_igd_combo_id_infos[0]);

Tiejun

Quoted 87 lines
         for (r = 0; r < num; r++)
             if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                 value = xen_igd_combo_id_infos[r].pch_device_id;
     }

     visit_type_uint32(v, &value, name, errp);
}

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj) {
object_property_add(obj, "device-id", "int",

xen_igd_passthrough_pciisabridge_get_pci_device_id,

                         NULL, NULL, NULL, NULL);
}

Thanks
Tiejun

Quoted 64 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#21 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Chen, Tiejun
Quoted 123 lines · Tiejun
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
    uint16_t gpu_device_id;
    uint16_t pch_device_id;
} XenIGDDeviceIDInfo;
Quoted 14 lines

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.

Pls write Haswell and Broadwell in full in comment.

Quoted 42 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
    /* HSW Classic */
    {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
    {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
    {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
    {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
    {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
    /* HSW ULT */
    {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
    {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
    {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
    {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
    {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
    {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
    /* HSW CRW */
    {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
    {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
    /* HSW Server */
    {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
    /* HSW SRVR */
    {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
    /* BSW */
    {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
    {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
    {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
    {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
    {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
    {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
    {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
    {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
    {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
    {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
    {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void *opaque, const char
*name,
Error **errp)

Quoted 13 lines
{
    uint32_t value = 0;
    XenHostPCIDevice hdev;
    int r = 0, num;

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        value = hdev.device_id;

        num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
        for (r = 0; r < num; r++)
            if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                value = xen_igd_combo_id_infos[r].pch_device_id;

that's messy, I would use different variables for ID of GPU and PCH.

Quoted 3 lines
    }

    visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).
Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

Quoted 8 lines

}

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj) {
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

OK and what reads this property?

Quoted 62 lines

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#22 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 139 lines · Michael S. Tsirkin
Quoted 123 lines · Tiejun
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
     uint16_t gpu_device_id;
     uint16_t pch_device_id;
} XenIGDDeviceIDInfo;
Quoted 14 lines

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.

Quoted 1 line

Pls write Haswell and Broadwell in full in comment.

Are you saying I should list all PCH device ids both of HSW and BDW here like this format?

HSWGT1D: 0xABCD
...

Quoted 52 lines
Quoted 52 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
     /* HSW Classic */
     {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
     {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
     {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
     {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
     {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
     /* HSW ULT */
     {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
     {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
     {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
     {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
     {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
     {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
     /* HSW CRW */
     {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
     {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
     /* HSW Server */
     {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
     /* HSW SRVR */
     {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
     /* BSW */
     {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
     {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
     {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
     {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
     {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
     {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
     {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
     {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
     {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
     {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
     {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void *opaque, const char
*name,
Error **errp)

{
     uint32_t value = 0;
     XenHostPCIDevice hdev;
     int r = 0, num;

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         value = hdev.device_id;
Quoted 7 lines
Quoted 4 lines
         num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
         for (r = 0; r < num; r++)
             if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                 value = xen_igd_combo_id_infos[r].pch_device_id;

that's messy, I would use different variables for ID of GPU and PCH.

        for (r = 0; r < num; r++)
            if (gpu_id == xen_igd_combo_id_infos[r].gpu_device_id)
                pch_id = xen_igd_combo_id_infos[r].pch_device_id;
Quoted 8 lines
Quoted 4 lines
     }

     visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).

I think current codes is doing this:

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        gpu_id = hdev.device_id;

Here xen_host_pci_device_get() is a wrapper of reading pci sysfs.

Quoted 6 lines

Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

I think we should return one initialized value, 0xffff, since often this represents an invalid PCI device.

Quoted 4 lines

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

We still fix this bridge at 1f.0, and current our implementation can cover our requirement and safe. I means this bridge should not be used for other use cases, so if its still be accessed we mightn't take care of them, right?

Quoted 4 lines
Quoted 4 lines

}

Quoted 8 lines
Quoted 6 lines

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj)
{
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

OK and what reads this property?

In sequent patch I will do something like this,

@@ -464,6 +464,32 @@ static void pc_xen_hvm_init(MachineState *machine)

     }

}

+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus) +{

+    struct PCIDevice *dev;
+    Error *local_err = NULL;
+    uint16_t device_id = 0xffff;

+
+ /* Currently IGD drivers always need to access PCH by 1f.0. */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+
+ /* Identify PCH card with its own real vendor/device ids.
+ * Here that vendor id is always PCI_VENDOR_ID_INTEL.
+ */
+ if (dev) {
+ device_id = (uint16_t)object_property_get_int(OBJECT(dev),
+ "device-id",
+ &local_err);
+ if ((!local_err) && (device_id != 0xffff)) {
+ pci_config_set_device_id(dev->config, device_id);
+ return;
+ }
+ }
+
+ fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+}
+
static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)

 {
     PCIBus *bus;
@@ -473,6 +499,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }

}
#endif

Tiejun

Quoted 64 lines
Quoted 63 lines

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#23 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Ping...

Thanks
Tiejun

Quoted 406 lines · Tiejun
Quoted 156 lines · Michael S. Tsirkin
Quoted 139 lines · Tiejun
Quoted 108 lines · Allen M
Quoted 108 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected];
Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix:
create
isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+
"xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 25 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 7 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the
card
and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you
previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out
how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

as I don't think they're generally mixed across generations,
though

SNB

Quoted 29 lines
Quoted 18 lines
Quoted 6 lines

and IVB did have compatible sockets, so there is the
possibility of
mixing CPT and PPT PCHs, but those are register identical as
far as the
graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

[GPU Card: device_id(s), PCH: device_id]

Quoted 7 lines

Then each time, instead of exposing that real PCH device id directly,
qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for
the guest driver to do the right thing.

Quoted 7 lines
Quoted 7 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can
do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this
process.

You know this involve different GPU components we have to take some time to
communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment
can help us to understand something, but if you have any question, we can
further respond inline.

---

typedef struct {
     uint16_t gpu_device_id;
     uint16_t pch_device_id;
} XenIGDDeviceIDInfo;
Quoted 15 lines

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW
scenarios,
* 0x9cc3 for BDW.

Quoted 1 line

Pls write Haswell and Broadwell in full in comment.

Are you saying I should list all PCH device ids both of HSW and BDW here like this format?

HSWGT1D: 0xABCD
...

Quoted 57 lines
Quoted 57 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
     /* HSW Classic */
     {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
     {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
     {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
     {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
     {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
     /* HSW ULT */
     {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
     {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
     {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
     {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
     {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
     {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
     /* HSW CRW */
     {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
     {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
     /* HSW Server */
     {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
     /* HSW SRVR */
     {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
     /* BSW */
     {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
     {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
     {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
     {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
     {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
     {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
     {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
     {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
     {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
     {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
     {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,

Visitor *v,
void
*opaque,
const
char
*name,
Error
**errp)

{
     uint32_t value = 0;
     XenHostPCIDevice hdev;
     int r = 0, num;

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         value = hdev.device_id;
Quoted 7 lines
Quoted 4 lines
         num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
         for (r = 0; r < num; r++)
             if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                 value = xen_igd_combo_id_infos[r].pch_device_id;

that's messy, I would use different variables for ID of GPU and PCH.

         for (r = 0; r < num; r++)
             if (gpu_id == xen_igd_combo_id_infos[r].gpu_device_id)
                 pch_id = xen_igd_combo_id_infos[r].pch_device_id;
Quoted 8 lines
Quoted 4 lines
     }

     visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).

I think current codes is doing this:

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         gpu_id = hdev.device_id;

Here xen_host_pci_device_get() is a wrapper of reading pci sysfs.

Quoted 6 lines

Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

I think we should return one initialized value, 0xffff, since often this represents an invalid PCI device.

Quoted 4 lines

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

We still fix this bridge at 1f.0, and current our implementation can cover our requirement and safe. I means this bridge should not be used for other use cases, so if its still be accessed we mightn't take care of them, right?

Quoted 8 lines
Quoted 8 lines

}

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj) {
object_property_add(obj, "device-id", "int",

Quoted 5 lines
Quoted 3 lines

xen_igd_passthrough_pciisabridge_get_pci_device_id,

                         NULL, NULL, NULL, NULL);
}

OK and what reads this property?

In sequent patch I will do something like this,

(quoted diff) +27 -0
@@ -464,6 +464,32 @@ static void pc_xen_hvm_init(MachineState *machine)
      }
  }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    Error *local_err = NULL;
+    uint16_t device_id = 0xffff;
+
+    /* Currently IGD drivers always need to access PCH by 1f.0. */
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+
+    /* Identify PCH card with its own real vendor/device ids.
+     * Here that vendor id is always PCI_VENDOR_ID_INTEL.
+     */
+    if (dev) {
+        device_id = (uint16_t)object_property_get_int(OBJECT(dev),
+                                                      "device-id",
+                                                      &local_err);
+        if ((!local_err) && (device_id != 0xffff)) {
+            pci_config_set_device_id(dev->config, device_id);
+            return;
+        }
+    }
+
+    fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+}
+
  static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
  {
      PCIBus *bus;
@@ -473,6 +499,7 @@ static void
 xen_igd_passthrough_pc_hvm_init(MachineState *machine)
      bus = pci_find_primary_bus();
      if (bus != NULL) {
          pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
      }
  }
  #endif

Tiejun

Quoted 71 lines
Quoted 70 lines

Thanks
Tiejun

Quoted 65 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 22 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Thanks
Tiejun

Quoted 3 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#24 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Chen, Tiejun
Quoted 140 lines · Tiejun
Quoted 139 lines · Michael S. Tsirkin
Quoted 137 lines · Tiejun
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card
and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you previously? Do you mean I should list all PCHs with a combo illustrated with the vendor/device id in advance? Then look up if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
    uint16_t gpu_device_id;
    uint16_t pch_device_id;
} XenIGDDeviceIDInfo;

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.

Quoted 7 lines
Quoted 1 line

Pls write Haswell and Broadwell in full in comment.

Are you saying I should list all PCH device ids both of HSW and BDW here like this format?

HSWGT1D: 0xABCD
...

I am merely saying don't say "HSW, BDW" in comments. Say "Haswell, Broadwell, or if you like HWS(Haswell), BDW(Broadwell).

Quoted 57 lines
Quoted 57 lines
Quoted 56 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
    /* HSW Classic */
    {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
    {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
    {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
    {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
    {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
    /* HSW ULT */
    {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
    {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
    {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
    {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
    {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
    {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
    /* HSW CRW */
    {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
    {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
    /* HSW Server */
    {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
    /* HSW SRVR */
    {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
    /* BSW */
    {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
    {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
    {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
    {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
    {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
    {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
    {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
    {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
    {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
    {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
    {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void *opaque, const char
*name,
Error **errp)

{
    uint32_t value = 0;
    XenHostPCIDevice hdev;
    int r = 0, num;

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        value = hdev.device_id;

        num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
        for (r = 0; r < num; r++)
            if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                value = xen_igd_combo_id_infos[r].pch_device_id;
Quoted 6 lines
Quoted 2 lines

that's messy, I would use different variables for ID of GPU and PCH.

        for (r = 0; r < num; r++)
            if (gpu_id == xen_igd_combo_id_infos[r].gpu_device_id)
                pch_id = xen_igd_combo_id_infos[r].pch_device_id;

yea

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
    }

    visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).

Quoted 7 lines

I think current codes is doing this:

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        gpu_id = hdev.device_id;

Here xen_host_pci_device_get() is a wrapper of reading pci sysfs.

Do you want the device ID of the GPU?
So please don't poke at it directly in sysfs.
Instead, find the GPU's PCIDevice and do

	gpu->config_read();

or just get from gpu->config.

Quoted 9 lines
Quoted 6 lines

Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

I think we should return one initialized value, 0xffff, since often this represents an invalid PCI device.

I'm not sure you really want an invalid PCI device, would be nicer not to have a PCH device there at all.

Quoted 8 lines
Quoted 4 lines

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

We still fix this bridge at 1f.0, and current our implementation can cover our requirement and safe. I means this bridge should not be used for other use cases, so if its still be accessed we mightn't take care of them, right?

I was asking about the host bridge device, not guest.

Quoted 26 lines
Quoted 4 lines
Quoted 4 lines

}

Quoted 8 lines
Quoted 6 lines

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj) {
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

OK and what reads this property?

In sequent patch I will do something like this,

(quoted diff) +7 -0
@@ -464,6 +464,32 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    Error *local_err = NULL;
+    uint16_t device_id = 0xffff;
+
+    /* Currently IGD drivers always need to access PCH by 1f.0. */

Review static void pc_xen_hvm_init(MachineState *machine) · line 483

Quoted 10 lines
(quoted diff) +10 -0
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+
+    /* Identify PCH card with its own real vendor/device ids.
+     * Here that vendor id is always PCI_VENDOR_ID_INTEL.
+     */
+    if (dev) {
+        device_id = (uint16_t)object_property_get_int(OBJECT(dev),
+                                                      "device-id",
+                                                      &local_err);

cast is not needed here.

Review static void pc_xen_hvm_init(MachineState *machine) · line 484

Quoted 1 line
(quoted diff) +1 -0
+        if ((!local_err) && (device_id != 0xffff)) {

too many ().

Quoted 21 lines
(quoted diff) +9 -0
+            pci_config_set_device_id(dev->config, device_id);
+            return;
+        }
+    }
+
+    fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+}
+
 static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
 {
     PCIBus *bus;
@@ -473,6 +499,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState
 *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }
 }

#endif

Quoted 2 lines

Tiejun

By the way, I wonder: would it make sense to add this code in xen_pt_initfn?

You would then do the following there:

- look up GPU by device/vendor ID
- if a legacy GPU is found, get the ID, translate to host bridge ID, and create the compat bridge.

saves the hassle of using a distinct machine type for passthrough, no?

Quoted 64 lines
Quoted 64 lines
Quoted 63 lines

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#19 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Chen, Tiejun
Quoted 10 lines · Tiejun
Quoted 10 lines

**errp)

{
    uint32_t value = 0;
    XenHostPCIDevice hdev;
    int r = 0, num;

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        value = hdev.device_id;
Quoted 7 lines
Quoted 1 line
        num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);

Sorry for this one typo:

sizeof(xen_igd_combo_id_infos)/sizeof(xen_igd_combo_id_infos[0]);

Tiejun

so don't opencode this, use ARRAY_SIZE.

#20 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 13 lines · Michael S. Tsirkin
Quoted 12 lines · Tiejun
Quoted 11 lines

**errp)

{
     uint32_t value = 0;
     XenHostPCIDevice hdev;
     int r = 0, num;

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         value = hdev.device_id;

         num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
Quoted 9 lines
Quoted 5 lines

Sorry for this one typo:

sizeof(xen_igd_combo_id_infos)/sizeof(xen_igd_combo_id_infos[0]);

Tiejun

so don't opencode this, use ARRAY_SIZE.

Yes, I will refine this with ARRAY_SIZE.

Thanks
Tiejun

#25 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

In reply to Michael S. Tsirkin
Quoted 143 lines · Michael S. Tsirkin
Quoted 142 lines · Tiejun
Quoted 140 lines · Michael S. Tsirkin
Quoted 123 lines · Tiejun
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card
and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you
previously? Do you mean I should list all PCHs with a combo
illustrated with the vendor/device id in advance? Then look up
if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
     uint16_t gpu_device_id;
     uint16_t pch_device_id;
} XenIGDDeviceIDInfo;
Quoted 14 lines

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.

Pls write Haswell and Broadwell in full in comment.

Quoted 7 lines
Quoted 5 lines

Are you saying I should list all PCH device ids both of HSW and BDW here like this format?

HSWGT1D: 0xABCD
...

I am merely saying don't say "HSW, BDW" in comments. Say "Haswell,

Sorry I'm misunderstanding what you mean.

Quoted 1 line

Broadwell, or if you like HWS(Haswell), BDW(Broadwell).

Looks the latter is moderate.

+ * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell)
+ * scenarios, 0x9cc3 for BDW(Broadwell).
+ */

Quoted 78 lines
Quoted 58 lines
Quoted 58 lines
Quoted 57 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
     /* HSW Classic */
     {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
     {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
     {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
     {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
     {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
     /* HSW ULT */
     {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
     {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
     {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
     {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
     {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
     {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
     /* HSW CRW */
     {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
     {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
     /* HSW Server */
     {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
     /* HSW SRVR */
     {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
     /* BSW */
     {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
     {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
     {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
     {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
     {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
     {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
     {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
     {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
     {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
     {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
     {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void *opaque, const char
*name,
Error **errp)

{
     uint32_t value = 0;
     XenHostPCIDevice hdev;
     int r = 0, num;

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         value = hdev.device_id;

         num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
         for (r = 0; r < num; r++)
             if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                 value = xen_igd_combo_id_infos[r].pch_device_id;
Quoted 6 lines
Quoted 2 lines

that's messy, I would use different variables for ID of GPU and PCH.

         for (r = 0; r < num; r++)
             if (gpu_id == xen_igd_combo_id_infos[r].gpu_device_id)
                 pch_id = xen_igd_combo_id_infos[r].pch_device_id;

yea

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
     }

     visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).

I think current codes is doing this:

Quoted 8 lines
Quoted 5 lines
     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         gpu_id = hdev.device_id;

Here xen_host_pci_device_get() is a wrapper of reading pci sysfs.

Do you want the device ID of the GPU?

Yes.

Quoted 4 lines

So please don't poke at it directly in sysfs.
Instead, find the GPU's PCIDevice and do

	gpu->config_read();

or just get from gpu->config.

Good, but how can we get gpu as pci_dev instance here? Then we can call pci_dev->config_read as expect.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

Quoted 5 lines
Quoted 2 lines

I think we should return one initialized value, 0xffff, since often this represents an invalid PCI device.

I'm not sure you really want an invalid PCI device, would be nicer not to have a PCH device there at all.

Yes, I means 0xffff indicates that there's no any PCI device.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

Quoted 5 lines
Quoted 3 lines

We still fix this bridge at 1f.0, and current our implementation can cover our requirement and safe. I means this bridge should not be used for other use cases, so if its still be accessed we mightn't take care of them, right?

I was asking about the host bridge device, not guest.

Are you assuming what will happen to a new device?

Quoted 40 lines
Quoted 27 lines
Quoted 5 lines
Quoted 5 lines

}

Quoted 8 lines
Quoted 6 lines

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj)
{
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

OK and what reads this property?

In sequent patch I will do something like this,

(quoted diff) +7 -0
@@ -464,6 +464,32 @@ static void pc_xen_hvm_init(MachineState *machine)
      }
  }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    Error *local_err = NULL;
+    uint16_t device_id = 0xffff;
+
+    /* Currently IGD drivers always need to access PCH by 1f.0. */

Review static void pc_xen_hvm_init(MachineState *machine) · line 483

Quoted 10 lines
(quoted diff) +10 -0
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+
+    /* Identify PCH card with its own real vendor/device ids.
+     * Here that vendor id is always PCI_VENDOR_ID_INTEL.
+     */
+    if (dev) {
+        device_id = (uint16_t)object_property_get_int(OBJECT(dev),
+                                                      "device-id",
+                                                      &local_err);

cast is not needed here.

Quoted 3 lines

Review static void pc_xen_hvm_init(MachineState *machine) · line 484

Quoted 1 line
(quoted diff) +1 -0
+        if ((!local_err) && (device_id != 0xffff)) {

too many ().

+ device_id = object_property_get_int(OBJECT(dev), "device-id",
+ &local_err);
+ if (!local_err && device_id != 0xffff) {

Quoted 27 lines
Quoted 22 lines
(quoted diff) +9 -0
+            pci_config_set_device_id(dev->config, device_id);
+            return;
+        }
+    }
+
+    fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+}
+
  static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
  {
      PCIBus *bus;
@@ -473,6 +499,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState
 *machine)
      bus = pci_find_primary_bus();
      if (bus != NULL) {
          pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
      }
  }
  #endif
Quoted 2 lines

Tiejun

By the way, I wonder: would it make sense to add this code in xen_pt_initfn?

Quoted 7 lines

You would then do the following there:

- look up GPU by device/vendor ID
- if a legacy GPU is found, get the ID, translate to host bridge ID, and create the compat bridge.

saves the hassle of using a distinct machine type for passthrough, no?

As I remember Paolo thought we'd better have a separate machine specific to IGD passthrough, so I'm not sure if its fine to him now.

Thanks
Tiejun

Quoted 67 lines
Quoted 65 lines
Quoted 65 lines
Quoted 64 lines

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

Quoted 2 lines

matched PCH? If yes, what is that benefit you expect in
passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

Thanks
Tiejun

Allen

#26 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 156 lines · Tiejun
Quoted 143 lines · Michael S. Tsirkin
Quoted 142 lines · Tiejun
Quoted 140 lines · Michael S. Tsirkin
Quoted 123 lines · Tiejun
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card
and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you
previously? Do you mean I should list all PCHs with a combo
illustrated with the vendor/device id in advance? Then look up
if we can find a

Quoted 10 lines
Quoted 2 lines

Michael,

Ping.

Thanks
Tiejun

Quoted 2 lines

Could you explain this exactly? Then I can try follow-up your
idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
    uint16_t gpu_device_id;
    uint16_t pch_device_id;
} XenIGDDeviceIDInfo;
Quoted 14 lines

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.

Pls write Haswell and Broadwell in full in comment.

Quoted 7 lines
Quoted 5 lines

Are you saying I should list all PCH device ids both of HSW and BDW here like this format?

HSWGT1D: 0xABCD
...

I am merely saying don't say "HSW, BDW" in comments. Say "Haswell,

Sorry I'm misunderstanding what you mean.

Quoted 7 lines
Quoted 1 line

Broadwell, or if you like HWS(Haswell), BDW(Broadwell).

Looks the latter is moderate.

+ * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell)
+ * scenarios, 0x9cc3 for BDW(Broadwell).
+ */

Exactly.

Quoted 90 lines
Quoted 79 lines
Quoted 59 lines
Quoted 59 lines
Quoted 58 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
    /* HSW Classic */
    {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
    {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
    {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
    {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
    {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
    /* HSW ULT */
    {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
    {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
    {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
    {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
    {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
    {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
    /* HSW CRW */
    {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
    {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
    /* HSW Server */
    {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
    /* HSW SRVR */
    {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
    /* BSW */
    {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
    {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
    {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
    {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
    {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
    {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
    {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
    {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
    {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
    {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
    {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void *opaque, const char
*name,
Error **errp)

{
    uint32_t value = 0;
    XenHostPCIDevice hdev;
    int r = 0, num;

    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        value = hdev.device_id;

        num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
        for (r = 0; r < num; r++)
            if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                value = xen_igd_combo_id_infos[r].pch_device_id;
Quoted 6 lines
Quoted 2 lines

that's messy, I would use different variables for ID of GPU and PCH.

        for (r = 0; r < num; r++)
            if (gpu_id == xen_igd_combo_id_infos[r].gpu_device_id)
                pch_id = xen_igd_combo_id_infos[r].pch_device_id;

yea

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
    }

    visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).

I think current codes is doing this:

Quoted 8 lines
Quoted 5 lines
    r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
    if (!r) {
        gpu_id = hdev.device_id;

Here xen_host_pci_device_get() is a wrapper of reading pci sysfs.

Do you want the device ID of the GPU?

Yes.

Quoted 7 lines
Quoted 4 lines

So please don't poke at it directly in sysfs.
Instead, find the GPU's PCIDevice and do

	gpu->config_read();

or just get from gpu->config.

Good, but how can we get gpu as pci_dev instance here? Then we can call pci_dev->config_read as expect.

You can't do this at host init but you can do this when gpu is added or at machine done.

Quoted 23 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

Quoted 5 lines
Quoted 2 lines

I think we should return one initialized value, 0xffff, since often this represents an invalid PCI device.

I'm not sure you really want an invalid PCI device, would be nicer not to have a PCH device there at all.

Yes, I means 0xffff indicates that there's no any PCI device.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

We still fix this bridge at 1f.0, and current our implementation can cover our requirement and safe. I means this bridge should not be used for other use cases, so if its still be accessed we mightn't take care of them, right?

I was asking about the host bridge device, not guest.

Are you assuming what will happen to a new device?

Yes, the assumption is a new devices will use a new driver which does everything through BAR, so it will not need these hacks.

Quoted 81 lines
Quoted 43 lines
Quoted 27 lines
Quoted 5 lines
Quoted 5 lines

}

Quoted 8 lines
Quoted 6 lines

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj) {
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

OK and what reads this property?

In sequent patch I will do something like this,

(quoted diff) +7 -0
@@ -464,6 +464,32 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    Error *local_err = NULL;
+    uint16_t device_id = 0xffff;
+
+    /* Currently IGD drivers always need to access PCH by 1f.0. */

Review static void pc_xen_hvm_init(MachineState *machine) · line 483

Quoted 10 lines
(quoted diff) +10 -0
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+
+    /* Identify PCH card with its own real vendor/device ids.
+     * Here that vendor id is always PCI_VENDOR_ID_INTEL.
+     */
+    if (dev) {
+        device_id = (uint16_t)object_property_get_int(OBJECT(dev),
+                                                      "device-id",
+                                                      &local_err);

cast is not needed here.

Review static void pc_xen_hvm_init(MachineState *machine) · line 484

Quoted 1 line
(quoted diff) +1 -0
+        if ((!local_err) && (device_id != 0xffff)) {

too many ().

(quoted diff) +3 -0
+        device_id = object_property_get_int(OBJECT(dev), "device-id",
+                                            &local_err);
+        if (!local_err && device_id != 0xffff) {
Quoted 34 lines
Quoted 23 lines
(quoted diff) +9 -0
+            pci_config_set_device_id(dev->config, device_id);
+            return;
+        }
+    }
+
+    fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+}
+
 static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
 {
     PCIBus *bus;
@@ -473,6 +499,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState
 *machine)
     bus = pci_find_primary_bus();
     if (bus != NULL) {
         pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
     }
 }

#endif

Quoted 2 lines

Tiejun

By the way, I wonder: would it make sense to add this code in xen_pt_initfn?

You would then do the following there:

- look up GPU by device/vendor ID
- if a legacy GPU is found, get the ID, translate to host bridge ID, and create the compat bridge.

Quoted 7 lines
Quoted 1 line

saves the hassle of using a distinct machine type for passthrough, no?

As I remember Paolo thought we'd better have a separate machine specific to IGD passthrough, so I'm not sure if its fine to him now.

Thanks
Tiejun

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ... Paolo?

Quoted 67 lines
Quoted 67 lines
Quoted 65 lines
Quoted 65 lines
Quoted 64 lines

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

matched PCH? If yes, what is that benefit you expect in
passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines

Thanks
Tiejun

Allen

#27 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 295 lines · Michael S. Tsirkin
Quoted 156 lines · Tiejun
Quoted 143 lines · Michael S. Tsirkin
Quoted 142 lines · Tiejun
Quoted 140 lines · Michael S. Tsirkin
Quoted 123 lines · Tiejun
Quoted 97 lines · Allen M
Quoted 97 lines

-----Original Message-----
From: Chen, Tiejun
Sent: Monday, September 01, 2014 12:50 AM
To: Michael S. Tsirkin
Cc: [email protected]; Kay, Allen M; [email protected]; Konrad Rzeszutek Wilk
Subject: Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Tiejun

On 2014/8/28 8:56, Chen, Tiejun wrote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ */
+ dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+ "xen-igd-passthrough-isa-bridge");
+ if (dev) {
+ r = xen_host_pci_device_get(&hdev, 0, 0,
+ PCI_DEVFN(0x1f,
0), 0);
+ if (!r) {
+ pci_config_set_vendor_id(dev->config,

hdev.vendor_id);

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 22 lines

+ pci_config_set_device_id(dev->config,
+ hdev.device_id);

Can you, instead, implement the reverse logic, probing the card
and supplying the correct device id for PCH?

Here what is your so-called reverse logic as I already asked you
previously? Do you mean I should list all PCHs with a combo
illustrated with the vendor/device id in advance? Then look up
if we can find a

Michael,

Ping.

Thanks
Tiejun

Could you explain this exactly? Then I can try follow-up your
idea ASAP if this is necessary and possible.

Quoted 7 lines

Michel,

Could you give us some explanation for your "reverse logic" when you're free?

Thanks
Tiejun

So future drivers will look at device ID for the card and figure out how things should work from there.
Old drivers still poke at device id of the chipset for this, but maybe qemu can do what newer drivers do:
look at the card and figure out what guest should do, then present the appropriate chipset id.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is based on what Jesse said:
Practically speaking, we could probably assume specific GPU/PCH

combos,

Quoted 1 line
Quoted 1 line
Quoted 1 line

as I don't think they're generally mixed across generations, though

SNB

Quoted 25 lines
Quoted 14 lines
Quoted 4 lines

and IVB did have compatible sockets, so there is the possibility of mixing CPT and PPT PCHs, but those are register identical as far as the graphics driver is concerned, so even that should be safe.

Michael,

Thanks for your explanation.

Quoted 2 lines

so the idea is to have a reverse table mapping GPU back to PCH. Present to guest the ID that will let it assume the correct GPU.

I guess you mean we should create to maintain such a table:

Quoted 8 lines

[GPU Card: device_id(s), PCH: device_id]

Then each time, instead of exposing that real PCH device id directly, qemu first can get the real GPU device id to lookup this table to present a appropriate PCH's device id to the guest.

And looks here that appropriate PCH's device id is not always a that real PCH's device id. Right? If I'm wrong please correct me.

Exactly: we don't really care what the PCH ID is - we only need it for the guest driver to do the right thing.

Quoted 6 lines
Quoted 6 lines

Agreed.

I need to ask Allen to check if one given GPU card device id is always corresponding to one given PCH on both HSW and BDW currently. If yes, I can do this quickly. Otherwise I need some time to establish that sort of connection.

Michael,

Sorry for this delay response but please keep in mind we really are in this process.

You know this involve different GPU components we have to take some time to communicate or even discuss internal.

Now I have a draft codes, could you take a look at this? I hope that comment can help us to understand something, but if you have any question, we can further respond inline.

---

typedef struct {
     uint16_t gpu_device_id;
     uint16_t pch_device_id;
} XenIGDDeviceIDInfo;
Quoted 14 lines

/* In real world different GPU should have different PCH. But actually
* the different PCH DIDs likely map to different PCH SKUs. We do the
* same thing for the GPU. For PCH, the different SKUs are going to be
* all the same silicon design and implementation, just different
* features turn on and off with fuses. The SW interfaces should be
* consistent across all SKUs in a given family (eg LPT). But just same
* features may not be supported.
*
* Most of these different PCH features probably don't matter to the
* Gfx driver, but obviously any difference in display port connections
* will so it should be fine with any PCH in case of passthrough. *
* So currently use one PCH version, 0x8c4e, to cover all HSW scenarios,
* 0x9cc3 for BDW.

Pls write Haswell and Broadwell in full in comment.

Quoted 7 lines
Quoted 5 lines

Are you saying I should list all PCH device ids both of HSW and BDW here like this format?

HSWGT1D: 0xABCD
...

I am merely saying don't say "HSW, BDW" in comments. Say "Haswell,

Sorry I'm misunderstanding what you mean.

Quoted 7 lines
Quoted 1 line

Broadwell, or if you like HWS(Haswell), BDW(Broadwell).

Looks the latter is moderate.

+ * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell)
+ * scenarios, 0x9cc3 for BDW(Broadwell).
+ */

Exactly.

Quoted 90 lines
Quoted 79 lines
Quoted 59 lines
Quoted 59 lines
Quoted 58 lines

*/

static const XenIGDDeviceIDInfo xen_igd_combo_id_infos[] = {
     /* HSW Classic */
     {0x0402, 0x8c4e}, /* HSWGT1D, HSWD_w7 */
     {0x0406, 0x8c4e}, /* HSWGT1M, HSWM_w7 */
     {0x0412, 0x8c4e}, /* HSWGT2D, HSWD_w7 */
     {0x0416, 0x8c4e}, /* HSWGT2M, HSWM_w7 */
     {0x041E, 0x8c4e}, /* HSWGT15D, HSWD_w7 */
     /* HSW ULT */
     {0x0A06, 0x8c4e}, /* HSWGT1UT, HSWM_w7 */
     {0x0A16, 0x8c4e}, /* HSWGT2UT, HSWM_w7 */
     {0x0A26, 0x8c4e}, /* HSWGT3UT, HSWM_w7 */
     {0x0A2E, 0x8c4e}, /* HSWGT3UT28W, HSWM_w7 */
     {0x0A1E, 0x8c4e}, /* HSWGT2UX, HSWM_w7 */
     {0x0A0E, 0x8c4e}, /* HSWGT1ULX, HSWM_w7 */
     /* HSW CRW */
     {0x0D26, 0x8c4e}, /* HSWGT3CW, HSWM_w7 */
     {0x0D22, 0x8c4e}, /* HSWGT3CWDT, HSWD_w7 */
     /* HSW Server */
     {0x041A, 0x8c4e}, /* HSWSVGT2, HSWD_w7 */
     /* HSW SRVR */
     {0x040A, 0x8c4e}, /* HSWSVGT1, HSWD_w7 */
     /* BSW */
     {0x1606, 0x9cc3}, /* BDWULTGT1, BDWM_w7 */
     {0x1616, 0x9cc3}, /* BDWULTGT2, BDWM_w7 */
     {0x1626, 0x9cc3}, /* BDWULTGT3, BDWM_w7 */
     {0x160E, 0x9cc3}, /* BDWULXGT1, BDWM_w7 */
     {0x161E, 0x9cc3}, /* BDWULXGT2, BDWM_w7 */
     {0x1602, 0x9cc3}, /* BDWHALOGT1, BDWM_w7 */
     {0x1612, 0x9cc3}, /* BDWHALOGT2, BDWM_w7 */
     {0x1622, 0x9cc3}, /* BDWHALOGT3, BDWM_w7 */
     {0x162B, 0x9cc3}, /* BDWHALO28W, BDWM_w7 */
     {0x162A, 0x9cc3}, /* BDWGT3WRKS, BDWM_w7 */
     {0x162D, 0x9cc3}, /* BDWGT3SRVR, BDWM_w7 */
};

static void xen_igd_passthrough_pciisabridge_get_pci_device_id(Object *obj,
Visitor *v, void *opaque, const char
*name,
Error **errp)

{
     uint32_t value = 0;
     XenHostPCIDevice hdev;
     int r = 0, num;

     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         value = hdev.device_id;

         num = sizeof(xen_igd_combo_id_infos)/sizeof(uint16_t);
         for (r = 0; r < num; r++)
             if (value == xen_igd_combo_id_infos[r].gpu_device_id)
                 value = xen_igd_combo_id_infos[r].pch_device_id;
Quoted 6 lines
Quoted 2 lines

that's messy, I would use different variables for ID of GPU and PCH.

         for (r = 0; r < num; r++)
             if (gpu_id == xen_igd_combo_id_infos[r].gpu_device_id)
                 pch_id = xen_igd_combo_id_infos[r].pch_device_id;

yea

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
     }

     visit_type_uint32(v, &value, name, errp);

what I was suggesting is to start with the GPU device ID (you can get it e.g. from the config array).

I think current codes is doing this:

Quoted 8 lines
Quoted 5 lines
     r = xen_host_pci_device_get(&hdev, 0, 0, 0x02, 0);
     if (!r) {
         gpu_id = hdev.device_id;

Here xen_host_pci_device_get() is a wrapper of reading pci sysfs.

Do you want the device ID of the GPU?

Yes.

Quoted 7 lines
Quoted 4 lines

So please don't poke at it directly in sysfs.
Instead, find the GPU's PCIDevice and do

	gpu->config_read();

or just get from gpu->config.

Good, but how can we get gpu as pci_dev instance here? Then we can call pci_dev->config_read as expect.

You can't do this at host init but you can do this when gpu is added or at machine done.

Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Use that to look up the PCH ID in xen_igd_combo_id_infos. If there, override the PCH ID.

If not there, this is a new device so its driver will not look at PCH at all, we can make it whatever or skip it completely.

Quoted 5 lines
Quoted 2 lines

I think we should return one initialized value, 0xffff, since often this represents an invalid PCI device.

I'm not sure you really want an invalid PCI device, would be nicer not to have a PCH device there at all.

Yes, I means 0xffff indicates that there's no any PCI device.

Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

This seems to almost do this, however
- Why are you looking at host PCH device ID at all?
- Why don't you look at the GPU device ID?

We still fix this bridge at 1f.0, and current our implementation can cover our requirement and safe. I means this bridge should not be used for other use cases, so if its still be accessed we mightn't take care of them, right?

Quoted 93 lines
Quoted 3 lines
Quoted 1 line

I was asking about the host bridge device, not guest.

Are you assuming what will happen to a new device?

Yes, the assumption is a new devices will use a new driver which does everything through BAR, so it will not need these hacks.

Quoted 85 lines
Quoted 43 lines
Quoted 27 lines
Quoted 5 lines
Quoted 5 lines

}

Quoted 8 lines
Quoted 6 lines

static void xen_igd_passthrough_isa_bridge_initfn(Object *obj)
{
object_property_add(obj, "device-id", "int",
xen_igd_passthrough_pciisabridge_get_pci_device_id, NULL, NULL, NULL, NULL);
}

OK and what reads this property?

In sequent patch I will do something like this,

(quoted diff) +7 -0
@@ -464,6 +464,32 @@ static void pc_xen_hvm_init(MachineState *machine)
      }
  }
 
+static void xen_igd_passthrough_isa_bridge_create(PCIBus *bus)
+{
+    struct PCIDevice *dev;
+    Error *local_err = NULL;
+    uint16_t device_id = 0xffff;
+
+    /* Currently IGD drivers always need to access PCH by 1f.0. */

Review static void pc_xen_hvm_init(MachineState *machine) · line 483

Quoted 10 lines
(quoted diff) +10 -0
+    dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0),
+                            "xen-igd-passthrough-isa-bridge");
+
+    /* Identify PCH card with its own real vendor/device ids.
+     * Here that vendor id is always PCI_VENDOR_ID_INTEL.
+     */
+    if (dev) {
+        device_id = (uint16_t)object_property_get_int(OBJECT(dev),
+                                                      "device-id",
+                                                      &local_err);

cast is not needed here.

Review static void pc_xen_hvm_init(MachineState *machine) · line 484

Quoted 1 line
(quoted diff) +1 -0
+        if ((!local_err) && (device_id != 0xffff)) {

too many ().

(quoted diff) +3 -0
+        device_id = object_property_get_int(OBJECT(dev), "device-id",
+                                            &local_err);
+        if (!local_err && device_id != 0xffff) {
Quoted 28 lines
Quoted 23 lines
(quoted diff) +9 -0
+            pci_config_set_device_id(dev->config, device_id);
+            return;
+        }
+    }
+
+    fprintf(stderr, "xen set xen-igd-passthrough-isa-bridge failed\n");
+}
+
  static void xen_igd_passthrough_pc_hvm_init(MachineState *machine)
  {
      PCIBus *bus;
@@ -473,6 +499,7 @@ static void xen_igd_passthrough_pc_hvm_init(MachineState
 *machine)
      bus = pci_find_primary_bus();
      if (bus != NULL) {
          pci_create_simple(bus, -1, "xen-platform");
+        xen_igd_passthrough_isa_bridge_create(bus);
      }
  }
  #endif
Quoted 2 lines

Tiejun

By the way, I wonder: would it make sense to add this code in xen_pt_initfn?

Quoted 7 lines

You would then do the following there:

- look up GPU by device/vendor ID
- if a legacy GPU is found, get the ID, translate to host bridge ID, and create the compat bridge.

saves the hassle of using a distinct machine type for passthrough, no?

As I remember Paolo thought we'd better have a separate machine specific to IGD passthrough, so I'm not sure if its fine to him now.

CCed Paolo.

Quoted 7 lines
Quoted 3 lines

Thanks
Tiejun

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Quoted 1 line

Paolo?

Thanks
Tiejun

Quoted 71 lines
Quoted 70 lines
Quoted 70 lines
Quoted 68 lines
Quoted 68 lines
Quoted 67 lines

Thanks
Tiejun

Quoted 58 lines
Quoted 1 line

If I understand this correctly, the only difference is instead of reading PCH DevID/RevID from the host hardware, QEMU inserts those values into PCH virtual device by looking at the reverse mapping table it maintains.

I agree the downside of doing this is the reverse mapping table may be hard to maintain.

What is the advantage of doing this instead of having QEMU reading it from the host? Is it to test to make sure reverse mapping methods works before it is adopted in the new drivers?

Quoted 25 lines

Thanks
Tiejun

Quoted 22 lines
Quoted 22 lines
Quoted 3 lines

the problem with these tables is they are hard to keep up to date

Yeah. But I think currently we can just start from some modern CPU such as HSW and BDW, then things could be easy.

Allen,

Any idea to this suggestion?

Quoted 2 lines

as new hardware comes out, but as future hardware won't need these hacks, we shall be fine.

Yeah.

Thanks
Tiejun

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks
Tiejun

matched PCH? If yes, what is that benefit you expect in
passthrough case? Shouldn't we pass these info to VM directly in

passthrough case?

Quoted 15 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

Thanks
Tiejun

Allen

#28 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 5 lines · Tiejun
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Signature · 1 line
MST
#29 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Sorry some urgent things always procrastinate on my response.

Quoted 9 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Yeah.

Actually based on current info we know, seems 1f is just specific to our scenario :) So I always think we can occupy that. But Paolo and you can really determine this point.

Thanks
Tiejun

#30 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 10 lines · Tiejun

Sorry some urgent things always procrastinate on my response.

Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Tiejun
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Quoted 8 lines
Quoted 2 lines

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Yeah.

Actually based on current info we know, seems 1f is just specific to our scenario :) So I always think we can occupy that. But Paolo and you can really determine this point.

Paolo,

What's your idea?

Thanks
Tiejun

#31 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 9 lines · Tiejun
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Quoted 7 lines
Quoted 5 lines

Yeah.

Actually based on current info we know, seems 1f is just specific to our scenario :) So I always think we can occupy that. But Paolo and you can really determine this point.

What's your idea?

I do not have any objection to always occupying 1f for Xen IGD passthrough.

Paolo

#32 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 12 lines · Paolo Bonzini
Quoted 11 lines · Tiejun
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Yeah.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Actually based on current info we know, seems 1f is just specific to our scenario :) So I always think we can occupy that. But Paolo and you can really determine this point.

What's your idea?

I do not have any objection to always occupying 1f for Xen IGD passthrough.

Cool ;-)

Thanks
Tiejun

#33 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 18 lines · Tiejun
Quoted 17 lines · Paolo Bonzini
Quoted 16 lines · Tiejun
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Yeah.

Actually based on current info we know, seems 1f is just specific to our
scenario :) So I always think we can occupy that. But Paolo and you can really determine this point.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

What's your idea?

I do not have any objection to always occupying 1f for Xen IGD passthrough.

After I go back to look at this again, I hope you don't misunderstand what Michael mean now. He was saying we don't need to create a new separate machine specific to IGD passthrough. But that idea is just from you :)

Thanks
Tiejun

#34 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 22 lines · Tiejun
Quoted 21 lines · Tiejun
Quoted 20 lines · Paolo Bonzini
Quoted 18 lines · Tiejun
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Quoted 7 lines

Yeah.

Actually based on current info we know, seems 1f is just specific to our
scenario :) So I always think we can occupy that. But Paolo and you can
really determine this point.

What's your idea?

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

I do not have any objection to always occupying 1f for Xen IGD passthrough.

After I go back to look at this again, I hope you don't misunderstand what Michael mean now. He was saying we don't need to create a new separate machine specific to IGD passthrough. But that idea is just from you :)

It's difficult for me to follow, because xen_igd_passthrough_pc_hvm_init does not exist in the current tree.

The patches seem good to me; I was assuming that the new machine type would call xen_igd_passthrough_pc_hvm_init, but apparently I'm wrong? Paolo

#35 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 33 lines · Paolo Bonzini
Quoted 22 lines · Tiejun
Quoted 21 lines · Tiejun
Quoted 20 lines · Paolo Bonzini
Quoted 18 lines · Tiejun
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Quoted 7 lines

Yeah.

Actually based on current info we know, seems 1f is just specific to our
scenario :) So I always think we can occupy that. But Paolo and you can
really determine this point.

What's your idea?

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

I do not have any objection to always occupying 1f for Xen IGD passthrough.

After I go back to look at this again, I hope you don't misunderstand what Michael mean now. He was saying we don't need to create a new separate machine specific to IGD passthrough. But that idea is just from you :)

Quoted 6 lines

It's difficult for me to follow, because xen_igd_passthrough_pc_hvm_init does not exist in the current tree.

The patches seem good to me; I was assuming that the new machine type would call xen_igd_passthrough_pc_hvm_init, but apparently I'm wrong? Paolo

Discussed on irc, Paolo said
<bonzini> so i don't really care how the ISA bridge is created

Signature · 1 line
MST
#36 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 2/2] xen:i386:pc_piix: create isa bridge specific to IGD passthrough

Quoted 37 lines · Michael S. Tsirkin
Quoted 36 lines · Paolo Bonzini
Quoted 22 lines · Tiejun
Quoted 21 lines · Tiejun
Quoted 20 lines · Paolo Bonzini
Quoted 18 lines · Tiejun
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I think the point was mostly to reserve 1f to prevent devices from using it.
As we populate slots in order it doesn't seem to important ...

If we populate slot at !1f GFX driver can't find this ISA bridge.

Right, but I mean if no special options are used, 1f will typically stay free without any effort on our side.

Quoted 7 lines

Yeah.

Actually based on current info we know, seems 1f is just specific to our
scenario :) So I always think we can occupy that. But Paolo and you can
really determine this point.

What's your idea?

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

I do not have any objection to always occupying 1f for Xen IGD passthrough.

After I go back to look at this again, I hope you don't misunderstand what Michael mean now. He was saying we don't need to create a new separate machine specific to IGD passthrough. But that idea is just from you :)

It's difficult for me to follow, because xen_igd_passthrough_pc_hvm_init does not exist in the current tree.

Quoted 7 lines
Quoted 3 lines

The patches seem good to me; I was assuming that the new machine type would call xen_igd_passthrough_pc_hvm_init, but apparently I'm wrong? Paolo

Discussed on irc, Paolo said
<bonzini> so i don't really care how the ISA bridge is created

This means all those previous patches creating new separate machine should be gone.

I would rebase these two patches to resend again as RFC.

Thanks
Tiejun