Skip to contentSkip to conversation

PCI bridge fixes and cleanup

PATCH In review Andreas Färber 4 participants 8 messages Aug 5, 2013 – Aug 12, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover PCI bridge fixes and cleanup

Hello Michael,

This mini-series cleans up Gerd's commit message and adds the generalization on top. Both look safe for 1.6 to me; doing it in two steps not only allows to record Gerd's authorship but allows to cherry-pick his patch for 1.5 while mine is 1.6+.

Regards,
Andreas

Gerd's v1 -> v2:
* Reworked commit message: Added qemu-stable, clarified scope and change.
* Appended patch

Cc Michael S. Tsirkin <[email protected]>
Cc Gerd Hoffmann <[email protected]>

Andreas Färber (1):
pci-bridge: Move common class initializations to base type

Gerd Hoffmann (1):
i82801b11: Fix i82801b11 PCI host bridge config space

 hw/pci-bridge/dec.c                |  4 ----
 hw/pci-bridge/i82801b11.c          |  1 -
 hw/pci-bridge/ioh3420.c            |  1 -
 hw/pci-bridge/pci_bridge_dev.c     |  1 -
 hw/pci-bridge/xio3130_downstream.c |  1 -
 hw/pci-bridge/xio3130_upstream.c   |  1 -
 hw/pci-host/apb.c                  |  4 ----
 hw/pci/pci_bridge.c                | 12 ++++++++++++
 8 files changed, 12 insertions(+), 13 deletions(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH v2 1/2 i82801b11: Fix i82801b11 PCI host bridge config space

From: Gerd Hoffmann <[email protected]>

pci_bridge_write_config() was not being used.

---
 hw/pci-bridge/i82801b11.c | 1 +
 1 file changed, 1 insertion(+)
hw/pci-bridge/i82801b11.c +1 -0
index 8a5e426..14cd7fd 100644
@@ -90,6 +90,7 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82801BA_11;
     k->revision = ICH9_D2P_A2_REVISION;
     k->init = i82801b11_bridge_initfn;
+    k->config_write = pci_bridge_write_config;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
Signature · 1 line
1.8.1.4
Acked-by on v2 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH for-1.6 v2 1/2] i82801b11: Fix i82801b11 PCI host bridge config space

Quoted 7 lines · Andreas Färber

From: Gerd Hoffmann <[email protected]>

pci_bridge_write_config() was not being used.

Quoted 18 lines
---
 hw/pci-bridge/i82801b11.c | 1 +
 1 file changed, 1 insertion(+)
hw/pci-bridge/i82801b11.c +1 -0
index 8a5e426..14cd7fd 100644
@@ -90,6 +90,7 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82801BA_11;
     k->revision = ICH9_D2P_A2_REVISION;
     k->init = i82801b11_bridge_initfn;
+    k->config_write = pci_bridge_write_config;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
Signature · 1 line
1.8.1.4
#3 lore raw

Re: [Qemu-devel] [PATCH for-1.6 v2 1/2] i82801b11: Fix i82801b11 PCI host bridge config space

In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

From: Gerd Hoffmann <[email protected]>

pci_bridge_write_config() was not being used.

Ping? I see it's not yet in master, can we *please* get this in? It is save to take just this one-liner and defer 2/2 to 1.7.

cheers,
Gerd

#4 lore raw

Re: [Qemu-devel] [PATCH for-1.6 v2 1/2] i82801b11: Fix i82801b11 PCI host bridge config space

Am 12.08.2013 10:51, schrieb Gerd Hoffmann:

Quoted 11 lines · Andreas Färber
Quoted 7 lines

From: Gerd Hoffmann <[email protected]>

pci_bridge_write_config() was not being used.

Ping? I see it's not yet in master, can we *please* get this in? It is save to take just this one-liner and defer 2/2 to 1.7.

Michael, please decide as PCI maintainer and send a pull. Thanks!

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#5 lore raw

