Skip to contentSkip to conversation

qdev: make reset semantics more clear and consistent, reset qbuses under virtio devices

PATCH NAK Paolo Bonzini 6 participants 62 messages Dec 17, 2012 – Jan 10, 2013

lore
Share & tools
lore
#0 lore raw

cover qdev: make reset semantics more clear and consistent, reset qbuses under virtio devices

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

1) device-level reset is the kind of reset that you get with a register write on the device. It will clear interrupts and DMAs among other things, but not any bus-level state, for example it will not clear PCI BARs and other configuration space data. It is done with qdev_reset_all.

2) bus-level reset is the kind of reset that you get with a register write on the device that exports the bus (including triggering a device-level reset on the device that exports the bus). It will do a device-level reset on the child, but also clear bus-level state such as PCI BARs and other configuration space data. It can be triggered for all devices on a bus with qbus_reset_all. There is still no API for a bus-level reset of a single device (like PCI FLR), this can be added later.

Patches 1-5 are miscellaneous fixes to the reset paths.

Patches 6-8 introduce qbus_reset_all and uses it.

Patches 9-12 switch qdev_reset_all and qbus_reset_all from pre-order to post-order, and document the resulting semantics.

Finally, patches 13-15 adjust the virtio implementations to use qdev device-level reset more extensively.

Paolo Bonzini (15):
qdev: do not reset a device until the parent has been initialized
intel-hda: do not reset codecs from intel_hda_reset
pci: clean up resetting of IRQs
virtio-pci: reset device before PCI layer
virtio-s390: add a reset function to virtio-s390 devices
qdev: add qbus_reset_all
pci: do not export pci_bus_reset
lsi: use qbus_reset_all to reset SCSI bus
qdev: allow both pre- and post-order vists in qdev walking functions
qdev: switch reset to post-order
qdev: remove device_reset
qdev: document reset semantics
virtio-pci: reset all qbuses too when writing to the status field
virtio-s390: reset all qbuses too when writing to the status field
virtio-serial: do not perform bus reset by hand

 hw/intel-hda.c         |  1 -
 hw/lsi53c895a.c        |  7 +----
 hw/pci.c               | 16 ++++------
 hw/pci.h               |  1 -
 hw/pci_bridge.c        |  2 +-
 hw/qdev-core.h         | 83 ++++++++++++++++++++++++++++++++++++++++++--------
 hw/qdev.c              | 70 +++++++++++++++++++++++++++---------------
 hw/s390-virtio-bus.c   | 16 +++++++++-
 hw/virtio-pci.c        | 27 +++++++---------
 hw/virtio-serial-bus.c | 19 +++---------
 10 files changed, 156 insertions(+), 86 deletions(-)
Signature · 1 line
1.8.0.2
#1 lore raw

PATCH 1/15 qdev: do not reset a device until the parent has been initialized

When a device creates a bus and more devices as part of its init callback, the child device could be reset while the parent is still only partly initialized. In this case, the right thing to do is to delay resetting the child. Do not do it at all in qdev_init, instead use qdev_reset_all to reset already-created devices when the state goes from CREATED to INITIALIZED.

This happens when hotplugging a usb-storage device. Without this patch, initialization of a hotplugged usb-storage device would run in pre-order. Initialization of a coldplugged usb-storage device would run according to qdev_reset_all semantics (pre-order right now, post-order later in the series). This patch makes things consistent.

---
 hw/qdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/qdev.c +3 -2
index 599382c..2fdf4ac 100644
@@ -176,8 +176,9 @@ int qdev_init(DeviceState *dev)
                                        dev->alias_required_for_version);
     }
     dev->state = DEV_STATE_INITIALIZED;
-    if (dev->hotplugged) {
-        device_reset(dev);
+    if (dev->hotplugged &&
+        dev->parent_bus->parent->state == DEV_STATE_INITIALIZED) {
+        qdev_reset_all(dev);
     }
     return 0;
 }
Signature · 1 line
1.8.0.2
#2 lore raw

Re: [Qemu-devel] [PATCH 01/15] qdev: do not reset a device until the parent has been initialized

Quoted 11 lines · Paolo Bonzini

When a device creates a bus and more devices as part of its init callback, the child device could be reset while the parent is still only partly initialized. In this case, the right thing to do is to delay resetting the child. Do not do it at all in qdev_init, instead use qdev_reset_all to reset already-created devices when the state goes from CREATED to INITIALIZED.

This happens when hotplugging a usb-storage device. Without this patch, initialization of a hotplugged usb-storage device would run in pre-order. Initialization of a coldplugged usb-storage device would run according to qdev_reset_all semantics (pre-order right now, post-order later in the series).

Is this a problem or just not pretty?

Quoted 12 lines

This patch makes things consistent.

---
 hw/qdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/qdev.c +0 -0
index 599382c..2fdf4ac 100644

hw/qdev.c int qdev_init(DeviceState *dev) · line 181

Quoted 8 lines
hw/qdev.c +3 -2
@@ -176,8 +176,9 @@ int qdev_init(DeviceState *dev)
                                        dev->alias_required_for_version);
     }
     dev->state = DEV_STATE_INITIALIZED;
-    if (dev->hotplugged) {
-        device_reset(dev);
+    if (dev->hotplugged &&
+        dev->parent_bus->parent->state == DEV_STATE_INITIALIZED) {
+        qdev_reset_all(dev);

Let's add a comment explaining the why of this test, and when will reset happen if it does not trigger here.

Quoted 6 lines
hw/qdev.c +0 -0
     }
     return 0;
 }
Signature · 1 line
1.8.0.2
#3 lore raw

Re: [Qemu-devel] [PATCH 01/15] qdev: do not reset a device until the parent has been initialized

Quoted 22 lines · Michael S. Tsirkin
Quoted 11 lines · Paolo Bonzini

When a device creates a bus and more devices as part of its init callback, the child device could be reset while the parent is still only partly initialized. In this case, the right thing to do is to delay resetting the child. Do not do it at all in qdev_init, instead use qdev_reset_all to reset already-created devices when the state goes from CREATED to INITIALIZED.

This happens when hotplugging a usb-storage device. Without this patch, initialization of a hotplugged usb-storage device would run in pre-order. Initialization of a coldplugged usb-storage device would run according to qdev_reset_all semantics (pre-order right now, post-order later in the series).

Is this a problem or just not pretty?

Quoted 7 lines

This patch makes things consistent.

---
 hw/qdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 16 lines

hw/qdev.c int qdev_init(DeviceState *dev) · line 181

Quoted 13 lines
hw/qdev.c +3 -2
index 599382c..2fdf4ac 100644
@@ -176,8 +176,9 @@ int qdev_init(DeviceState *dev)
                                        dev->alias_required_for_version);
     }
     dev->state = DEV_STATE_INITIALIZED;
-    if (dev->hotplugged) {
-        device_reset(dev);
+    if (dev->hotplugged &&
+        dev->parent_bus->parent->state == DEV_STATE_INITIALIZED) {
+        qdev_reset_all(dev);

Let's add a comment explaining the why of this test, and when will reset happen if it does not trigger here.

Also - shouldn't device init be delayed as well?
What do you think?

Quoted 6 lines
Quoted 6 lines
hw/qdev.c +0 -0
     }
     return 0;
 }
Signature · 1 line
1.8.0.2
#4 lore raw

Re: [Qemu-devel] [PATCH 01/15] qdev: do not reset a device until the parent has been initialized

Il 17/12/2012 17:53, Michael S. Tsirkin ha scritto:

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

This happens when hotplugging a usb-storage device. Without this patch, initialization of a hotplugged usb-storage device would run in pre-order. Initialization of a coldplugged usb-storage device would run according to qdev_reset_all semantics (pre-order right now, post-order later in the series).

Is this a problem or just not pretty?

Not pretty. The child device doesn't exist until the parent has been initialized, it doesn't make sense to reset it.

I can add an assertion to make it a problem, of course. :)

Quoted 24 lines
Quoted 7 lines
Quoted 7 lines

This patch makes things consistent.

---
 hw/qdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 16 lines

hw/qdev.c int qdev_init(DeviceState *dev) · line 181

Quoted 13 lines
hw/qdev.c +3 -2
index 599382c..2fdf4ac 100644
@@ -176,8 +176,9 @@ int qdev_init(DeviceState *dev)
                                        dev->alias_required_for_version);
     }
     dev->state = DEV_STATE_INITIALIZED;
-    if (dev->hotplugged) {
-        device_reset(dev);
+    if (dev->hotplugged &&
+        dev->parent_bus->parent->state == DEV_STATE_INITIALIZED) {
+        qdev_reset_all(dev);

Let's add a comment explaining the why of this test, and when will reset happen if it does not trigger here.

Quoted 2 lines

Also - shouldn't device init be delayed as well?
What do you think?

Initialization should run in pre-order (unlike reset): the parent needs to be ready in order to start the child. What you typically have, is that the parent device initializes itself, and then calls qdev_create/qdev_init on the child before returning. So it is already being delayed. The delay is explicit in program flow, not hidden in qdev semantics.

Paolo

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
hw/qdev.c +0 -0
     }
     return 0;
 }
Signature · 1 line
1.8.0.2
#5 lore raw

Re: [Qemu-devel] [PATCH 01/15] qdev: do not reset a device until the parent has been initialized

In reply to Paolo Bonzini

Am 17.12.2012 17:24, schrieb Paolo Bonzini:

Quoted 22 lines

When a device creates a bus and more devices as part of its init callback, the child device could be reset while the parent is still only partly initialized. In this case, the right thing to do is to delay resetting the child. Do not do it at all in qdev_init, instead use qdev_reset_all to reset already-created devices when the state goes from CREATED to INITIALIZED.

This happens when hotplugging a usb-storage device. Without this patch, initialization of a hotplugged usb-storage device would run in pre-order. Initialization of a coldplugged usb-storage device would run according to qdev_reset_all semantics (pre-order right now, post-order later in the series). This patch makes things consistent.

---
 hw/qdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/qdev.c +0 -0
index 599382c..2fdf4ac 100644

hw/qdev.c int qdev_init(DeviceState *dev) · line 180

Quoted 7 lines
hw/qdev.c +2 -2
@@ -176,8 +176,9 @@ int qdev_init(DeviceState *dev)
                                        dev->alias_required_for_version);
     }
     dev->state = DEV_STATE_INITIALIZED;
