diff mbox

[v3,2/5] xen, gfx passthrough: create intel isa bridge

Message ID 1401097389-4255-3-git-send-email-tiejun.chen@intel.com
State New
Headers show

Commit Message

Tiejun Chen May 26, 2014, 9:43 a.m. UTC
ISA bridge is needed since Intel gfx drive will probe it instead
of Dev31:Fun0 to make graphics device passthrough work easy for VMM, that
only need to expose ISA bridge to let driver know the real hardware underneath.

The original patch is from Allen Kay [allen.m.kay@intel.com]

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
Cc: Allen Kay <allen.m.kay@intel.com>
---
v3:

* Fix some typos.
* Improve some return paths.

v2:

* Nothing is changed.

 hw/xen/xen_pt_graphics.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

Comments

Konrad Rzeszutek Wilk May 27, 2014, 2:55 p.m. UTC | #1
On Mon, May 26, 2014 at 05:43:06PM +0800, Tiejun Chen wrote:
> ISA bridge is needed since Intel gfx drive will probe it instead
> of Dev31:Fun0 to make graphics device passthrough work easy for VMM, that
> only need to expose ISA bridge to let driver know the real hardware underneath.
> 
> The original patch is from Allen Kay [allen.m.kay@intel.com]
> 
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> Cc: Allen Kay <allen.m.kay@intel.com>
> ---
> v3:
> 
> * Fix some typos.
> * Improve some return paths.
> 
> v2:
> 
> * Nothing is changed.
> 
>  hw/xen/xen_pt_graphics.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> 
> diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c
> index e63bd6f..51b174f 100644
> --- a/hw/xen/xen_pt_graphics.c
> +++ b/hw/xen/xen_pt_graphics.c
> @@ -230,3 +230,66 @@ out:
>      g_free(bios);
>      return rc;
>  }
> +
> +static uint32_t isa_bridge_read_config(PCIDevice *d, uint32_t addr, int len)
> +{
> +    return pci_default_read_config(d, addr, len);
> +}
> +
> +static void isa_bridge_write_config(PCIDevice *d, uint32_t addr, uint32_t v,
> +                                    int len)
> +{
> +    pci_default_write_config(d, addr, v, len);
> +
> +    return;

You don't need the return there.
> +}
> +
> +static void isa_bridge_class_init(ObjectClass *klass, void *data)
> +{
> +    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
> +
> +    k->config_read = isa_bridge_read_config;
> +    k->config_write = isa_bridge_write_config;
> +
> +    return;

Ditto
> +};
> +
> +typedef struct {
> +    PCIDevice dev;
> +} ISABridgeState;
> +
> +static TypeInfo isa_bridge_info = {
> +    .name          = "intel-pch-isa-bridge",
> +    .parent        = TYPE_PCI_DEVICE,
> +    .instance_size = sizeof(ISABridgeState),
> +    .class_init = isa_bridge_class_init,
> +};
> +
> +static void xen_pt_graphics_register_types(void)
> +{
> +    type_register_static(&isa_bridge_info);
> +}
> +
> +type_init(xen_pt_graphics_register_types)
> +
> +static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev)
> +{
> +    struct PCIDevice *dev;
> +
> +    char rid;
> +
> +    dev = pci_create(bus, PCI_DEVFN(0x1f, 0), "intel-pch-isa-bridge");
> +
> +    qdev_init_nofail(&dev->qdev);
> +
> +    pci_config_set_vendor_id(dev->config, hdev->vendor_id);
> +    pci_config_set_device_id(dev->config, hdev->device_id);
> +
> +    xen_host_pci_get_block(hdev, PCI_REVISION_ID, (uint8_t *)&rid, 1);
> +
> +    pci_config_set_revision(dev->config, rid);
> +    pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_ISA);
> +
> +    XEN_PT_LOG(dev, "Intel PCH ISA bridge created.\n");
> +    return 0;
> +}
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
Stefano Stabellini May 27, 2014, 5:52 p.m. UTC | #2
On Tue, 27 May 2014, Konrad Rzeszutek Wilk wrote:
> On Mon, May 26, 2014 at 05:43:06PM +0800, Tiejun Chen wrote:
> > ISA bridge is needed since Intel gfx drive will probe it instead
> > of Dev31:Fun0 to make graphics device passthrough work easy for VMM, that
> > only need to expose ISA bridge to let driver know the real hardware underneath.
> > 
> > The original patch is from Allen Kay [allen.m.kay@intel.com]
> > 
> > Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> > Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> > Cc: Allen Kay <allen.m.kay@intel.com>
> > ---
> > v3:
> > 
> > * Fix some typos.
> > * Improve some return paths.
> > 
> > v2:
> > 
> > * Nothing is changed.
> > 
> >  hw/xen/xen_pt_graphics.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 63 insertions(+)
> > 
> > diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c
> > index e63bd6f..51b174f 100644
> > --- a/hw/xen/xen_pt_graphics.c
> > +++ b/hw/xen/xen_pt_graphics.c
> > @@ -230,3 +230,66 @@ out:
> >      g_free(bios);
> >      return rc;
> >  }
> > +
> > +static uint32_t isa_bridge_read_config(PCIDevice *d, uint32_t addr, int len)
> > +{
> > +    return pci_default_read_config(d, addr, len);
> > +}
> > +
> > +static void isa_bridge_write_config(PCIDevice *d, uint32_t addr, uint32_t v,
> > +                                    int len)
> > +{
> > +    pci_default_write_config(d, addr, v, len);
> > +
> > +    return;
> 
> You don't need the return there.
> > +}
> > +
> > +static void isa_bridge_class_init(ObjectClass *klass, void *data)
> > +{
> > +    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
> > +
> > +    k->config_read = isa_bridge_read_config;
> > +    k->config_write = isa_bridge_write_config;
> > +
> > +    return;
> 
> Ditto

Aside from these 2 minor changes, the patch looks good to me.

> > +};
> > +
> > +typedef struct {
> > +    PCIDevice dev;
> > +} ISABridgeState;
> > +
> > +static TypeInfo isa_bridge_info = {
> > +    .name          = "intel-pch-isa-bridge",
> > +    .parent        = TYPE_PCI_DEVICE,
> > +    .instance_size = sizeof(ISABridgeState),
> > +    .class_init = isa_bridge_class_init,
> > +};
> > +
> > +static void xen_pt_graphics_register_types(void)
> > +{
> > +    type_register_static(&isa_bridge_info);
> > +}
> > +
> > +type_init(xen_pt_graphics_register_types)
> > +
> > +static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev)
> > +{
> > +    struct PCIDevice *dev;
> > +
> > +    char rid;
> > +
> > +    dev = pci_create(bus, PCI_DEVFN(0x1f, 0), "intel-pch-isa-bridge");
> > +
> > +    qdev_init_nofail(&dev->qdev);
> > +
> > +    pci_config_set_vendor_id(dev->config, hdev->vendor_id);
> > +    pci_config_set_device_id(dev->config, hdev->device_id);
> > +
> > +    xen_host_pci_get_block(hdev, PCI_REVISION_ID, (uint8_t *)&rid, 1);
> > +
> > +    pci_config_set_revision(dev->config, rid);
> > +    pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_ISA);
> > +
> > +    XEN_PT_LOG(dev, "Intel PCH ISA bridge created.\n");
> > +    return 0;
> > +}
> > -- 
> > 1.9.1
> > 
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > http://lists.xen.org/xen-devel
>
Tiejun Chen May 28, 2014, 1:20 a.m. UTC | #3
> -----Original Message-----
> From: Konrad Rzeszutek Wilk [mailto:konrad.wilk@oracle.com]
> Sent: Tuesday, May 27, 2014 10:56 PM
> To: Chen, Tiejun
> Cc: anthony.perard@citrix.com; stefano.stabellini@eu.citrix.com;
> mst@redhat.com; Kelly.Zytaruk@amd.com; peter.maydell@linaro.org;
> xen-devel@lists.xensource.com; Kay, Allen M; qemu-devel@nongnu.org;
> anthony@codemonkey.ws; Zhang, Yang Z
> Subject: Re: [Xen-devel] [v3][PATCH 2/5] xen, gfx passthrough: create intel isa
> bridge
> 
> On Mon, May 26, 2014 at 05:43:06PM +0800, Tiejun Chen wrote:
> > ISA bridge is needed since Intel gfx drive will probe it instead of
> > Dev31:Fun0 to make graphics device passthrough work easy for VMM, that
> > only need to expose ISA bridge to let driver know the real hardware
> underneath.
> >
> > The original patch is from Allen Kay [allen.m.kay@intel.com]
> >
> > Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> > Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> > Cc: Allen Kay <allen.m.kay@intel.com>
> > ---
> > v3:
> >
> > * Fix some typos.
> > * Improve some return paths.
> >
> > v2:
> >
> > * Nothing is changed.
> >
> >  hw/xen/xen_pt_graphics.c | 63
> > ++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 63 insertions(+)
> >
> > diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index
> > e63bd6f..51b174f 100644
> > --- a/hw/xen/xen_pt_graphics.c
> > +++ b/hw/xen/xen_pt_graphics.c
> > @@ -230,3 +230,66 @@ out:
> >      g_free(bios);
> >      return rc;
> >  }
> > +
> > +static uint32_t isa_bridge_read_config(PCIDevice *d, uint32_t addr,
> > +int len) {
> > +    return pci_default_read_config(d, addr, len); }
> > +
> > +static void isa_bridge_write_config(PCIDevice *d, uint32_t addr, uint32_t v,
> > +                                    int len) {
> > +    pci_default_write_config(d, addr, v, len);
> > +
> > +    return;
> 
> You don't need the return there.

Fixed.

> > +}
> > +
> > +static void isa_bridge_class_init(ObjectClass *klass, void *data) {
> > +    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
> > +
> > +    k->config_read = isa_bridge_read_config;
> > +    k->config_write = isa_bridge_write_config;
> > +
> > +    return;
> 
> Ditto

Fixed.

Thanks
Tiejun
Tiejun Chen May 28, 2014, 1:44 a.m. UTC | #4
> -----Original Message-----
> From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com]
> Sent: Wednesday, May 28, 2014 1:52 AM
> To: Konrad Rzeszutek Wilk
> Cc: Chen, Tiejun; anthony.perard@citrix.com; stefano.stabellini@eu.citrix.com;
> mst@redhat.com; Kelly.Zytaruk@amd.com; peter.maydell@linaro.org;
> xen-devel@lists.xensource.com; Kay, Allen M; qemu-devel@nongnu.org;
> anthony@codemonkey.ws; Zhang, Yang Z
> Subject: Re: [Xen-devel] [v3][PATCH 2/5] xen, gfx passthrough: create intel isa
> bridge
> 
> On Tue, 27 May 2014, Konrad Rzeszutek Wilk wrote:
> > On Mon, May 26, 2014 at 05:43:06PM +0800, Tiejun Chen wrote:
> > > ISA bridge is needed since Intel gfx drive will probe it instead of
> > > Dev31:Fun0 to make graphics device passthrough work easy for VMM,
> > > that only need to expose ISA bridge to let driver know the real hardware
> underneath.
> > >
> > > The original patch is from Allen Kay [allen.m.kay@intel.com]
> > >
> > > Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> > > Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> > > Cc: Allen Kay <allen.m.kay@intel.com>
> > > ---
> > > v3:
> > >
> > > * Fix some typos.
> > > * Improve some return paths.
> > >
> > > v2:
> > >
> > > * Nothing is changed.
> > >
> > >  hw/xen/xen_pt_graphics.c | 63
> > > ++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 63 insertions(+)
> > >
> > > diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c
> > > index e63bd6f..51b174f 100644
> > > --- a/hw/xen/xen_pt_graphics.c
> > > +++ b/hw/xen/xen_pt_graphics.c
> > > @@ -230,3 +230,66 @@ out:
> > >      g_free(bios);
> > >      return rc;
> > >  }
> > > +
> > > +static uint32_t isa_bridge_read_config(PCIDevice *d, uint32_t addr,
> > > +int len) {
> > > +    return pci_default_read_config(d, addr, len); }
> > > +
> > > +static void isa_bridge_write_config(PCIDevice *d, uint32_t addr, uint32_t
> v,
> > > +                                    int len) {
> > > +    pci_default_write_config(d, addr, v, len);
> > > +
> > > +    return;
> >
> > You don't need the return there.
> > > +}
> > > +
> > > +static void isa_bridge_class_init(ObjectClass *klass, void *data) {
> > > +    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
> > > +
> > > +    k->config_read = isa_bridge_read_config;
> > > +    k->config_write = isa_bridge_write_config;
> > > +
> > > +    return;
> >
> > Ditto
> 
> Aside from these 2 minor changes, the patch looks good to me.
> 

Already addressed

Thanks
Tiejun
diff mbox

Patch

diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c
index e63bd6f..51b174f 100644
--- a/hw/xen/xen_pt_graphics.c
+++ b/hw/xen/xen_pt_graphics.c
@@ -230,3 +230,66 @@  out:
     g_free(bios);
     return rc;
 }
