From nobody Tue May 7 07:20:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558624042; cv=none; d=zoho.com; s=zohoarc; b=ZhmwleBWWTCeM6eTFFiTdvnywpKSPkX54Bnbaq8nSPqn0RlBn9AisfoHwia0mHhvZvkAihhk91XSEEZ4TLGUMKbdOpolCeybQy/emYGP88kXsSbJ83S2+EewAEl85KwuV/2+YvJynHx0y5c4XLQ2ZKJBHX9n5uGAMSAvH2vL20w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558624042; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=Ume50n8qkYBKGcbQ5wkyvsOh4prOkl3w7x4Kl5qGVnc=; b=icmjTBM1iFzpuBJ9zdR5bu2QsnaA7fGMybg5bieSh8gs53ZtVJ8OccnWxu6TuYP7biIeYSdRMTqpElAdNJoT5WQocu5qSP7a/USqvqUPYSvEwLsRqIvyPz5hgIfNxDe9erljhnKHIP7qG6RROWWL+jDquGDluPR7FbCQWLmptFM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558624041997519.650253062856; Thu, 23 May 2019 08:07:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:38460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpJK-00058a-Ux for importer@patchew.org; Thu, 23 May 2019 11:07:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpI0-0004Of-Et for qemu-devel@nongnu.org; Thu, 23 May 2019 11:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTpHz-0000P2-3C for qemu-devel@nongnu.org; Thu, 23 May 2019 11:05:52 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:36695) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTpHy-0000MW-FH for qemu-devel@nongnu.org; Thu, 23 May 2019 11:05:50 -0400 Received: by mail-wr1-x443.google.com with SMTP id s17so6696237wru.3 for ; Thu, 23 May 2019 08:05:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id h17sm13739322wrq.79.2019.05.23.08.05.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 May 2019 08:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ume50n8qkYBKGcbQ5wkyvsOh4prOkl3w7x4Kl5qGVnc=; b=Fpfl0mDdESslAV3eqgH6v7fmBKDioLGiugegouZenqv4Pa+q6n9wLUuJa2xi+ZC74x 8l7Hb8ISfA0Ycvop0Eteio3pLNgGKGrmbWMljcjJQLDfNXgyJOhUJ57GDtbIQaqM51ED Ij919ZZZ//o1tsmUXzT75avK9ZjM8MmRgkZZgSeATgxvCv+5Ig8vmKjZdAXX1KI50PbR JECNaF3N5X8zJ0UWKzYkJ27Bnk8SNUWG3umFQEngYxoHTaKw8JzEyqjypBRybVq4Ul5J WDnhYq/JlBHSrjCzluidfD/RV8TZbGGQkb+3Mlrp3nP11I3ev5Fv+Vkebn+XETj2mubF /0PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ume50n8qkYBKGcbQ5wkyvsOh4prOkl3w7x4Kl5qGVnc=; b=t8HCVjiE0iqAzvjeuV1ULN5fwB/fDr2KY0LZh2zrkkFSuOncCfonStpLBUWSg4jKS6 qu3xKAZQh4oyrPP2i/JM6vwOk+iX9GnwSWelXe9JbSaI2sfUG1//CazgvwUXf/Q/SA9X k/FduqkLDfOWH89sx7rjGxKf0pQrANQuRfW8mxFSBeAq0jyFWroOFjMw2nXzLwEpjoyr d3ZH7XmSdGXtvAeiP3h4owF0dT90qvfDWJJAXoq2d/AYIAjDIFy93njX8eoSQdzb/7ol hwKGSDkz29yRhkz9noAPH1tJUNkHUJJL9Ef36KhzBhHEeloAnuBRzBLG3SBERkwrdcLv xgbw== X-Gm-Message-State: APjAAAXLYwHMBj7p46StthhNDELaQDdYD4D3q+kf1/G7stz/tZ3/ROo2 uUMWYQBT5mdpqrm/QMxkKivUIGascolDgg== X-Google-Smtp-Source: APXvYqzgUqxEKtbLKVGbzZZCZqiMb1olqo6S5Ki6sYYlF8qar5NEzDcmXh8f0YhEMakVY4cTNscCNw== X-Received: by 2002:adf:f7c8:: with SMTP id a8mr2113431wrq.148.1558623946354; Thu, 23 May 2019 08:05:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 23 May 2019 16:05:43 +0100 Message-Id: <20190523150543.22676-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v2] hw/core/bus.c: Only the main system bus can have no parent X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In commit 80376c3fc2c38fdd453 in 2010 we added a workaround for some qbus buses not being connected to qdev devices -- if the bus has no parent object then we register a reset function which resets the bus on system reset (and unregister it when the bus is unparented). Nearly a decade later, we have now no buses in the tree which are created with non-NULL parents, so we can remove the workaround and instead just assert that if the bus has a NULL parent then it is the main system bus. (The absence of other parentless buses was confirmed by code inspection of all the callsites of qbus_create() and qbus_create_inplace() and cross-checked by 'make check'.) Signed-off-by: Peter Maydell Reviewed-by: Markus Armbruster Reviewed-by: Damien Hedde Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- v1->v2: clean up also the bus_unparent() code --- hw/core/bus.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/hw/core/bus.c b/hw/core/bus.c index e09843f6abe..b8839c7268d 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -96,10 +96,9 @@ static void qbus_realize(BusState *bus, DeviceState *par= ent, const char *name) bus->parent->num_child_bus++; object_property_add_child(OBJECT(bus->parent), bus->name, OBJECT(b= us), NULL); object_unref(OBJECT(bus)); - } else if (bus !=3D sysbus_get_default()) { - /* TODO: once all bus devices are qdevified, - only reset handler for main_system_bus should be registered her= e. */ - qemu_register_reset(qbus_reset_all_fn, bus); + } else { + /* The only bus without a parent is the main system bus */ + assert(bus =3D=3D sysbus_get_default()); } } =20 @@ -108,18 +107,16 @@ static void bus_unparent(Object *obj) BusState *bus =3D BUS(obj); BusChild *kid; =20 + /* Only the main system bus has no parent, and that bus is never freed= */ + assert(bus->parent); + while ((kid =3D QTAILQ_FIRST(&bus->children)) !=3D NULL) { DeviceState *dev =3D kid->child; object_unparent(OBJECT(dev)); } - if (bus->parent) { - QLIST_REMOVE(bus, sibling); - bus->parent->num_child_bus--; - bus->parent =3D NULL; - } else { - assert(bus !=3D sysbus_get_default()); /* main_system_bus is never= freed */ - qemu_unregister_reset(qbus_reset_all_fn, bus); - } + QLIST_REMOVE(bus, sibling); + bus->parent->num_child_bus--; + bus->parent =3D NULL; } =20 void qbus_create_inplace(void *bus, size_t size, const char *typename, --=20 2.20.1