From patchwork Mon Sep 18 10:17:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 724147 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1601159wro; Mon, 18 Sep 2023 03:18:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdT0hNHbyNCF7l9XqynJDaCLOXmf6+Q6T+vov9bDLXuRnJIUKRF9Rq4rOSbntCVETFUv/I X-Received: by 2002:a0c:b2ce:0:b0:64f:518d:ac8d with SMTP id d14-20020a0cb2ce000000b0064f518dac8dmr8544529qvf.25.1695032330949; Mon, 18 Sep 2023 03:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695032330; cv=none; d=google.com; s=arc-20160816; b=UXZnL/0058XoqkctZnzK9AtxZBgWdkaSRQHjlaN+c3Jjwu2P4sVtrkQL4Q1ZGwlvEa h1hDml5hTahl0S1dLMssIX5BYACC0qR3AgGik8sMu8/KRun7iU0Qaa5tAuLigiuDRQiU wq1E/gUFUruMW+/JU7pv1b0ggJrBCoKNIvNDcTX+7bdYFllKucb0yUNyHFVT+GRbKLIq LN0QK86/Ufx3gGFXgfxX/DcowpPpfbQYSfB5d21J/Z7IHTNyr4lX7ngLfFEyfeQt4xSO U+1FNQZ9od7Sk0BlpCDTfrdV3ihFaL+fGDAT8Zdl1Rtl0lov7JVdQIkXIdIOFOWV3LHg GRaw== 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=+N+N/3iRKVrfEHVPUQcucmLszQ7ytIQTEiwcco5Pois=; fh=9n/Cm2KnMX6Qk7SoVbKt4LcEa/gSBuZo6NwnCSpbrp4=; b=wlGKxhn3dcHDL6dOvrjpNoJ8PIFSDtpNsaMpJ9vEWQIUnWagz0cRlqPbTV4DL/G+53 gi6ZcxdFZnMEQXVZhDTBJie5jyxyJSrNOiuFvOYFYsdByAnW5WM6aBAJ3mKB3hPvvDwK qdvHWfoAauNMJbZH8MIQmoHnjj2oCD/+2Fg8AR0uRWCKwhqce2DUg8ESNIFv//WwZE21 iuPnGLnwj6Ym0y155xoyQ2j71jUDVry2JOHJ1i7v6BtmWr3EaCSN+A4EJw18ca1euFnq 6pn5/IqIz+OawSw7a7ev65T14bqg+j7gWvgdR3Sv5clTpToBo9PIFAXbfXB6CWyeqLAE Qm9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R6YxzazM; 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 l2-20020a05620a28c200b0076da614eba1si6176308qkp.170.2023.09.18.03.18.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Sep 2023 03:18:50 -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=pass header.i=@linaro.org header.s=google header.b=R6YxzazM; 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 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Mark Cave-Ayland , Bernhard Beschow , Peter Maydell , Alessandro Di Federico , qemu-arm@nongnu.org, Luc Michel , =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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); 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 *host) host->fifo_len = 0; } -void omap_mmc_reset(struct omap_mmc_s *host) +void omap_mmc_reset(struct omap_mmc_s *host, bool realized) { host->last_cmd = 0; memset(host->rsp, 0, sizeof(host->rsp)); @@ -314,11 +314,14 @@ void omap_mmc_reset(struct omap_mmc_s *host) omap_mmc_pseudo_reset(host); - /* 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 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)); + } } 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); } - omap_mmc_reset(s); + omap_mmc_reset(s, false); return s; } @@ -643,7 +646,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, s->cdet = qemu_allocate_irq(omap_mmc_cover_cb, s, 0); sd_set_cb(s->card, NULL, s->cdet); - omap_mmc_reset(s); + omap_mmc_reset(s, false); return s; }