From nobody Wed May 15 19:39:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1695032331; cv=none; d=zohomail.com; s=zohoarc; b=eXCELk2IMc4VN/nfMkGFhXuQsZAohBDtWRiFP2aqSdMG99wsZkjl/na1cWEODemhsI4IrV/feUqB3ZqNFgOkm+FMzlkqNu79fFL88YHDg1FLb4WoDWc2H21Grq52vIsnSQVfjOAZzvr4KFpfL618DJqO7gYqECpy26G0jO/eVIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695032331; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+N+N/3iRKVrfEHVPUQcucmLszQ7ytIQTEiwcco5Pois=; b=HGvuwnxLhWAaoGDzEwAmM3svUGqT49Bb7u1XtqCabvmB3VXXzbyqJZQcOsNDilBOAKXlhDGnfPVNw//cuNEnCiK3eI/+Q6/n6AEins43FJ/iJKkmiOYjcjsvtfSOVs2KnuZooWf4Kd2JUs4Yw2OZIU+g6Ub6Ampkyyf73O3wS68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169503233143030.942427940662697; Mon, 18 Sep 2023 03:18:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiBKE-0006I6-CE; Mon, 18 Sep 2023 06:17:54 -0400 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 1qiBKC-0006Hi-7N for qemu-devel@nongnu.org; Mon, 18 Sep 2023 06:17:52 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiBKA-0006nu-C8 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 06:17:51 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31f7400cb74so3808291f8f.2 for ; Mon, 18 Sep 2023 03:17:49 -0700 (PDT) Received: from localhost.localdomain (5.red-88-29-175.dynamicip.rima-tde.net. [88.29.175.5]) by smtp.gmail.com with ESMTPSA id z2-20020adfd0c2000000b0030ada01ca78sm1139386wrh.10.2023.09.18.03.17.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 03:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695032268; x=1695637068; 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=+N+N/3iRKVrfEHVPUQcucmLszQ7ytIQTEiwcco5Pois=; b=R6YxzazMzK0pyfjwwiHM9RVk2MMjey8oBDhjW/fpjUzLkhZYYJCr25tewfft2L+yeA yuL+sLmxgnyX1pI3O4/ZulhFh48pvZIGO8DQ8PIFs1O+NkS/C86tSG6bJM1zH7ayoyLu +vpOEJDjlTpCzyJb4FUHGb07zzVdVRI4jw3KoAtPCYIF2atsoaT/Vcpyiym5uTlokO85 hsI4ZU+TcySkH4bk1MJ4cQ0yFmCLvIiFPG7kxrhtYSQzuduTMOC1gp7/245hr3okYHdn VIMlSWfzUbwXxit9QC2lClyRF7XnWMp34RM5Qv6V5afA3WpatRjuIHtGESp59X5VSd1Z EJWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695032268; x=1695637068; 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=+N+N/3iRKVrfEHVPUQcucmLszQ7ytIQTEiwcco5Pois=; b=FZsCgjWl2/jZHmZXDx3/ilJ/ca2D7reOL/koOPafzUbAUHG4tNiU6p8ILtPSGmvGZU 0fdNPacG8NYJzlRK13BZrAHGLKZ7eGDBul3mwpyCUlAhyuq0x2UJotJh3FG4xuGpElcK VS7oMeO+nJ7fAEnCdqIj/KIapOcT2dduGYJDtDR6oiXpqerts4br1ceeGFlhN+pRHZzE YIQM0YXGTyFJcuTUXykZo7lHokBLH0i/pzD9uCkb9bC5xs6wggAPdQ8od7yqkTDTxhCE 4258eawA/wAp4aA8Ro9HYVZbRcr/GVWqTYIf3tpXMoaWi7rprPaeJLSUVSP5AqhIjVeM GHTQ== X-Gm-Message-State: AOJu0YyNRGoE2FpyrbpzBy1S2OIC3ADzDjRPgos6X9EKKUojLeDgCCd9 PazGTXklmHgJEjRqnHgfAW9VHnFACuEpVdf9I8Yxlyz9 X-Google-Smtp-Source: AGHT+IHWMSpr0y6MCVX2hooNyuRT1fVi428WYsZ88A7x03zFL0krS2oMP2+1KEjkccO2CaSgsJp+4Q== X-Received: by 2002:a05:6000:703:b0:320:121:2300 with SMTP id bs3-20020a056000070300b0032001212300mr5316225wrb.1.1695032268227; Mon, 18 Sep 2023 03:17:48 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , "Daniel P . Berrange" , Eduardo Habkost , Alistair Francis , Paolo Bonzini , Anton Johansson , "Edgar E . Iglesias" , Markus Armbruster , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Mark Cave-Ayland , Bernhard Beschow , Peter Maydell , Alessandro Di Federico , qemu-arm@nongnu.org, Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] hw/sd/omap_mmc: Do not reset SDCard until being fully realized Date: Mon, 18 Sep 2023 12:17:35 +0200 Message-ID: <20230918101736.23905-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918101736.23905-1-philmd@linaro.org> References: <20230918101736.23905-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1695032332944100003 We shouldn't call QDev DeviceReset() before DeviceRealize(). Since the OMAP MMC model is not QDev'ified, it has to manually call the SDCard reset() handler. This breaks QDev assumptions that DeviceReset() is never called before a device is fully realized. In order to avoid that, pass a 'realized' argument to omap_mmc_reset(). All cases are explicit manual resets, except in omap_mmc_write() where we expect the sdcard to be realized. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/arm/omap.h | 2 +- hw/arm/omap1.c | 2 +- hw/arm/omap2.c | 2 +- hw/sd/omap_mmc.c | 21 ++++++++++++--------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h index 067e9419f7..d331467946 100644 --- a/include/hw/arm/omap.h +++ b/include/hw/arm/omap.h @@ -808,7 +808,7 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, BlockBackend *blk, qemu_irq irq, qemu_irq dma[], omap_clk fclk, omap_clk iclk); -void omap_mmc_reset(struct omap_mmc_s *s); +void omap_mmc_reset(struct omap_mmc_s *s, bool realized); void omap_mmc_handlers(struct omap_mmc_s *s, qemu_irq ro, qemu_irq cover); void omap_mmc_enable(struct omap_mmc_s *s, int enable); =20 diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c index d5438156ee..3afeba6f86 100644 --- a/hw/arm/omap1.c +++ b/hw/arm/omap1.c @@ -3728,7 +3728,7 @@ static void omap1_mpu_reset(void *opaque) omap_uart_reset(mpu->uart[0]); omap_uart_reset(mpu->uart[1]); omap_uart_reset(mpu->uart[2]); - omap_mmc_reset(mpu->mmc); + omap_mmc_reset(mpu->mmc, false); omap_mpuio_reset(mpu->mpuio); omap_uwire_reset(mpu->microwire); omap_pwl_reset(mpu->pwl); diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c index d5a2ae7af6..ef9b0dd60a 100644 --- a/hw/arm/omap2.c +++ b/hw/arm/omap2.c @@ -2253,7 +2253,7 @@ static void omap2_mpu_reset(void *opaque) omap_uart_reset(mpu->uart[0]); omap_uart_reset(mpu->uart[1]); omap_uart_reset(mpu->uart[2]); - omap_mmc_reset(mpu->mmc); + omap_mmc_reset(mpu->mmc, false); omap_mcspi_reset(mpu->mcspi[0]); omap_mcspi_reset(mpu->mcspi[1]); cpu_reset(CPU(mpu->cpu)); diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c index edd3cf2a1e..3c906993eb 100644 --- a/hw/sd/omap_mmc.c +++ b/hw/sd/omap_mmc.c @@ -287,7 +287,7 @@ static void omap_mmc_pseudo_reset(struct omap_mmc_s *ho= st) host->fifo_len =3D 0; } =20 -void omap_mmc_reset(struct omap_mmc_s *host) +void omap_mmc_reset(struct omap_mmc_s *host, bool realized) { host->last_cmd =3D 0; memset(host->rsp, 0, sizeof(host->rsp)); @@ -314,11 +314,14 @@ void omap_mmc_reset(struct omap_mmc_s *host) =20 omap_mmc_pseudo_reset(host); =20 - /* Since we're still using the legacy SD API the card is not plugged - * into any bus, and we must reset it manually. When omap_mmc is - * QOMified this must move into the QOM reset function. - */ - device_cold_reset(DEVICE(host->card)); + if (realized) { + /* + * Since we're still using the legacy SD API the card is not plugg= ed + * into any bus, and we must reset it manually. When omap_mmc is + * QOMified this must move into the QOM reset function. + */ + device_cold_reset(DEVICE(host->card)); + } } =20 static uint64_t omap_mmc_read(void *opaque, hwaddr offset, unsigned size) @@ -556,7 +559,7 @@ static void omap_mmc_write(void *opaque, hwaddr offset, break; case 0x64: /* MMC_SYSC */ if (value & (1 << 2)) /* SRTS */ - omap_mmc_reset(s); + omap_mmc_reset(s, true); break; case 0x68: /* MMC_SYSS */ OMAP_RO_REG(offset); @@ -613,7 +616,7 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, exit(1); } =20 - omap_mmc_reset(s); + omap_mmc_reset(s, false); =20 return s; } @@ -643,7 +646,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_ag= ent_s *ta, s->cdet =3D qemu_allocate_irq(omap_mmc_cover_cb, s, 0); sd_set_cb(s->card, NULL, s->cdet); =20 - omap_mmc_reset(s); + omap_mmc_reset(s, false); =20 return s; } --=20 2.41.0 From nobody Wed May 15 19:39:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1695032319; cv=none; d=zohomail.com; s=zohoarc; b=RC+y82DJLVv7A5VequIPEmH6TLSThy7rirOd3h2T9Hx3DpgEFxABEojoERWRo4sffYougPkZO8qO02RKGmGziT1EiC+bNsjY7iaecJlRdDzwEoWyIQBMUGkuUbk6RnytUOzXsjXMzBAAYLW+zMgRGVrde8A+KwCsiXF+mQbSHRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695032319; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8I52HFJ7JIIVf6/kc1x9A3KkqjzDotpu4ox1BgoUxm4=; b=QTiN6X/z+BO/D8BSW1P0BCU5BQLS8LRaxC8eqehPUC491DcKciv/W7s/z4heNvUPvmqPPczZtnshcZOJ4EY+7OUK7W9/TZNlquLfbfV5Yyzhv9G8Hx7p4jJ1/9X1OzEcfZhx/33fmxKwtbWxuex/v93UvrpAnKUlW2zvZfwHpjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695032319498434.39938187431926; Mon, 18 Sep 2023 03:18:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiBKM-0006JW-TD; Mon, 18 Sep 2023 06:18:02 -0400 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 1qiBKJ-0006Iq-Tw for qemu-devel@nongnu.org; Mon, 18 Sep 2023 06:17:59 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiBKH-0006ou-DW for qemu-devel@nongnu.org; Mon, 18 Sep 2023 06:17:58 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4050bd2e33aso7090895e9.2 for ; Mon, 18 Sep 2023 03:17:57 -0700 (PDT) Received: from localhost.localdomain (5.red-88-29-175.dynamicip.rima-tde.net. [88.29.175.5]) by smtp.gmail.com with ESMTPSA id c4-20020a05600c0ac400b004030c778396sm14945294wmr.4.2023.09.18.03.17.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 03:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695032276; x=1695637076; 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=8I52HFJ7JIIVf6/kc1x9A3KkqjzDotpu4ox1BgoUxm4=; b=NO/fDZs9W5HiqDat34WSBqcyUio2okr25QwI6p7cCubnPGxOYMSjJUAt6dy3hh81YH 21btOA8H3QDOeJMQiOQJrcfVVBbwsabxmWdKnrYBmVjrYbBypTVyT91Reaot9vk5GXE9 vw2aExYzkuIQf34C+wzcRQeeCm3O+IheKsWK7OKRUFJb9RDyLxW0EWp8HkQ5ONLtT920 gC8Fgli4TFKpfFdiBzr4JHiYJRegpW5c1CA1LzzRBziKvFoaaTiM7O3WBrCmkuT1njUY +jS1BSbqAHIlCMCxQqWpMtCQXsQZgULpDODi8XLKpDRdDBszwsGIYGjPcW8bGSQX7hz3 FDPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695032276; x=1695637076; 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=8I52HFJ7JIIVf6/kc1x9A3KkqjzDotpu4ox1BgoUxm4=; b=qP05ST8y5ktED1AoDxBVrZDAdk+2svM4fA1+Yn718h2qTq7dxrh7hcQAEDhNKAP4uk XJ6WMIpvpI+jbuAAjSfO0fJcfg2rjbbYGOxigqadZQDXk0x3xm4q7raFF9JrVQrxgunm yLenaYpKfR3t0U/Ia96vkaD6ebPYbWAruzGV0JwZIHSf+HvTBKxgcxE9WS/8pqcJ0pGu STh5ZlaHkgWrinPin/E4w1n5qg4RA0OgX9M2WwkI/fDXx0ypJJlwzeOY7dgCGs8dbq4H fa9TyYIqd+NiO+P2wzuXPG4p+2fNWLFW+AMbCg23aKzXGjWXpA5qZOHWyg9NjCGBCA4e 5wWA== X-Gm-Message-State: AOJu0YykxyHCHpATNckaMOQR6oQAQsngWo5yHWN/oJie/Wg0khw6E0YJ 8taBcqj8bnn5esdOzYeFc2a9T3nCE2WlyNouNCPRpNZh X-Google-Smtp-Source: AGHT+IH7/y3yF55C3oZAeNYtJqB5yvAg/wEoCbqXe27X2kIcnR9KuYdj/L9rALct7aG27VOWyC58xg== X-Received: by 2002:a05:600c:2901:b0:401:906b:7e9d with SMTP id i1-20020a05600c290100b00401906b7e9dmr7999543wmd.18.1695032275800; Mon, 18 Sep 2023 03:17:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , "Daniel P . Berrange" , Eduardo Habkost , Alistair Francis , Paolo Bonzini , Anton Johansson , "Edgar E . Iglesias" , Markus Armbruster , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Mark Cave-Ayland , Bernhard Beschow , Peter Maydell , Alessandro Di Federico , qemu-arm@nongnu.org, Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/2] qdev: Ensure devices are fully realized when calling DeviceReset handler Date: Mon, 18 Sep 2023 12:17:36 +0200 Message-ID: <20230918101736.23905-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918101736.23905-1-philmd@linaro.org> References: <20230918101736.23905-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1695032321008100003 We shouldn't call a DeviceReset() handler on unrealized device. In order to enforce that, add an assertion. CPU devices are a bit particular because we manually reset them in various places, so corner case them out for now. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 43d863b0c5..c51b4c98de 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -252,6 +252,8 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int = alias_id, =20 void device_cold_reset(DeviceState *dev) { + /* TODO: Also cover CPUs once we removed manual calls to cpu_reset() */ + assert(object_dynamic_cast(OBJECT(dev), TYPE_CPU) || dev->realized); resettable_reset(OBJECT(dev), RESET_TYPE_COLD); } =20 @@ -280,6 +282,7 @@ static void device_reset_child_foreach(Object *obj, Res= ettableChildCallback cb, bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp) { assert(!dev->realized && !dev->parent_bus); + assert(!device_is_in_reset(dev)); =20 if (bus) { if (!qdev_set_parent_bus(dev, bus, errp)) { --=20 2.41.0