-    if (dev->hotplugged) {
-        device_reset(dev);
+    if (dev->hotplugged &&
+        dev->parent_bus->parent->state == DEV_STATE_INITIALIZED) {

This assumes that parent_bus != NULL, when we are trying to let our fallback bus SysBus die out. The CPU in the current proposal is not a SysBus device, to avoid compiling SysBus unnecessarily into *-user.

Your direct access into the parent's state also conflicts with my QOM realize series IIUC.

So please at least add appropriate checks to do the below reset only when there is a bus and leave the old behavior otherwise.

Andreas

Quoted 5 lines
hw/qdev.c +1 -0
+        qdev_reset_all(dev);
     }
     return 0;
 }
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
#6 lore raw

PATCH 2/15 intel-hda: do not reset codecs from intel_hda_reset

In reply to Paolo Bonzini

They are reset implicitly by walking the qdev tree, before calling intel_hda_reset.

---
 hw/intel-hda.c | 1 -
 1 file changed, 1 deletion(-)
hw/intel-hda.c +0 -1
index a68c368..e7c9dd9 100644
@@ -1112,7 +1112,6 @@ static void intel_hda_reset(DeviceState *dev)
     QTAILQ_FOREACH(kid, &d->codecs.qbus.children, sibling) {
         DeviceState *qdev = kid->child;
         cdev = DO_UPCAST(HDACodecDevice, qdev, qdev);
-        device_reset(DEVICE(cdev));
         d->state_sts |= (1 << cdev->cad);
     }
     intel_hda_update_irq(d);
Signature · 1 line
1.8.0.2
#7 lore raw

PATCH 3/15 pci: clean up resetting of IRQs

In reply to Paolo Bonzini

A PCI bus reset will deassert the INTX pins, and this will make the irq_count array all-zeroes. Check that this is the case, and remove the existing loop which might even unsync irq_count and irq_state.

---
 hw/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/pci.c +3 -3
index 97a0cd7..ace9368 100644
@@ -213,14 +213,14 @@ void pci_bus_reset(PCIBus *bus)
 {
     int i;
 
-    for (i = 0; i < bus->nirq; i++) {
-        bus->irq_count[i] = 0;
-    }
     for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
         if (bus->devices[i]) {
             pci_device_reset(bus->devices[i]);
         }
     }
+    for (i = 0; i < bus->nirq; i++) {
+        assert(bus->irq_count[i] == 0);
+    }
 }
 
 static int pcibus_reset(BusState *qbus)
Signature · 1 line
1.8.0.2
#8 lore raw

PATCH 4/15 virtio-pci: reset device before PCI layer

In reply to Paolo Bonzini

At the end of this series, qdev will reset devices in post-order: first the children, then the parents. The ->vdev link is logically a child of the virtio-pci device and, even though it is not explicitly modeled like that, we want to use the same reset semantics as qdev.

---
 hw/virtio-pci.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
hw/virtio-pci.c +6 -3
index 71f4fb5..a7c75fe 100644
@@ -245,8 +245,8 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
 void virtio_pci_reset(DeviceState *d)
 {
     VirtIOPCIProxy *proxy = container_of(d, VirtIOPCIProxy, pci_dev.qdev);
-    virtio_pci_stop_ioeventfd(proxy);
     virtio_reset(proxy->vdev);
+    virtio_pci_stop_ioeventfd(proxy);
     msix_unuse_all_vectors(&proxy->pci_dev);
     proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
 }
@@ -268,8 +268,8 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case VIRTIO_PCI_QUEUE_PFN:
         pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
         if (pa == 0) {
-            virtio_pci_stop_ioeventfd(proxy);
             virtio_reset(proxy->vdev);
+            virtio_pci_stop_ioeventfd(proxy);
             msix_unuse_all_vectors(&proxy->pci_dev);
         }
         else
@@ -285,6 +285,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         }
         break;
     case VIRTIO_PCI_STATUS:
+        if (vdev->status == 0) {
+            virtio_reset(proxy->vdev);
+        }
+
         if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
             virtio_pci_stop_ioeventfd(proxy);
         }
@@ -296,7 +300,6 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         }
 
         if (vdev->status == 0) {
-            virtio_reset(proxy->vdev);
             msix_unuse_all_vectors(&proxy->pci_dev);
         }
 
Signature · 1 line
1.8.0.2
#9 lore raw

PATCH 5/15 virtio-s390: add a reset function to virtio-s390 devices

In reply to Paolo Bonzini

virtio-s390 devices are not being reset when their bus is. To fix this, add a reset method that forwards to virtio_reset. This is only needed because of the "strange" modeling of virtio devices; the ->vdev link is being handled manually rather than through qdev.

---
 hw/s390-virtio-bus.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/s390-virtio-bus.c +8 -0
index e0ac2d1..34173a7 100644
@@ -492,6 +492,13 @@ static int s390_virtio_busdev_init(DeviceState *dev)
     return _info->init(_dev);
 }
 
+static void s390_virtio_busdev_reset(DeviceState *dev)
+{
+    VirtIOS390Device *_dev = (VirtIOS390Device *)dev;
+
+    virtio_reset(_dev->vdev);
+}
+
 static void virtio_s390_device_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -499,6 +506,7 @@ static void virtio_s390_device_class_init(ObjectClass *klass, void *data)
     dc->init = s390_virtio_busdev_init;
     dc->bus_type = TYPE_S390_VIRTIO_BUS;
     dc->unplug = qdev_simple_unplug_cb;
+    dc->reset = s390_virtio_busdev_reset;
 }
 
 static TypeInfo virtio_s390_device_info = {
Signature · 1 line
1.8.0.2
#10 lore raw

PATCH 6/15 qdev: add qbus_reset_all

In reply to Paolo Bonzini
---
 hw/qdev-core.h | 12 ++++++++++++
 hw/qdev.c      |  7 ++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
hw/qdev-core.h +12 -0
index d672cca..f8bf9dd 100644
@@ -182,6 +182,18 @@ int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
 int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
                        qbus_walkerfn *busfn, void *opaque);
 void qdev_reset_all(DeviceState *dev);
+
+/**
+ * @qbus_reset_all:
+ * @bus: Bus to be reset.
+ *
+ * Reset @bus and perform a bus-level ("hard") reset of all devices connected
+ * to it, including recursive processing of all buses below @bus itself.  A
+ * hard reset means that qbus_reset_all will reset all state of the device.
+ * For PCI devices, for example, this will include the base address registers
+ * or configuration space.
+ */
+void qbus_reset_all(BusState *bus);
 void qbus_reset_all_fn(void *opaque);
 
 void qbus_free(BusState *bus);
hw/qdev.c +6 -1
index 2fdf4ac..87ffad8 100644
@@ -230,10 +230,15 @@ void qdev_reset_all(DeviceState *dev)
     qdev_walk_children(dev, qdev_reset_one, qbus_reset_one, NULL);
 }
 
+void qbus_reset_all(BusState *bus)
+{
+    qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL);
+}
+
 void qbus_reset_all_fn(void *opaque)
 {
     BusState *bus = opaque;
-    qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL);
+    qbus_reset_all(bus);
 }
 
 /* can be used as ->unplug() callback for the simple cases */
Signature · 1 line
1.8.0.2
#11 lore raw

PATCH 7/15 pci: do not export pci_bus_reset

In reply to Paolo Bonzini

qbus_reset_all can be used instead. There is no semantic change because pcibus_reset returns 1 and takes care of the device tree traversal.

---
 hw/pci.c        | 10 +++-------
 hw/pci.h        |  1 -
 hw/pci_bridge.c |  2 +-
 3 files changed, 4 insertions(+), 9 deletions(-)
hw/pci.c +3 -7
index ace9368..436982e 100644
@@ -209,8 +209,9 @@ void pci_device_reset(PCIDevice *dev)
  * Trigger pci bus reset under a given bus.
  * To be called on RST# assert.
  */
-void pci_bus_reset(PCIBus *bus)
+static int pcibus_reset(BusState *qbus)
 {
+    PCIBus *bus = DO_UPCAST(PCIBus, qbus, qbus);
     int i;
 
     for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
@@ -221,13 +222,8 @@ void pci_bus_reset(PCIBus *bus)
     for (i = 0; i < bus->nirq; i++) {
         assert(bus->irq_count[i] == 0);
     }
-}
-
-static int pcibus_reset(BusState *qbus)
-{
-    pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus));
 
-    /* topology traverse is done by pci_bus_reset().
+    /* topology traverse is done in the pci_device_reset() loop above.
        Tell qbus/qdev walker not to traverse the tree */
     return 1;
 }
hw/pci.h +0 -1
index 4da0c2a..88fd4a3 100644
@@ -334,7 +334,6 @@ void pci_bus_fire_intx_routing_notifier(PCIBus *bus);
 void pci_device_set_intx_routing_notifier(PCIDevice *dev,
                                           PCIINTxRoutingNotifier notifier);
 void pci_device_reset(PCIDevice *dev);
-void pci_bus_reset(PCIBus *bus);
 
 PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
                         const char *default_devaddr);
hw/pci_bridge.c +1 -1
index 4680501..30ed34e 100644
@@ -234,7 +234,7 @@ void pci_bridge_write_config(PCIDevice *d,
     newctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
     if (~oldctl & newctl & PCI_BRIDGE_CTL_BUS_RESET) {
         /* Trigger hot reset on 0->1 transition. */
-        pci_bus_reset(&s->sec_bus);
+        qbus_reset_all(&s->sec_bus.qbus);
     }
 }
 
Signature · 1 line
1.8.0.2
#12 lore raw

PATCH 8/15 lsi: use qbus_reset_all to reset SCSI bus

In reply to Paolo Bonzini
---
 hw/lsi53c895a.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
hw/lsi53c895a.c +1 -6
index 04f2fae..83ac5e9 100644
@@ -1670,12 +1670,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
         }
         if (val & LSI_SCNTL1_RST) {
             if (!(s->sstat0 & LSI_SSTAT0_RST)) {
-                BusChild *kid;
-
-                QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
-                    DeviceState *dev = kid->child;
-                    device_reset(dev);
-                }
+                qbus_reset_all(&s->bus.qbus);
                 s->sstat0 |= LSI_SSTAT0_RST;
                 lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
             }
Signature · 1 line
1.8.0.2
#13 lore raw

PATCH 9/15 qdev: allow both pre- and post-order vists in qdev walking functions

In reply to Paolo Bonzini

Resetting should be done in post-order, not pre-order. However, qdev_walk_children and qbus_walk_children do not allow this. Fix it by adding two extra arguments to the functions.

---
 hw/qdev-core.h | 13 +++++++++----
 hw/qdev.c      | 45 +++++++++++++++++++++++++++++++++------------
 2 files changed, 42 insertions(+), 16 deletions(-)
