From patchwork Thu Jun 13 12:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 166617 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp700830ilk; Thu, 13 Jun 2019 05:32:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzanaZWyjF8uPFCO7BtY53MSmytQgcKvotrN+ZZjcKVCms8+wKAu3xB7sbLZ27ixBeVdS5m X-Received: by 2002:a0c:8722:: with SMTP id 31mr3285704qvh.164.1560429177995; Thu, 13 Jun 2019 05:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560429177; cv=none; d=google.com; s=arc-20160816; b=YedWbRtMMY2CgHrsUTHtlZho0ELzc6+ew4WMDnFjh53hvhFxPLCkUl65i8RhZDJYd1 8DXMUZyHi1hOWjQJrJwHAnq+aIrQcUdrMcVO+RoAnTT+7O0m7kh1whouq6NvXgoyHWcB 4dB2nyn7fB+oTSUl+Z4RptnSoNgJ88Z3/L2WCU/vNUpfAWHx++skNVTIUpQFW2SJHsgv oR8N+AcbtgaR/3GgS3cfyqaHh35o2oev3aiKF+vjJW3X1elxUFOEI9rwNOubPvkVN0i6 /znkKEtkcy1BMTiQItk4RAWTc7wqw1Fprtx6jPDc6tTvoNUA4x+24Vn3Rc+oFNg3wHLO c4eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bX4hRH4lVhTWXUt9Xxv5/AT7FDCVaSNWnYXS84dsZh8=; b=uHnVAD297qOVNIRmaTIUtSewYjAQj0IWhS9iuaW4JWblypvPL4yGVOglhwDzWgqLgu M/ECotUOfQYj+inBDcMKjD/j63sXmx+mAQ2gima9k42SpHZ5hLBPDQrVnaI19ewnzJ4Z QlecTmp+1a+KbOQZV4UR2yq84gVfk9dMtz69LebaGvejQu3scdcrjjyqP59GvLL+kxig DwzYN+blL6Vj5iljkp7FRkENiMrD/2DU52hrDWG6auypk5ZY+BlmxOxHn7B80UYXeTt7 l8Kc2s/j0JAMAeb4fRz2+00pDx0NP50n42MZP+slpH1uP/bC/p9/4BiM+G5brO3x5x3X U/gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WvAXgAMk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w2si1486285qkf.216.2019.06.13.05.32.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 05:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WvAXgAMk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOuX-0001E1-IK for patch@linaro.org; Thu, 13 Jun 2019 08:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58813) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbOcz-0007uG-Rg for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbOcx-0003zA-Dc for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:49 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:52231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbOcv-0003ub-5m for qemu-devel@nongnu.org; Thu, 13 Jun 2019 08:14:45 -0400 Received: by mail-wm1-x343.google.com with SMTP id s3so9965488wms.2 for ; Thu, 13 Jun 2019 05:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bX4hRH4lVhTWXUt9Xxv5/AT7FDCVaSNWnYXS84dsZh8=; b=WvAXgAMkHfkAb0RVlgzGELM/5iiBMiC4eT16/axY8wTQ+6tmguvh7HbrWvUL0i5CQl qlmYHWLcvOr76KlMxLZ1wcp3INz3C6i7dZanzkyxK6rh7neJ+rFMjeKLXXiayElItj7P MvsKe8sXqgdpqkK/oHjTwsDXmB/yYTBtkgey5P5b4Vecyk/fml2UF7ZIS0qWy5zjj118 MP7XnamQ2bYVeTqPfge2/tMtYmwJdXtE3K0xqt6oO0pnnVyNrgp16+7qVlZVmfIVjxDz G85poM9KHZjsW//0VYJRBqhLU3zxBOfE1I9TtwbNbu6VBT/Rhu8736TiB7DQcUZQnXil haqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bX4hRH4lVhTWXUt9Xxv5/AT7FDCVaSNWnYXS84dsZh8=; b=SSxxPFM7mw9zkcbmgzpJHCBvn4LWRF6XFiVK+gPmEqWk80tDUYQKdTP/xNHYRdT/nt jdjmhnjwUFvspzn6i62JmpyUq5Nfpi18Fqo71Qrg2FK7cYBsKa4GPIZR5R2DU6QTgOeK ERWnd/Y81XQj1IkCZHUF2JZMY9Rtsz902hIk7OKhoMfleO7fbV8tjALS+d9NmoLBDbBR h37K5Wgm7haniVsiuuQxgm4pT2G4CrdOCpKKn3VEGN4tr6bpB7da4md4FcotOr6zIwM4 OUratHoIF+cI8jXN4LBibECnsfEgwm6lmN2cYUqDNeVIWvFDBfV89Qs08wky+SxSPaQ8 1ODA== X-Gm-Message-State: APjAAAXwgLaCAnqcfuRrorCMPu8qoE/0DOKJKrgNPQIA70sLJaNzW+Gq Z0IBLimAseUMxMK6cPKbd2evl1sPFSQh/g== X-Received: by 2002:a1c:c907:: with SMTP id f7mr3639072wmb.142.1560428081281; Thu, 13 Jun 2019 05:14:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y6sm2010576wrp.12.2019.06.13.05.14.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 05:14:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2019 13:13:50 +0100 Message-Id: <20190613121433.5246-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190613121433.5246-1-peter.maydell@linaro.org> References: <20190613121433.5246-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 05/48] hw/core/bus.c: Only the main system bus can have no parent X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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: Philippe Mathieu-Daudé Reviewed-by: Damien Hedde Tested-by: Philippe Mathieu-Daudé Message-id: 20190523150543.22676-1-peter.maydell@linaro.org --- hw/core/bus.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/hw/core/bus.c b/hw/core/bus.c index e6baa04e52b..17bc1edcde6 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -97,10 +97,9 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name) bus->parent->num_child_bus++; object_property_add_child(OBJECT(bus->parent), bus->name, OBJECT(bus), NULL); object_unref(OBJECT(bus)); - } else if (bus != 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); + } else { + /* The only bus without a parent is the main system bus */ + assert(bus == sysbus_get_default()); } } @@ -109,18 +108,16 @@ static void bus_unparent(Object *obj) BusState *bus = BUS(obj); BusChild *kid; + /* Only the main system bus has no parent, and that bus is never freed */ + assert(bus->parent); + while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) { DeviceState *dev = kid->child; object_unparent(OBJECT(dev)); } - if (bus->parent) { - QLIST_REMOVE(bus, sibling); - bus->parent->num_child_bus--; - bus->parent = NULL; - } else { - assert(bus != 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 = NULL; } void qbus_create_inplace(void *bus, size_t size, const char *typename,