Received: from eggs.gnu.org ([2001:4830:134:3::10]:60633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDB9U-0007cp-SY for qemu-devel@nongnu.org; Thu, 09 Jul 2015 08:42:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDB9R-0001pB-2D for qemu-devel@nongnu.org; Thu, 09 Jul 2015 08:42:08 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:50682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDB9Q-0001o6-PO for qemu-devel@nongnu.org; Thu, 09 Jul 2015 08:42:04 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Jul 2015 13:42:00 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 56C401B08061 for ; Thu, 9 Jul 2015 13:43:11 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t69Cfxt933751128 for ; Thu, 9 Jul 2015 12:41:59 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t69CfxRY022972 for ; Thu, 9 Jul 2015 06:41:59 -0600 Date: Thu, 9 Jul 2015 14:41:57 +0200 From: Cornelia Huck Message-ID: <20150709144157.5f7b1718.cornelia.huck@de.ibm.com> In-Reply-To: <20150708123140.65e40003.cornelia.huck@de.ibm.com> References: <1436259202-20509-1-git-send-email-cornelia.huck@de.ibm.com> <1436259202-20509-2-git-send-email-cornelia.huck@de.ibm.com> <559BE08A.9010305@de.ibm.com> <20150708094505.11a3364b.cornelia.huck@de.ibm.com> <20150708123140.65e40003.cornelia.huck@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org Developers" Cc: Christian Borntraeger , Peter Crosthwaite , jfrei@linux.vnet.ibm.com, Alexander Graf , Xu Wang On Wed, 8 Jul 2015 12:31:40 +0200 Cornelia Huck wrote: > On Wed, 8 Jul 2015 09:45:05 +0200 > Cornelia Huck wrote: > > > On Tue, 7 Jul 2015 14:11:18 -0700 > > Peter Crosthwaite 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? Ping? Does this make sense? > 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) {