PATCH v2 2/2 pci-bridge: Move common class initializations to base type

In reply to Andreas Färber

Set PCIDeviceClass::is_bridge as well as PCIDeviceClass::config_write(), PCIDeviceClass::exit() and DeviceClass::reset() defaults directly for TYPE_PCI_BRIDGE (complements f055e96bd4311d287c0e03faec02a1bdbc351925).

This avoids another pci_bridge_config_write() missing somewhere, unless explicitly overridden.

---
 hw/pci-bridge/dec.c                |  4 ----
 hw/pci-bridge/i82801b11.c          |  2 --
 hw/pci-bridge/ioh3420.c            |  1 -
 hw/pci-bridge/pci_bridge_dev.c     |  1 -
 hw/pci-bridge/xio3130_downstream.c |  1 -
 hw/pci-bridge/xio3130_upstream.c   |  1 -
 hw/pci-host/apb.c                  |  4 ----
 hw/pci/pci_bridge.c                | 12 ++++++++++++
 8 files changed, 12 insertions(+), 14 deletions(-)
hw/pci-bridge/dec.c +0 -4
index e5e3be8..379f9f0 100644
@@ -62,13 +62,9 @@ static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->init = dec_pci_bridge_initfn;
-    k->exit = pci_bridge_exitfn;
     k->vendor_id = PCI_VENDOR_ID_DEC;
     k->device_id = PCI_DEVICE_ID_DEC_21154;
-    k->config_write = pci_bridge_write_config;
-    k->is_bridge = 1;
     dc->desc = "DEC 21154 PCI-PCI bridge";
-    dc->reset = pci_bridge_reset;
     dc->vmsd = &vmstate_pci_device;
 }
 
hw/pci-bridge/i82801b11.c +0 -2
index 14cd7fd..ab0c8e1 100644
@@ -85,12 +85,10 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    k->is_bridge = 1;
     k->vendor_id = PCI_VENDOR_ID_INTEL;
     k->device_id = PCI_DEVICE_ID_INTEL_82801BA_11;
     k->revision = ICH9_D2P_A2_REVISION;
     k->init = i82801b11_bridge_initfn;
-    k->config_write = pci_bridge_write_config;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
hw/pci-bridge/ioh3420.c +0 -1
index 0f7f209..2748b06 100644
@@ -200,7 +200,6 @@ static void ioh3420_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->is_express = 1;
-    k->is_bridge = 1;
     k->config_write = ioh3420_write_config;
     k->init = ioh3420_initfn;
     k->exit = ioh3420_exitfn;
hw/pci-bridge/pci_bridge_dev.c +0 -1
index a9392c7..716d0af 100644
@@ -142,7 +142,6 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data)
     k->vendor_id = PCI_VENDOR_ID_REDHAT;
     k->device_id = PCI_DEVICE_ID_REDHAT_BRIDGE;
     k->class_id = PCI_CLASS_BRIDGE_PCI;
-    k->is_bridge = 1,
     dc->desc = "Standard PCI Bridge";
     dc->reset = qdev_pci_bridge_dev_reset;
     dc->props = pci_bridge_dev_properties;
hw/pci-bridge/xio3130_downstream.c +0 -1
index 94f9781..07da9bf 100644
@@ -167,7 +167,6 @@ static void xio3130_downstream_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->is_express = 1;
-    k->is_bridge = 1;
     k->config_write = xio3130_downstream_write_config;
     k->init = xio3130_downstream_initfn;
     k->exit = xio3130_downstream_exitfn;
hw/pci-bridge/xio3130_upstream.c +0 -1
index 59f97f6..def08c8 100644
@@ -146,7 +146,6 @@ static void xio3130_upstream_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->is_express = 1;
-    k->is_bridge = 1;
     k->config_write = xio3130_upstream_write_config;
     k->init = xio3130_upstream_initfn;
     k->exit = xio3130_upstream_exitfn;
hw/pci-host/apb.c +0 -4
index 92f289f..1cb2ef4 100644
@@ -553,14 +553,10 @@ static void pbm_pci_bridge_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     k->init = apb_pci_bridge_initfn;
-    k->exit = pci_bridge_exitfn;
     k->vendor_id = PCI_VENDOR_ID_SUN;
     k->device_id = PCI_DEVICE_ID_SUN_SIMBA;
     k->revision = 0x11;
-    k->config_write = pci_bridge_write_config;
-    k->is_bridge = 1;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
-    dc->reset = pci_bridge_reset;
     dc->vmsd = &vmstate_pci_device;
 }
 
hw/pci/pci_bridge.c +12 -0
index a90671d..23a5c7d 100644
@@ -405,11 +405,23 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,
     br->bus_name = bus_name;
 }
 
+static void pci_bridge_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+    PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
+
+    pdc->is_bridge = 1;
+    pdc->exit = pci_bridge_exitfn;
+    pdc->config_write = pci_bridge_write_config;
+    dc->reset = pci_bridge_reset;
+}
+
 static const TypeInfo pci_bridge_type_info = {
     .name = TYPE_PCI_BRIDGE,
     .parent = TYPE_PCI_DEVICE,
     .instance_size = sizeof(PCIBridge),
     .abstract = true,
+    .class_init = pci_bridge_class_init,
 };
 
 static void pci_bridge_register_types(void)
Signature · 1 line
1.8.1.4
#6 lore raw

Re: [Qemu-devel] [PATCH for-1.6 v2 2/2] pci-bridge: Move common class initializations to base type

Quoted 9 lines · Andreas Färber

Set PCIDeviceClass::is_bridge as well as PCIDeviceClass::config_write(), PCIDeviceClass::exit() and DeviceClass::reset() defaults directly for TYPE_PCI_BRIDGE (complements f055e96bd4311d287c0e03faec02a1bdbc351925).

This avoids another pci_bridge_config_write() missing somewhere, unless explicitly overridden.

Why for 1.6?

Paolo

Quoted 142 lines
---
  hw/pci-bridge/dec.c                |  4 ----
  hw/pci-bridge/i82801b11.c          |  2 --
  hw/pci-bridge/ioh3420.c            |  1 -
  hw/pci-bridge/pci_bridge_dev.c     |  1 -
  hw/pci-bridge/xio3130_downstream.c |  1 -
  hw/pci-bridge/xio3130_upstream.c   |  1 -
  hw/pci-host/apb.c                  |  4 ----
  hw/pci/pci_bridge.c                | 12 ++++++++++++
  8 files changed, 12 insertions(+), 14 deletions(-)
hw/pci-bridge/dec.c +0 -4
index e5e3be8..379f9f0 100644
@@ -62,13 +62,9 @@ static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      k->init = dec_pci_bridge_initfn;
-    k->exit = pci_bridge_exitfn;
      k->vendor_id = PCI_VENDOR_ID_DEC;
      k->device_id = PCI_DEVICE_ID_DEC_21154;
-    k->config_write = pci_bridge_write_config;
-    k->is_bridge = 1;
      dc->desc = "DEC 21154 PCI-PCI bridge";
-    dc->reset = pci_bridge_reset;
      dc->vmsd = &vmstate_pci_device;
  }
 
hw/pci-bridge/i82801b11.c +0 -2
index 14cd7fd..ab0c8e1 100644
@@ -85,12 +85,10 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
      DeviceClass *dc = DEVICE_CLASS(klass);
 
-    k->is_bridge = 1;
      k->vendor_id = PCI_VENDOR_ID_INTEL;
      k->device_id = PCI_DEVICE_ID_INTEL_82801BA_11;
      k->revision = ICH9_D2P_A2_REVISION;
      k->init = i82801b11_bridge_initfn;
-    k->config_write = pci_bridge_write_config;
      set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  }
 