hw/qdev-core.h +9 -4
index f8bf9dd..7c2598e 100644
@@ -177,10 +177,15 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam
 /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
  *         < 0 if either devfn or busfn terminate walk somewhere in cursion,
  *           0 otherwise. */
-int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
-                       qbus_walkerfn *busfn, void *opaque);
-int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
-                       qbus_walkerfn *busfn, void *opaque);
+int qbus_walk_children(BusState *bus,
+                       qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
+                       qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
+                       void *opaque);
+int qdev_walk_children(DeviceState *dev,
+                       qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
+                       qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
+                       void *opaque);
+
 void qdev_reset_all(DeviceState *dev);
 
 /**
hw/qdev.c +33 -12

94 lines not on this page · raw message

Signature · 1 line
1.8.0.2
#14 lore raw

PATCH 10/15 qdev: switch reset to post-order

In reply to Paolo Bonzini

Post-order is the only sensible direction for the reset signals. For example, suppose pre-order is used and the parent has some data structures that cache children state (for example a list of active requests). When the reset method is invoked on the parent, these caches cannot be left in a consistent state, nor asserted to be in a consistent state.

If post-order is used, on the other hand, these will be in a known state when the reset method is invoked on the parent.

I checked the existing bus-reset implementation and they are all fine with post-order. USB doesn't use qdev reset, but it should be fine with post-order too.

---
 hw/qdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/qdev.c +2 -2
index 457f7bf..833d571 100644
@@ -227,12 +227,12 @@ static int qbus_reset_one(BusState *bus, void *opaque)
 
 void qdev_reset_all(DeviceState *dev)
 {
-    qdev_walk_children(dev, qdev_reset_one, qbus_reset_one, NULL, NULL, NULL);
+    qdev_walk_children(dev, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL);
 }
 
 void qbus_reset_all(BusState *bus)
 {
-    qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL, NULL, NULL);
+    qbus_walk_children(bus, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL);
 }
 
 void qbus_reset_all_fn(void *opaque)
Signature · 1 line
1.8.0.2
#15 lore raw

PATCH 11/15 qdev: remove device_reset

In reply to Paolo Bonzini

The right thing to do is always to use qdev_reset_all (or qbus_reset_all). Call the reset method straight from qdev_reset_one.

---
 hw/qdev-core.h |  7 -------
 hw/qdev.c      | 15 +++++----------
 2 files changed, 5 insertions(+), 17 deletions(-)
hw/qdev-core.h +0 -7
index 7c2598e..28f12a4 100644
@@ -218,13 +218,6 @@ char *qdev_get_fw_dev_path(DeviceState *dev);
  */
 void qdev_machine_init(void);
 
-/**
- * @device_reset
- *
- * Reset a single device (by calling the reset method).
- */
-void device_reset(DeviceState *dev);
-
 const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 
 const char *qdev_fw_name(DeviceState *dev);
hw/qdev.c +5 -10
index 833d571..1736d6f 100644
@@ -211,7 +211,11 @@ void qdev_unplug(DeviceState *dev, Error **errp)
 
 static int qdev_reset_one(DeviceState *dev, void *opaque)
 {
-    device_reset(dev);
+    DeviceClass *klass = DEVICE_GET_CLASS(dev);
+
+    if (klass->reset) {
+        klass->reset(dev);
+    }
 
     return 0;
 }
@@ -750,15 +754,6 @@ static void device_class_init(ObjectClass *class, void *data)
     class->unparent = qdev_remove_from_bus;
 }
 
