From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56737 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5oRk-0001D9-PO for qemu-devel@nongnu.org; Fri, 01 Apr 2011 20:12:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5oRj-0007k9-Av for qemu-devel@nongnu.org; Fri, 01 Apr 2011 20:12:08 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:40735) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5oRi-0007jk-PI for qemu-devel@nongnu.org; Fri, 01 Apr 2011 20:12:07 -0400 Date: Sat, 2 Apr 2011 09:12:03 +0900 From: Isaku Yamahata Subject: Re: [Qemu-devel] [PATCH] Register only one qbus_reset_all_fn() for system bus Message-ID: <20110402001203.GA11748@valinux.co.jp> References: <1298243333-23799-1-git-send-email-dbaryshkov@gmail.com> <20110401195746.GB24630@volta.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110401195746.GB24630@volta.aurel32.net> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: Dmitry Eremin-Solenikov , qemu-devel@nongnu.org > Have you verified that all bus devices have been qdevified since this > code has been added? I wouldn't bet it is the case. I think his analysis is valid. So how about the following patch. >>From ee27041a238d51247e30100d1909066978cd8858 Mon Sep 17 00:00:00 2001 Message-Id: From: Isaku Yamahata Date: Sat, 2 Apr 2011 09:04:54 +0900 Subject: [PATCH] qdev: Register only one qbus_reset_all_fn() for system bus This is the revised version of Dmitry's. his report is as follows and this patch fixes it. > Currently reset handler is registered for System bus twice: once during > bus creation and once in vl.c. Remove the second qemu_register_reset() > invocation. Also while we are at it, remove incorrect check at > qbus_create_inplace(): when system bus is created, main_system_bus is > NULL (as it's not yet created, it cannot be set), so the check is just > wrong. the check bus == main_system_bus in qbus_create_inplace() was wrong because sysbus_get_default() creates bus for main_system_bus and then set main_system_bus to it. So main_system_bus == NULL in qbus_create_inplace() when creating main_system_bus. So this patch fixes the check whether creating main_system_bus or not by seeing BusInfo. Cc: Dmitry Eremin-Solenikov Signed-off-by: Isaku Yamahata --- hw/qdev.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 1aa1ea0..659de23 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -762,7 +762,12 @@ void qbus_create_inplace(BusState *bus, BusInfo *info, if (parent) { QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; - } else if (bus != main_system_bus) { + } else if (info != &system_bus_info) { + /* see if bus == main_system_bus + * Here we can't check bus == main_system_bus because + * main_system_bus == NULL here before setting it by + * sysbus_get_default() + */ /* TODO: once all bus devices are qdevified, only reset handler for main_system_bus should be registered here. */ qemu_register_reset(qbus_reset_all_fn, bus); -- 1.7.1.1 -- yamahata