From patchwork Wed Jul 8 10:31:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 492844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 11051140772 for ; Wed, 8 Jul 2015 20:32:21 +1000 (AEST) Received: from localhost ([::1]:34255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCmeJ-0005ds-8l for incoming@patchwork.ozlabs.org; Wed, 08 Jul 2015 06:32:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCmds-00052I-Oz for qemu-devel@nongnu.org; Wed, 08 Jul 2015 06:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCmdo-0001aD-LI for qemu-devel@nongnu.org; Wed, 08 Jul 2015 06:31:52 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:51265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCmdo-0001Z8-BG for qemu-devel@nongnu.org; Wed, 08 Jul 2015 06:31:48 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Jul 2015 11:31:45 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 8 Jul 2015 11:31:44 +0100 X-Helo: d06dlp01.portsmouth.uk.ibm.com X-MailFrom: cornelia.huck@de.ibm.com X-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4C66117D805F for ; Wed, 8 Jul 2015 11:33:00 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t68AViIB33751140 for ; Wed, 8 Jul 2015 10:31:44 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t685Od6O008126 for ; Wed, 8 Jul 2015 01:24:39 -0400 Received: from gondolin (dyn-9-152-224-169.boeblingen.de.ibm.com [9.152.224.169]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t685OdHQ008116; Wed, 8 Jul 2015 01:24:39 -0400 Date: Wed, 8 Jul 2015 12:31:40 +0200 From: Cornelia Huck To: "qemu-devel@nongnu.org Developers" Message-ID: <20150708123140.65e40003.cornelia.huck@de.ibm.com> In-Reply-To: <20150708094505.11a3364b.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> Organization: IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz =?UTF-8?B?R2VzY2jDpGZ0c2bDvGhydW5nOg==?= Dirk Wittkopp Sitz der Gesellschaft: =?UTF-8?B?QsO2Ymxpbmdlbg==?= Registergericht: Amtsgericht Stuttgart, HRB 243294 X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; i686-pc-linux-gnu) Mime-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15070810-0041-0000-0000-000004DABB6D X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.106 Cc: Christian Borntraeger , Peter Crosthwaite , jfrei@linux.vnet.ibm.com, Alexander Graf , Xu Wang Subject: Re: [Qemu-devel] [PATCH for-2.4] watchdog/diag288: correctly register for system reset requests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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? 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) {