Patchwork [qom-next,for-next,v2,5/6] pci: Move vmstate_pcie_aer_log into vmstate_pci_device

login
register
mail settings
Submitter Andreas Färber
Date July 29, 2013, 12:27 a.m.
Message ID <1375057621-19961-6-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/262630/
State New
Headers show

Comments

Andreas Färber - July 29, 2013, 12:27 a.m.
Make it conditional on PCIe and allocation of the AER log.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/pci-bridge/ioh3420.c            | 2 --
 hw/pci-bridge/xio3130_downstream.c | 2 --
 hw/pci-bridge/xio3130_upstream.c   | 2 --
 hw/pci/pci.c                       | 9 +++++++++
 hw/pci/pcie_aer.c                  | 1 +
 5 files changed, 10 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index 680a13d..bf92884 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -188,8 +188,6 @@  static const VMStateDescription vmstate_ioh3420 = {
     .post_load = pcie_cap_slot_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(),
-        VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
-                       PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index 3fa4ec2..bf7099d 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -155,8 +155,6 @@  static const VMStateDescription vmstate_xio3130_downstream = {
     .post_load = pcie_cap_slot_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(),
-        VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
-                       PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index 0edacc3..b564c7f 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -134,8 +134,6 @@  static const VMStateDescription vmstate_xio3130_upstream = {
     .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(),
-        VMSTATE_STRUCT(parent_obj.parent_obj.exp.aer_log, PCIEPort, 0,
-                       vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6461c9d..b790d98 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -474,6 +474,13 @@  static bool pci_device_non_express_needed(void *opaque, int version_id)
     return !pci_is_express(s);
 }
 
+static bool pci_device_aer_needed(void *opaque, int version_id)
+{
+    PCIDevice *s = opaque;
+
+    return pci_is_express(s) && s->exp.aer_log.log != NULL;
+}
+
 const VMStateDescription vmstate_pci_device = {
     .name = "PCIDevice",
     .version_id = 2,
@@ -492,6 +499,8 @@  const VMStateDescription vmstate_pci_device = {
         VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
                                    vmstate_info_pci_irq_state,
                                    PCI_NUM_PINS * sizeof(int32_t)),
+        VMSTATE_STRUCT_TEST(exp.aer_log, PCIDevice, pci_device_aer_needed, 0,
+                            vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index ca762ab..2767ebc 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -166,6 +166,7 @@  int pcie_aer_init(PCIDevice *dev, uint16_t offset)
 void pcie_aer_exit(PCIDevice *dev)
 {
     g_free(dev->exp.aer_log.log);
+    dev->exp.aer_log.log = NULL;
 }
 
 static void pcie_aer_update_uncor_status(PCIDevice *dev)