Skip to contentSkip to conversation

s390x: diag288 reset fix

PATCH New Cornelia Huck 6 participants 18 messages Jul 7, 2015 – Jul 14, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: diag288 reset fix

One more fix for s390x: The newly introduced diag288 watchdog driver is not on the sysbus but bus-less (as feedback suggested). Unfortunately, this also means we need to wire up any resets by hand.

Xu Wang (1):
watchdog/diag288: correctly register for system reset requests

 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
Signature · 1 line
2.4.5
#1 lore raw

PATCH 1/1 watchdog/diag288: correctly register for system reset requests

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

---
 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +5 -1
index 3d20d6a..4c51d1a 100644
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
hw/watchdog/wdt_diag288.c +8 -0
index 1185e06..2a885a4 100644
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
+    qemu_register_reset(diag288_reset, diag288);
     diag288->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, diag288_timer_expired,
                                   dev);
 }
Signature · 1 line
2.4.5
Tested-by on v1 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Am 07.07.2015 um 10:53 schrieb Cornelia Huck:

Quoted 5 lines

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Quoted 7 lines

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

kdump/kexec and reboot disable the watchdog.

Quoted 56 lines
---
 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +5 -1
index 3d20d6a..4c51d1a 100644
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
hw/watchdog/wdt_diag288.c +8 -0
index 1185e06..2a885a4 100644
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
+    qemu_register_reset(diag288_reset, diag288);
     diag288->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, diag288_timer_expired,
                                   dev);
 }
#3 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

In reply to Cornelia Huck
Quoted 60 lines · Cornelia Huck

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

---
 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +5 -1
index 3d20d6a..4c51d1a 100644
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
hw/watchdog/wdt_diag288.c +7 -0
index 1185e06..2a885a4 100644
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 4 lines
hw/watchdog/wdt_diag288.c +1 -0
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

I.E. What string do you get with an object_get_canonical_path() of the obj after machine init?

Regards,
Peter

Quoted 7 lines
hw/watchdog/wdt_diag288.c +0 -1
     diag288->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, diag288_timer_expired,
                                   dev);
 }
--

2.4.5

#4 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Am 07.07.2015 um 12:51 schrieb Peter Crosthwaite:

Quoted 10 lines

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 6 lines
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
hw/watchdog/wdt_diag288.c +1 -0
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Hmm, to me it seems that qemu_devices_reset does only work for devices on a bus. This is a busless-device so the reset function gets not triggered.

Quoted 3 lines

I.E. What string do you get with an object_get_canonical_path() of the obj after machine init?

path /machine/peripheral/watchdog0

#5 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 6 lines · Christian Borntraeger

Am 07.07.2015 um 12:51 schrieb Peter Crosthwaite:

Quoted 5 lines
Quoted 5 lines
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
hw/watchdog/wdt_diag288.c +0 -0
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
Quoted 9 lines
Quoted 5 lines

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 1 line
hw/watchdog/wdt_diag288.c +1 -0
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Hmm, to me it seems that qemu_devices_reset does only work for devices on a bus. This is a busless-device so the reset function gets not triggered.

Yes I see. I think it is a core code bug though and we want to avoid having to patch individual devs based on their system level connectivity. I'm looking at qbus_realize, and there, there is code to register a reset for orphaned busses. So we have precedent for lazily setting up a reset for an orphaned bus at realize time, just not for indiv. devs. We can do the same.

I think this can be added to device_set_realized(). If a devices parent is not a bus, then register its reset individually to catch-all these. There are other devs that will qualify as well. I remember a similar issue for NAND (hw/block/nand.c) where we lost it from the qtree because we removed it from the sysbus. Looking at the code, I fear NAND may be susceptible to this same missing-reset bug.

Regards,
Peter

Quoted 9 lines
Quoted 4 lines

I.E. What string do you get with an object_get_canonical_path() of the obj after machine init?

path /machine/peripheral/watchdog0

#6 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 25 lines · On Tue, 7 Jul 2015 14:11:18 -0700 Peter Crosthwaite…
Quoted 6 lines · Christian Borntraeger

Am 07.07.2015 um 12:51 schrieb Peter Crosthwaite:

Quoted 5 lines
Quoted 5 lines
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
hw/watchdog/wdt_diag288.c +0 -0
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
Quoted 9 lines
Quoted 5 lines

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 1 line
hw/watchdog/wdt_diag288.c +1 -0
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Hmm, to me it seems that qemu_devices_reset does only work for devices on a bus. This is a busless-device so the reset function gets not triggered.

Yes I see. I think it is a core code bug though and we want to avoid having to patch individual devs based on their system level connectivity. I'm looking at qbus_realize, and there, there is code to register a reset for orphaned busses. So we have precedent for lazily setting up a reset for an orphaned bus at realize time, just not for indiv. devs. We can do the same.

