qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	jfrei@linux.vnet.ibm.com, Alexander Graf <agraf@suse.de>,
	Xu Wang <gesaint@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests
Date: Wed, 8 Jul 2015 12:31:40 +0200	[thread overview]
Message-ID: <20150708123140.65e40003.cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <20150708094505.11a3364b.cornelia.huck@de.ibm.com>

On Wed, 8 Jul 2015 09:45:05 +0200
Cornelia Huck <cornelia.huck@de.ibm.com> wrote:

> On Tue, 7 Jul 2015 14:11:18 -0700
> Peter Crosthwaite <peter.crosthwaite@xilinx.com> wrote:

> > 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.

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?


diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index b2f404a..5c7c27b 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -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) {
-- 
2.4.5

  reply	other threads:[~2015-07-08 10:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07  8:53 [Qemu-devel] [PATCH for-2.4] s390x: diag288 reset fix Cornelia Huck
2015-07-07  8:53 ` [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests Cornelia Huck
2015-07-07 10:29   ` Christian Borntraeger
2015-07-07 10:51   ` Peter Crosthwaite
2015-07-07 14:22     ` Christian Borntraeger
2015-07-07 21:11       ` Peter Crosthwaite
2015-07-08  7:45         ` Cornelia Huck
2015-07-08 10:31           ` Cornelia Huck [this message]
2015-07-09 12:41             ` Cornelia Huck
2015-07-09 16:16               ` Peter Crosthwaite
2015-07-14 13:51                 ` Peter Maydell
2015-07-07 14:22     ` Cornelia Huck
2015-07-08  7:54     ` Paolo Bonzini
2015-07-08  8:01       ` Christian Borntraeger
2015-07-08  8:44         ` Paolo Bonzini
2015-07-08  8:48           ` Christian Borntraeger
2015-07-08  9:59             ` Paolo Bonzini
2015-07-14 13:33   ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150708123140.65e40003.cornelia.huck@de.ibm.com \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=gesaint@linux.vnet.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).