-void device_reset(DeviceState *dev)
-{
-    DeviceClass *klass = DEVICE_GET_CLASS(dev);
-
-    if (klass->reset) {
-        klass->reset(dev);
-    }
-}
-
 Object *qdev_get_machine(void)
 {
     static Object *dev;
Signature · 1 line
1.8.0.2
#16 lore raw

PATCH 12/15 qdev: document reset semantics

In reply to Paolo Bonzini
---
 hw/qdev-core.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
hw/qdev-core.h +50 -1
index 28f12a4..1274994 100644
@@ -36,7 +36,24 @@ typedef struct DeviceClass {
     Property *props;
     int no_user;
 
-    /* callbacks */
+    /* reset:
+     * @dev: Device being reset.
+     *
+     * Performs the device-specific part of a device-level ("soft") reset
+     * of @dev.  This is called by QEMU internally as part of initialization
+     * or resetting a bus, but it is often accessible using a device register
+     * as well.  Devices can access it using qdev_reset_all.
+     *
+     * In general, a soft reset will not reset any state that depends on the
+     * type of bus that the device resides on.  For example, PCI devices do not
+     * reset their base address registers or configuration space in the reset
+     * callback.  Resetting these registers is handled by the bus, not by the
+     * device.
+     *
+     * A device-level reset also includes a hard reset of all the buses exposed
+     * by @dev (and all devices below those, recursively).  However, this is
+     * handled by qdev_reset_all and this callback need not care about it.
+     */
     void (*reset)(DeviceState *dev);
 
     /* device state */
@@ -86,6 +103,23 @@ struct BusClass {
      * bindings can be found at http://playground.sun.com/1275/bindings/.
      */
     char *(*get_fw_dev_path)(DeviceState *dev);
+
+    /* reset:
+     * @bus: Bus being reset.
+     *
+     * This callback performs a reset of @bus.  It is usually done when
+     * qdev_reset_all is called on the parent of @bus.
+     *
+     * Resetting a bus includes a bus-level ("hard") reset of all devices on
+     * the bus itself.  Compared to a device-level ("soft") reset, this will
+     * also remove all the configuration for devices.  In the case of PCI, for
+     * example, this means the base address registers, configuration space,
+     * etc.
+     *
+     * The callback may take care of calling qdev_reset_all on all devices
+     * to perform the soft reset, or not.  In the first case, it should return
+     * 1; in the second case, it should return 0 (see also qbus_walkerfn).
+     */
     int (*reset)(BusState *bus);
 };
 
@@ -186,6 +220,21 @@ int qdev_walk_children(DeviceState *dev,
                        qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
                        void *opaque);
 
+/**
+ * @qdev_reset_all:
+ * @dev: Device to be reset.
+ *
+ * Perform a device-level ("soft") reset of dev, including all buses
+ * and all devices connected to those buses.  A soft reset means that
+ * qdev_reset_all will not reset any state that depends on the type of
+ * bus that the device resides on.  For example, PCI devices will not
+ * reset their base address registers or configuration space.
+ *
+ * However, this is not true for device connected to @dev's buses; these are
+ * reset completely.  For example, if @dev is a PCI-to-PCI bridge, the base
+ * address registers will be reset for devices on the bridge, but not for @dev
+ * itself.
+ */
 void qdev_reset_all(DeviceState *dev);
 
 /**
Signature · 1 line
1.8.0.2
#17 lore raw

PATCH 13/15 virtio-pci: reset all qbuses too when writing to the status field

In reply to Paolo Bonzini

virtio-pci devices do not perform a full reset when zero is written to the status byte. While PCI-specific status is initialized, the reset does not propagate down the qdev bus hierarchy. Because of this, a virtio reset does not cancel in-flight I/O for virtio-scsi (where the cancellation is handled automatically by the SCSI devices underneath virtio-scsi-pci).

---
 hw/virtio-pci.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)
hw/virtio-pci.c +10 -18
index a7c75fe..2cf5282 100644
@@ -268,12 +268,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case VIRTIO_PCI_QUEUE_PFN:
         pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
         if (pa == 0) {
-            virtio_reset(proxy->vdev);
-            virtio_pci_stop_ioeventfd(proxy);
-            msix_unuse_all_vectors(&proxy->pci_dev);
-        }
-        else
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
             virtio_queue_set_addr(vdev, vdev->queue_sel, pa);
+        }
         break;
     case VIRTIO_PCI_QUEUE_SEL:
         if (val < VIRTIO_PCI_QUEUE_MAX)
@@ -285,22 +283,16 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         }
         break;
     case VIRTIO_PCI_STATUS:
-        if (vdev->status == 0) {
-            virtio_reset(proxy->vdev);
-        }
-
-        if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
-            virtio_pci_stop_ioeventfd(proxy);
-        }
-
         virtio_set_status(vdev, val & 0xFF);
 
-        if (val & VIRTIO_CONFIG_S_DRIVER_OK) {
-            virtio_pci_start_ioeventfd(proxy);
-        }
-
         if (vdev->status == 0) {
-            msix_unuse_all_vectors(&proxy->pci_dev);
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
+            if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
+                virtio_pci_stop_ioeventfd(proxy);
+            } else {
+                virtio_pci_start_ioeventfd(proxy);
+            }
         }
 
         /* Linux before 2.6.34 sets the device as OK without enabling
Signature · 1 line
1.8.0.2
#18 lore raw

Re: [Qemu-devel] [PATCH 13/15] virtio-pci: reset all qbuses too when writing to the status field

Quoted 10 lines · Paolo Bonzini

virtio-pci devices do not perform a full reset when zero is written to the status byte. While PCI-specific status is initialized, the reset does not propagate down the qdev bus hierarchy. Because of this, a virtio reset does not cancel in-flight I/O for virtio-scsi (where the cancellation is handled automatically by the SCSI devices underneath virtio-scsi-pci).

I would still prefer this logic to reside in virtio.c instead of being duplicated in each bus.
My idea was to simply call qdev_reset_all on the binding from virtio.c but other ideas wellcome.

Quoted 57 lines
---
 hw/virtio-pci.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)
hw/virtio-pci.c +10 -18
index a7c75fe..2cf5282 100644
@@ -268,12 +268,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case VIRTIO_PCI_QUEUE_PFN:
         pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
         if (pa == 0) {
-            virtio_reset(proxy->vdev);
-            virtio_pci_stop_ioeventfd(proxy);
-            msix_unuse_all_vectors(&proxy->pci_dev);
-        }
-        else
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
             virtio_queue_set_addr(vdev, vdev->queue_sel, pa);
+        }
         break;
     case VIRTIO_PCI_QUEUE_SEL:
         if (val < VIRTIO_PCI_QUEUE_MAX)
@@ -285,22 +283,16 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         }
         break;
     case VIRTIO_PCI_STATUS:
-        if (vdev->status == 0) {
-            virtio_reset(proxy->vdev);
-        }
-
-        if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
-            virtio_pci_stop_ioeventfd(proxy);
-        }
-
         virtio_set_status(vdev, val & 0xFF);
 
-        if (val & VIRTIO_CONFIG_S_DRIVER_OK) {
-            virtio_pci_start_ioeventfd(proxy);
-        }
-
         if (vdev->status == 0) {
-            msix_unuse_all_vectors(&proxy->pci_dev);
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
+            if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
+                virtio_pci_stop_ioeventfd(proxy);
+            } else {
+                virtio_pci_start_ioeventfd(proxy);
+            }
         }
 
         /* Linux before 2.6.34 sets the device as OK without enabling
Signature · 1 line
1.8.0.2
#19 lore raw

Re: [Qemu-devel] [PATCH 13/15] virtio-pci: reset all qbuses too when writing to the status field

Il 17/12/2012 17:48, Michael S. Tsirkin ha scritto:

Quoted 8 lines · Paolo Bonzini
Quoted 7 lines

virtio-pci devices do not perform a full reset when zero is written to the status byte. While PCI-specific status is initialized, the reset does not propagate down the qdev bus hierarchy. Because of this, a virtio reset does not cancel in-flight I/O for virtio-scsi (where the cancellation is handled automatically by the SCSI devices underneath virtio-scsi-pci).

Quoted 8 lines
Quoted 3 lines

I would still prefer this logic to reside in virtio.c instead of being duplicated in each bus.
My idea was to simply call qdev_reset_all on the binding from virtio.c but other ideas wellcome.

I think you're confusing "in the common superclass of all virtio transports" vs "in the common superclass of all virtio devices". virtio.c only implements a common superclass of all virtio devices; in fact, there is no common superclass of all virtio transports, and it is not possible without multiple inheritance or stuff like traits (you're already inheriting from PCIDevice for virtio-*-pci).

Such common superclass, if it existed, would abstract stuff like "write zero to the status register" and would call qdev_reset_all. But again, we don't have this concept.

Paolo

Quoted 59 lines
Quoted 59 lines

---
 hw/virtio-pci.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)
hw/virtio-pci.c +10 -18
index a7c75fe..2cf5282 100644
@@ -268,12 +268,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case VIRTIO_PCI_QUEUE_PFN:
         pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
         if (pa == 0) {
-            virtio_reset(proxy->vdev);
-            virtio_pci_stop_ioeventfd(proxy);
-            msix_unuse_all_vectors(&proxy->pci_dev);
-        }
-        else
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
             virtio_queue_set_addr(vdev, vdev->queue_sel, pa);
+        }
         break;
     case VIRTIO_PCI_QUEUE_SEL:
         if (val < VIRTIO_PCI_QUEUE_MAX)
@@ -285,22 +283,16 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         }
         break;
     case VIRTIO_PCI_STATUS:
-        if (vdev->status == 0) {
-            virtio_reset(proxy->vdev);
-        }
-
-        if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
-            virtio_pci_stop_ioeventfd(proxy);
-        }
-
         virtio_set_status(vdev, val & 0xFF);
 
-        if (val & VIRTIO_CONFIG_S_DRIVER_OK) {
-            virtio_pci_start_ioeventfd(proxy);
-        }
-
         if (vdev->status == 0) {
-            msix_unuse_all_vectors(&proxy->pci_dev);
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
+            if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
+                virtio_pci_stop_ioeventfd(proxy);
+            } else {
+                virtio_pci_start_ioeventfd(proxy);
+            }
         }
 
         /* Linux before 2.6.34 sets the device as OK without enabling
Signature · 1 line
1.8.0.2
#20 lore raw

Re: [Qemu-devel] [PATCH 13/15] virtio-pci: reset all qbuses too when writing to the status field

Quoted 25 lines · Paolo Bonzini

Il 17/12/2012 17:48, Michael S. Tsirkin ha scritto:

Quoted 8 lines · Paolo Bonzini
Quoted 7 lines

virtio-pci devices do not perform a full reset when zero is written to the status byte. While PCI-specific status is initialized, the reset does not propagate down the qdev bus hierarchy. Because of this, a virtio reset does not cancel in-flight I/O for virtio-scsi (where the cancellation is handled automatically by the SCSI devices underneath virtio-scsi-pci).

Quoted 8 lines
Quoted 3 lines

I would still prefer this logic to reside in virtio.c instead of being duplicated in each bus.
My idea was to simply call qdev_reset_all on the binding from virtio.c but other ideas wellcome.

I think you're confusing "in the common superclass of all virtio transports" vs "in the common superclass of all virtio devices". virtio.c only implements a common superclass of all virtio devices; in fact, there is no common superclass of all virtio transports, and it is not possible without multiple inheritance or stuff like traits (you're already inheriting from PCIDevice for virtio-*-pci).

Quoted 5 lines

Such common superclass, if it existed, would abstract stuff like "write zero to the status register" and would call qdev_reset_all. But again, we don't have this concept.

Paolo

There's some misunderstanding here.

This is not about classes and stuff.

Common code should be in a single place so everyone can reuse it through function calls, not duplicated in all transports.
And yes we do have examples of this if you are asking for examples; examples are functions like virtio_reset, virtio_set_status, etc.

Quoted 59 lines
Quoted 59 lines
Quoted 59 lines

---
 hw/virtio-pci.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)
hw/virtio-pci.c +10 -18
index a7c75fe..2cf5282 100644
@@ -268,12 +268,10 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case VIRTIO_PCI_QUEUE_PFN:
         pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
         if (pa == 0) {
-            virtio_reset(proxy->vdev);
-            virtio_pci_stop_ioeventfd(proxy);
-            msix_unuse_all_vectors(&proxy->pci_dev);
-        }
-        else
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
             virtio_queue_set_addr(vdev, vdev->queue_sel, pa);
+        }
         break;
     case VIRTIO_PCI_QUEUE_SEL:
         if (val < VIRTIO_PCI_QUEUE_MAX)
@@ -285,22 +283,16 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
         }
         break;
     case VIRTIO_PCI_STATUS:
-        if (vdev->status == 0) {
-            virtio_reset(proxy->vdev);
-        }
-
-        if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
-            virtio_pci_stop_ioeventfd(proxy);
-        }
-
         virtio_set_status(vdev, val & 0xFF);
 
-        if (val & VIRTIO_CONFIG_S_DRIVER_OK) {
-            virtio_pci_start_ioeventfd(proxy);
-        }
-
         if (vdev->status == 0) {
-            msix_unuse_all_vectors(&proxy->pci_dev);
+            qdev_reset_all(&proxy->pci_dev.qdev);
+        } else {
+            if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
+                virtio_pci_stop_ioeventfd(proxy);
+            } else {
+                virtio_pci_start_ioeventfd(proxy);
+            }
         }
 
         /* Linux before 2.6.34 sets the device as OK without enabling
Signature · 1 line
1.8.0.2
#21 lore raw

Re: [Qemu-devel] [PATCH 13/15] virtio-pci: reset all qbuses too when writing to the status field

Il 17/12/2012 18:08, Michael S. Tsirkin ha scritto:

Quoted 16 lines
Quoted 12 lines
Quoted 4 lines

I would still prefer this logic to reside in virtio.c instead of being duplicated in each bus.
My idea was to simply call qdev_reset_all on the binding from virtio.c but other ideas wellcome.

I think you're confusing "in the common superclass of all virtio transports" vs "in the common superclass of all virtio devices". virtio.c only implements a common superclass of all virtio devices; in fact, there is no common superclass of all virtio transports, and it is not possible without multiple inheritance or stuff like traits (you're already inheriting from PCIDevice for virtio-*-pci).

Quoted 3 lines

Such common superclass, if it existed, would abstract stuff like "write zero to the status register" and would call qdev_reset_all. But again, we don't have this concept.

Quoted 8 lines

There's some misunderstanding here.

This is not about classes and stuff.

Common code should be in a single place so everyone can reuse it through function calls, not duplicated in all transports.
And yes we do have examples of this if you are asking for examples; examples are functions like virtio_reset, virtio_set_status, etc.

We shouldn't need a virtio_reset at all. It should be invoked automatically by virtue of having a correct, complete description of virtio in terms of qdev buses.

In other words, qdev_reset_all _is_ the common code you're seeking.

Paolo

#22 lore raw

PATCH 14/15 virtio-s390: reset all qbuses too when writing to the status field

In reply to Paolo Bonzini

virtio-s390 devices do not perform a reset when zero is written to the status byte. Because of this, a virtio reset does not cancel in-flight I/O for virtio-scsi.

Use qdev_reset_all so that the reset correctly propagates down the qdev bus hierarchy.

---
 hw/s390-virtio-bus.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
hw/s390-virtio-bus.c +7 -1
index 34173a7..b8465d1 100644
@@ -309,8 +309,14 @@ void s390_virtio_device_update_status(VirtIOS390Device *dev)
 {
     VirtIODevice *vdev = dev->vdev;
     uint32_t features;
+    unsigned char status;
 
-    virtio_set_status(vdev, ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS));
+    status = ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS);
+    if (status == 0) {
+        qdev_reset_all((DeviceState *)dev);
+    }
+
+    virtio_set_status(vdev, status);
 
     /* Update guest supported feature bitmap */
 
Signature · 1 line
1.8.0.2
#23 lore raw

Re: [Qemu-devel] [PATCH 14/15] virtio-s390: reset all qbuses too when writing to the status field

Quoted 6 lines · Paolo Bonzini

virtio-s390 devices do not perform a reset when zero is written to the status byte. Because of this, a virtio reset does not cancel in-flight I/O for virtio-scsi.

Use qdev_reset_all so that the reset correctly propagates down the qdev bus hierarchy.

Works for me.

Alex

Quoted 32 lines

---
hw/s390-virtio-bus.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
hw/s390-virtio-bus.c +7 -1
index 34173a7..b8465d1 100644
@@ -309,8 +309,14 @@ void s390_virtio_device_update_status(VirtIOS390Device *dev)
 {
    VirtIODevice *vdev = dev->vdev;
    uint32_t features;
+    unsigned char status;
 
-    virtio_set_status(vdev, ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS));
+    status = ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS);
+    if (status == 0) {
+        qdev_reset_all((DeviceState *)dev);
+    }
+
+    virtio_set_status(vdev, status);
 
    /* Update guest supported feature bitmap */
 
Signature · 1 line
1.8.0.2
#24 lore raw

PATCH 15/15 virtio-serial: do not perform bus reset by hand

In reply to Paolo Bonzini

Implement guest_reset as a bus-level reset callback. Then, the qdev and virtio core will call it when needed every time the device is reset or the status field is set to 0.

---
 hw/virtio-serial-bus.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
hw/virtio-serial-bus.c +5 -14
index 155da58..1564482 100644
@@ -532,12 +532,13 @@ static void set_config(VirtIODevice *vdev, const uint8_t *config_data)
     memcpy(&config, config_data, sizeof(config));
 }
 
