From patchwork Sat Apr 2 00:12:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 89371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B546AB6F8E for ; Sat, 2 Apr 2011 11:13:03 +1100 (EST) Received: from localhost ([127.0.0.1]:48363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5oSR-0001DE-7C for incoming@patchwork.ozlabs.org; Fri, 01 Apr 2011 20:12:51 -0400 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 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 4EBA518919; Sat, 2 Apr 2011 09:12:03 +0900 (JST) Received: (nullmailer pid 11756 invoked by uid 1000); Sat, 02 Apr 2011 00:12:03 -0000 Date: Sat, 2 Apr 2011 09:12:03 +0900 From: Isaku Yamahata To: Aurelien Jarno 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-Disposition: inline In-Reply-To: <20110401195746.GB24630@volta.aurel32.net> User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 210.128.90.3 Cc: Dmitry Eremin-Solenikov , qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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);