Quoted 3 lines

I think this can be added to device_set_realized(). If a devices parent is not a bus, then register its reset individually to catch-all these.

Solving this in the core sounds good, but do you already have some kind of patch ready? :) As we're pretty late in the cycle, it might make sense to merge the existing fix for diag288 first, and switch to a generic solution later on.

Quoted 4 lines

There are other devs that will qualify as well. I remember a similar issue for NAND (hw/block/nand.c) where we lost it from the qtree because we removed it from the sysbus. Looking at the code, I fear NAND may be susceptible to this same missing-reset bug.

#7 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 10 lines · On Wed, 8 Jul 2015 09:45:05 +0200 Cornelia Huck <[email protected]>…
Quoted 7 lines · On Tue, 7 Jul 2015 14:11:18 -0700 Peter Crosthwaite…

Yes I see. I think it is a core code bug though and we want to avoid having to patch individual devs based on their system level connectivity. I'm looking at qbus_realize, and there, there is code to register a reset for orphaned busses. So we have precedent for lazily setting up a reset for an orphaned bus at realize time, just not for indiv. devs. We can do the same.

Quoted 8 lines
Quoted 3 lines

I think this can be added to device_set_realized(). If a devices parent is not a bus, then register its reset individually to catch-all these.

Solving this in the core sounds good, but do you already have some kind of patch ready? :) As we're pretty late in the cycle, it might make sense to merge the existing fix for diag288 first, and switch to a generic solution later on.

OTOH, this is less code than I expected. With the following code, I see the diag288 reset callback called on system reset. If this looks good, I can resend as a proper patch; we can reduce Xu's patch to the io_subsystem_reset() part in that case. Opinions?

hw/core/qdev.c +15 -0
index b2f404a..5c7c27b 100644
@@ -1018,6 +1018,13 @@ static bool device_get_realized(Object *obj, Error **errp)
     return dev->realized;
 }
 
+static void do_device_reset(void *opaque)
+{
+    DeviceState *dev = opaque;
+
+    device_reset(dev);
+}
+
 static void device_set_realized(Object *obj, bool value, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -1061,6 +1068,11 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
             goto post_realize_fail;
         }
 
+        if (!dev->parent_bus) {
+            /* Make sure that reset is called for bus-less devices. */
+            qemu_register_reset(do_device_reset, dev);
+        }
+
         if (qdev_get_vmsd(dev)) {
             vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
                                            dev->instance_id_alias,
@@ -1094,6 +1106,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
+        if (!dev->parent_bus) {
+            qemu_unregister_reset(do_device_reset, dev);
+        }
     }
 
     if (local_err != NULL) {
Signature · 1 line
2.4.5
#8 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 22 lines · On Wed, 8 Jul 2015 12:31:40 +0200 Cornelia Huck <[email protected]>…
Quoted 10 lines · On Wed, 8 Jul 2015 09:45:05 +0200 Cornelia Huck <[email protected]>…
Quoted 7 lines · On Tue, 7 Jul 2015 14:11:18 -0700 Peter Crosthwaite…

Yes I see. I think it is a core code bug though and we want to avoid having to patch individual devs based on their system level connectivity. I'm looking at qbus_realize, and there, there is code to register a reset for orphaned busses. So we have precedent for lazily setting up a reset for an orphaned bus at realize time, just not for indiv. devs. We can do the same.

Quoted 8 lines
Quoted 3 lines

I think this can be added to device_set_realized(). If a devices parent is not a bus, then register its reset individually to catch-all these.

Solving this in the core sounds good, but do you already have some kind of patch ready? :) As we're pretty late in the cycle, it might make sense to merge the existing fix for diag288 first, and switch to a generic solution later on.

Quoted 4 lines

OTOH, this is less code than I expected. With the following code, I see the diag288 reset callback called on system reset. If this looks good, I can resend as a proper patch; we can reduce Xu's patch to the io_subsystem_reset() part in that case. Opinions?

Ping? Does this make sense?

Quoted 40 lines
hw/core/qdev.c +15 -0
index b2f404a..5c7c27b 100644
@@ -1018,6 +1018,13 @@ static bool device_get_realized(Object *obj, Error **errp)
     return dev->realized;
 }
 
+static void do_device_reset(void *opaque)
+{
+    DeviceState *dev = opaque;
+
+    device_reset(dev);
+}
+
 static void device_set_realized(Object *obj, bool value, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -1061,6 +1068,11 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
             goto post_realize_fail;
         }
 
+        if (!dev->parent_bus) {
+            /* Make sure that reset is called for bus-less devices. */
+            qemu_register_reset(do_device_reset, dev);
+        }
+
         if (qdev_get_vmsd(dev)) {
             vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
                                            dev->instance_id_alias,
@@ -1094,6 +1106,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
+        if (!dev->parent_bus) {
+            qemu_unregister_reset(do_device_reset, dev);
+        }
     }
 
     if (local_err != NULL) {
#9 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 25 lines · Cornelia Huck
Quoted 22 lines · On Wed, 8 Jul 2015 12:31:40 +0200 Cornelia Huck <[email protected]>…
Quoted 18 lines · On Wed, 8 Jul 2015 09:45:05 +0200 Cornelia Huck <[email protected]>…
Quoted 10 lines · On Tue, 7 Jul 2015 14:11:18 -0700 Peter Crosthwaite…

Yes I see. I think it is a core code bug though and we want to avoid having to patch individual devs based on their system level connectivity. I'm looking at qbus_realize, and there, there is code to register a reset for orphaned busses. So we have precedent for lazily setting up a reset for an orphaned bus at realize time, just not for indiv. devs. We can do the same.

I think this can be added to device_set_realized(). If a devices parent is not a bus, then register its reset individually to catch-all these.

Solving this in the core sounds good, but do you already have some kind of patch ready? :) As we're pretty late in the cycle, it might make sense to merge the existing fix for diag288 first, and switch to a generic solution later on.

Quoted 5 lines
Quoted 4 lines

OTOH, this is less code than I expected. With the following code, I see the diag288 reset callback called on system reset. If this looks good, I can resend as a proper patch; we can reduce Xu's patch to the io_subsystem_reset() part in that case. Opinions?

I'm for sending that new core patch, as I'm suspicious I can make it fail in other places than your diag case. Runtime reset is poorly exercised code so I think you are going to pickup half-a-dozen bugfixes here.

Regards,
Peter

Quoted 44 lines

Ping? Does this make sense?

Quoted 40 lines
hw/core/qdev.c +15 -0
index b2f404a..5c7c27b 100644
@@ -1018,6 +1018,13 @@ static bool device_get_realized(Object *obj, Error **errp)
     return dev->realized;
 }
 
+static void do_device_reset(void *opaque)
+{
+    DeviceState *dev = opaque;
+
+    device_reset(dev);
+}
+
 static void device_set_realized(Object *obj, bool value, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
@@ -1061,6 +1068,11 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
             goto post_realize_fail;
         }
 
