Update mappings after PCI bridge live migration or save-restore.
PATCH 1/1 Update mappings after PCI bridge live migration or save-restore.
From: Don Koch <[email protected]>
Update mappings for PCI bridge after live migration.
---
This fixes bug 1187529: devices on a PCI bridge stop working after migration.
hw/pci-bridge/pci_bridge_dev.c | 9 +++++++++ hw/pci/pci_bridge.c | 2 +- include/hw/pci/pci_bridge.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
hw/pci-bridge/pci_bridge_dev.c +9 -0
@@ -110,6 +110,14 @@ static void qdev_pci_bridge_dev_reset(DeviceState *qdev)shpc_reset (dev); } +static int pci_bridge_dev_post_load (void *opaque,int ver) { +PCIDevice *d = opaque; +PCIBridge *s =container_of (d, PCIBridge, dev); + +pci_bridge_update_mappings (s); +return 0 ; +} +static Property pci_bridge_dev_properties[] = {/* Note: 0 is not a legal chassis number. */ DEFINE_PROP_UINT8 ("chassis_nr" , PCIBridgeDev, chassis_nr,0 ),
@@ -119,6 +127,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , + .post_load = pci_bridge_dev_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (bridge.dev, PCIBridgeDev),SHPC_VMSTATE (bridge.dev.shpc, PCIBridgeDev),
hw/pci/pci_bridge.c +1 -1
@@ -224,7 +224,7 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)g_free (w); } -static void pci_bridge_update_mappings (PCIBridge *br) +void pci_bridge_update_mappings (PCIBridge *br) {PCIBridgeWindows *w = br->windows;
include/hw/pci/pci_bridge.h +1 -0
@@ -37,6 +37,7 @@ PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);pcibus_t pci_bridge_get_base (const PCIDevice *bridge,uint8_t type);pcibus_t pci_bridge_get_limit (const PCIDevice *bridge,uint8_t type); +void pci_bridge_update_mappings (PCIBridge *br);void pci_bridge_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len);void pci_bridge_disable_base_limit (PCIDevice *dev);
Signature · 1 line
1.7.11.7
Am 03.07.2013 17:04, schrieb Don Koch:
Quoted 7 lines
From: Don Koch <[email protected]>
Update mappings for PCI bridge after live migration.
Signed-off-by Don Koch <[email protected]>---
This fixes bug 1187529: devices on a PCI bridge stop working after migration.
Feel free to reference this as LP#1187529 in the commit message if this is from QEMU's Launchpad bug tracker.
Quoted 11 lines
hw/pci-bridge/pci_bridge_dev.c | 9 +++++++++ hw/pci/pci_bridge.c | 2 +- include/hw/pci/pci_bridge.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)hw/pci-bridge/pci_bridge_dev.c +0
-0
hw/pci-bridge/pci_bridge_dev.c static void qdev_pci_bridge_dev_reset(DeviceState *qdev) · line 115
Quoted 6 lines
hw/pci-bridge/pci_bridge_dev.c +3
-0@@ -110,6 +110,14 @@ static void qdev_pci_bridge_dev_reset(DeviceState *qdev)shpc_reset (dev); } +static int pci_bridge_dev_post_load (void *opaque,int ver) { +PCIDevice *d = opaque; +PCIBridge *s =container_of (d, PCIBridge, dev);
Casting should no longer be done that way. It seems there is no PCI_BRIDGE() cast macro in upstream yet, but it doesn't seem necessary either. You can just use:
PCIBridge *s = opaque;
for simplicity.
Functional change looks sensible to me.
Regards,
Andreas
Quoted 42 lines
hw/pci-bridge/pci_bridge_dev.c +6
-0+ +pci_bridge_update_mappings (s); +return 0 ; +} +static Property pci_bridge_dev_properties[] = {/* Note: 0 is not a legal chassis number. */ DEFINE_PROP_UINT8 ("chassis_nr" , PCIBridgeDev, chassis_nr,0 ),@@ -119,6 +127,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , + .post_load = pci_bridge_dev_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (bridge.dev, PCIBridgeDev),SHPC_VMSTATE (bridge.dev.shpc, PCIBridgeDev),hw/pci/pci_bridge.c +1
-1@@ -224,7 +224,7 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)g_free (w); } -static void pci_bridge_update_mappings (PCIBridge *br) +void pci_bridge_update_mappings (PCIBridge *br) {PCIBridgeWindows *w = br->windows;include/hw/pci/pci_bridge.h +1
-0@@ -37,6 +37,7 @@ PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);pcibus_t pci_bridge_get_base (const PCIDevice *bridge,uint8_t type);pcibus_t pci_bridge_get_limit (const PCIDevice *bridge,uint8_t type); +void pci_bridge_update_mappings (PCIBridge *br);void pci_bridge_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len);void pci_bridge_disable_base_limit (PCIDevice *dev);
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
Quoted 11 lines · Andreas Färber
Am 03.07.2013 17:04, schrieb Don Koch:
Quoted 7 lines
From: Don Koch <[email protected]>
Update mappings for PCI bridge after live migration.
Signed-off-by Don Koch <[email protected]>---
This fixes bug 1187529: devices on a PCI bridge stop working after migration.Feel free to reference this as LP#1187529 in the commit message if this is from QEMU's Launchpad bug tracker.
OK, will do. (Wasn't aware of this convention.)
Quoted 22 lines
Quoted 11 lines
hw/pci-bridge/pci_bridge_dev.c | 9 +++++++++ hw/pci/pci_bridge.c | 2 +- include/hw/pci/pci_bridge.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)hw/pci-bridge/pci_bridge_dev.c +0
-0hw/pci-bridge/pci_bridge_dev.c static void qdev_pci_bridge_dev_reset(DeviceState *qdev) · line 115
Quoted 6 lines
hw/pci-bridge/pci_bridge_dev.c +3
-0@@ -110,6 +110,14 @@ static void qdev_pci_bridge_dev_reset(DeviceState *qdev)shpc_reset (dev); } +static int pci_bridge_dev_post_load (void *opaque,int ver) { +PCIDevice *d = opaque; +PCIBridge *s =container_of (d, PCIBridge, dev);Casting should no longer be done that way. It seems there is no
PCI_BRIDGE()cast macro in upstream yet, but it doesn't seem necessary either. You can just use:
Quoted 3 lines
PCIBridge *s = opaque;
for simplicity.
Might I suggest submitting the patch as is (possibly modulo Michael Tsirkin's suggestions) and later submitting a PCI_BRIDGE macro patch to "standardize" the casting?
Quoted 50 lines
Functional change looks sensible to me.
Regards,
AndreasQuoted 42 lines
hw/pci-bridge/pci_bridge_dev.c +6
-0+ +pci_bridge_update_mappings (s); +return 0 ; +} +static Property pci_bridge_dev_properties[] = {/* Note: 0 is not a legal chassis number. */ DEFINE_PROP_UINT8 ("chassis_nr" , PCIBridgeDev, chassis_nr,0 ),@@ -119,6 +127,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , + .post_load = pci_bridge_dev_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (bridge.dev, PCIBridgeDev),SHPC_VMSTATE (bridge.dev.shpc, PCIBridgeDev),hw/pci/pci_bridge.c +1
-1@@ -224,7 +224,7 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)g_free (w); } -static void pci_bridge_update_mappings (PCIBridge *br) +void pci_bridge_update_mappings (PCIBridge *br) {PCIBridgeWindows *w = br->windows;include/hw/pci/pci_bridge.h +1
-0@@ -37,6 +37,7 @@ PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);pcibus_t pci_bridge_get_base (const PCIDevice *bridge,uint8_t type);pcibus_t pci_bridge_get_limit (const PCIDevice *bridge,uint8_t type); +void pci_bridge_update_mappings (PCIBridge *br);void pci_bridge_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len);void pci_bridge_disable_base_limit (PCIDevice *dev);
Quoted 7 lines · Don Koch
From: Don Koch <[email protected]>
Update mappings for PCI bridge after live migration.
Signed-off-by Don Koch <[email protected]>---
This fixes bug 1187529: devices on a PCI bridge stop working after migration.
Thanks, this looks good, but any bridge device would need this fix, won't it?
Could we call this from get_pci_config_device instead? This way all bridge devices would be fixed.
Quoted 59 lines
hw/pci-bridge/pci_bridge_dev.c | 9 +++++++++ hw/pci/pci_bridge.c | 2 +- include/hw/pci/pci_bridge.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)hw/pci-bridge/pci_bridge_dev.c +9
-0@@ -110,6 +110,14 @@ static void qdev_pci_bridge_dev_reset(DeviceState *qdev)shpc_reset (dev); } +static int pci_bridge_dev_post_load (void *opaque,int ver) { +PCIDevice *d = opaque; +PCIBridge *s =container_of (d, PCIBridge, dev); + +pci_bridge_update_mappings (s); +return 0 ; +} +static Property pci_bridge_dev_properties[] = {/* Note: 0 is not a legal chassis number. */ DEFINE_PROP_UINT8 ("chassis_nr" , PCIBridgeDev, chassis_nr,0 ),@@ -119,6 +127,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , + .post_load = pci_bridge_dev_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (bridge.dev, PCIBridgeDev),SHPC_VMSTATE (bridge.dev.shpc, PCIBridgeDev),hw/pci/pci_bridge.c +1
-1@@ -224,7 +224,7 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)g_free (w); } -static void pci_bridge_update_mappings (PCIBridge *br) +void pci_bridge_update_mappings (PCIBridge *br) {PCIBridgeWindows *w = br->windows;include/hw/pci/pci_bridge.h +1
-0@@ -37,6 +37,7 @@ PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);pcibus_t pci_bridge_get_base (const PCIDevice *bridge,uint8_t type);pcibus_t pci_bridge_get_limit (const PCIDevice *bridge,uint8_t type); +void pci_bridge_update_mappings (PCIBridge *br);void pci_bridge_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len);void pci_bridge_disable_base_limit (PCIDevice *dev);Signature · 1 line
1.7.11.7
Quoted 10 lines · Michael S. Tsirkin
Quoted 7 lines · Don Koch
From: Don Koch <[email protected]>
Update mappings for PCI bridge after live migration.
Signed-off-by Don Koch <[email protected]>---
This fixes bug 1187529: devices on a PCI bridge stop working after migration.Thanks, this looks good, but any bridge device would need this fix, won't it?
One would think so.
Quoted 1 line
Could we call this from
get_pci_config_deviceinstead?
Seems a bit odd, but I can't find a better spot (there is no pci_bridge equivalent).
I'll look into a patch for that (but can't guarantee total testing).
Quoted 1 line
This way all bridge devices would be fixed.
Well, all that support migration (e.g., not the i82801b11). ;)
Quoted 60 lines
Quoted 60 lines
hw/pci-bridge/pci_bridge_dev.c | 9 +++++++++ hw/pci/pci_bridge.c | 2 +- include/hw/pci/pci_bridge.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)hw/pci-bridge/pci_bridge_dev.c +9
-0@@ -110,6 +110,14 @@ static void qdev_pci_bridge_dev_reset(DeviceState *qdev)shpc_reset (dev); } +static int pci_bridge_dev_post_load (void *opaque,int ver) { +PCIDevice *d = opaque; +PCIBridge *s =container_of (d, PCIBridge, dev); + +pci_bridge_update_mappings (s); +return 0 ; +} +static Property pci_bridge_dev_properties[] = {/* Note: 0 is not a legal chassis number. */ DEFINE_PROP_UINT8 ("chassis_nr" , PCIBridgeDev, chassis_nr,0 ),@@ -119,6 +127,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , + .post_load = pci_bridge_dev_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (bridge.dev, PCIBridgeDev),SHPC_VMSTATE (bridge.dev.shpc, PCIBridgeDev),hw/pci/pci_bridge.c +1
-1@@ -224,7 +224,7 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)g_free (w); } -static void pci_bridge_update_mappings (PCIBridge *br) +void pci_bridge_update_mappings (PCIBridge *br) {PCIBridgeWindows *w = br->windows;include/hw/pci/pci_bridge.h +1
-0@@ -37,6 +37,7 @@ PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);pcibus_t pci_bridge_get_base (const PCIDevice *bridge,uint8_t type);pcibus_t pci_bridge_get_limit (const PCIDevice *bridge,uint8_t type); +void pci_bridge_update_mappings (PCIBridge *br);void pci_bridge_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len);void pci_bridge_disable_base_limit (PCIDevice *dev);Signature · 1 line
1.7.11.7