hw/pci-bridge/ioh3420.c +0 -1
index 0f7f209..2748b06 100644
@@ -200,7 +200,6 @@ static void ioh3420_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      k->is_express = 1;
-    k->is_bridge = 1;
      k->config_write = ioh3420_write_config;
      k->init = ioh3420_initfn;
      k->exit = ioh3420_exitfn;
hw/pci-bridge/pci_bridge_dev.c +0 -1
index a9392c7..716d0af 100644
@@ -142,7 +142,6 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data)
      k->vendor_id = PCI_VENDOR_ID_REDHAT;
      k->device_id = PCI_DEVICE_ID_REDHAT_BRIDGE;
      k->class_id = PCI_CLASS_BRIDGE_PCI;
-    k->is_bridge = 1,
      dc->desc = "Standard PCI Bridge";
      dc->reset = qdev_pci_bridge_dev_reset;
      dc->props = pci_bridge_dev_properties;
hw/pci-bridge/xio3130_downstream.c +0 -1
index 94f9781..07da9bf 100644
@@ -167,7 +167,6 @@ static void xio3130_downstream_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      k->is_express = 1;
-    k->is_bridge = 1;
      k->config_write = xio3130_downstream_write_config;
      k->init = xio3130_downstream_initfn;
      k->exit = xio3130_downstream_exitfn;
hw/pci-bridge/xio3130_upstream.c +0 -1
index 59f97f6..def08c8 100644
@@ -146,7 +146,6 @@ static void xio3130_upstream_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      k->is_express = 1;
-    k->is_bridge = 1;
      k->config_write = xio3130_upstream_write_config;
      k->init = xio3130_upstream_initfn;
      k->exit = xio3130_upstream_exitfn;
hw/pci-host/apb.c +0 -4
index 92f289f..1cb2ef4 100644
@@ -553,14 +553,10 @@ static void pbm_pci_bridge_class_init(ObjectClass *klass, void *data)
      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
      k->init = apb_pci_bridge_initfn;
-    k->exit = pci_bridge_exitfn;
      k->vendor_id = PCI_VENDOR_ID_SUN;
      k->device_id = PCI_DEVICE_ID_SUN_SIMBA;
      k->revision = 0x11;
-    k->config_write = pci_bridge_write_config;
-    k->is_bridge = 1;
      set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
-    dc->reset = pci_bridge_reset;
      dc->vmsd = &vmstate_pci_device;
  }
 
hw/pci/pci_bridge.c +12 -0
index a90671d..23a5c7d 100644
@@ -405,11 +405,23 @@ void pci_bridge_map_irq(PCIBridge *br, const char* bus_name,
      br->bus_name = bus_name;
  }
 
+static void pci_bridge_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+    PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
+
+    pdc->is_bridge = 1;
+    pdc->exit = pci_bridge_exitfn;
+    pdc->config_write = pci_bridge_write_config;
+    dc->reset = pci_bridge_reset;
+}
+
  static const TypeInfo pci_bridge_type_info = {
      .name = TYPE_PCI_BRIDGE,
      .parent = TYPE_PCI_DEVICE,
      .instance_size = sizeof(PCIBridge),
      .abstract = true,
+    .class_init = pci_bridge_class_init,
  };
 
  static void pci_bridge_register_types(void)
#7 lore raw

Re: [Qemu-devel] [PATCH for-1.6 v2 2/2] pci-bridge: Move common class initializations to base type

Am 05.08.2013 16:41, schrieb Paolo Bonzini:

Quoted 5 lines · Andreas Färber
Quoted 4 lines

Set PCIDeviceClass::is_bridge as well as PCIDeviceClass::config_write(), PCIDeviceClass::exit() and DeviceClass::reset() defaults directly for TYPE_PCI_BRIDGE (complements f055e96bd4311d287c0e03faec02a1bdbc351925).

Quoted 7 lines
Quoted 5 lines

This avoids another pci_bridge_config_write() missing somewhere, unless explicitly overridden.

Why for 1.6?

This is The Real Fix. We could squash it as one patch, but then we can't backport it.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg