From patchwork Tue Jun 25 05:53:42 2024 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: 807237 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195611wrt; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/TVNff9sEmMAa0ZiCaZo0ka69IbO2mpXYFcJzUSo8o44EV1cvjxfz8park2EbTndfxnrrP+CeDcLxLt8SqzPy X-Google-Smtp-Source: AGHT+IH3jUIMLiiirBbZ7JE6ATi7QrkcIkuo3bM6c36S9nLLO072EgZfKJdf0gKNZ7Rh9j4pyKPl X-Received: by 2002:a05:622a:548a:b0:444:9f76:83ea with SMTP id d75a77b69052e-444eee174abmr43545541cf.23.1719294914034; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294914; cv=none; d=google.com; s=arc-20160816; b=fDYEKE0t4oI++qY2amFXT/OyaZdZq9YoQjv9koA+Ewcgq4WctEdw5HJXJUY08uKNQm f0WHZa7BB67mDYmmVnuuo67vHhoAOg3x8t4oD5DGnnqfpuq82DIC7y4INgHbHNFTWhId JnzBAK4ASK7+lJ2ZtTYxNXvuyry0NFjLYM6yPWhGvmtn1d4OffgYHqLH9pQpYX/dSVmF SqlqjThBk9KbrC6TAoXbVQAn4OT9BaTbMWhdoM/9fWwsz6DTOhMo7Pyl0sxIS6WVmnwZ k3e9txEeL8yWwi+6WjdKpbrObdVO7krz37vexH2u6+Wxnn/3JU/kwXrvgU2NcdmKt7TC hVwA== 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=FRec2147tzGGJgDwnAFCM7MdLQrzjYCwJA0fQ2k29gM=; fh=1Wxb/i2cR4f+aVg5BTvU+lrsnHBZmrcHjHjV8dFwld8=; b=rUwnYAolxH/FJAWBM2ZqEQ/pT/vXNYAZr0mhmcCqB/CZu7rcSBNZDYV5AgPRBGqu4R NU1NIvgr0r17scAHmcG7QlfNYukK95WW5JUfCoxjdk7rSsUy5hciH4LidHB95eg5m6jF ezgkCdis+691bsP/629eMGXsHiWAnUR/hLjVUKnZesvHvNhfD+ZhKAY/8OkWSyylOT6z Brq2tWpwm2NIoy16P1sCdwYJjI1+o+1Wl2nc5veZaPDmWl/KHZIBdwX0uYr2vlaI640g a7eKKRNZCcEQ12Jiis6qlMoMx0Vvdb2Mz+1kdeUwGTKCFJQ97uym9HcGRqLhC45DXj1G FLmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lbXzn8zC; 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 d75a77b69052e-444c2c389d4si96680751cf.463.2024.06.24.22.55.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:14 -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=lbXzn8zC; 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 1sLz83-0001bA-Qg; Tue, 25 Jun 2024 01:54:07 -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 1sLz82-0001aQ-7z for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:06 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz80-0001Wb-GP for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:05 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-424a2ad06f1so1798535e9.1 for ; Mon, 24 Jun 2024 22:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294843; x=1719899643; 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=FRec2147tzGGJgDwnAFCM7MdLQrzjYCwJA0fQ2k29gM=; b=lbXzn8zCEM/eFhv9FQbcfblXmtgXwrTwVOnwN/0y0nzt2U0J8Rr1YaQAjKRMaSBX4s zEHh0IUOk2Q4vRDE39zXnoW/g6XoLCR2sZ8OUqakcyI+0MeT/e77ISrl5ChETnyfUupI jwp4YFLhQ0j5QBKcrc0o6nAxegIdE9GtewtkxaSlnD1ATUb4S4LoDhDCQ9dSNGomSFEs o4G0Kqn8MXlPGd6wUquyT+ntBVuiYhGYsloNtKZ+lY5kNtElQWWQ/UZle+F3B1+Xlzxo fNV1a9ego3cYth8kOwr7dxhCH7P0dsB2pVOIpCBRiYgu/j2QXaJm2BPqd2ys62WcWOVc PhAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294843; x=1719899643; 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=FRec2147tzGGJgDwnAFCM7MdLQrzjYCwJA0fQ2k29gM=; b=F9jDbat2ooKc60dqo26UA2BJEAwEp7nD3IRsrODrK25E/SyxPnV9bON5oEY+OzK0Lr oZO9kRmFFx3g98h9dL2isUSdMGbPjqLogLEd5gHMjI24wR+y3BVVcR8nMiqnz8brfHEq ue1PxtTJNtqR/4Om1MsZ2zMb6DmoZop8d6ySj2ONs3fqiXa2ICcsXqWJ/hjtsOx9JoaQ GnRhCtbmGwTkn2N8am/5G1VvdDnO0EZT345ytthExQY+qgF3+Kon8VjBjIfvp3oB3LGA MJuLwG3+WasmGh1Zy6YRINlIdYOzCkD1fFeGE+9/jpw47ygnKMP1PLcVYItViEVe8d1G 38yA== X-Gm-Message-State: AOJu0Yz4PeIP4HYjvcZx6o7P38K4r//gV7AaisesmN1uShBFAqbqpqiK jybN4deIPAMPnrTZe9n9UMH2epSkxok2oAQS6rJqPU8rx7gFgef5at+rHlPTSZf9qK5zj03bWWG 0 X-Received: by 2002:a05:600c:3c91:b0:424:8fe1:41f9 with SMTP id 5b1f17b1804b1-4248fe14320mr36673165e9.11.1719294842831; Mon, 24 Jun 2024 22:54:02 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424a49d6112sm4561375e9.6.2024.06.24.22.54.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng , Hao Wu , Shengtan Mao , Tyrone Ting Subject: [PATCH v2 01/12] tests/qtest: Disable npcm7xx_sdhci tests using hardcoded RCA Date: Tue, 25 Jun 2024 07:53:42 +0200 Message-ID: <20240625055354.23273-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Disable tests using 0x4567 hardcoded RCA otherwise when using random RCA we get: ERROR:../../tests/qtest/npcm7xx_sdhci-test.c:69:write_sdread: assertion failed: (ret == len) not ok /arm/npcm7xx_sdhci/read_sd - ERROR:../../tests/qtest/npcm7xx_sdhci-test.c:69:write_sdread: assertion failed: (ret == len) Bail out! See https://lore.kernel.org/qemu-devel/37f83be9-deb5-42a1-b704-14984351d803@linaro.org/ Signed-off-by: Philippe Mathieu-Daudé --- Cc: Hao Wu Cc: Shengtan Mao Cc: Tyrone Ting --- tests/qtest/npcm7xx_sdhci-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/npcm7xx_sdhci-test.c b/tests/qtest/npcm7xx_sdhci-test.c index 5d68540e52..6a42b142ad 100644 --- a/tests/qtest/npcm7xx_sdhci-test.c +++ b/tests/qtest/npcm7xx_sdhci-test.c @@ -44,6 +44,7 @@ static QTestState *setup_sd_card(void) sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x41200000, 0, (41 << 8)); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_ALL_SEND_CID); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_SEND_RELATIVE_ADDR); + g_test_skip("hardcoded 0x4567 card address"); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x45670000, 0, SDHC_SELECT_DESELECT_CARD); @@ -76,6 +77,9 @@ static void test_read_sd(void) { QTestState *qts = setup_sd_card(); + g_test_skip("hardcoded 0x4567 card address used in setup_sd_card()"); + return; + write_sdread(qts, "hello world"); write_sdread(qts, "goodbye"); @@ -108,6 +112,9 @@ static void test_write_sd(void) { QTestState *qts = setup_sd_card(); + g_test_skip("hardcoded 0x4567 card address used in setup_sd_card()"); + return; + sdwrite_read(qts, "hello world"); sdwrite_read(qts, "goodbye"); From patchwork Tue Jun 25 05:53:43 2024 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: 807239 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195620wrt; Mon, 24 Jun 2024 22:55:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhLtwGQ4FRFyHhVUzteck5IPN7W+eIA8WMzXhFXTehAiw2vq9K9/sPhosV57XqftpamsgUiv1Mw7fvoSjDCOhf X-Google-Smtp-Source: AGHT+IGPDrPwhWviqKrgd0NnIUkrVnTBB/iZWqJ+xzGqBkHY3Q4vbGRNHi+TyMQYBNscVcm5KnFx X-Received: by 2002:a0c:f6cb:0:b0:6b4:fead:738b with SMTP id 6a1803df08f44-6b5632e24c2mr46881026d6.6.1719294914873; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294914; cv=none; d=google.com; s=arc-20160816; b=BFNtnq/yRwbPo4SndX83WXtZzSj6jVe3pKnKP4fVwHHUwX+Z4MsKpsOamets9TfG3c /ME6OQlbpJWXcNB4rdS2n8jLCJkncPdJZ6GSDidVtYK+nD1DqLYwI2eC6t2jqBvHtMFf UQEYOKtxHjC0jAp+w15BnlmrurhIXYEFEHTvh+l4U4Xh8QtHrSPjU3KjEvbqXhPCf+IX TC94SBw5qZTEHvVOJLvFQjCg0Hr5U+OGWmM/E99WHNzydD2wp0VwyPjaw2sp1r8OgZD/ HW8K83Yq616HwM7W0jgM+R2QYjpnKURwZ13cv9nShlIpLnKkzQ0y0adTUJM4IZRyXAX2 09Ng== 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=MsF8niTdQH3Vk+tuBHzzhdAif0xIcoOBVyM8lpmJF7M=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=xzLpX6lx37B297oAK0H3gE5CSgv8fWr7AkjpfR+txumx9S8/DDFJp4K5CbFitIlnQb OLHeCb6yPWEkRl458HeYErcnl3zxBitTypbaYJmkh/ODtYyJDPjRVzS5+KREfSJGvuSH XMLD5Wh2F9ixfJ6lkT/STubCATYQVso9fuRgWWwhcgfyCmctqHblTpOnkC8CLEocQ2hs 2tZiRll07x7uM1iRBSXuGry5FKLQ1AAjovT1Q4pwkUZfqD60AKwFeiR6A6643HuWwyyx ocG0OkSQX0b74K4kTktJPSjFHboiHaE9wbjZACvkGGftD5Yb6+6dqGyGrc5SqQHa7Fct k/Zg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ons9rj7Y; 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 6a1803df08f44-6b51ed133b6si99091466d6.126.2024.06.24.22.55.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:14 -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=Ons9rj7Y; 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 1sLz8A-0001cL-CF; Tue, 25 Jun 2024 01:54:14 -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 1sLz88-0001bY-0N for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:12 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz86-0001Yw-El for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:11 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52cdd03d6aaso2934485e87.0 for ; Mon, 24 Jun 2024 22:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294848; x=1719899648; 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=MsF8niTdQH3Vk+tuBHzzhdAif0xIcoOBVyM8lpmJF7M=; b=Ons9rj7YfM1tfAl1ZK0cfaA9xpYUfWSjT13aoDvi/whcoiglKyLplYWCtNgMXKj8df fpU+4XJzmpjfSpsDUNlnBONaP1Rbwcz652iJxLjlC8US9PWi/MLxvUHQyZIyg4m/cCwq HknRNt7TPytOZFvQttx8m6NgOCIeemxO9A5juuzLGzcjBKiFiCSlpMSq6xNwIi2ebnBI Cq2phsfgluMSh5htyZHGlruBYd5rAQNCn+0J5TNAeUQj45KC4ZnM067ZMkLPbvh14tLz Nxx9hrHBbP17+lxHVgpIdTSCmuApPGoNoWsfH1zFx7e+R7pZymBHGVa9gl7c6Sl8Bjop yfQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294848; x=1719899648; 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=MsF8niTdQH3Vk+tuBHzzhdAif0xIcoOBVyM8lpmJF7M=; b=JO8tK69Bqra2pEGviOp+iE2jWzlKXL214+K2BVWkMjEvD4no/MX76KoVKSt9xFJxwL VEcN+AZ20qlDs3zXPSTXmSUDwmPDDTdcaPMCwHmXhIkAnz4EDNEUaCETdqic4G6L90gl P7Shpcdz43uL33xXHvXn4u0FLYlW8xpufnhqZ2kAgeuHHPvtD1dr0K/Spn/zGV8hwsps PSG0D/QXqPQ9VNwzQBLU1remeDl4yR7y2DohKPtjLHU0kATnk5s+jBaRlJ44KHYYrq2b +jHTpVw9uBcTipjrVXLgiUqa23PGjtNyGflx2T4guprhh446StIYDWI256kNlY+N4Srw R2MQ== X-Gm-Message-State: AOJu0YyQTRD0X5EnlVyfCwK+Gujjxx/EU960VRw8fT7Ew8dMAuGWcFj3 zUcCNVkUNYqRcE+zhYrc0laMKq+C5yfM0kzDPkzZR/+1Bbw/WMVc/DrerC+0BVxsYRVyCgAo6ZY e X-Received: by 2002:a05:6512:3e0c:b0:52c:89b5:27bc with SMTP id 2adb3069b0e04-52ce0673582mr4629523e87.42.1719294848316; Mon, 24 Jun 2024 22:54:08 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191fac8sm156993215e9.42.2024.06.24.22.54.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 02/12] hw/sd/sdcard: Generate random RCA value Date: Tue, 25 Jun 2024 07:53:43 +0200 Message-ID: <20240625055354.23273-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than using the obscure 0x4567 magic value, use a real random one. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a48010cfc1..ec58c5e2a6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -46,6 +46,7 @@ #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h" +#include "qemu/guest-random.h" #include "qemu/module.h" #include "sdmmc-internal.h" #include "trace.h" @@ -490,11 +491,6 @@ static void sd_set_csd(SDState *sd, uint64_t size) /* Relative Card Address register */ -static void sd_set_rca(SDState *sd) -{ - sd->rca += 0x4567; -} - static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_adtc) { @@ -1107,7 +1103,7 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) case sd_identification_state: case sd_standby_state: sd->state = sd_standby_state; - sd_set_rca(sd); + qemu_guest_getrandom_nofail(&sd->rca, sizeof(sd->rca)); return sd_r6; default: From patchwork Tue Jun 25 05:53:44 2024 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: 807246 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195740wrt; Mon, 24 Jun 2024 22:55:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPGhamG0A/JpfxZl/D6/a2PuPIWwozYTdc9S2wXPClri2J8FbuI6dZNqtVLvBIyvJSllKB/UB0lx40rl6/Ao/U X-Google-Smtp-Source: AGHT+IETnDPp0VZwZBcS17YMexYOABH462mvKCd3hzCwgOWPeY3H5eGSUXIq+1HewOa85NpTccZ+ X-Received: by 2002:a0c:dd8c:0:b0:6b2:e201:a366 with SMTP id 6a1803df08f44-6b540a12f9dmr64679386d6.39.1719294949760; Mon, 24 Jun 2024 22:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294949; cv=none; d=google.com; s=arc-20160816; b=s3d1+/gQDxudV239VE9kAkM51gz/03dJANNLAxJQhSQWZhGKAjezj4ljYEParJGn9P KAy0/QJw9kOp7ftWh2Z6TQeiSVxfFwimYTzaqALwIXJ01rnSBEtrBG4cekMUflVYtL6n N5kAi0CZmPqbjjGU+uN6i/+vs2JlqehToVOBze6yOZcCUtw2JsyurGDVJyWfe7NCnMeW pnhdjyuC/wMjog3WxmDH5FFq+2FvY0iMOxs6HwOVwy7kUs2GsCBOfcKtpNmHKBVIgvfC w8q27If40A1IKZdUdkgdA9jIWaC8nh9RB6QIqBJMbkRMXd6t7xFDSmmDIT7suC1onmDd gQEw== 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=+Dw7TbCqvf3FA5r7Q8Kk2fU8m/vY/FUcBZ3OzTc5F+s=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=UTFKrHri6ZMmDwjjqVfd4MecZWGcP0X2aF2y2sn91FgKQ0m37asNGGRCI+NlPTrBLq 4LSCqpYErpaCIn1zkxYTC9AREskRscxdiVx6cTvb8x5qhgpKWIWZxTHB9m/7B5q3qzWd dLIgAZzxrh0fQAfrGMv5fC07xFAIY+gJwKDS1LTUOFxBKLun1BhesY8IbzaM3H65cWVh DrQd6MUHTcQ0soOqup95I3iS0pnq7G89a/6aFJ/8S8XHyhyadK4aBR+1gc+7x1A/JKZF WW5qfXhs+F4g+s0wtsmFeq1XT0qV0NELzpF9jW94ovhQiSssFweNjjgOrf6qGjYYYMMy ZU/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GMg2j5T+; 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 6a1803df08f44-6b51edbb907si97992716d6.269.2024.06.24.22.55.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:49 -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=GMg2j5T+; 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 1sLz8F-0001dO-0a; Tue, 25 Jun 2024 01:54:19 -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 1sLz8D-0001cR-2q for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:17 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8B-0001Zn-Hb for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:16 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-424720e73e1so42223355e9.1 for ; Mon, 24 Jun 2024 22:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294854; x=1719899654; 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=+Dw7TbCqvf3FA5r7Q8Kk2fU8m/vY/FUcBZ3OzTc5F+s=; b=GMg2j5T+iuAn33zVveDz8E0MOwz3R5bgqXy3vVap0o62HLsN48KXttFPRLoVLZSUul ivGdt8fSmxfGyIp0udlgFDCEV3unvIPZMUDQdZP5zGKJpPTk31ZpSAaZJ1sicfemxJYc JkhrtvOulzloU2Onc9gb9/mjh3jOwn1zXMP5yxI7fTIrftiBS5bD0Wp5KlaUYXUgxigj yM7jC9Upmv+Hb6JAmR+ioRjYdeFbYpQcmKf0wC8muejCeqYHRmyccJMWYJBfZjyqlcxG 36sKdp76QohsJyOyDxnGYO/erBzNHDmpzRFwaAYPjh/G024AkOsWvWCgS9tYQqZ/EPwH D1pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294854; x=1719899654; 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=+Dw7TbCqvf3FA5r7Q8Kk2fU8m/vY/FUcBZ3OzTc5F+s=; b=uJdGIUCITS9JzulK8+HrReizvAL1oxfQIS2Nv+qlDyS+KAAWvHF6WdoRVeTi/88uA5 /kqSf942C8Ec+vaKLRswqlgPmmDOFWgRvO0PIOAskODpqzv83Cbh3BAGVAxnI7r2511B Y9D9Rmt4o/Bx6niNt8ykMtCNzo0/b17BvVoBHsWAZblMhHkQpujmWlBDl8/+nxSXKsoA xPaAcpc9umQzh2WXqTTUkYlw5ZcplsAcbEA8Q+rbi6h+NuKOwklg1gUDeQdnsjI5RYdR H7W/twG12VTOFD8AvwWz+mqmZRNkMhh0xlWraZpbX4XeCkpYGeP/YE+MwwC1QprSqts5 qGqA== X-Gm-Message-State: AOJu0Yw0XW6ePdd8UkBBqmdIT6d6NWvbX27gyO451wi94VKDM3Qm+Sz0 6LWfc9R7ZsH2Y+HeM3u+eCeJs9MVyhbPlkRHQ4bIYZ7v7kPH13PWAC6wOYrFOwFXwk0lK6/M99F c X-Received: by 2002:a05:600c:2d05:b0:421:82ed:28d1 with SMTP id 5b1f17b1804b1-4248cc73e25mr42975115e9.41.1719294853895; Mon, 24 Jun 2024 22:54:13 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3666dc46d50sm11549452f8f.67.2024.06.24.22.54.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 03/12] hw/sd/sdcard: Track last command used to help logging Date: Tue, 25 Jun 2024 07:53:44 +0200 Message-ID: <20240625055354.23273-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The command is selected on the I/O lines, and further processing might be done on the DAT lines via the sd_read_byte() and sd_write_byte() handlers. Since these methods can't distinct between normal and APP commands, keep the name of the current command in the SDState and use it in the DAT handlers. This fixes a bug that all normal commands were displayed as APP commands. Fixes: 2ed61fb57b ("sdcard: Display command name when tracing CMD/ACMD") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ec58c5e2a6..14bfcc5d6b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -134,6 +134,7 @@ struct SDState { uint32_t pwd_len; uint8_t function_group[6]; uint8_t current_cmd; + const char *last_cmd_name; /* True if we will handle the next command as an ACMD. Note that this does * *not* track the APP_CMD status bit! */ @@ -1150,12 +1151,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) uint16_t rca; uint64_t addr; + sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { trace_sdcard_normal_command(sd_proto(sd)->name, - sd_cmd_name(req.cmd), req.cmd, + sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1616,7 +1618,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - trace_sdcard_app_command(sd_proto(sd)->name, sd_acmd_name(req.cmd), + sd->last_cmd_name = sd_acmd_name(req.cmd); + trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; @@ -1909,7 +1912,7 @@ void sd_write_byte(SDState *sd, uint8_t value) return; trace_sdcard_write_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -2065,7 +2068,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; trace_sdcard_read_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ @@ -2210,6 +2213,7 @@ static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); } From patchwork Tue Jun 25 05:53:45 2024 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: 807247 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195794wrt; Mon, 24 Jun 2024 22:56:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoljDvEZn8kvTT59nMrVtqKUDxE8/MxmFyLbC6PeLRWYvJdhyvU0hUa907gMv9WG809gYfiqYAgKztIrExL7ms X-Google-Smtp-Source: AGHT+IGaRcqd7MVhVW0SVTu7UJ3bqq7ZsRjJpERnfJa7d3A6pm0jyU5EowJlGBt9m7+UD39IjHGI X-Received: by 2002:a05:622a:1b8c:b0:444:f42a:eb8 with SMTP id d75a77b69052e-444f42a18f9mr8811811cf.27.1719294963347; Mon, 24 Jun 2024 22:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294963; cv=none; d=google.com; s=arc-20160816; b=mtniPRQD7dV96xrARwNr+1RsPJ8c73YDayVzBLfmBvsHHlSa9WWyKMZxfVKzBZ8ZTq HjKJK5P7QcRiisAl07jHuQaHkzGy3Pbsx5yOqXpx3pPZF9Eg7VJ61Y45jcUtDz7A6CIh FnooBysnSV9DSl9+oSyAcAfvxi9+g4aIPOLjtx150KMXcftSaX65dPjrq+vDusWlqkNs 5UaaVqnUj5hdHyVKEA6M+UZqCh836jjN+n63ZBsxk733yTgXxrkm5K7o0R3MdRjs93d6 qrYGhLqUWJHu54WIrzgS/za9JUkQUvQsVUzs5xloPMIASZon/EnBWC0L2BDsv/GLBjZH wjBA== 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=QasiI5Og3o+xZHl0uXbjz82y8xzUq9DKLys9TXhovwY=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=znja8UZGBmg4PCwdYFD8j0oRgnDm2t8mAzvvqcGIi9D2Ea3fJ69Vi+rgyoFfVVi0sz SPZaKlpmqZ+/XZIzAeWo/0k1nN0NrTR6vyx+YELGyzmZkf0L/RZ1JGBLYGT0P511//38 ADCVOwk6dAhvUb63dV8vT3klks3xXSlqLmk7PFh1cLNILf4t2DsepRpvzEChsmdpR6Vz EJAoitlLefPqm8X63AgW0gdVAz3nx20X+YV5rKjq/oLE9tZhEj3Jm68b63hAq40jtYBF zkk4TGd3nawgPDBp/BkLm2Ar5ryDwNoKbwALKr+5aUoFiTWTZ0z72M/gXYiXacvOjhNw Gtow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+fGnjib; 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 d75a77b69052e-444c2c64cd5si97008021cf.552.2024.06.24.22.56.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:56:03 -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=B+fGnjib; 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 1sLz8K-0001ek-C5; Tue, 25 Jun 2024 01:54:24 -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 1sLz8I-0001dx-UU for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:22 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8H-0001am-FD for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:22 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42172ed3597so29971895e9.0 for ; Mon, 24 Jun 2024 22:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294859; x=1719899659; 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=QasiI5Og3o+xZHl0uXbjz82y8xzUq9DKLys9TXhovwY=; b=B+fGnjib6o/XAH2VhPr4Lw38NqLOqdkWhpfNVqwvZLcyI/5jxfvmOyQ7mWxen7la36 S2B/Qr09hyXOgXH5/JFY/omSaEjJNfxeju3DquYWqBwBLCHHJREtfCuW/Rkh5NQR75mK X4XkYA71u8PgKHg29r0f6NmFqg0W8r7iVjTUbB3ETpEFP1C0q/gHr/3IT8n5Xsyqqfa1 iTtHHNFkX3UfNXblN7DrNRnb8BPGKDwYdOx+isiVz3k9tV18dcvyra1mgcye/oSMVxGF yUb52XPWwoyOx447vvcOwXjAp51TwEDRXeMgemUh3WAk0ulMYzcllnT/imJIeFoOQp16 8TaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294859; x=1719899659; 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=QasiI5Og3o+xZHl0uXbjz82y8xzUq9DKLys9TXhovwY=; b=kna4C42r0RP1634s+pXovDzzRFZ0IiO2fUz6PmJItegpYppkKMsL6MluhrXYmxUOEG rIJh48PMDv2Y6yp6JyLUFmwZ4F2HAkUwSRdAgPUjyX2kbv8Sia0nKkz1b1PBCqRA+y4L 0n4Lb81SqfS+B5qxASfGgArPuycfkHcwOM3kmsaqM/Njez/u5202sCWsrl/gUvxaowL2 EEYkiA7oij2MI/b+PaaUVrt3TzdKfVlUKqvgJEb/NEf2qjPY+QlxbryW40vgBrnLVR54 PN6lER7Qv1UZbUojKBAk2HXp8w2CGr2Q3gPNVCkr5BAGrWz0rUXNSXUlru14/6yg19A/ G/oA== X-Gm-Message-State: AOJu0Ywc9T2j2Rx9kb10lqn3YysaeDbSgvqgZKdXwPxg0o3YuGG9wvw9 Kpyb3b3MNRoSybHKxPd7T1yOQtfJAiQk/pWqTgYE4VcZOI9V2gkjTyAUxLTiwKwozlEKHf5ddAg q X-Received: by 2002:a05:600c:2e04:b0:424:86fe:ac99 with SMTP id 5b1f17b1804b1-424895eaf2dmr72866125e9.14.1719294859638; Mon, 24 Jun 2024 22:54:19 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0c54c9sm199933385e9.27.2024.06.24.22.54.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 04/12] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Tue, 25 Jun 2024 07:53:45 +0200 Message-ID: <20240625055354.23273-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 14bfcc5d6b..e4587a0a37 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1913,7 +1913,7 @@ void sd_write_byte(SDState *sd, uint8_t value) trace_sdcard_write_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, value); + sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] = value; @@ -2069,7 +2069,7 @@ uint8_t sd_read_byte(SDState *sd) trace_sdcard_read_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, io_len); + sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret = sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 724365efc3..0eee98a646 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,8 +52,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c From patchwork Tue Jun 25 05:53:46 2024 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: 807245 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195736wrt; Mon, 24 Jun 2024 22:55:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEYEFyeaY4AWIYtvFSM+osEHNH4+E4uzY01rgQ2G7nsq62CR4vBOrwACdIGtBTwUtoXVCROreNiDcD+V2HHtOg X-Google-Smtp-Source: AGHT+IE0AnOxF03cpRvM2qi+0AiUXRBpCzqojtEGML2lWbLQ2BzOnHY3Q5NKLm6Ug+8klbXDYVfT X-Received: by 2002:a67:ee41:0:b0:48f:3f55:c550 with SMTP id ada2fe7eead31-48f52a356dfmr6754371137.16.1719294949177; Mon, 24 Jun 2024 22:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294949; cv=none; d=google.com; s=arc-20160816; b=CEmILRZlOPvitB+ZIkkZFeJ7e33ZPU/lNDbfV8Cn5zf4bXHMXIHOgFTyQcwptBF418 LbbeWmZWXxHq3x7Tcbcu2Kl+nQcy1aYwZzKDJILLrh50ZaaYeixem/B/g4NLvBSmMd9/ l1GAwvCcAeatSHjPdw0QXXxxtoTK+G5qIObrMyffvBSawzh/be/Q4Vipb6VbPOicy8Ou Q+9GIw3BecPp56zuDmLPLsL9+q6+KfNoxaB3S21mUbtTCtvv0jSZXu1aWCnub48eJ0O+ fNLoKFGm39r7oLV2MhwghfoN7/pyFSKbJWwi5Npcr5SEpEq5Auw2ltvOTvx+ORJfuM0i ax4g== 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=Jx8nddqay2J5qb2F3WGg5BgvSRB/NLqHqQ/hS1TB/ro=; fh=kCRCpXTlg6+oYN72O8LggFIMjcK4P6HtgE+/z1k9kdE=; b=UpPqDY9ZQaVZDdRWxNfbHBNxgwNxUSwtweo32PUtSfXXzZa5QjFcidVFvxFSuwSJ/H qyqivOz4Jxp1M5Q/HYrfTfsAj6T/CdyvDnKMb9J2CQ1YOtOy1Nccfq91HZbRJk6CHPKS bCTc4IPuRB/C4Cwt686g7o5e6/BTXVKvfS75RD9H9AjZzgto6N6yEyuvxpQ45FGgpsMp lgRzNbRz48qsDRty6tUJ0dO1O96g46b/byVeGOIImPYrk9B4fYZLhHP7BqWAuFkbYdKi bG44QCmdteobaUHxfaDfDHAXc3KuDtPRZPMUEIqOcK3x9MrrThOri9AW8UNR97QXcSYZ yaXQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BHgf19KF; 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 d75a77b69052e-444c2c0bd57si97812201cf.230.2024.06.24.22.55.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:49 -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=BHgf19KF; 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 1sLz8P-0001fs-R4; Tue, 25 Jun 2024 01:54:29 -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 1sLz8O-0001fP-TI for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:28 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8N-0001bl-9P for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:28 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3636c572257so4373476f8f.0 for ; Mon, 24 Jun 2024 22:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294865; x=1719899665; 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=Jx8nddqay2J5qb2F3WGg5BgvSRB/NLqHqQ/hS1TB/ro=; b=BHgf19KFSS35ocGMl5MjIlgWSey0IrQlkmrvZVEQI7itULuEjgpaCyKzgvGIVqTyce fmk9a0ZOVbieokPHS9d5DNQ2cUjZA7pYuD4DDJieHkgFvXTSgIh/NTCBe4PmjRtdVpVx kNu1JW9X26TsvZozqD0XDZk7x8jYSCkLynsmA8PI8kF51g1VpGHF0C+cJ0YwbZCGEUnL 3Mu2o+tptn1xNJlH9Q7X04yz3dt6Y/0JUT936PdlpsTDl7Ny8V+TNYbd0DQ9MfYJvojI QTi5hS9xTVoDdE4+xnmay60kxpO3JIrdkv6uQERK8luydxHTKCTm7cTYibFFpUezRFBG EvIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294865; x=1719899665; 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=Jx8nddqay2J5qb2F3WGg5BgvSRB/NLqHqQ/hS1TB/ro=; b=l1sZtTdpMOiF/cW2bI5Wxo3f9ymEN9+cDszYRmnTpl+Y4D+yxhWRxUXpNaV+UggtBZ rIYfQxFEUp66K+mE/hzFu8MazfAPHX7pcRaL69yUnbxjpwbvBxW4Ok+ySUF++O1n+NYn 3TUpvNuLG1DvgMzby68ognRHcjG/YGBcRy4EBn0aEea4qKmkoik1JCnMvCIvCaOC5v7W CVfjltcfREoPIQzFQPoTwvEL72A/yYwzgaoG1lgkFzTigh/rxSydYt77CGgcYBvzRRtc 7Ptlvfwoib6Jdr/LaXwJPOAvVS4sG+yoYeboAiO9JQ55/4LTandHTYL250YVaQNavkBl 3USA== X-Gm-Message-State: AOJu0YxxPtUmUG3qfU8qQ2m68OPF1NGi74OzQFN33AzM/Wpocxkb+ptK LtRjvond+c7nP3aVkPKqpT4s6QskvN7G6eizzKc0maQGLUrJuk42ZwEqWYqN4C7iDSBZbJIiwqT j X-Received: by 2002:adf:f450:0:b0:360:9a40:3dd8 with SMTP id ffacd0b85a97d-366e96567cemr5210858f8f.65.1719294865378; Mon, 24 Jun 2024 22:54:25 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d208e13sm195345575e9.36.2024.06.24.22.54.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng , Peter Xu , Fabiano Rosas Subject: [PATCH v2 05/12] hw/sd/sdcard: Do not store vendor data on block drive (CMD56) Date: Tue, 25 Jun 2024 07:53:46 +0200 Message-ID: <20240625055354.23273-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org "General command" (GEN_CMD, CMD56) is described as: GEN_CMD is the same as the single block read or write commands (CMD24 or CMD17). The difference is that [...] the data block is not a memory payload data but has a vendor specific format and meaning. Thus this block must not be stored overwriting data block on underlying storage drive. Keep it in a dedicated 'vendor_data[]' array. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC: Is it safe to reuse VMSTATE_UNUSED_V() (which happens to be the same size)? Cc: Peter Xu Cc: Fabiano Rosas --- hw/sd/sd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e4587a0a37..0f8440efcc 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -143,6 +143,8 @@ struct SDState { uint64_t data_start; uint32_t data_offset; uint8_t data[512]; + uint8_t vendor_data[512]; + qemu_irq readonly_cb; qemu_irq inserted_cb; QEMUTimer *ocr_power_timer; @@ -647,6 +649,7 @@ static void sd_reset(DeviceState *dev) sd->wp_switch = sd->blk ? !blk_is_writable(sd->blk) : false; sd->wp_group_bits = sect; sd->wp_group_bmap = bitmap_new(sd->wp_group_bits); + memset(sd->vendor_data, 0xec, sizeof(sd->vendor_data)); memset(sd->function_group, 0, sizeof(sd->function_group)); sd->erase_start = INVALID_ADDRESS; sd->erase_end = INVALID_ADDRESS; @@ -762,7 +765,7 @@ static const VMStateDescription sd_vmstate = { VMSTATE_UINT64(data_start, SDState), VMSTATE_UINT32(data_offset, SDState), VMSTATE_UINT8_ARRAY(data, SDState, 512), - VMSTATE_UNUSED_V(1, 512), + VMSTATE_UINT8_ARRAY(vendor_data, SDState, 512), VMSTATE_BOOL(enable, SDState), VMSTATE_END_OF_LIST() }, @@ -2020,9 +2023,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 56: /* CMD56: GEN_CMD */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { - APP_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd->vendor_data[sd->data_offset ++] = value; + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; } break; @@ -2156,12 +2158,11 @@ uint8_t sd_read_byte(SDState *sd) break; case 56: /* CMD56: GEN_CMD */ - if (sd->data_offset == 0) - APP_READ_BLOCK(sd->data_start, sd->blk_len); - ret = sd->data[sd->data_offset ++]; + ret = sd->vendor_data[sd->data_offset ++]; - if (sd->data_offset >= sd->blk_len) + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; + } break; default: From patchwork Tue Jun 25 05:53:47 2024 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: 807238 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195617wrt; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2RHH67wrzm8uvVZ+zJ/r6t8IYkVJ6eOg3L9KpyZOAgyVEGe0SXp3L1JD4FXm9GWm+tg+e8EjFlT631muZLKhb X-Google-Smtp-Source: AGHT+IFoeuFJlFzJclvTsZyZlDOkLjYZn2ev9ZPLESxzcaHbgOiumCCkdwQwz+BSInUpbGmjWptv X-Received: by 2002:a0c:e0d4:0:b0:6b5:683:df5e with SMTP id 6a1803df08f44-6b5409e0b74mr57593386d6.32.1719294914629; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294914; cv=none; d=google.com; s=arc-20160816; b=O7Ow3NRPI83IpPvXVq73SNJCaa6Cmo5eY8hXdfFqoNdU0trPTqvLwoL9dFA8SJlDsJ ASW2aAa/ujLtBqvUAqjNePUNcjdXiAS6oub4l12TJ75I6e2h7qvguJIXnvMrgt6QveKY +hbMsxBZbuzX4JZcvEsRcQa5vDSHRkwmJudzPwtFlGrTH6exgrvf6SpPjYvFOIvhNk5g E8w3AVUiNGtImWEmUq0Srv9Nujs5jzB3cm+0W4UnhZ8BcEW6xcnPXdFv+uqofKsyJjex NjWzjZHKHpAnS9U2Pxa3sEpi7uBF8mZlnujHPyb2zyXIT/xn9f15F6X6nZuRgMHS++pC iC2A== 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=Ee/yL80E0AWtVNbCxQaoN9WZIZ5QGojNiR7WBNpSOHo=; fh=GKTErd9AQuz8EtLVaBm0jy/HTz/AwRiMD9Bu+kmtebE=; b=L3TvxZO6u5UOlwDatO+/iXZnkgJJIb2g9Jz5xtSKPoKwbcyZ2R3cEljhqMnzwwgCNz 8ec0afKr/Y8NLF35a3upIiBp4/i0miguZ1FtIIN2qszGHHvJ13t2j78HdFkLFfWZBkWL ZXmKATDLoJhapSAkgy2JEgACNglZxm1OKTAAECV5iwbE0Qm4ULooIwpEMUjyXFAwM02J epJs1JQA54DbSrbgs9/Kn96/mCBYB3k9ruFq+xmQsY/xdmb6SoL9RD1gWdYoywtMxgj0 ePtgTqXqqxzm4g831XRTkq/QUWIXCQrSqJrvA3zhyr3dRBpS1Jx9PYW5sYLj/KtZXXeN B5ig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XzBJdxLr; 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 6a1803df08f44-6b536d02f41si68995136d6.472.2024.06.24.22.55.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:14 -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=XzBJdxLr; 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 1sLz8U-0001ha-WF; Tue, 25 Jun 2024 01:54:35 -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 1sLz8U-0001hP-9N for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:34 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8S-0001d3-Pv for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:34 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-366edce6493so1544176f8f.3 for ; Mon, 24 Jun 2024 22:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294871; x=1719899671; 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=Ee/yL80E0AWtVNbCxQaoN9WZIZ5QGojNiR7WBNpSOHo=; b=XzBJdxLrNJSWQg8q1FGJcRJsNq+nwT/g8qQpaxeyOM+4Xjkplyex/5elNlXI5rjsVc GJxpQN4ldxDvDcttUD2RlYk2PuvmnWSe3BnEbnP8+hHeCWApT+6uWhan6t0Lw4fF+Ja5 NA17v22c0eslrn6qTl3YE5m3o6VQdCFn1BO4dTmUuIS8/wkfpazXRBTLZWN70GfUeFXa feqCpq7TkSEsy58sexDd0wFyuhMfXvCPo9Af2uUbrAvblkSNjaCqy3/c3SbEDkCc818t vN6xGFZfasLRZZFquGSJrEAHTg2mx/+Y+zzXnEI/GDVf2KiuZ3XcxKD5h8zQdwwArwJy a7GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294871; x=1719899671; 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=Ee/yL80E0AWtVNbCxQaoN9WZIZ5QGojNiR7WBNpSOHo=; b=sJWNQNIOGmT0duw3bhGh5fcuJuabfbLCYEQnI6awpl6C2tJvg48/yns6kfLlo8GIyC nUdN6uR/BjVxht5vEKPzbm3buNE3+inULvksSrD6kjzYS5ii0EvVMNEJXwM4NNX3rI/T fCPNL+Q67cEk9SqYkd3mGvOsrUJsEUUuEq5KosU/b7565WiwhNlFHRS2yoWdmDZ4lF/v wyOZoOVdGApkEwZKi6rO12iQUf7W/2HkJG42P/GOdywAH2oD50dI2qvA6EoIEZFpJyfQ JnY+bSlbSMwrWoDzOhVaLigu4JRX9CygUbxW/k7FKOSX7OCb+5Vlr40bW+XRoa24eSVK H3Dg== X-Gm-Message-State: AOJu0YxJ2yCmy0DDAU8Cp3B6/3+QTcNJ/x/8u34f1n12fno2JCIjXoos IKTHJOunN9NvPyKQA2PVxkV684r7rc3eve0ul0vjU296EyKkku2sDRe1sjxtb0kF3dEYJulciWr I X-Received: by 2002:a05:6000:178a:b0:360:7092:728 with SMTP id ffacd0b85a97d-366e95ddf7cmr5466388f8f.55.1719294871034; Mon, 24 Jun 2024 22:54:31 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367003b1fc8sm846275f8f.57.2024.06.24.22.54.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng , Peter Maydell Subject: [PATCH v2 06/12] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30) Date: Tue, 25 Jun 2024 07:53:47 +0200 Message-ID: <20240625055354.23273-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Per sections 3.6.1 (SD Bus Protocol) and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0f8440efcc..b604b8e71f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1498,7 +1498,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; - *(uint32_t *) sd->data = sd_wpbits(sd, req.arg); + stl_be_p(sd->data, sd_wpbits(sd, req.arg)); sd->data_start = addr; sd->data_offset = 0; return sd_r1; From patchwork Tue Jun 25 05:53:48 2024 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: 807240 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195621wrt; Mon, 24 Jun 2024 22:55:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXYR5kI7vX738IlANEb5llveXPvu3pdDZBghuUly9lykXF9bXHeQEv3yERSSP6dvFhigUVpdsJYL5X+eN36+EeF X-Google-Smtp-Source: AGHT+IE+s40wKBxTGbk9HzjoPGpgldTKONxw/HmTulE2VBpphY1Of7vQdyC2NEuLx50S33aGUH5I X-Received: by 2002:a67:ec4e:0:b0:48f:3e67:78d2 with SMTP id ada2fe7eead31-48f52b50f0fmr6755391137.26.1719294914947; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294914; cv=none; d=google.com; s=arc-20160816; b=Ymz2oKRAqyOMeEkaFxxtTC5YC4tfP086QyQ0kdgOkkeledIA5P3TOsqL4yqrbhLl55 JXFLkmVhe3xG++khRM3qEcQ5nnQmrpxfsopWVty1CM/h3xpjxDs2nYfq7hywx3QmIwzY duoiS+aSCpY2uzuO/aSjeKOeS3UP/BLUb/2T7msUFL2yHsUXc689UkzR9lZDX74PmIS3 D26vgQAx/1M3rqITr0m4jsQN65f0ELP/FkZSBGSI3tafbtexSiuRIZdpRkRzpAS+Sx+K jnY7yexLbnKzQV3lbapz8XKtEQyKxB+5Cs7zIFfMhPBOw4bQ7wXFPtq+3kHiAhT4Xs5h YrDQ== 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=UJN6KVZ4KFMiBqbYHgPGiBcO7JIk6P/og2YV9T7n/3A=; fh=GKTErd9AQuz8EtLVaBm0jy/HTz/AwRiMD9Bu+kmtebE=; b=RRLTOEh7CaGV6J7qNZ8QSWABqG8OetXRa2CpVY5iG9j27dmVuduOWkvlmHG3iR5OPs yZ3A7pIv1zYFHnN9zMrQbCpWSAJjUvnMDTKDAdtsRBsJfJvYQBejmc3SOxztC/KUoNYi rLu20L0i3k7IovEm42xCnzg4stuX6O5oua3MLbqHPwHtRz3FLrcs5EVKMpAuHr9Jz99E gsF27ybP91U8cYW3rjwf4nIpdbHiwdz27DP3G2YHZDFUgTLA9D1EJkGgiot6a7T0BkMq 3++/UIsW9paQr41ogU6wjTady8VOMk3C8fi/zQO5PKQUIBo0dS86DsGXmOkT4mZDkKLm +iOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u5Wt2HsQ; 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 d75a77b69052e-444c2c0aa39si97630811cf.278.2024.06.24.22.55.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:14 -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=u5Wt2HsQ; 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 1sLz8c-0001yT-03; Tue, 25 Jun 2024 01:54:42 -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 1sLz8Z-0001tG-UZ for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:39 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8Y-0001dz-Du for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:39 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4248ea53493so14912805e9.3 for ; Mon, 24 Jun 2024 22:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294876; x=1719899676; 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=UJN6KVZ4KFMiBqbYHgPGiBcO7JIk6P/og2YV9T7n/3A=; b=u5Wt2HsQpuXTs4R8DmoC9v0oQst0mwNwc0oj6NTwYKSyBpoNycK+d5ROAbT9pujyLV wo/TW6JTcLqvt3hWdFJgVrlmXZojVxSG3e46ewTPzKAXbXN9XiKa2tQg8fCdjpbqD73K Fi+6hpvFqPKS1QOa7tE8oKx9lL7kuL2CKo9DVROcwCtAI2ULb11p/vXKujJgTyvpiO1R tS6qpiOx8tqUbY8KvJMhPAqveiuiuSrlE7B+FNTrmfPSp+NrNloE5JAXTZPiNlXOLLss 3PvF8sHTznWobzvX0gw/BWGROrZH+mTHhZ3jieiPxgEFgcs3O8n/B3MdOUDFEJD3LL2A hqDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294876; x=1719899676; 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=UJN6KVZ4KFMiBqbYHgPGiBcO7JIk6P/og2YV9T7n/3A=; b=mpVSjSzBCyeGM9MEY6CZa82fcPk+OSut1aexuT4E4apZ4TfM5Pnx/bC9aSahVuhv7r dAWpKR1sOZTpRka7O8eywOGf9b+g5uV8GVO68C85FSnWWujHPpNxrEHRffUkwkaWinlh OcHBoUtqzFYl+KqHBVynJzdn1g3/ETldupKImVC0zIS2s3fBtsQDSOa5febv1JYFYxsE BI5Cb/aEBpIFzXXg9csylMnN0I5vN/oQ7S1Bfa3JkbxUbuMxMYAa3DC1r6fHyR+KRZ7j 8+p1w2c88I72iUbX33qVDLyfERAC5vSccxRj97E3DxGVQaSR22XKdfkmp7iM66yxiEqA gEIw== X-Gm-Message-State: AOJu0YwqE/sGGxYpDJv/pimZPmDH2lyWwYQXQN4agE6oj/Np6rWeZNJQ CxR3gYIGxVI8962BK2dPzuDE3ZtBObjb8ixFzfeoJAD51ZidJJW6BgJZBCgNLWotByANBaXDVNR u X-Received: by 2002:a05:600c:4da1:b0:424:8e88:a6a6 with SMTP id 5b1f17b1804b1-4248e88a753mr53922045e9.8.1719294876771; Mon, 24 Jun 2024 22:54:36 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366383f6355sm11849035f8f.17.2024.06.24.22.54.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng , Peter Maydell Subject: [PATCH v2 07/12] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Tue, 25 Jun 2024 07:53:48 +0200 Message-ID: <20240625055354.23273-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Per sections 3.6.1 (SD Bus Protocol), 4.3.4 "Data Write" and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b604b8e71f..0742ba8b38 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1659,8 +1659,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - *(uint32_t *) sd->data = sd->blk_written; - + stl_be_p(sd->data, sd->blk_written); sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; From patchwork Tue Jun 25 05:53:49 2024 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: 807244 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195731wrt; Mon, 24 Jun 2024 22:55:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/pI1CwN4+u97oEY2YksDd/EilFpNtae4BNwaQxjT/deIk459gboitpHtniNDadUrN7qcVizfm81vv4WScnyMd X-Google-Smtp-Source: AGHT+IEppJa/IuO3iQ/avfg+ob1lcr42wwO2Gaan5S7JYiQ9DGFh63g5smReEuoI3XcPwW5dsX8P X-Received: by 2002:a05:6214:29e1:b0:6b4:7910:2b60 with SMTP id 6a1803df08f44-6b5409a5064mr81838126d6.6.1719294948520; Mon, 24 Jun 2024 22:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294948; cv=none; d=google.com; s=arc-20160816; b=S9n2ghKoLU5ijhZjo3rmxondSnvCzp281sC9Dg6ZU0WJdagEjlQOo5EMQJGzmtuIp1 RkNY+azSFgFWbJi2cZgsS2O5pCIw77SDnrWAABvBrNzACOcy4szfxmEp/pnaZVXgvKiT Kmv1xzU6yl5nvho9Snzly+TH3mef+0fxQ1qBSpzoinVQhw1vr10kFLj6fuVFGPrpAEVL gcEXAtbX8UzZIkIO7o1JPcVmcbK0SskyXG3pdFL/TpHgrOV71GgOsYGujSz27BqkhjgP PIIh1ut/RHWu4Yxyw/1JKtuxrReQIO2ncvgrs4RpKnzaBtW/EkfHr1VR1/WzOFi+GYbL hR3w== 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=DSh3z/dbSRZy4hlbUrmDOZ6ZGH/UkGencdxAnicUEVY=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=m6Vc2bIF7+3nRIms/mGekdBy/hGnHTx7JkNhq4Z+PdW+LtaxEPgJYFHkQ5q94XYH9x tF3/puWIyfK9aU1eSfFrw0bFQLc29UwcEEyyfeJjlfBFV4FjY9eLeGyWkVAw4qmfnEkO h3CWNykyzGnGzHSu52lUVfB3KNKVGQdBMHLqXeV8czBstzY+B/gqZ18HpPzOmUFRjz6W bz+ZoqJt5AUeaZfJcSOKugNYX8FO/Bcv/PyCdmqeCG9i2UIjMO0J+qNuQNLxy8PzAOJJ zFVHWWvn5nIe+XdDTgeZTN5s8YCJy9Yh684yswS5xG4hQfkGAxTrh7cWV9c9K76osLug 3Okg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ek6BuXH1; 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 6a1803df08f44-6b51ecebb6dsi100269856d6.32.2024.06.24.22.55.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:48 -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=ek6BuXH1; 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 1sLz8h-0002GI-SZ; Tue, 25 Jun 2024 01:54:47 -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 1sLz8f-0002DZ-Ol for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:45 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8e-0001f1-8v for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:45 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-421a1b834acso42172975e9.3 for ; Mon, 24 Jun 2024 22:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294882; x=1719899682; 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=DSh3z/dbSRZy4hlbUrmDOZ6ZGH/UkGencdxAnicUEVY=; b=ek6BuXH12R2UURVh7SCD/ZV+v7CXyLk94XCMJ5H0xfwUAZFhn3ZD+K71MiUzgnhby/ VuOAElUTC/DLbyyp0Om8k9ZORIRpp6aio1ULXPR3+VA1O8qqr74DlQL/KqOic/rIMNtv jhi4gKGQi/+6DOavXot09m8u75107WBTC5jhTafdTHw2u/RGbI2AY2R29QmuxAn0TcJ3 dACecCQJAOAA1RSwAxYFW9ik1JSTuSwUT8/nf4QtpzUrdaNYdnoqrzB1krpa/jFRrOjP ChzQx7bJEfkgJb2Q1xwkAogJSzvUeex5usVPL/jGiKUgHPYTYbtnNIl1D0FjGfdQGcfo p13A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294882; x=1719899682; 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=DSh3z/dbSRZy4hlbUrmDOZ6ZGH/UkGencdxAnicUEVY=; b=cAiXXkIgjlN4V3L9+LX2ATK4bZiZ6MB4fkM2txf0tsdGVyL+9e7/t+/3Rtk41pXiyC ZcQ3EG8eeOYuREqCQWUuHKT43ncbOa4mlw7ppYzIMrDQN2owxMuU75tTLp//yB69y3PF e7GHckokDXE5aUWdbKWm/bBW9V0UCPNsy/MFAW3JX6Q+N0YPSJb79FGCuPoKnVTeTPjJ 6SDQMyJEI8xtTPDR1gCPcwPSp/IRRAvKDbCIFDmqrG5USFqirVu2Hl7OvXaOppfZKkXz WCS4lBgU2MMhmjFlCksQQyhrMjp0ftNdw8WI4cSRFXH1tboJFfBnBzgZ6B5zflS8KL3p hFiQ== X-Gm-Message-State: AOJu0YyonwLAxnv5u/H5g4kugnFOd2A+q9znDgTkLqkSODSDhhLR+ukH P5Syf/Y2fEid2EuthcUYQ8DRcHLWdlqS0QcuMZpqfp0PsYFbRUSJtgpNZrNWBHVtaFkb6ehpOB8 3 X-Received: by 2002:a05:600c:4f4d:b0:424:8f0d:c07f with SMTP id 5b1f17b1804b1-4248f0dce13mr33943175e9.4.1719294882495; Mon, 24 Jun 2024 22:54:42 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424817a9975sm155739065e9.14.2024.06.24.22.54.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 08/12] hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value Date: Tue, 25 Jun 2024 07:53:49 +0200 Message-ID: <20240625055354.23273-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0742ba8b38..8816bd6671 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -557,7 +557,7 @@ FIELD(CSR, OUT_OF_RANGE, 31, 1) static void sd_set_cardstatus(SDState *sd) { - sd->card_status = 0x00000100; + sd->card_status = READY_FOR_DATA; } static void sd_set_sdstatus(SDState *sd) From patchwork Tue Jun 25 05:53:50 2024 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: 807248 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195820wrt; Mon, 24 Jun 2024 22:56:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVQlOmB9Bv1gtCszfNZgG7JlEQhLPv2y7WtclxqUAqro0Pawi5srIU86CjeV3stQe1Z5fgXLLTHvkTcx3jf218e X-Google-Smtp-Source: AGHT+IEtef2/1+E3kA0QGcxiDjuhUiETVK79CIBsCTSxTf4BgvzXDSpEFSjVSkBj/TGC8zxcanoS X-Received: by 2002:a05:620a:4115:b0:79b:f65a:d04e with SMTP id af79cd13be357-79bf65ad06dmr380804885a.20.1719294969082; Mon, 24 Jun 2024 22:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294969; cv=none; d=google.com; s=arc-20160816; b=NCyGUtkKh8uwqZz8oYM5fbtBPKfZZrVU5k1ys0JCrzn3NAIWhtDPklyIIMIFyDsnHC Qmcl/f8ULMpBJqp5w1ZkZvt9WH3vzbXLahTojwqCsSzdoy1WASJUgPlqJMRg79lbEacD meATdtVQkt1WeRjpU7Ovo3HdblTPWAV0xG4Hq4XgWdR2BwjLK7AMzdk42hAUGjOzkC1+ Ez04NP8BkJFR8uXf4BsDIRRHY18SCkXOa2mr/cHkR2QidyX4XL+8YGQQOIlSkergYlQQ DxJxNQTjDCyB5upA/14kFZ5DcnweuOlLnS72WXQHNATOMWZnw74m4zZKzzcFxuOCXfvY 4PAg== 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=rePHr36mkrTbTL5WwJD6QrkkFRWrQAZ68gdScQGNuYc=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=qDbJnMecGYdXoiSU5ZFEOBPNT5YUmvy/f6UxjuIbTCDj2NWYb+M8SGLhKqSUDDkc4Q gcbNheIrny0NsTuHotZCr/Wk5lwreb9/NhxVtzg+vvB2tQW7nDolw6IQ2H90Vp5rRQ0V ssHedU+PFrz8yl1jtMqqhpm1OmrrejxASk1zPO6TlsyJ4jS3kDg26QiFoiGXKulNxLC+ ikPHKDNhjk/2JOZoijWwf3Mk3FTLwOARTHi/LRBx9ufmB5TQ3kRrw2XkzHeFzA6WGbLE 1wyk3ZvUnOqf6C9K+GN3ANkC0Sxaf6jz9LCDHmqr7NgAjIyLJk1l6+MC/r3gJhbeaVeq 4ibw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ebDp/fvX"; 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 af79cd13be357-79bce941529si991743285a.613.2024.06.24.22.56.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:56:09 -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="ebDp/fvX"; 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 1sLz8n-0002XI-1N; Tue, 25 Jun 2024 01:54:53 -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 1sLz8l-0002UK-Mm for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:51 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8k-0001g6-3i for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:51 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-35f090093d8so3462651f8f.0 for ; Mon, 24 Jun 2024 22:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294888; x=1719899688; 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=rePHr36mkrTbTL5WwJD6QrkkFRWrQAZ68gdScQGNuYc=; b=ebDp/fvXtDRbOhsy16ZxMhNSsUUS8POT6ouUdiyzY8vFn7y7WmY9M0zM5hoby4KTz5 gZM2V+me5ERHr1W0wf98gRObk5bR5tjHLerN4HucD9fqzPoEh4O4hLjhu6FSrhX5A+I2 Nd4wZShLIGXuphkxwkpiX/o21b5/pKdp5u1NRzPspuPCjwdnZSOof7AZZYmiQi/bhDfo 4ZdNEC/2Mk49AjzPdUfylvlZbqceVKHMaSUkcQ+VKZu/fIhqSgO495jM3CV6n4EzNWQT feoCIIUO/d51MXBTJ6J00k+CkGbOgNXqcRIBgOwN/dct78ecguwYKPWzjPVxs4gRaSoa AtPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294888; x=1719899688; 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=rePHr36mkrTbTL5WwJD6QrkkFRWrQAZ68gdScQGNuYc=; b=BKZVuEqiB4UC94NrtbmIZ+7f8SdzZpbTVHkoiaJlp+7o2mx+p8rHgQyyCNKc3uBXA9 1x+qMQlWfqiVCRCIlzdBeVe7j30y8xLEJHl0woqH61oFQ0gvT9iEgyj6ELhO4j9tSLfe tT+UEKphVNNGYVGfdW8/KNN94u8ZlG973bQmXb/hXL+00uHu0i3/NB8waXnitvOUiG/g m+rMjkUClfDiHgPi/Tl8s+rxhAreu+GmBK7dfd6B5hN925aHd7Qu8M+sY0gHgg42Vz5p KNEgUJWv6xlG8STqTVuuQb5Q2Dp830FOiSaazQGnvi3yEcveh9TMyVrWkl4A0CiOVON5 9L6Q== X-Gm-Message-State: AOJu0YzwHTcBuiGkl4QotPzqJxXWLfuiXGHoJkVKFq/0Pgd91PukM90E 25I3kfcpXvICFjVvImpqT7m9pVd8GPBIX2wyOV4cSB14OYyOHwL3LFk1zZ6LuQSF6fbMzCyLmFw b X-Received: by 2002:adf:f7cb:0:b0:35f:cd7:5ba1 with SMTP id ffacd0b85a97d-366e7a6367amr4875249f8f.60.1719294888263; Mon, 24 Jun 2024 22:54:48 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36638d9c1d1sm11898372f8f.51.2024.06.24.22.54.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 09/12] hw/sd/sdcard: Assign SDCardStates enum values Date: Tue, 25 Jun 2024 07:53:50 +0200 Message-ID: <20240625055354.23273-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org SDCardStates enum values are specified, so assign them correspondingly. It will be useful later when we add states from later specs, which might not be continuous. See CURRENT_STATE bits in section 4.10.1 "Card Status". Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8816bd6671..36955189e8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -76,16 +76,16 @@ enum SDCardModes { }; enum SDCardStates { - sd_inactive_state = -1, - sd_idle_state = 0, - sd_ready_state, - sd_identification_state, - sd_standby_state, - sd_transfer_state, - sd_sendingdata_state, - sd_receivingdata_state, - sd_programming_state, - sd_disconnect_state, + sd_inactive_state = -1, + sd_idle_state = 0, + sd_ready_state = 1, + sd_identification_state = 2, + sd_standby_state = 3, + sd_transfer_state = 4, + sd_sendingdata_state = 5, + sd_receivingdata_state = 6, + sd_programming_state = 7, + sd_disconnect_state = 8, }; typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); From patchwork Tue Jun 25 05:53:51 2024 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: 807249 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195841wrt; Mon, 24 Jun 2024 22:56:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW5wqJNZo0I36uvUntCWWjNVkxsLTbhYpgHsZUNZOHOVWGmG6V+x/mI0GiX2zvcwGa9GsMlyu5X3oCL3/iLsPcd X-Google-Smtp-Source: AGHT+IGnhQLKUOvsCsv0GpADdZoHcsF04+GSCdtRQyd5O3xh5aPAnZ4uzMSNBPUVrdrRs6WsPZxg X-Received: by 2002:ad4:4092:0:b0:6b5:86:ccc0 with SMTP id 6a1803df08f44-6b5632e2dcemr42994906d6.5.1719294976224; Mon, 24 Jun 2024 22:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294976; cv=none; d=google.com; s=arc-20160816; b=Z55Z2afqj4wN0jYEYYhJ6SjHy8XA0wSAgugE4lcC65MYxGM4Sw5hDYR7B+QE5Y1Fp+ cd8YQyidL/ybMPKCzZyZqGc1UWgDAtfIwcNpPNX3Jv1Pa4Sg3zDc3qXbATwHYyxjLMBG dL1kCmfOkbys+VfijXIUQ00x+Cbb7j6BON7LE0PqDZ400EBGDvGHkFCIts8fqAZGnpty TIzbwMZeUgrgeTrZljU6gzYchfpDNBVA7mRwpxKtXfGALfDGEF0VC2BR05Mfeh9tCbf/ 20DuoevlUnrKmnRnhImCQUrXDICtemc5JmG8GRzvXTRY+0kcdcRx9VFKtmbC8CTsy4vh HO2w== 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=5P7HyM7CLqMyqYOTJNfxbyYOLKZqsQ3trYZWJFhWDzE=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=aYjth4l1jyuMYexkmVj0qz6hfqhmUI+VQUV5r68Na3VhkIV8qqDrlsjxCYqvrMtbOT VF4zE5vaC5dmgiQBh2H4UTqYh8rhX2zH6YautHr4gmPZ11irnq0sqMscr66yR5qhN762 u9DQ+urx13ctgYci7pzCgn2Cf1iLcXlO8vWA4k9nHGhWLqEx34ihIswOhcviK5duBZ1H /tME2FY/k/cXFhf4f29qxrVNv9YftvMCHVDKIkZys/iwcR1iFKTPiFU4VFHRIQFzGQgw MSqZ5e2U+Zxbolq7ubYej0C8I3bY4VMULc5bpUEvGG4u4a1C5BroWSaVhPXY8jEeJMKg y7+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jUxo+UMR; 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 6a1803df08f44-6b51ef3128dsi101500886d6.480.2024.06.24.22.56.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:56:16 -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=jUxo+UMR; 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 1sLz8t-0002hL-AO; Tue, 25 Jun 2024 01:54:59 -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 1sLz8r-0002ZK-2S for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:57 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8p-0001gy-HQ for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:56 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so2925350f8f.1 for ; Mon, 24 Jun 2024 22:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294894; x=1719899694; 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=5P7HyM7CLqMyqYOTJNfxbyYOLKZqsQ3trYZWJFhWDzE=; b=jUxo+UMRrb4lQQJOA1iKG8vA2k7OE0McSg16cyQRGH+1+H5Md9XTIrKFhWTCxvoLyV kXwPTFiGFI3ItGHq1B0mzAIhpPNzpA33/znaQq9PjrOnTOgBPL4V2vgYkY8Vr4sZJCPV 198lvfcNO65oumKNZXtKj5NtijfAyZA3IKKOY+Tlah6JkqF7joS++UGEsNWgmmPkCspZ YAa4abh71wSTaamug3R0u4vLILfbrzaCRafdK5JwdM1PMpL+dJch7xQVv8LyWfrHViiy lYhpcxQGiQgPbZ7DOh8oI8bOUNQS/Mv4bhdyKctnopFX8XvTTA3D/QZPTE+JnR9CB6Gs rgdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294894; x=1719899694; 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=5P7HyM7CLqMyqYOTJNfxbyYOLKZqsQ3trYZWJFhWDzE=; b=VWeSlgYHBoIUFMDM5ICNwZmy1GC+FQLFJ/iz7sAHetQhKckY3zRatP5ViXA4B6ap7h ztBrHpTB/Moj2lqqUMxp2+nzs7lbtfUn0X4fpfMZ9VHwzcrCOjPU7DlQFSdshI9uEFEq PSnN8qB8i9dbi++4wWc1BLLE8CvVuZR2n1gi4+ev3EgqNXUqbdeCXEd4zgxCKHdEz+lU i+Ae5R4rq/pnQKAgLIEIJZjZvOIh34lTau5n3zw0QtsboldA7KwKDUoFR9byK9fQdOjP 6doz7geRbVu3t/jta6Z2OUAtN+gt/+EDqJaOUb8TtejBMPBeN4V62ut8CDcvnpK2yibf NiNQ== X-Gm-Message-State: AOJu0YxRO6xpaHdLCKCI33yYxAoV3EdzGPqvV1GYAcWqF1g24EAWHEH6 R8FR96BACp/LZUsEJrTuXNYaho4NAxlmVCVIgsFz/4KotSSQToavlVtZCEfI6drEcLV+44IX7FS y X-Received: by 2002:a05:6000:b0c:b0:366:dfc4:3790 with SMTP id ffacd0b85a97d-366e34a3d7dmr6074472f8f.0.1719294893836; Mon, 24 Jun 2024 22:54:53 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366e88c0c38sm7509752f8f.32.2024.06.24.22.54.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 10/12] hw/sd/sdcard: Simplify sd_inactive_state handling Date: Tue, 25 Jun 2024 07:53:51 +0200 Message-ID: <20240625055354.23273-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Card entering sd_inactive_state powers off, and won't respond anymore. Handle that once when entering sd_do_command(). Remove condition always true in sd_cmd_GO_IDLE_STATE(). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 36955189e8..fce99d655d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1072,10 +1072,8 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - if (sd->state != sd_inactive_state) { - sd->state = sd_idle_state; - sd_reset(DEVICE(sd)); - } + sd->state = sd_idle_state; + sd_reset(DEVICE(sd)); return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1570,7 +1568,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (sd->state) { case sd_ready_state: case sd_identification_state: - case sd_inactive_state: return sd_illegal; case sd_idle_state: if (rca) { @@ -1791,6 +1788,11 @@ int sd_do_command(SDState *sd, SDRequest *req, return 0; } + if (sd->state == sd_inactive_state) { + rtype = sd_illegal; + goto send_response; + } + if (sd_req_crc_validate(req)) { sd->card_status |= COM_CRC_ERROR; rtype = sd_illegal; From patchwork Tue Jun 25 05:53:52 2024 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: 807242 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195648wrt; Mon, 24 Jun 2024 22:55:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUaC3J5BVnhVyT3Xn6SCjA41udxCRMnTlqah3iOERo3OhtXp32I0IGGEXg05JVCzWTmSlhpDqYEme4htrETULq4 X-Google-Smtp-Source: AGHT+IGZjIqwCz8bvgyRYfnABMhXxJAI1AoqOeM4O+lsnH++lBhzlWSeMmIp8aippKPfW8dyAbdS X-Received: by 2002:a05:622a:1a13:b0:444:e8e2:29a8 with SMTP id d75a77b69052e-444e8e22ce5mr56293091cf.7.1719294921388; Mon, 24 Jun 2024 22:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294921; cv=none; d=google.com; s=arc-20160816; b=Jm2/GOiC/LMe1wBGhIh9dYiSIAfhyvk1PoxCUFSRq0Jp6feXcaYJCtcNq6z6RyWj7Y R9aStpAxrdSVNzt+tsxgmS9oZxzt8/YKCaJpB6lrLsib20KD7jH/5B7GHyWsRWxw8Dv4 5GxNrzbbBNlR7e5Y8AUe48fKsOP9F9GOZ9JIHkqhNVhxvFYtDEFXNUWjeHXd7pzDkZ4J cmc5mWC4lSEWT3CpU/MqK+OovkVpemam1X3vUeDOOJg2vgVJLo+IWMqd/jKSUVc2HHfR T2gEudtzJdiNyTUsoFf8tINCInhxU7qXXBp9+E1Ta4aEokIpBJNS/jGZWeE/jt7DLWCt 5oWA== 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=YAYGjbFJNuy9OHUJ805jrPNXsWJBhB1UqPytiuUZXwI=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=qcLP2KffpdS/ecBwCoSDmks1oxuvsNaZ0e2SZMBNgv6kSD2KueSl9o4KWg6F5K4WpY M6QK0BpX/bcWaAugvlIaoqqToCmIGmSHmMk9FMZFMdl+ty66u+vg15wkVaZVGGCtK+MS yCTJxn14Ck/tnIAHu4i5XcRy3JFJl2SbUOBMwBR4x3hTTBQ0pe1tYnGZZxIpoZxPY7xv K9luFcQfjj2VPVCj3i5TRYSCJaoiINbH+THuH/a4uCLZtkB7IZnYdtsJAV0iflp5Chfe 2ukKsBU2tZh91VE49BKBfMoCGFyuvl5q2RZ/iAOdv4BLBNY8n8+Vn+0kvE0LUNlYu0jM wxxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H/vF1o+b"; 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 d75a77b69052e-444c2b4d721si109666091cf.109.2024.06.24.22.55.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:21 -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="H/vF1o+b"; 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 1sLz8y-0002ts-Os; Tue, 25 Jun 2024 01:55:04 -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 1sLz8x-0002tK-6N for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:55:03 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8v-0001i0-H2 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:55:02 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-363bd55bcc2so4213353f8f.2 for ; Mon, 24 Jun 2024 22:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294899; x=1719899699; 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=YAYGjbFJNuy9OHUJ805jrPNXsWJBhB1UqPytiuUZXwI=; b=H/vF1o+bAUQ7usNqJVvrFJDQXQIdCn9NqVcABKWJ8wnAsksNvH93KZPJZbbWqDimxC JG9YOxtPlWTmtUFe1q20dtLWwWsqsE0gKXlRmegWim5hXEwKEaneeMmWpwdqwh2PXZQY sJKXt3iedv2l+OJyy0yuG0V8x01JiRpDUFNDCws1hg8DUSg7hGRQCHRWdf8LGNp/ZvO4 gmdgKVJcQ3lJ8DNb8N11ug5Kg7f9A/nY+UeHy12VPbz/bmJsKwt8FrjP17iLisBxHtjN EyXRIccDnvJPHIo9SBRL1K+sRDA8/yGSUBu1pE86Q7a2f4t/v2H6esqnRA81DMosm7ih SibA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294899; x=1719899699; 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=YAYGjbFJNuy9OHUJ805jrPNXsWJBhB1UqPytiuUZXwI=; b=RkpXsUdN573ncezqXLzy21wVMZv+OsbwvZanHolJHBZK8DdhZqWnzHuOrOECkxtAtF kyJNix7LpBBtNjD1z0Kk4I19JJhYZSLsBWwMNW2AfftmscLEswpTNA7J8nmozTXHzXhg 66N3zjwce/3Wk+CelduyqeudgjnsrWmNbInZVNtHW7oZEP917rumnfZhLXfSU6iyMdsU Fy+9mvB101XbzL16/aKOINFdRy+6o5EOinIuqaShGKvsuCvKl7CREcq4kERZxWSTrqCF CUYr4ddRqjzvHt1zkiTsX7tZmO6MqmHDtlq5uvBIi1jWcR5Nh+h0MRsosCEIJ2vPLFjl 5Vtw== X-Gm-Message-State: AOJu0YwYzNZqeof3Q9XOdWzCBGISY0I5VF3tjFx/ztAVQ5lhXAsa/EJg qYLjKaG4YHXNXt5mr/WB+P8fVw1uTHnEsbVKSLn0J6KR8G0o6Ix9z1LLx7K2uq1EilEmWO5L3si O X-Received: by 2002:adf:a21a:0:b0:362:8918:1830 with SMTP id ffacd0b85a97d-366e94ee0d8mr3348812f8f.42.1719294899468; Mon, 24 Jun 2024 22:54:59 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366f624cdacsm3996960f8f.70.2024.06.24.22.54.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 11/12] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6) Date: Tue, 25 Jun 2024 07:53:52 +0200 Message-ID: <20240625055354.23273-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org SWITCH_FUNCTION is only allowed in TRANSFER state (See 4.8 "Card State Transition Table). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fce99d655d..3b885ba8a0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1196,6 +1196,10 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd_function_switch(sd, req.arg); sd->state = sd_sendingdata_state; sd->data_start = 0; From patchwork Tue Jun 25 05:53:53 2024 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: 807243 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195688wrt; Mon, 24 Jun 2024 22:55:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXqnFZucvqNuxtcScLMzTXvV1Gb8EYe2zXuzeR7vz4z1snVJxLBFLJW3COvecCiL7Qm2pj7/TuDlFBsHHBVpHgY X-Google-Smtp-Source: AGHT+IG43wqbtbI9u6tbadxpufkG3W+hOS9ZAZaGxFzHmEjI7+aaADw/56EU3aFh8DoqTFof4O8w X-Received: by 2002:ac8:5dcf:0:b0:43d:9d93:f5e0 with SMTP id d75a77b69052e-444d393a2e9mr81574101cf.4.1719294933068; Mon, 24 Jun 2024 22:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294933; cv=none; d=google.com; s=arc-20160816; b=pzwuW4k1qW4XGWL/L3g6N151Yq2G4O7lL1/awems8/LwdCgXpiGez7/VAawGa61SFp cb9OLzo+1FBvdHqJBrXxkVoruDTLDacLzdFOkXXe2KEpC/z0BZkzWfntPGkBKkzA85eC Uclq5rnzIYVBrZylfkB8RfCk3QKUntVtPoP2m5VmV9o4O8Q2nL46xnglNnFbkQmAFLD0 SFdJy8aEjhUS7UA+IwQ3oK2ZmmcPJFYbznad6/WDju8rwxw2o7W3nOh5FtAgeG8hLGm2 XNNr2yOHlSDyh7SUsv4GYmLmXSysqtzEBuBj8/rkRhLcJiy6fFvJRZbO8uCWjByDnqg6 r16g== 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=rEDUclqNQG81lYieISPwXKSAxhsKsmBHUM+5O9kJWv4=; fh=quH1+0vgULqv3LP6tEyzMNyrHO9n10VlAKocz0j0xjQ=; b=nyIL8GvO52NFBZXpc43eJ+zx2kf2KoCNSJ4k905AXMZ+8iy4Zma89D+5o+Z6T65CwI 33lWD3lrFGL7YC0EfNtEBdC33g8mfwpgQ9ASeVH3UYI1NLt9oErl63r6s8CtLGaYGAWc JJq0Ju+a2zKCGN9eQtofabHFNzACoOWhn5Vu04tyDOFt5NJ0qCEOtO32ZpA7xV6QYEt1 q9ev4KD9zFNqsJ8aaojqq96p/Ou3BRi34wUnjteWOypqN3H6ssq61dyfJeHR29k0xfGJ w15pADUVFQLCAWt/hwFp8zSyapSaKpZBVFwihF+eMHRUdreSrEeqIHz6M8k+/HlnwPYZ x1Kg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Njinapm9; 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 d75a77b69052e-444c2c0fc32si107354671cf.345.2024.06.24.22.55.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:33 -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=Njinapm9; 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 1sLz96-000341-RW; Tue, 25 Jun 2024 01:55:12 -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 1sLz94-0002wc-B6 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:55:10 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz91-0001vk-Vy for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:55:10 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-35f06861ae6so3994464f8f.2 for ; Mon, 24 Jun 2024 22:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294905; x=1719899705; 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=rEDUclqNQG81lYieISPwXKSAxhsKsmBHUM+5O9kJWv4=; b=Njinapm9RlueUbmV1cpGwt2JFT/J5NyDZxbDLynDAU4K0d2/df4vxkMlNSAJSzoPZ+ PgC2Ikt7GnHEZ5I8IiUfLI4TTP8JlxirT7hFRfkFVwmk0WbZqExS5vPWFUvwpTk73ERn h1Nji7B7srKSx5Cru0uBYVdTQd4RdZAlcl9+IS598qbxdtDHlGXF3ZfCbSIZmrq1BcLA P2EtmiTUJ26JqgezuuOBI6ePGFOOumPDh9woPMBw18UBZ30UqZkzBFVZM78uwiPYbQWs 8WG4QMlaiu8zUkZKI8r1tGKnAHf4aBkdHc+VSNqCIVkQPvXV3bj68e2HnD7VZWqrok5Y t0rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294905; x=1719899705; 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=rEDUclqNQG81lYieISPwXKSAxhsKsmBHUM+5O9kJWv4=; b=pbb0df6xmFS93h5sQJHpFc7mA3ZomgG9QburJ0xabvW9UtzYGg4WoZY326o0wHSkQe oB5c1PF3PDr+CKTvVJg/3iWbGMsNZCbI46UaT7ghyfWQbxoPhwj1U5A2NLvc57fpsfzV wMQRNQMlVl0MKmYYT2anojUKuF2fUEA/5Keegelo4+vd4iyTrndo86b9/Zm6sxrelgrv twslqdbtOF7FvTkXS+YFoRA5MhCQRwE2wxBNeNc954iY2r9MwHjn9Uq4tTuElK7rLHQL kNUtlrCHWTneetTK0fHY7NuoWOCSVCuSPQJzBiama6GAPwSbB1wu2WPvTfzrSOjB1Laa M9SQ== X-Gm-Message-State: AOJu0YxfwAY7/qPYzTuL+h/BEOSZXkbet9e5VovpC6qlOXh18w0ZytO5 uhmNZ7VVGo+weAWNFIofXdY8O/FGKDLzO64B/XdqBYOWfYxExQjYdhgyaxfC+XiwLQRnsW2h5pJ 1 X-Received: by 2002:adf:e806:0:b0:35f:1161:e1a3 with SMTP id ffacd0b85a97d-366e94db399mr4136006f8f.5.1719294905408; Mon, 24 Jun 2024 22:55:05 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d208b4asm196304145e9.29.2024.06.24.22.55.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:55:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH v2 12/12] hw/sd/sdcard: Add direct reference to SDProto in SDState Date: Tue, 25 Jun 2024 07:53:53 +0200 Message-ID: <20240625055354.23273-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Keep direct reference to SDProto in SDState, remove then unnecessary sd_proto(). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3b885ba8a0..6685fba4bb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -117,6 +117,8 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; + const SDProto *proto; + /* Runtime changeables */ uint32_t mode; /* current card mode, one of SDCardModes */ @@ -155,18 +157,11 @@ struct SDState { static void sd_realize(DeviceState *dev, Error **errp); -static const struct SDProto *sd_proto(SDState *sd) -{ - SDCardClass *sc = SD_CARD_GET_CLASS(sd); - - return sc->proto; -} - static const SDProto sd_proto_spi; static bool sd_is_spi(SDState *sd) { - return sd_proto(sd) == &sd_proto_spi; + return sd->proto == &sd_proto_spi; } static const char *sd_version_str(enum SDPhySpecificationVersion version) @@ -1035,7 +1030,7 @@ static bool address_in_range(SDState *sd, const char *desc, static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong state: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_state_name(sd->state), + sd->proto->name, req.cmd, sd_state_name(sd->state), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1044,7 +1039,7 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong mode: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_mode_name(sd->mode), + sd->proto->name, req.cmd, sd_mode_name(sd->mode), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1053,7 +1048,7 @@ static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Unknown CMD%i for spec %s\n", - sd_proto(sd)->name, req.cmd, + sd->proto->name, req.cmd, sd_version_str(sd->spec_version)); return sd_illegal; @@ -1064,7 +1059,7 @@ __attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", - sd_proto(sd)->name, req.cmd); + sd->proto->name, req.cmd); return sd_illegal; } @@ -1157,7 +1152,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { - trace_sdcard_normal_command(sd_proto(sd)->name, + trace_sdcard_normal_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1176,8 +1171,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_illegal; } - if (sd_proto(sd)->cmd[req.cmd]) { - return sd_proto(sd)->cmd[req.cmd](sd, req); + if (sd->proto->cmd[req.cmd]) { + return sd->proto->cmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1623,12 +1618,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { sd->last_cmd_name = sd_acmd_name(req.cmd); - trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, + trace_sdcard_app_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; - if (sd_proto(sd)->acmd[req.cmd]) { - return sd_proto(sd)->acmd[req.cmd](sd, req); + if (sd->proto->acmd[req.cmd]) { + return sd->proto->acmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1919,7 +1914,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return; - trace_sdcard_write_data(sd_proto(sd)->name, + trace_sdcard_write_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { @@ -2074,7 +2069,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; - trace_sdcard_read_data(sd_proto(sd)->name, + trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { @@ -2218,7 +2213,9 @@ static const SDProto sd_proto_sd = { static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); + sd->proto = sc->proto; sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd);