From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3bIz-0002bf-Ee for qemu-devel@nongnu.org; Sun, 28 Jul 2013 20:27:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3bIs-0003Dr-KG for qemu-devel@nongnu.org; Sun, 28 Jul 2013 20:27:17 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44759 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3bIs-0003De-7s for qemu-devel@nongnu.org; Sun, 28 Jul 2013 20:27:10 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 29 Jul 2013 02:26:59 +0200 Message-Id: <1375057621-19961-5-git-send-email-afaerber@suse.de> In-Reply-To: <1375057621-19961-1-git-send-email-afaerber@suse.de> References: <1375057621-19961-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-next for-next v2 4/6] pci: Unify vmstate_{pci, pcie}_device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" The only difference so far is the size of the config space. It is always used through either VMSTATE_{PCI,PCIE}_DEVICE() or pci_device_save(), so the name change for PCIe shouldn't matter. Suggested-by: Michael S. Tsirkin Signed-off-by: Andreas F=C3=A4rber --- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci/pci.c | 56 ++++++++++++++++++--------------= ------ hw/usb/hcd-xhci.c | 2 +- include/hw/pci/pcie.h | 10 ------- 6 files changed, 31 insertions(+), 43 deletions(-) diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c index 0657354..680a13d 100644 --- a/hw/pci-bridge/ioh3420.c +++ b/hw/pci-bridge/ioh3420.c @@ -187,7 +187,7 @@ static const VMStateDescription vmstate_ioh3420 =3D { .minimum_version_id_old =3D 1, .post_load =3D pcie_cap_slot_post_load, .fields =3D (VMStateField[]) { - VMSTATE_PCIE_DEVICE(), + 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_d= ownstream.c index 9022949..3fa4ec2 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -154,7 +154,7 @@ static const VMStateDescription vmstate_xio3130_downs= tream =3D { .minimum_version_id_old =3D 1, .post_load =3D pcie_cap_slot_post_load, .fields =3D (VMStateField[]) { - VMSTATE_PCIE_DEVICE(), + 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_ups= tream.c index 046b790..0edacc3 100644 --- a/hw/pci-bridge/xio3130_upstream.c +++ b/hw/pci-bridge/xio3130_upstream.c @@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstr= eam =3D { .minimum_version_id =3D 1, .minimum_version_id_old =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_PCIE_DEVICE(), + 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 4c004f5..6461c9d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -460,6 +460,20 @@ static VMStateInfo vmstate_info_pci_irq_state =3D { .put =3D put_pci_irq_state, }; =20 +static bool pci_device_express_needed(void *opaque, int version_id) +{ + PCIDevice *s =3D opaque; + + return pci_is_express(s); +} + +static bool pci_device_non_express_needed(void *opaque, int version_id) +{ + PCIDevice *s =3D opaque; + + return !pci_is_express(s); +} + const VMStateDescription vmstate_pci_device =3D { .name =3D "PCIDevice", .version_id =3D 2, @@ -467,38 +481,21 @@ const VMStateDescription vmstate_pci_device =3D { .minimum_version_id_old =3D 1, .fields =3D (VMStateField []) { VMSTATE_INT32_LE(version_id, PCIDevice), - VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0, - vmstate_info_pci_config, - PCI_CONFIG_SPACE_SIZE), - VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2, - vmstate_info_pci_irq_state, - PCI_NUM_PINS * sizeof(int32_t)), - VMSTATE_END_OF_LIST() - } -}; - -const VMStateDescription vmstate_pcie_device =3D { - .name =3D "PCIEDevice", - .version_id =3D 2, - .minimum_version_id =3D 1, - .minimum_version_id_old =3D 1, - .fields =3D (VMStateField []) { - VMSTATE_INT32_LE(version_id, PCIDevice), - VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0, - vmstate_info_pci_config, - PCIE_CONFIG_SPACE_SIZE), + VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, 0, + pci_device_non_express_needed, + vmstate_info_pci_config, + PCI_CONFIG_SPACE_SIZE), + VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, 0, + pci_device_express_needed, + vmstate_info_pci_config, + PCIE_CONFIG_SPACE_SIZE), VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2, - vmstate_info_pci_irq_state, - PCI_NUM_PINS * sizeof(int32_t)), + vmstate_info_pci_irq_state, + PCI_NUM_PINS * sizeof(int32_t)), VMSTATE_END_OF_LIST() } }; =20 -static inline const VMStateDescription *pci_get_vmstate(PCIDevice *s) -{ - return pci_is_express(s) ? &vmstate_pcie_device : &vmstate_pci_devic= e; -} - void pci_device_save(PCIDevice *s, QEMUFile *f) { /* Clear interrupt status bit: it is implicit @@ -506,7 +503,7 @@ void pci_device_save(PCIDevice *s, QEMUFile *f) * This makes us compatible with old devices * which never set or clear this bit. */ s->config[PCI_STATUS] &=3D ~PCI_STATUS_INTERRUPT; - vmstate_save_state(f, pci_get_vmstate(s), s); + vmstate_save_state(f, &vmstate_pci_device, s); /* Restore the interrupt status bit. */ pci_update_irq_status(s); } @@ -514,7 +511,8 @@ void pci_device_save(PCIDevice *s, QEMUFile *f) int pci_device_load(PCIDevice *s, QEMUFile *f) { int ret; - ret =3D vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id); + + ret =3D vmstate_load_state(f, &vmstate_pci_device, s, s->version_id)= ; /* Restore the interrupt status bit. */ pci_update_irq_status(s); return ret; diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index a22861f..167b58d 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3544,7 +3544,7 @@ static const VMStateDescription vmstate_xhci =3D { .version_id =3D 1, .post_load =3D usb_xhci_post_load, .fields =3D (VMStateField[]) { - VMSTATE_PCIE_DEVICE(), + VMSTATE_PCI_DEVICE(), VMSTATE_MSIX(parent_obj, XHCIState), =20 VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1, diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index fc4ebd3..41e2f8c 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -130,14 +130,4 @@ void pcie_add_capability(PCIDevice *dev, =20 void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn); =20 -extern const VMStateDescription vmstate_pcie_device; - -#define VMSTATE_PCIE_DEVICE() { \ - .name =3D "parent_obj", \ - .size =3D sizeof(PCIDevice), \ - .vmsd =3D &vmstate_pcie_device, \ - .flags =3D VMS_STRUCT, \ - .offset =3D 0, \ -} - #endif /* QEMU_PCIE_H */ --=20 1.8.1.4