diff mbox series

[v2,5/6] bochs-display: add pcie support

Message ID 20180522165058.15404-6-kraxel@redhat.com
State New
Headers show
Series None | expand

Commit Message

Gerd Hoffmann May 22, 2018, 4:50 p.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/bochs-display.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Philippe Mathieu-Daudé May 22, 2018, 8:52 p.m. UTC | #1
Hi Gerd,

On 05/22/2018 01:50 PM, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/display/bochs-display.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c
> index 9607df1c34..c33524b558 100644
> --- a/hw/display/bochs-display.c
> +++ b/hw/display/bochs-display.c
> @@ -253,6 +253,7 @@ static void bochs_display_realize(PCIDevice *dev, Error **errp)
>  {
>      BochsDisplayState *s = BOCHS_DISPLAY(dev);
>      Object *obj = OBJECT(dev);
> +    int ret;
>  
>      s->con = graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops, s);
>  
> @@ -280,6 +281,12 @@ static void bochs_display_realize(PCIDevice *dev, Error **errp)
>      pci_register_bar(&s->pci, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
>      pci_register_bar(&s->pci, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
>  
> +    if (pci_bus_is_express(pci_get_bus(dev))) {
> +        dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
> +        ret = pcie_endpoint_cap_init(dev, 0x80);
> +        assert(ret > 0);

Maybe error_setg(errp, ...) && return?

> +    }
> +
>      memory_region_set_log(&s->vram, true, DIRTY_MEMORY_VGA);
>  }
>  
> @@ -342,6 +349,7 @@ static const TypeInfo bochs_display_type_info = {
>      .instance_init  = bochs_display_init,
>      .class_init     = bochs_display_class_init,
>      .interfaces     = (InterfaceInfo[]) {
> +        { INTERFACE_PCIE_DEVICE },
>          { INTERFACE_CONVENTIONAL_PCI_DEVICE },
>          { },
>      },
>
Gerd Hoffmann May 23, 2018, 6:50 a.m. UTC | #2
Hi,

> > +    if (pci_bus_is_express(pci_get_bus(dev))) {
> > +        dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
> > +        ret = pcie_endpoint_cap_init(dev, 0x80);
> > +        assert(ret > 0);
> 
> Maybe error_setg(errp, ...) && return?

No.  It really should not trigger, and if it does it is a bug in qemu
and not the user doing something wrong.

cheers,
  Gerd
diff mbox series

Patch

diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c
index 9607df1c34..c33524b558 100644
--- a/hw/display/bochs-display.c
+++ b/hw/display/bochs-display.c
@@ -253,6 +253,7 @@  static void bochs_display_realize(PCIDevice *dev, Error **errp)
 {
     BochsDisplayState *s = BOCHS_DISPLAY(dev);
     Object *obj = OBJECT(dev);
+    int ret;
 
     s->con = graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops, s);
 
@@ -280,6 +281,12 @@  static void bochs_display_realize(PCIDevice *dev, Error **errp)
     pci_register_bar(&s->pci, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
     pci_register_bar(&s->pci, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
 
+    if (pci_bus_is_express(pci_get_bus(dev))) {
+        dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
+        ret = pcie_endpoint_cap_init(dev, 0x80);
+        assert(ret > 0);
+    }
+
     memory_region_set_log(&s->vram, true, DIRTY_MEMORY_VGA);
 }
 
@@ -342,6 +349,7 @@  static const TypeInfo bochs_display_type_info = {
     .instance_init  = bochs_display_init,
     .class_init     = bochs_display_class_init,
     .interfaces     = (InterfaceInfo[]) {
+        { INTERFACE_PCIE_DEVICE },
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
         { },
     },