+        if (!dev->parent_bus) {
+            /* Make sure that reset is called for bus-less devices. */
+            qemu_register_reset(do_device_reset, dev);
+        }
+
         if (qdev_get_vmsd(dev)) {
             vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
                                            dev->instance_id_alias,
@@ -1094,6 +1106,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
+        if (!dev->parent_bus) {
+            qemu_unregister_reset(do_device_reset, dev);
+        }
     }
 
     if (local_err != NULL) {
#10 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 9 lines · Peter Crosthwaite
Quoted 7 lines · Cornelia Huck
Quoted 4 lines · On Wed, 8 Jul 2015 12:31:40 +0200 Cornelia Huck <[email protected]>…

OTOH, this is less code than I expected. With the following code, I see the diag288 reset callback called on system reset. If this looks good, I can resend as a proper patch; we can reduce Xu's patch to the io_subsystem_reset() part in that case. Opinions?

Quoted 4 lines

I'm for sending that new core patch, as I'm suspicious I can make it fail in other places than your diag case. Runtime reset is poorly exercised code so I think you are going to pickup half-a-dozen bugfixes here.

FWIW this patch would mean we would try to call dc->reset on the ARM CPU devices; the only reason this doesn't cause a problem is that those devices don't happen to register a dc->reset function pointer. (It's this sort of "now we start calling a reset method on a device that was probably doing its own reset via another path" that meant I wasn't too keen on it for 2.4, though quite possibly it would work out better than the ad-hoc reset we have currently in the longer term...)

-- PMM

#11 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

In reply to Peter Crosthwaite
Quoted 64 lines · On Tue, 7 Jul 2015 03:51:59 -0700 Peter Crosthwaite…
Quoted 63 lines · Cornelia Huck

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

---
 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +5 -1
index 3d20d6a..4c51d1a 100644
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
hw/watchdog/wdt_diag288.c +7 -0
index 1185e06..2a885a4 100644
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
Quoted 5 lines

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 1 line
hw/watchdog/wdt_diag288.c +1 -0
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

It will show up as /machine/peripheral-anon/device[].

But is just showing up really enough? For the sysbus, qbus_reset_all_fn is registered as a reset handler, and that called our reset handler when diag288 was still a sysbus device in a previous patch version.

#12 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

In reply to Peter Crosthwaite
Quoted 64 lines · Peter Crosthwaite
Quoted 63 lines · Cornelia Huck

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

---
 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +5 -1
index 3d20d6a..4c51d1a 100644
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
hw/watchdog/wdt_diag288.c +7 -0
index 1185e06..2a885a4 100644
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
Quoted 5 lines

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 1 line
hw/watchdog/wdt_diag288.c +1 -0
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Reset doesn't follow the QOM tree.

In fact this is the main reason why I dislike TYPE_DEVICE as a superclass...

Paolo

#13 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Am 08.07.2015 um 09:54 schrieb Paolo Bonzini:

Quoted 73 lines · Peter Crosthwaite
Quoted 64 lines · Cornelia Huck
Quoted 63 lines

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

---
 hw/s390x/s390-virtio-ccw.c | 6 +++++-
 hw/watchdog/wdt_diag288.c  | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +5 -1
index 3d20d6a..4c51d1a 100644
@@ -36,7 +36,7 @@ typedef struct S390CcwMachineState {
 
 void io_subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic;
+    DeviceState *css, *sclp, *flic, *diag288;
 
     css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
     if (css) {
@@ -51,6 +51,10 @@ void io_subsystem_reset(void)
     if (flic) {
         qdev_reset_all(flic);
     }
+    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
+    if (diag288) {
+        qdev_reset_all(diag288);
+    }
 }
 
 static int virtio_ccw_hcall_notify(const uint64_t *args)
hw/watchdog/wdt_diag288.c +7 -0
index 1185e06..2a885a4 100644
@@ -40,6 +40,13 @@ static void wdt_diag288_reset(DeviceState *dev)
     timer_del(diag288->timer);
 }
 
+static void diag288_reset(void *opaque)
+{
+    DeviceState *diag288 = opaque;
+
+    wdt_diag288_reset(diag288);
+}
+
 static void diag288_timer_expired(void *dev)
 {
     qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
@@ -80,6 +87,7 @@ static void wdt_diag288_realize(DeviceState *dev, Error **errp)
 {
     DIAG288State *diag288 = DIAG288(dev);
 
Quoted 5 lines

hw/watchdog/wdt_diag288.c static void wdt_diag288_realize(DeviceState *dev, Error **errp) · line 90

Quoted 1 line
hw/watchdog/wdt_diag288.c +1 -0
+    qemu_register_reset(diag288_reset, diag288);

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Quoted 3 lines

Reset doesn't follow the QOM tree.

In fact this is the main reason why I dislike TYPE_DEVICE as a superclass...

Oh, thats why we were asked to use that instead of sysbus device? ;-)

#14 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 9 lines · Christian Borntraeger
Quoted 7 lines
Quoted 3 lines

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Reset doesn't follow the QOM tree.

In fact this is the main reason why I dislike TYPE_DEVICE as a superclass...

Oh, thats why we were asked to use that instead of sysbus device? ;-)

Did I? I've always liked sysbus... :)

Paolo

#15 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Am 08.07.2015 um 10:44 schrieb Paolo Bonzini:

Quoted 7 lines · Christian Borntraeger
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Doesn't seem right. Even if it is not a SBD it should still sit in the QOM tree in a place where the reset is reached. Where is this device in the QOM tree?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Reset doesn't follow the QOM tree.

In fact this is the main reason why I dislike TYPE_DEVICE as a superclass...

Oh, thats why we were asked to use that instead of sysbus device? ;-)

Did I? I've always liked sysbus... :)

Not you.
But its a pattern that I have seen 3 or 4 times: "Oh no, please do not use xxx any more, we have fancy new stuff that nobody else is using in the tree, but its the way to go..." But most of the time the hickups can be handled. :-)

Christian

#16 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

Quoted 10 lines · Christian Borntraeger
Quoted 5 lines
Quoted 3 lines

In fact this is the main reason why I dislike TYPE_DEVICE as a superclass...

Oh, thats why we were asked to use that instead of sysbus device? ;-)

Did I? I've always liked sysbus... :)

Not you.
But its a pattern that I have seen 3 or 4 times: "Oh no, please do not use xxx any more, we have fancy new stuff that nobody else is using in the tree, but its the way to go..." But most of the time the hickups can be handled. :-)

I know, and it's a problem. :(

Paolo

Reviewed-by on v1 1/1
#17 lore raw

Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests

In reply to Cornelia Huck

Am 07.07.2015 um 10:53 schrieb Cornelia Huck:

Quoted 5 lines

From: Xu Wang <[email protected]>

The diag288 watchdog is no sysbus device, therefore it doesn't get triggered on resets automatically using dc->reset.

Quoted 7 lines

Let's register the reset handler manually, so we get correctly notified again when a system reset was requested. Also reset the watchdog on subsystem resets that don't trigger a full system reset.

Thanks,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)