+
+static uint32_t isa_bridge_read_config(PCIDevice *d, uint32_t addr, int len)
+{
+    return pci_default_read_config(d, addr, len);
+}
+
+static void isa_bridge_write_config(PCIDevice *d, uint32_t addr, uint32_t v,
+                                    int len)
+{
+    pci_default_write_config(d, addr, v, len);
+
+    return;
+}
+
+static void isa_bridge_class_init(ObjectClass *klass, void *data)
+{
+    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+    k->config_read = isa_bridge_read_config;
+    k->config_write = isa_bridge_write_config;
+
+    return;
+};
+
+typedef struct {
+    PCIDevice dev;
+} ISABridgeState;
+
+static TypeInfo isa_bridge_info = {
+    .name          = "intel-pch-isa-bridge",
+    .parent        = TYPE_PCI_DEVICE,
+    .instance_size = sizeof(ISABridgeState),
+    .class_init = isa_bridge_class_init,
+};
+
+static void xen_pt_graphics_register_types(void)
+{
+    type_register_static(&isa_bridge_info);
+}
+
+type_init(xen_pt_graphics_register_types)
+
+static int create_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev)
+{
+    struct PCIDevice *dev;
+
+    char rid;
+
+    dev = pci_create(bus, PCI_DEVFN(0x1f, 0), "intel-pch-isa-bridge");
+
+    qdev_init_nofail(&dev->qdev);
+
+    pci_config_set_vendor_id(dev->config, hdev->vendor_id);
+    pci_config_set_device_id(dev->config, hdev->device_id);
+
+    xen_host_pci_get_block(hdev, PCI_REVISION_ID, (uint8_t *)&rid, 1);
+
+    pci_config_set_revision(dev->config, rid);
+    pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_ISA);
+
+    XEN_PT_LOG(dev, "Intel PCH ISA bridge created.\n");
+    return 0;
+}