Skip to contentSkip to conversation

virtio-pci: don't touch pci on virtio reset

PATCH Superseded Michael S. Tsirkin 2 participants 3 messages Jul 27, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-pci: don't touch pci on virtio reset

virtio level reset should not affect pci express
registers such as PM, error or link.

Fixes 27ce0f3afc ("hw/virtio: fix Power Management Control Register for PCI Express virtio devices")
Fixes d584f1b9ca ("hw/virtio: fix Link Control Register for PCI Express virtio devices")
Fixes c2cabb3422 ("hw/virtio: fix error enabling flags in Device Control register")
Cc "Marcel Apfelbaum" <[email protected]>
---
 hw/virtio/virtio-pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/virtio/virtio-pci.c +8 -1
index 45327f0b31..3189ec014d 100644
@@ -1955,6 +1955,13 @@ static void virtio_pci_reset(DeviceState *qdev)
         proxy->vqs[i].avail[0] = proxy->vqs[i].avail[1] = 0;
         proxy->vqs[i].used[0] = proxy->vqs[i].used[1] = 0;
     }
+}
+
+static void virtio_pci_bus_reset(DeviceState *qdev)
+{
+    PCIDevice *dev = PCI_DEVICE(qdev);
+
+    virtio_pci_reset(qdev);
 
     if (pci_is_express(dev)) {
         pcie_cap_deverr_reset(dev);
@@ -2022,7 +2029,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_OTHERS;
     device_class_set_parent_realize(dc, virtio_pci_dc_realize,
                                     &vpciklass->parent_dc_realize);
-    dc->reset = virtio_pci_reset;
+    dc->reset = virtio_pci_bus_reset;
 }
 
 static const TypeInfo virtio_pci_info = {
Signature · 1 line
MST
#1 lore raw

testing it now...

Thanks!

C

Quoted 39 lines · Michael S. Tsirkin

virtio level reset should not affect pci express
registers such as PM, error or link.

Fixes 27ce0f3afc ("hw/virtio: fix Power Management Control Register for PCI Express virtio devices")
Fixes d584f1b9ca ("hw/virtio: fix Link Control Register for PCI Express virtio devices")
Fixes c2cabb3422 ("hw/virtio: fix error enabling flags in Device Control register")
Cc "Marcel Apfelbaum" <[email protected]>
---
 hw/virtio/virtio-pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/virtio/virtio-pci.c +8 -1
index 45327f0b31..3189ec014d 100644
@@ -1955,6 +1955,13 @@ static void virtio_pci_reset(DeviceState *qdev)
         proxy->vqs[i].avail[0] = proxy->vqs[i].avail[1] = 0;
         proxy->vqs[i].used[0] = proxy->vqs[i].used[1] = 0;
     }
+}
+
+static void virtio_pci_bus_reset(DeviceState *qdev)
+{
+    PCIDevice *dev = PCI_DEVICE(qdev);
+
+    virtio_pci_reset(qdev);
 
     if (pci_is_express(dev)) {
         pcie_cap_deverr_reset(dev);
@@ -2022,7 +2029,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_OTHERS;
     device_class_set_parent_realize(dc, virtio_pci_dc_realize,
                                     &vpciklass->parent_dc_realize);
-    dc->reset = virtio_pci_reset;
+    dc->reset = virtio_pci_bus_reset;
 }
 
 static const TypeInfo virtio_pci_info = {
#2 lore raw

Hmm, no that's not it,
still segfault in ovs, but I'll try to see if I can merge that and the workaround I am currently using...

Quoted 49 lines · Claudio Fontana

testing it now...

Thanks!

C

Quoted 39 lines · Michael S. Tsirkin

virtio level reset should not affect pci express
registers such as PM, error or link.

Fixes 27ce0f3afc ("hw/virtio: fix Power Management Control Register for PCI Express virtio devices")
Fixes d584f1b9ca ("hw/virtio: fix Link Control Register for PCI Express virtio devices")
Fixes c2cabb3422 ("hw/virtio: fix error enabling flags in Device Control register")
Cc "Marcel Apfelbaum" <[email protected]>
---
 hw/virtio/virtio-pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/virtio/virtio-pci.c +8 -1
index 45327f0b31..3189ec014d 100644
@@ -1955,6 +1955,13 @@ static void virtio_pci_reset(DeviceState *qdev)
         proxy->vqs[i].avail[0] = proxy->vqs[i].avail[1] = 0;
         proxy->vqs[i].used[0] = proxy->vqs[i].used[1] = 0;
     }
+}
+
+static void virtio_pci_bus_reset(DeviceState *qdev)
+{
+    PCIDevice *dev = PCI_DEVICE(qdev);
+
+    virtio_pci_reset(qdev);
 
     if (pci_is_express(dev)) {
         pcie_cap_deverr_reset(dev);
@@ -2022,7 +2029,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_OTHERS;
     device_class_set_parent_realize(dc, virtio_pci_dc_realize,
                                     &vpciklass->parent_dc_realize);
-    dc->reset = virtio_pci_reset;
+    dc->reset = virtio_pci_bus_reset;
 }
 
 static const TypeInfo virtio_pci_info = {