From patchwork Tue Feb 20 16:06:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 774276 Delivered-To: patch@linaro.org Received: by 2002:a5d:4943:0:b0:33b:4db1:f5b3 with SMTP id r3csp1730336wrs; Tue, 20 Feb 2024 08:08:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVfswBELcbPL1Tl537aYEQxl0qd07WcjG/M6CHLLFgnjw0PjLFYjEp00l+8A2eO46Rca7VY4WNNkttkOHDpE7Fq X-Google-Smtp-Source: AGHT+IEkClDn5hsoAgR6UWBdyYn++UAnCEt/MNtwwmzSdFrSOlX414k9ZFdIwd0D+fppqM65Jl8/ X-Received: by 2002:a05:6214:4001:b0:68f:36a0:5e8b with SMTP id kd1-20020a056214400100b0068f36a05e8bmr11337331qvb.47.1708445289120; Tue, 20 Feb 2024 08:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708445289; cv=none; d=google.com; s=arc-20160816; b=Jbb5zNvD5RMmJVRXLpmuXkFw4P/ar9l22uCvGZavOgPN38xaPhO+tcDTQztW6eFj5f G/1iOrwytAtVluT5b3uuHP6ITdoZ/OP0Z0TZDunu+5wH69ictgoc+W6ppNDOweabpxYG tTDAX3Ui3BIwkAK34JS93nn2gHCZ2Qb1MC2JkEWZ8/vdC+gjr3CNARepZc+AXyisMP+n Dc/nMfNfPuylH+ALuMZE/LTBjgW6OGNX1rbtsMn9wc583AueR0wX0SwygaZtAAzhZCsH NvFrCP22zoU6tdiCiqKzAZQRyub8wBU4t+5O1O9Koh1bVRJ5BpKcDxNojgmWshKbHARc 9BSQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=19euJWj2Bsd7+44lYFRoDEAxkKA5sWf1qGZsesZBvWY=; fh=dm0WNFmBzWrd+9ibIS2DbEOUrG4x0hquFjik6cek7jE=; b=xIhgUAUAMrMMJDUssqkO26WsGGCgUFSvhGtWy5pI4ChsUNhzIGZPntHKCYm2jL6QEV sli6KtQYpysba2sIPe+Fz4bheFfFSKAaJc5ZlTQYclhq1TY8d5qR0/tcVFIvHZkzB9hO lz2g6GzZDNG9bXtiz5CcKuiQTiMxKOmOcgiYdRXZa13c8Xg8Dh3AjQD74k+GCEa0STmA 9MX5sj+Z/W4zCmAUaFrt/UDxWIIkh89xdFz6RzjD3t7jXKNzgMO+MZqplURkiCriRKpZ rVbWh3ip9JfxbdYGNfUtvJHblgevPO4TahGXKthjVGHNBBvIPuYWON+064CZwbAsNH5X mTdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tkn6ECuC; 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=pass (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 w12-20020a05622a134c00b0042e02fcfc98si6888503qtk.795.2024.02.20.08.08.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2024 08:08:09 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=tkn6ECuC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcSdj-0002B7-FE; Tue, 20 Feb 2024 11:06:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcSdg-000292-2N for qemu-devel@nongnu.org; Tue, 20 Feb 2024 11:06:36 -0500 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcSdc-0005Ft-LX for qemu-devel@nongnu.org; Tue, 20 Feb 2024 11:06:35 -0500 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d09cf00214so61652191fa.0 for ; Tue, 20 Feb 2024 08:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708445190; x=1709049990; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=19euJWj2Bsd7+44lYFRoDEAxkKA5sWf1qGZsesZBvWY=; b=tkn6ECuCmoesHxSOsV0ZKKFXyGs9c1qULWX9ah9kscQsj7aHFxSvgkyKxUoydZF9Qe ue/Nu6XLpKO2n0E78b5Rdi9uh89OUGUZXSRP+Myk4o9sZk9Cl54UKG0hKfANzqWM2aUZ ExRPUFnb2rBxmZ6WscWmBfpY2jVGefp1YA1a2R47y+zuOB9Syp9B6soNeZ5f+vCiPYSM 7zsbPIm0iJH4Zd4sD8NsOstinikgVhB7mibOtrn2gW6H8ZLqtkcc4v5l2IU5gzDPpNpm dHJ2LUKGRqT/hayh4E3Nln/QH3I/PMsZ4FhfaivzoZybLQ9W6V883rRoV6zbfmyeW5QY yAKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708445190; x=1709049990; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=19euJWj2Bsd7+44lYFRoDEAxkKA5sWf1qGZsesZBvWY=; b=HG90MbEWBDzDKlttfp4RfhyhTzUz+y+p5cQJ2KcroEp/sK7bcCICp0hPBdtZPYIr0O V6ssMRn9946KUHQi57AVorl1vGwy7SJfIiBpbTDoyV2D1TjlTyP31g7/48Qq5OMGO1mS 3NP/eFXkAgotcFTaouM/zg8B3HAhgaBTVXvBpYKhla1/ShXD+4ip+yUYclYQwAb/v2Xg zSbm5SK4qZ7cTiRKo7p4lhcTtdJ6g9J0PAfFKAGfD1oDcU6VXsux5BItQqfu4ODoZqiU U5L5KCVb4HVUF84YFm85lwiVahf9FOmaKeEHtT+HmOrs3A5RqgDMKM6VxhzehjUT1cH9 U91Q== X-Gm-Message-State: AOJu0YwwtZIjY6zQ2kxCxA/sDFYsOeFzO5Jn1RnkbkXs9sCgd9GtFYiq FbGl1MF8HTk3hQd4YxWTW1nHDHz5oLix6hmPfb7lca2c5q62KVGJ87lmQlUXvSCJzopnWfew/4q H X-Received: by 2002:a05:651c:1250:b0:2d2:3186:4597 with SMTP id h16-20020a05651c125000b002d231864597mr4262564ljh.25.1708445190048; Tue, 20 Feb 2024 08:06:30 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f8-20020a05600c4e8800b0040f0219c371sm15299927wmq.19.2024.02.20.08.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 08:06:29 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , "Michael S. Tsirkin" , "Gonglei (Arei)" Subject: [PATCH 09/10] hw/core/machine: Use qemu_register_resettable for sysbus reset Date: Tue, 20 Feb 2024 16:06:21 +0000 Message-Id: <20240220160622.114437-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220160622.114437-1-peter.maydell@linaro.org> References: <20240220160622.114437-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org Move the reset of the sysbus (and thus all devices and buses anywhere on the qbus tree) from qemu_register_reset() to qemu_register_resettable(). This is a behaviour change: because qemu_register_resettable() is aware of three-phase reset, this now means that: * 'enter' phase reset methods of devices and buses are called before any legacy reset callbacks registered with qemu_register_reset() * 'exit' phase reset methods of devices and buses are called after any legacy qemu_register_reset() callbacks Put another way, a qemu_register_reset() callback is now correctly ordered in the 'hold' phase along with any other 'hold' phase methods. The motivation for doing this is that we will now be able to resolve some reset-ordering issues using the three-phase mechanism, because the 'exit' phase is always after the 'hold' phase, even when the 'hold' phase function was registered with qemu_register_reset(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Zhao Liu --- I believe that given we don't make much use of enter/exit phases currently that this is unlikely to cause unexpected regressions due to an accidental reset-order dependency that is no longer satisfied, but it's always possible... --- hw/core/machine.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index fb5afdcae4c..9ac5d5389a6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1577,14 +1577,13 @@ void qdev_machine_creation_done(void) /* TODO: once all bus devices are qdevified, this should be done * when bus is created by qdev.c */ /* - * TODO: If we had a main 'reset container' that the whole system - * lived in, we could reset that using the multi-phase reset - * APIs. For the moment, we just reset the sysbus, which will cause + * This is where we arrange for the sysbus to be reset when the + * whole simulation is reset. In turn, resetting the sysbus will cause * all devices hanging off it (and all their child buses, recursively) * to be reset. Note that this will *not* reset any Device objects * which are not attached to some part of the qbus tree! */ - qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default()); + qemu_register_resettable(OBJECT(sysbus_get_default())); notifier_list_notify(&machine_init_done_notifiers, NULL);