-static void guest_reset(VirtIOSerial *vser)
+static int virtser_bus_reset(BusState *qbus)
 {
+    VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qbus);
     VirtIOSerialPort *port;
     VirtIOSerialPortClass *vsc;
 
-    QTAILQ_FOREACH(port, &vser->ports, next) {
+    QTAILQ_FOREACH(port, &bus->vser->ports, next) {
         vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
         if (port->guest_connected) {
             port->guest_connected = false;
@@ -546,6 +547,7 @@ static void guest_reset(VirtIOSerial *vser)
                 vsc->guest_close(port);
         }
     }
+    return 0;
 }
 
 static void set_status(VirtIODevice *vdev, uint8_t status)
@@ -566,17 +568,6 @@ static void set_status(VirtIODevice *vdev, uint8_t status)
          */
         port->guest_connected = true;
     }
-    if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
-        guest_reset(vser);
-    }
-}
-
-static void vser_reset(VirtIODevice *vdev)
-{
-    VirtIOSerial *vser;
-
-    vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
-    guest_reset(vser);
 }
 
 static void virtio_serial_save(QEMUFile *f, void *opaque)
@@ -766,6 +757,7 @@ static void virtser_bus_class_init(ObjectClass *klass, void *data)
 {
     BusClass *k = BUS_CLASS(klass);
     k->print_dev = virtser_bus_dev_print;
+    k->reset = virtser_bus_reset;
 }
 
 static const TypeInfo virtser_bus_info = {
@@ -985,7 +977,6 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
     vser->vdev.get_config = get_config;
     vser->vdev.set_config = set_config;
     vser->vdev.set_status = set_status;
-    vser->vdev.reset = vser_reset;
 
     vser->qdev = dev;
 
Signature · 1 line
1.8.0.2
#25 lore raw
In reply to Paolo Bonzini
Quoted 5 lines · Paolo Bonzini

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

So just to clarify, what I proposed was this (on top of my type safety patch). Then all transports can call virtio_config_reset when appropriate (e.g. when PA is set to 0).

hw/virtio.c +8 -0
index f40a8c5..e65d7c8 100644
@@ -554,6 +554,14 @@ void virtio_reset(void *opaque)
     }
 }
 
+/* Device-specific reset through virtio config space.
+ * Reset virtio config and backend child devices if any.
+ */
+void virtio_config_reset(VirtIODevice *vdev)
+{
+    qdev_reset_all(vdev->binding_opaque);
+}
+
 uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
 {
     uint8_t val;
hw/virtio.h +1 -0
index 7c17f7b..e2e57a4 100644
@@ -187,11 +187,12 @@ uint16_t virtio_queue_vector(VirtIODevice *vdev, int n);
 void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector);
 void virtio_set_status(VirtIODevice *vdev, uint8_t val);
 void virtio_reset(void *opaque);
+void virtio_config_reset(VirtIODevice *vdev);
 void virtio_update_irq(VirtIODevice *vdev);
 int virtio_set_features(VirtIODevice *vdev, uint32_t val);
 
 void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
                         DeviceState *opaque);
 
 /* Base devices.  */
 typedef struct VirtIOBlkConf VirtIOBlkConf;
#26 lore raw

Il 17/12/2012 22:43, Michael S. Tsirkin ha scritto:

Quoted 19 lines · Paolo Bonzini
Quoted 5 lines

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

So just to clarify, what I proposed was this (on top of my type safety patch). Then all transports can call virtio_config_reset when appropriate (e.g. when PA is set to 0).

hw/virtio.c +0 -0
index f40a8c5..e65d7c8 100644

hw/virtio.c void virtio_reset(void *opaque) · line 563

Quoted 10 lines
hw/virtio.c +7 -0
@@ -554,6 +554,14 @@ void virtio_reset(void *opaque)
     }
 }
 
+/* Device-specific reset through virtio config space.
+ * Reset virtio config and backend child devices if any.
+ */
+void virtio_config_reset(VirtIODevice *vdev)
+{
+    qdev_reset_all(vdev->binding_opaque);
+}

Yes, I had understood. As I said, this is the wrong direction. Resetting happens from vdev->binding_opaque, it can just do qdev_reset_all(myself).

Paolo

Quoted 22 lines
hw/virtio.c +0 -0
 uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
 {
     uint8_t val;
hw/virtio.h +1 -0
index 7c17f7b..e2e57a4 100644
@@ -187,11 +187,12 @@ uint16_t virtio_queue_vector(VirtIODevice *vdev, int n);
 void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector);
 void virtio_set_status(VirtIODevice *vdev, uint8_t val);
 void virtio_reset(void *opaque);
+void virtio_config_reset(VirtIODevice *vdev);
 void virtio_update_irq(VirtIODevice *vdev);
 int virtio_set_features(VirtIODevice *vdev, uint32_t val);
 
 void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
                         DeviceState *opaque);
 
 /* Base devices.  */
 typedef struct VirtIOBlkConf VirtIOBlkConf;
#27 lore raw

Il 18/12/2012 08:27, Paolo Bonzini ha scritto:

Quoted 23 lines

Il 17/12/2012 22:43, Michael S. Tsirkin ha scritto:

Quoted 22 lines · Paolo Bonzini
Quoted 5 lines

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

So just to clarify, what I proposed was this (on top of my type safety patch). Then all transports can call virtio_config_reset when appropriate (e.g. when PA is set to 0).

hw/virtio.c +0 -0
index f40a8c5..e65d7c8 100644
@@ -554,6 +554,14 @@ void virtio_reset(void *opaque)
     }
 }
 
Quoted 11 lines

hw/virtio.c void virtio_reset(void *opaque) · line 563

Quoted 7 lines
hw/virtio.c +7 -0
+/* Device-specific reset through virtio config space.
+ * Reset virtio config and backend child devices if any.
+ */
+void virtio_config_reset(VirtIODevice *vdev)
+{
+    qdev_reset_all(vdev->binding_opaque);
+}

Yes, I had understood. As I said, this is the wrong direction. Resetting happens from vdev->binding_opaque, it can just do qdev_reset_all(myself).

... besides, this only works if the reset callback of vdev->binding_opaque remembers to call virtio_reset (in the s390 bindings, it doesn't and this series fixes it). So IMO it is not only useless, it is also misleading.

Paolo

#28 lore raw
Quoted 35 lines · Paolo Bonzini

Il 18/12/2012 08:27, Paolo Bonzini ha scritto:

Quoted 34 lines

Il 17/12/2012 22:43, Michael S. Tsirkin ha scritto:

Quoted 19 lines · Paolo Bonzini
Quoted 5 lines

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

So just to clarify, what I proposed was this (on top of my type safety patch). Then all transports can call virtio_config_reset when appropriate (e.g. when PA is set to 0).

hw/virtio.c +0 -0
index f40a8c5..e65d7c8 100644

hw/virtio.c void virtio_reset(void *opaque) · line 563

Quoted 10 lines
hw/virtio.c +7 -0
@@ -554,6 +554,14 @@ void virtio_reset(void *opaque)
     }
 }
 
+/* Device-specific reset through virtio config space.
+ * Reset virtio config and backend child devices if any.
+ */
+void virtio_config_reset(VirtIODevice *vdev)
+{
+    qdev_reset_all(vdev->binding_opaque);
+}

Yes, I had understood. As I said, this is the wrong direction. Resetting happens from vdev->binding_opaque, it can just do qdev_reset_all(myself).

It can but it's the wrong thing for transport to know about. Let PCI worry about PCI things. This is not
a transport specific thing so belongs in virtio.c

Quoted 3 lines

... besides, this only works if the reset callback of vdev->binding_opaque remembers to call virtio_reset (in the s390 bindings, it doesn't and this series fixes it).

That's a separate bug I think.

Quoted 4 lines

So IMO it is not only
useless, it is also misleading.

Paolo

#29 lore raw

Il 18/12/2012 10:49, Michael S. Tsirkin ha scritto:

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

hw/virtio.c void virtio_reset(void *opaque) · line 563

Quoted 7 lines
hw/virtio.c +7 -0
+/* Device-specific reset through virtio config space.
+ * Reset virtio config and backend child devices if any.
+ */
+void virtio_config_reset(VirtIODevice *vdev)
+{
+    qdev_reset_all(vdev->binding_opaque);
+}

Yes, I had understood. As I said, this is the wrong direction. Resetting happens from vdev->binding_opaque, it can just do qdev_reset_all(myself).

Quoted 1 line

It can but it's the wrong thing for transport to know about.

The transport provides an implementation of dc->reset, not virtio.c (e.g. virtio_pci_reset). Sure it knows what the effect of qdev_reset_all are on itself.

Quoted 2 lines

Let PCI worry about PCI things. This is not
a transport specific thing so belongs in virtio.c

This _is_ a transport specific thing. Sure it will reset the virtio device (virtio_reset), but it will also reset things such as MSI-X vectors and VIRTIO_PCI_FLAG_BUS_MASTER_BUG. It doesn't belong in virtio.c.

Quoted 5 lines
Quoted 3 lines

... besides, this only works if the reset callback of vdev->binding_opaque remembers to call virtio_reset (in the s390 bindings, it doesn't and this series fixes it).

That's a separate bug I think.

Yes, I agree.

Paolo

#30 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines
Quoted 3 lines

... besides, this only works if the reset callback of vdev->binding_opaque remembers to call virtio_reset (in the s390 bindings, it doesn't and this series fixes it).

That's a separate bug I think.

Yes, I agree.

Paolo

Anyway, I think the only argument is about a bit of code duplication, we can fix it up later.
Andreas Färber pointed out what looks like a buglet in this patchset, were you going to repost a fixed one?

Nacked-by on the v1 series NAK
#31 lore raw
In reply to Paolo Bonzini

Hi,

This is an automated message generated from the QEMU Patches. Thank you for submitting this patch. This patch no longer applies to qemu.git.

This may have occurred due to:

1) Changes in mainline requiring your patch to be rebased and re-tested.

2) Sending the mail using a tool other than git-send-email. Please use git-send-email to send patches to QEMU.

3) Basing this patch off of a branch that isn't tracking the QEMU master branch. If that was done purposefully, please include the name of the tree in the subject line in the future to prevent this message.

For instance: "[PATCH block-next 1/10] qcow3: add fancy new feature"

4) You no longer wish for this patch to be applied to QEMU. No additional action is required on your part.

Below is the output from git-am:

Applying: qdev: do not reset a device until the parent has been initialized
Applying: intel-hda: do not reset codecs from intel_hda_reset
Applying: pci: clean up resetting of IRQs
Using index info to reconstruct a base tree...
A hw/pci.c
Falling back to patching base and 3-way merge...
Auto-merging hw/pci/pci.c
Applying: virtio-pci: reset device before PCI layer
Using index info to reconstruct a base tree...
M hw/virtio-pci.c
Falling back to patching base and 3-way merge...
Auto-merging hw/virtio-pci.c
CONFLICT (content): Merge conflict in hw/virtio-pci.c
Failed to merge in the changes.
Patch failed at 0004 virtio-pci: reset device before PCI layer The copy of the patch that failed is found in:
/home/aliguori/patches/qemu.git/.git/rebase-apply/patch
When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".

#32 lore raw

Sorry for breaking threading... I've fixed that bug.

FWIW, the reason this got notified but other patches haven't is that as of this afternoon, this patch no longer applies but it did apply before my earlier commits. So it's the first patch series to get identified by my scripts.

Regards,

Anthony Liguori

Quoted 45 lines · Anthony Liguori

Hi,

This is an automated message generated from the QEMU Patches. Thank you for submitting this patch. This patch no longer applies to qemu.git.

This may have occurred due to:

1) Changes in mainline requiring your patch to be rebased and re-tested.

2) Sending the mail using a tool other than git-send-email. Please use git-send-email to send patches to QEMU.

3) Basing this patch off of a branch that isn't tracking the QEMU master branch. If that was done purposefully, please include the name of the tree in the subject line in the future to prevent this message.

For instance: "[PATCH block-next 1/10] qcow3: add fancy new feature"

4) You no longer wish for this patch to be applied to QEMU. No additional action is required on your part.

Below is the output from git-am:

Applying: qdev: do not reset a device until the parent has been initialized
Applying: intel-hda: do not reset codecs from intel_hda_reset
Applying: pci: clean up resetting of IRQs
Using index info to reconstruct a base tree...
A hw/pci.c
Falling back to patching base and 3-way merge...
Auto-merging hw/pci/pci.c
Applying: virtio-pci: reset device before PCI layer
Using index info to reconstruct a base tree...
M hw/virtio-pci.c
Falling back to patching base and 3-way merge...
Auto-merging hw/virtio-pci.c
CONFLICT (content): Merge conflict in hw/virtio-pci.c
Failed to merge in the changes.
Patch failed at 0004 virtio-pci: reset device before PCI layer The copy of the patch that failed is found in:
/home/aliguori/patches/qemu.git/.git/rebase-apply/patch
When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".

#33 lore raw
In reply to Paolo Bonzini
Quoted 11 lines · Paolo Bonzini

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

1) device-level reset is the kind of reset that you get with a register write on the device. It will clear interrupts and DMAs among other things, but not any bus-level state, for example it will not clear PCI BARs and other configuration space data. It is done with qdev_reset_all.

Quoted 7 lines

2) bus-level reset is the kind of reset that you get with a register write on the device that exports the bus (including triggering a device-level reset on the device that exports the bus). It will do a device-level reset on the child, but also clear bus-level state such as PCI BARs and other configuration space data. It can be triggered for all devices on a bus with qbus_reset_all. There is still no API for a bus-level reset of a single device (like PCI FLR), this can be added later.

I don't really understand this dual abstraction. I suspect it's overgeneralizing something that's the result of poor modeling.

Very often with PCI devices, you have an otherwise independent chipset embedded on a PCI card There's a clear separate between the chipset and the card.

It may be possible to poke the chipset directly to do a reset and that may only affect state that's on the chipset but not any card-specific state.

But this has nothing to do with busses, this is just about encapsulation. IOW, what you have is:

E1000 is-a PCIDevice
has-a E1000 chipset
PCIDevice::reset()

    -> calls chipset->reset()

But with the right register write, chipset->reset() can be called w/o PCIDevice::reset(). But again, this has nothing to do with busses.

What I'm missing with this series is what problem are we trying to solve? I don't think we model reset correctly today because I don't think there's a single notion of reset.

I think reset really ought to just be a bus level concept with individual implementations for each bus.

Regards,

Anthony Liguori

Quoted 42 lines

Patches 1-5 are miscellaneous fixes to the reset paths.

Patches 6-8 introduce qbus_reset_all and uses it.

Patches 9-12 switch qdev_reset_all and qbus_reset_all from pre-order to post-order, and document the resulting semantics.

Finally, patches 13-15 adjust the virtio implementations to use qdev device-level reset more extensively.

Paolo Bonzini (15):
qdev: do not reset a device until the parent has been initialized
intel-hda: do not reset codecs from intel_hda_reset
pci: clean up resetting of IRQs
virtio-pci: reset device before PCI layer
virtio-s390: add a reset function to virtio-s390 devices
qdev: add qbus_reset_all
pci: do not export pci_bus_reset
lsi: use qbus_reset_all to reset SCSI bus
qdev: allow both pre- and post-order vists in qdev walking functions
qdev: switch reset to post-order
qdev: remove device_reset
qdev: document reset semantics
virtio-pci: reset all qbuses too when writing to the status field
virtio-s390: reset all qbuses too when writing to the status field
virtio-serial: do not perform bus reset by hand

 hw/intel-hda.c         |  1 -
 hw/lsi53c895a.c        |  7 +----
 hw/pci.c               | 16 ++++------
 hw/pci.h               |  1 -
 hw/pci_bridge.c        |  2 +-
 hw/qdev-core.h         | 83 ++++++++++++++++++++++++++++++++++++++++++--------
 hw/qdev.c              | 70 +++++++++++++++++++++++++++---------------
 hw/s390-virtio-bus.c   | 16 +++++++++-
 hw/virtio-pci.c        | 27 +++++++---------
 hw/virtio-serial-bus.c | 19 +++---------
 10 files changed, 156 insertions(+), 86 deletions(-)
Signature · 1 line
1.8.0.2
#34 lore raw
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Paolo Bonzini

1) device-level reset is the kind of reset that you get with a register write on the device. It will clear interrupts and DMAs among other things, but not any bus-level state, for example it will not clear PCI BARs and other configuration space data. It is done with qdev_reset_all.

This isn't really right -- often writing the register on the device will reset some things but not the whole device state the way a qdev reset does. qdev reset (to the extent it's modelling anything) is more like yanking power to the device and reapplying it.

Quoted 7 lines
Quoted 7 lines

2) bus-level reset is the kind of reset that you get with a register write on the device that exports the bus (including triggering a device-level reset on the device that exports the bus). It will do a device-level reset on the child, but also clear bus-level state such as PCI BARs and other configuration space data. It can be triggered for all devices on a bus with qbus_reset_all. There is still no API for a bus-level reset of a single device (like PCI FLR), this can be added later.

This doesn't sound very plausible: when would you do a bus level reset anyway?

Quoted 2 lines

I don't really understand this dual abstraction. I suspect it's overgeneralizing something that's the result of poor modeling.

Agreed.

Quoted 3 lines

What I'm missing with this series is what problem are we trying to solve? I don't think we model reset correctly today because I don't think there's a single notion of reset.

Also agreed.

Quoted 2 lines

I think reset really ought to just be a bus level concept with individual implementations for each bus.

I'm not sure I really agree here, especially since QOM/qdev are moving away from the idea that there is a single bus tree and every device is on a single bus. It's quite common for a bus to include a reset signal but not all device reset is handled by a signal on a bus.

If we want to model reset properly we should model actual reset lines (and/or power-cycling). If we don't care we can continue with whatever fudge we like :-)

-- PMM

#35 lore raw
Quoted 32 lines · Peter Maydell
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Paolo Bonzini

1) device-level reset is the kind of reset that you get with a register write on the device. It will clear interrupts and DMAs among other things, but not any bus-level state, for example it will not clear PCI BARs and other configuration space data. It is done with qdev_reset_all.

This isn't really right -- often writing the register on the device will reset some things but not the whole device state the way a qdev reset does. qdev reset (to the extent it's modelling anything) is more like yanking power to the device and reapplying it.

Quoted 7 lines
Quoted 7 lines

2) bus-level reset is the kind of reset that you get with a register write on the device that exports the bus (including triggering a device-level reset on the device that exports the bus). It will do a device-level reset on the child, but also clear bus-level state such as PCI BARs and other configuration space data. It can be triggered for all devices on a bus with qbus_reset_all. There is still no API for a bus-level reset of a single device (like PCI FLR), this can be added later.

This doesn't sound very plausible: when would you do a bus level reset anyway?

Quoted 2 lines

I don't really understand this dual abstraction. I suspect it's overgeneralizing something that's the result of poor modeling.

Agreed.

Quoted 3 lines

What I'm missing with this series is what problem are we trying to solve? I don't think we model reset correctly today because I don't think there's a single notion of reset.

Quoted 8 lines

Also agreed.

Quoted 2 lines

I think reset really ought to just be a bus level concept with individual implementations for each bus.

I'm not sure I really agree here, especially since QOM/qdev are moving away from the idea that there is a single bus tree and every device is on a single bus.

I don't mean a BusState level concept, I mean a PCIBus concept.

There is clearly such a thing as a PCI bus reset. In fact, there are multiple types of PCI bus resets. There should be a PCIBus method that calls out to PCIDevices on the bus.

But that isn't something that should be fitted into generalized to a BusState::reset method.

Quoted 2 lines

It's quite common for a bus to include a
reset signal but not all device reset is handled by a signal on a bus.

Agreed.

Quoted 4 lines

If we want to model reset properly we should model actual reset lines (and/or power-cycling). If we don't care we can continue with whatever fudge we like :-)

Yes, and that's basically what qemu_system_reset() is. Of course, we model it like everything is directly connected to a single power source which is true 99% of the time. That's why we've gotten away with it for so long.

Regards,

Anthony Liguori

Quoted 1 line

-- PMM

#36 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Peter Maydell
Quoted 2 lines · Anthony Liguori

I think reset really ought to just be a bus level concept with individual implementations for each bus.

I'm not sure I really agree here, especially since QOM/qdev are moving away from the idea that there is a single bus tree and every device is on a single bus.

Quoted 8 lines

I don't mean a BusState level concept, I mean a PCIBus concept.

There is clearly such a thing as a PCI bus reset. In fact, there are multiple types of PCI bus resets. There should be a PCIBus method that calls out to PCIDevices on the bus.

But that isn't something that should be fitted into generalized to a BusState::reset method.

Ah, I see what you mean now -- yes, definitely.

Quoted 8 lines
Quoted 3 lines

If we want to model reset properly we should model actual reset lines (and/or power-cycling). If we don't care we can continue with whatever fudge we like :-)

Yes, and that's basically what qemu_system_reset() is. Of course, we model it like everything is directly connected to a single power source which is true 99% of the time. That's why we've gotten away with it for so long.

I think the bit that's most creaky here is what you do about devices that want to assert outgoing irq/whatever lines immediately on powerup.

-- PMM

#37 lore raw
Quoted 25 lines · Peter Maydell
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Peter Maydell
Quoted 2 lines · Anthony Liguori

I think reset really ought to just be a bus level concept with individual implementations for each bus.

I'm not sure I really agree here, especially since QOM/qdev are moving away from the idea that there is a single bus tree and every device is on a single bus.

Quoted 8 lines

I don't mean a BusState level concept, I mean a PCIBus concept.

There is clearly such a thing as a PCI bus reset. In fact, there are multiple types of PCI bus resets. There should be a PCIBus method that calls out to PCIDevices on the bus.

But that isn't something that should be fitted into generalized to a BusState::reset method.

Ah, I see what you mean now -- yes, definitely.

Quoted 4 lines
Quoted 3 lines

If we want to model reset properly we should model actual reset lines (and/or power-cycling). If we don't care we can continue with whatever fudge we like :-)

Quoted 8 lines
Quoted 4 lines

Yes, and that's basically what qemu_system_reset() is. Of course, we model it like everything is directly connected to a single power source which is true 99% of the time. That's why we've gotten away with it for so long.

I think the bit that's most creaky here is what you do about devices that want to assert outgoing irq/whatever lines immediately on powerup.

This isn't so much a reset problem as a consequence of stateless IRQ lines. If IRQ lines were stateful, this problem wouldn't exist.

And yes, I will post Pins one day...

Regards,

Anthony Liguori

Quoted 2 lines

-- PMM

#38 lore raw
In reply to Anthony Liguori

Il 07/01/2013 20:10, Anthony Liguori ha scritto:

Quoted 21 lines
Quoted 11 lines · Paolo Bonzini

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

1) device-level reset is the kind of reset that you get with a register write on the device. It will clear interrupts and DMAs among other things, but not any bus-level state, for example it will not clear PCI BARs and other configuration space data. It is done with qdev_reset_all.

Quoted 7 lines

2) bus-level reset is the kind of reset that you get with a register write on the device that exports the bus (including triggering a device-level reset on the device that exports the bus). It will do a device-level reset on the child, but also clear bus-level state such as PCI BARs and other configuration space data. It can be triggered for all devices on a bus with qbus_reset_all. There is still no API for a bus-level reset of a single device (like PCI FLR), this can be added later.

Quoted 2 lines

I don't really understand this dual abstraction. I suspect it's overgeneralizing something that's the result of poor modeling.

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

Paolo

#39 lore raw
Quoted 22 lines · Paolo Bonzini

Il 07/01/2013 20:10, Anthony Liguori ha scritto:

Quoted 21 lines
Quoted 18 lines · Paolo Bonzini

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

After this series, there are two kinds of resets:

1) device-level reset is the kind of reset that you get with a register write on the device. It will clear interrupts and DMAs among other things, but not any bus-level state, for example it will not clear PCI BARs and other configuration space data. It is done with qdev_reset_all.

2) bus-level reset is the kind of reset that you get with a register write on the device that exports the bus (including triggering a device-level reset on the device that exports the bus). It will do a device-level reset on the child, but also clear bus-level state such as PCI BARs and other configuration space data. It can be triggered for all devices on a bus with qbus_reset_all. There is still no API for a bus-level reset of a single device (like PCI FLR), this can be added later.

Quoted 8 lines
Quoted 2 lines

I don't really understand this dual abstraction. I suspect it's overgeneralizing something that's the result of poor modeling.

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

Paolo

I'm not sure what would you like to change with PCIDevice.

Signature · 1 line
MST
#40 lore raw

Il 09/01/2013 11:22, Michael S. Tsirkin ha scritto:

Quoted 5 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

I'm not sure what would you like to change with PCIDevice.

Replace the DeviceState reset method with one in PCIDevice, and call it from the PCI bus reset.

Paolo

#41 lore raw
Quoted 11 lines · Paolo Bonzini

Il 09/01/2013 11:22, Michael S. Tsirkin ha scritto:

Quoted 5 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

I'm not sure what would you like to change with PCIDevice.

Replace the DeviceState reset method with one in PCIDevice, and call it from the PCI bus reset.

Paolo

You are talking about the call to qdev_reset_all(&dev->qdev)
in pci_device_reset, and you want to detect, there, that device is a bridge and replace qdev_reset_all(&dev->qdev) with cast and call to pci_bus_reset for the secondary bus?

Signature · 1 line
MST
#42 lore raw

Il 09/01/2013 12:09, Michael S. Tsirkin ha scritto:

Quoted 8 lines · Paolo Bonzini
Quoted 7 lines

Il 09/01/2013 11:22, Michael S. Tsirkin ha scritto:

Quoted 5 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

I'm not sure what would you like to change with PCIDevice.

Quoted 7 lines
Quoted 4 lines

Replace the DeviceState reset method with one in PCIDevice, and call it from the PCI bus reset.

Paolo

You are talking about the call to qdev_reset_all(&dev->qdev) in pci_device_reset

Yes.

Quoted 3 lines

, and you want to detect, there, that device is a bridge
and replace qdev_reset_all(&dev->qdev) with cast and call to pci_bus_reset for the secondary bus?

The bridge would call pci_bus_reset for its secondary bus in the PCIDevice reset method.

I.e. all bus navigation would have to be explicit in the reset callbacks. I'm going to do that for the SCSI HBAs.

Paolo

#43 lore raw
Quoted 23 lines · Paolo Bonzini

Il 09/01/2013 12:09, Michael S. Tsirkin ha scritto:

Quoted 8 lines · Paolo Bonzini
Quoted 7 lines

Il 09/01/2013 11:22, Michael S. Tsirkin ha scritto:

Quoted 5 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

I'm not sure what would you like to change with PCIDevice.

Quoted 7 lines
Quoted 4 lines

Replace the DeviceState reset method with one in PCIDevice, and call it from the PCI bus reset.

Paolo

You are talking about the call to qdev_reset_all(&dev->qdev) in pci_device_reset

Yes.

Quoted 3 lines

, and you want to detect, there, that device is a bridge
and replace qdev_reset_all(&dev->qdev) with cast and call to pci_bus_reset for the secondary bus?

Quoted 7 lines

The bridge would call pci_bus_reset for its secondary bus in the PCIDevice reset method.

I.e. all bus navigation would have to be explicit in the reset callbacks. I'm going to do that for the SCSI HBAs.

Paolo

OK you mean like this this? Completely untested - if you and Anthony think we need this change please let me know and I'll test and repost.

-->

pci: make secondary bus reset explicit

---

hw/pci/pci.c +1 -1
index 94840c4..ad81040 100644
@@ -172,7 +172,7 @@ void pci_device_reset(PCIDevice *dev)
 {
     int r;
 
-    qdev_reset_all(&dev->qdev);
+    device_reset(&dev->qdev);
 
     dev->irq_state = 0;
     pci_update_irq_status(dev);
hw/pci/pci_bridge.c +5 -1
index 995842a..a08b479 100644
@@ -258,10 +258,12 @@ void pci_bridge_disable_base_limit(PCIDevice *dev)
     pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0);
 }
 
-/* reset bridge specific configuration registers */
+/* reset bridge specific configuration registers.
+ * Propagate reset on the secondary bus. */
 void pci_bridge_reset(DeviceState *qdev)
 {
     PCIDevice *dev = PCI_DEVICE(qdev);
+    PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
     uint8_t *conf = dev->config;
 
     conf[PCI_PRIMARY_BUS] = 0;
@@ -295,6 +297,8 @@ void pci_bridge_reset(DeviceState *qdev)
     pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0);
 
     pci_set_word(conf + PCI_BRIDGE_CONTROL, 0);
+
+    pci_bus_reset(&br->sec_bus);
 }
 
 /* default qdev initialization function for PCI-to-PCI bridge */
#44 lore raw

Il 09/01/2013 13:10, Michael S. Tsirkin ha scritto:

Quoted 9 lines

OK you mean like this this? Completely untested - if you and Anthony think we need this change please let me know and I'll test and repost.

-->

pci: make secondary bus reset explicit

Yes, but this can only be done after looking at all PCI devices that have buses below (of which the bridge is a special case). And Anthony also metioned using a new method of PCIDevice instead of device_reset.

Paolo

#45 lore raw
Quoted 7 lines · Paolo Bonzini

Il 09/01/2013 13:10, Michael S. Tsirkin ha scritto:

Quoted 6 lines

OK you mean like this this? Completely untested - if you and Anthony think we need this change please let me know and I'll test and repost.

-->

Quoted 7 lines
Quoted 3 lines

pci: make secondary bus reset explicit

Yes, but this can only be done after looking at all PCI devices that have buses below (of which the bridge is a special case). And Anthony also metioned using a new method of PCIDevice instead of device_reset.

Sorry, what's the bug here? Is this a reset bug with cold reset or with a form of warm reset?

Regards,

Anthony Liguori

Quoted 2 lines

Paolo

#46 lore raw

Il 09/01/2013 21:40, Anthony Liguori ha scritto:

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Yes, but this can only be done after looking at all PCI devices that have buses below (of which the bridge is a special case). And Anthony also metioned using a new method of PCIDevice instead of device_reset.

Sorry, what's the bug here? Is this a reset bug with cold reset or with a form of warm reset?

Warm reset (virtio status register reset) of virtio-scsi wasn't propagated down to the SCSI bus. I fixed it using qdev_reset_all, but now I'll do it manually in the HBA. I'm fine with that as long as all buses move away from device_reset.

Paolo

#47 lore raw
Quoted 7 lines · Paolo Bonzini

Il 09/01/2013 21:40, Anthony Liguori ha scritto:

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Yes, but this can only be done after looking at all PCI devices that have buses below (of which the bridge is a special case). And Anthony also metioned using a new method of PCIDevice instead of device_reset.

Sorry, what's the bug here? Is this a reset bug with cold reset or with a form of warm reset?

Quoted 6 lines

Warm reset (virtio status register reset) of virtio-scsi wasn't propagated down to the SCSI bus. I fixed it using qdev_reset_all, but now I'll do it manually in the HBA. I'm fine with that as long as all buses move away from device_reset.

Paolo

You also pointed out some bug related to status register handling in virtio on s390, right?

Signature · 1 line
MST
#48 lore raw

Il 09/01/2013 22:40, Michael S. Tsirkin ha scritto:

Quoted 7 lines
Quoted 4 lines

