From patchwork Tue Jun 25 06:10:12 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: 807259 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2200107wrt; Mon, 24 Jun 2024 23:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVXWOeTEy1qz5lISgWJaa2/6SgFoJTuO/ipa5b2qJ9LNDphKruKhk8mYJsuA0izdKf5uWrr3mDyu9q1irj51cdg X-Google-Smtp-Source: AGHT+IEDeR8K+dHxP6AQDhbivrZO2VNOY0tAICzfhj5/n7keiI49rIo8xKZ9ucXWvOUc+BcG3RoZ X-Received: by 2002:a05:6214:3012:b0:6b5:480f:b592 with SMTP id 6a1803df08f44-6b5480fb797mr80704656d6.20.1719295934076; Mon, 24 Jun 2024 23:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295934; cv=none; d=google.com; s=arc-20160816; b=0eOSLeyXovyijizMuAXD5Ifpld893FUY7g1XXwKAI3Q7FUBqw63kN5JufsRAa2zPUS sVApEhZNJCKzfKP7fF+icxgHpCDoOdd3z1bLKK9qrt85aRsWWHhKMEcgA5/qHLcGYTP+ YMvneI4Ubds5tn6FXBy9sv+2aeA9W0190H15QtGTYTNYgNzqst2BS+9R6ZHTipdnjhAL Nwj+5OezgVTXk+JxvUZjgel3wtiTCQoO7i0iONhQ6iGblsI8wLFKdYVcpS3eXeANrEyo sIT0bVg/nw307btbXl4N6pI7HsHc6ch312LurfsdOmf2ne4ZURb9QfeF57JicMHif4jf w6sA== 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=0rzBRaI/ZYbZ2jDlEcvd1eH3g2vJ/qZ3lsOwA042yyE=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=y6oOi7XqumrH960cuJPI+CNkkqfOMCeqhCcDG9YgriZlLbKEOY8v3bklBj0ql/KINq sKHDwCYyicoUzSJx9eBDC49FCam6/DyWP9C2gNUvvTFEU9lNsQ371SozbDIUIZMJ4GbL 2DVaOYQAo5MzoCiZN/5BRwTG6AcCUGOIDgSOAozx/xLj4IkyN1pn7u91U52XWCcZbJ6U jvFYHYQ2y+shiIpK6pLfG/+bqpFKWXbYoLh+AYIwaFvHgtGGYg5uyEtokaqZP1wNHYe1 7dR1IypFsZu9CWQNVk1OAy8kVnJhK5dPGbYqAWCIbaMOSC4yQ3kqnp0diHqDO1G5hHWJ yYEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gutgh3Mk; 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-6b51ef2e82esi98365556d6.469.2024.06.24.23.12.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:12: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=Gutgh3Mk; 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 1sLzOi-0001TQ-FX; Tue, 25 Jun 2024 02:11:20 -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 1sLzOa-00016Q-SQ for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:16 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOY-0005hI-F5 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:12 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4217136a74dso42276715e9.2 for ; Mon, 24 Jun 2024 23:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295868; x=1719900668; 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=0rzBRaI/ZYbZ2jDlEcvd1eH3g2vJ/qZ3lsOwA042yyE=; b=Gutgh3Mkf7/a3886owZbmEZJrEPLjFvOoskBGQsH0bNRIdchiSRgt9hZK5JrR5B8Kv DIk8v+rZ1RXWFoS2Gb49neYcnSCYoL5ydk+ALrY1VzBxFw5I+WIe3QUk2cn9123G80gk AZHrmxStSLYe1bj7TTdJgztFC+ebRD1ucEryzAexIxX/JBh01D3UnQYrjvcBrv1KEnXi /6Ux7JUnMbgR0p0FP31i2/e6hLb0VqiMk+pAVcKUVmPH74O7Q4b6NIcpSA19B8XcwkKf aXNDD2WweUCGaziedkZqCG3Kna+kOxqFm6uyQg1OkbxLQtHKaDy0If7UxoKuFtWIjsnR qZ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295868; x=1719900668; 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=0rzBRaI/ZYbZ2jDlEcvd1eH3g2vJ/qZ3lsOwA042yyE=; b=dO2oYo8odhShKVkNrGKT4k0kiRRw9QY1y/tWEqrKYwcyP8Cb1ciw29KgfzgNKNHqpa HwSmf+W+24i/7ULmuqchoNJe136HeMJDS4yB7BbjfZ9dtc490/BgAy9j82QQd+OAxdYs DrG/5T5Yp2PbR0FLIDi7vlfEZPUkgvwsh82qws7du1fxOiNxH4jyvsxzq5lRJVSxU0J3 2F/gyu3aPlvfPunR0ofdIND/Z/LbWheB8iKktLkLb8rUKhGWOaMBrRj4UO5bFcZCvD7T h+mcWvA7WJj5lFY9tmOodFGRZp5i+zv99rjcW+TeiwP3DTcjFqksDat+kPrjypyXuRih esbA== X-Gm-Message-State: AOJu0Yzy6wAY/YAOwrwTRre+IeqMt5M9Hpfz/L3Kjs82OuRSEFEfrcYI QSAIZTEeYScN9boPVwgiW9QAd/krinKLmZ7bkZKyu2oTFLlJlgL6SZZ3wHNUKESl8D+Kv79mDp+ 2 X-Received: by 2002:a05:600c:3204:b0:421:7296:ba3f with SMTP id 5b1f17b1804b1-4248cc340e9mr42008765e9.22.1719295867776; Mon, 24 Jun 2024 23:11:07 -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-424817a8d8esm161294755e9.12.2024.06.24.23.11.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:11:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 08/11] hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56) Date: Tue, 25 Jun 2024 08:10:12 +0200 Message-ID: <20240625061015.24095-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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 | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6e6b37bd2d..bf78f06b5c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1626,10 +1626,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (sd->state) { case sd_transfer_state: sd->data_offset = 0; - if (req.arg & 1) - sd->state = sd_sendingdata_state; - else - sd->state = sd_receivingdata_state; + if (req.arg & 1) { + return sd_cmd_to_sendingdata(sd, req, 0, + sd->vendor_data, + sizeof(sd->vendor_data)); + } + sd->state = sd_receivingdata_state; return sd_r1; default: @@ -2115,6 +2117,7 @@ uint8_t sd_read_byte(SDState *sd) case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 30: /* CMD30: SEND_WRITE_PROT */ + case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); break; @@ -2163,14 +2166,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 56: /* CMD56: GEN_CMD */ - ret = sd->vendor_data[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->vendor_data)) { - sd->state = sd_transfer_state; - } - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00;