Warm reset (virtio status register reset) of virtio-scsi wasn't propagated down to the SCSI bus. I fixed it using qdev_reset_all, but now I'll do it manually in the HBA. I'm fine with that as long as all buses move away from device_reset.

You also pointed out some bug related to status register handling in virtio on s390, right?

Yes, that would be a separate patch. A large part of this series can also be kept.

Paolo

#49 lore raw
Quoted 6 lines · Paolo Bonzini

Il 09/01/2013 22:40, Michael S. Tsirkin ha scritto:

Quoted 5 lines
Quoted 4 lines

Warm reset (virtio status register reset) of virtio-scsi wasn't propagated down to the SCSI bus. I fixed it using qdev_reset_all, but now I'll do it manually in the HBA. I'm fine with that as long as all buses move away from device_reset.

Quoted 7 lines
Quoted 2 lines

You also pointed out some bug related to status register handling in virtio on s390, right?

Yes, that would be a separate patch. A large part of this series can also be kept.

Paolo

Let's start with bugfixes, no need to bundle them in a series.

#50 lore raw
In reply to Paolo Bonzini
Quoted 3 lines · Paolo Bonzini

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

-- PMM

#51 lore raw

Il 10/01/2013 12:46, Peter Maydell ha scritto:

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

Yes, exactly.

Paolo

#52 lore raw
Quoted 7 lines · Paolo Bonzini

Il 10/01/2013 12:46, Peter Maydell ha scritto:

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

So how should it work instead? I kind of feel like all qdev devices should get their reset hook called on machine reset, regardless of bus [since it's modelling power cycling the whole system], but would that break something?

-- PMM

#53 lore raw

Il 10/01/2013 12:59, Peter Maydell ha scritto:

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

So how should it work instead? I kind of feel like all qdev devices should get their reset hook called on machine reset, regardless of bus [since it's modelling power cycling the whole system], but would that break something?

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

Paolo

#54 lore raw
Quoted 12 lines · Paolo Bonzini

Il 10/01/2013 12:59, Peter Maydell ha scritto:

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

So how should it work instead? I kind of feel like all qdev devices should get their reset hook called on machine reset, regardless of bus [since it's modelling power cycling the whole system], but would that break something?

Quoted 5 lines

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

But machine reset shouldn't call bus specific PCI or SCSI reset methods -- we've just effectively yanked the power to the VM so everything should just reset as if it was freshly constructed.

A bus-specific reset method would be for buses where the bus itself has some sort of guest-triggerable reset (by prodding the chipset, for instance).

Quoted 2 lines

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

*Something* has to say "call reset for every qdev object in the system", surely?

-- PMM

#55 lore raw

Il 10/01/2013 13:31, Peter Maydell ha scritto:

Quoted 19 lines · Paolo Bonzini
Quoted 12 lines

Il 10/01/2013 12:59, Peter Maydell ha scritto:

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

So how should it work instead? I kind of feel like all qdev devices should get their reset hook called on machine reset, regardless of bus [since it's modelling power cycling the whole system], but would that break something?

Quoted 5 lines

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

Quoted 3 lines

But machine reset shouldn't call bus specific PCI or SCSI reset methods -- we've just effectively yanked the power to the VM so everything should just reset as if it was freshly constructed.

Yes, but we do not have a way to do that, so QEMU resorts to a warm reset.

Quoted 3 lines

A bus-specific reset method would be for buses where the bus itself has some sort of guest-triggerable reset (by prodding the chipset, for instance).

Yes.

Quoted 5 lines
Quoted 2 lines

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

*Something* has to say "call reset for every qdev object in the system", surely?

It will call it on sysbus, which will call it on every sysbus child. Devices that have a child bus will propagate it further down.

Paolo

#56 lore raw
Quoted 8 lines · Paolo Bonzini

Il 10/01/2013 13:31, Peter Maydell ha scritto:

Quoted 7 lines · Paolo Bonzini
Quoted 5 lines

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

Quoted 5 lines
Quoted 3 lines

But machine reset shouldn't call bus specific PCI or SCSI reset methods -- we've just effectively yanked the power to the VM so everything should just reset as if it was freshly constructed.

Yes, but we do not have a way to do that, so QEMU resorts to a warm reset.

qdev reset is cold reset, not warm reset.

Quoted 6 lines
Quoted 3 lines

A bus-specific reset method would be for buses where the bus itself has some sort of guest-triggerable reset (by prodding the chipset, for instance).

Yes.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

*Something* has to say "call reset for every qdev object in the system", surely?

It will call it on sysbus, which will call it on every sysbus child. Devices that have a child bus will propagate it further down.

This doesn't work when we get rid of the idea that every qdev device is attached to a tree of buses.

(At this point in the conversation I'm pretty confused about exactly what we're trying to do :-))

-- PMM

#57 lore raw

Il 10/01/2013 14:01, Peter Maydell ha scritto:

Quoted 9 lines · Paolo Bonzini
Quoted 8 lines

Il 10/01/2013 13:31, Peter Maydell ha scritto:

Quoted 7 lines · Paolo Bonzini
Quoted 5 lines

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

But machine reset shouldn't call bus specific PCI or SCSI reset methods -- we've just effectively yanked the power to the VM so everything should just reset as if it was freshly constructed.

Yes, but we do not have a way to do that, so QEMU resorts to a warm reset.

qdev reset is cold reset, not warm reset.

Whatever. :) It resorts to a reset (as if it was freshly constructed) instead of _really_ doing a fresh construction.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

A bus-specific reset method would be for buses where the bus itself has some sort of guest-triggerable reset (by prodding the chipset, for instance).

Yes.

Quoted 3 lines
Quoted 2 lines

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

*Something* has to say "call reset for every qdev object in the system", surely?

It will call it on sysbus, which will call it on every sysbus child. Devices that have a child bus will propagate it further down.

This doesn't work when we get rid of the idea that every qdev device is attached to a tree of buses.

At least for now, devices that should be bus-free are sysbus devices, aren't they?

Paolo

#58 lore raw
In reply to Peter Maydell
Quoted 19 lines · Peter Maydell
Quoted 12 lines · Paolo Bonzini

Il 10/01/2013 12:59, Peter Maydell ha scritto:

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

So how should it work instead? I kind of feel like all qdev devices should get their reset hook called on machine reset, regardless of bus [since it's modelling power cycling the whole system], but would that break something?

Quoted 5 lines

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

Quoted 7 lines

But machine reset shouldn't call bus specific PCI or SCSI reset methods -- we've just effectively yanked the power to the VM so everything should just reset as if it was freshly constructed.

A bus-specific reset method would be for buses where the bus itself has some sort of guest-triggerable reset (by prodding the chipset, for instance).

The challenge is how we go from what we have to what we want.

Right now we have DeviceState::reset. This is used both as a soft and hard reset.

What I would propose is that we:

s/DeviceState::reset/DeviceState::hard_reset/g

Then introduce PCIDevice::soft_reset. We can convert the PCI layer to call soft_reset() instead of hard_reset.

Over time, it would be great if we could find a way to implement hard_reset in terms of device destruction/recreation but we're not there yet.

I think the reset/hard_reset rename can be done via sed mostly.

Would this solve the bug that you're trying to fix Michael/Paolo?

Regards,

Anthony Liguori

Quoted 7 lines
Quoted 2 lines

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

*Something* has to say "call reset for every qdev object in the system", surely?

-- PMM

#59 lore raw

Il 10/01/2013 15:14, Anthony Liguori ha scritto:

Quoted 7 lines

What I would propose is that we:

s/DeviceState::reset/DeviceState::hard_reset/g

Then introduce PCIDevice::soft_reset. We can convert the PCI layer to call soft_reset() instead of hard_reset.

Quoted 7 lines

Over time, it would be great if we could find a way to implement hard_reset in terms of device destruction/recreation but we're not there yet.

I think the reset/hard_reset rename can be done via sed mostly.

Would this solve the bug that you're trying to fix Michael/Paolo?

I can fix the bug easily just in virtio-scsi. I don't want anywone to trip on it again due to false expectations about reset, though.

Paolo

#60 lore raw
In reply to Anthony Liguori
Quoted 45 lines · Anthony Liguori
Quoted 19 lines · Peter Maydell
Quoted 12 lines · Paolo Bonzini

Il 10/01/2013 12:59, Peter Maydell ha scritto:

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

It's possible. I'll move the SCSI bus away from qdev reset. Anthony/Michael, can you help doing the same with PCIDevice? And perhaps Peter and Andreas with sysbus?

What does it even mean to reset a sysbus? Do we do it anywhere? (it looks like vl.c does, just as a shortcut so memory mapped devices get their reset hooks called?)

So how should it work instead? I kind of feel like all qdev devices should get their reset hook called on machine reset, regardless of bus [since it's modelling power cycling the whole system], but would that break something?

Quoted 5 lines

It's just an implementation detail. Right now we have a common callback. The idea is to give each bus its own callback. In the case of sysbus it would just call a method; for PCI it would reset some configuration and then call a method; for SCSI there is no need to call a method at all; and so on.

Quoted 7 lines

But machine reset shouldn't call bus specific PCI or SCSI reset methods -- we've just effectively yanked the power to the VM so everything should just reset as if it was freshly constructed.

A bus-specific reset method would be for buses where the bus itself has some sort of guest-triggerable reset (by prodding the chipset, for instance).

The challenge is how we go from what we have to what we want.

Right now we have DeviceState::reset. This is used both as a soft and hard reset.

What I would propose is that we:

s/DeviceState::reset/DeviceState::hard_reset/g

Then introduce PCIDevice::soft_reset. We can convert the PCI layer to call soft_reset() instead of hard_reset.

Over time, it would be great if we could find a way to implement hard_reset in terms of device destruction/recreation but we're not there yet.

Quoted 7 lines

I think the reset/hard_reset rename can be done via sed mostly.

Would this solve the bug that you're trying to fix Michael/Paolo?

Regards,

Anthony Liguori

I don't think we need a rename to fix a specific bug. The bugs Paolo found can be fixed in virtio and virtio-scsi.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

In addition, navigating the qdev tree should be explicit in the methods.
It will not happen anymore via the "magic" qdev_reset_all.

*Something* has to say "call reset for every qdev object in the system", surely?

-- PMM

#61 lore raw
In reply to Paolo Bonzini
Quoted 3 lines · Paolo Bonzini

After discussion with mst on the topic of resetting virtio devices, here is a series that hopefully clarifies the semantics of bus and device resets.

what started all this is a bug that affects virtio scsi. Since there's still a lot of argument about reworking reset, how about we fix the bug first, and attempt to rework reset on top?
Will help stable etc as well.

Signature · 1 line
MST