From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506095; cv=none; d=zohomail.com; s=zohoarc; b=S4HuGtCEHu6yqhaFAOEqN4fmfDK+Jc4J0m2N5X7pG4xnBW9S5shv/v69lcjpATDnm011InHtL0DVXGWGQwR4rNEhnKd9zz7kuIcPGcmpLPGp9fBha6xf6w3DWE9DXvpLrR8wwZ15oK7xHn/Tm7Nv0OJK7eBgE0/Xu5nIxZhC5NA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506095; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dnn8g/1r/IDbgXO0nM+fG6kuhQufIGWzDGBB4WRk/v4=; b=duzzfbHZX0Xgj5A6DEzCTWVk6cl5Yph65/d0qFP021TvruA8rNNZftx/kBm/acJfafkyQaiLKSk7M1jxCG+x6qoqeXQLpcbsZJm3jLNZEBAJuusu5tGYVdcRCj4ba83qPK+RZMahHAA3Yu02wZYWSsU4N3lQf2yN/M46QxguEPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719506095142687.2668838517671; Thu, 27 Jun 2024 09:34:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs4o-0001UR-7Y; Thu, 27 Jun 2024 12:34:26 -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 1sMs4m-0001Tb-Af for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:24 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs4k-0004Uz-KV for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:24 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3672aec418cso1316020f8f.0 for ; Thu, 27 Jun 2024 09:34:22 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367435852fesm2368830f8f.56.2024.06.27.09.34.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506061; x=1720110861; 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=dnn8g/1r/IDbgXO0nM+fG6kuhQufIGWzDGBB4WRk/v4=; b=DP65HpRMXK9/XazTsYgxsxuuenuEcuZ3a9rYP03uVLZeH8DYhRT0mdHKMOCVOe7Cq5 t5r7H5RCiMlMXRjLsoXiDx7bmdGkBwQFN/nKwU/a8Jr6hDippZpDejunb3B952Asytl4 AbLJxgcm4sUdGUG8NWNvv1rGb5IqG7pxmxZ2gHvtekyXrYPiZgom1McWNRszU9heOrTO lQegG4fVAbvWd4/NyZJ2KpzCPk0IDbuFHk0jMO2jtzgfapC02Ir1NOtkdWuc8Bnt0iZQ k7NV2elyfX1ZCcpArh8jXVYtZuqIV8VQLMmMQKIuBABj2SkAqGi0dnO18s7lExNmHNvf TtEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506061; x=1720110861; 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=dnn8g/1r/IDbgXO0nM+fG6kuhQufIGWzDGBB4WRk/v4=; b=YCmkGEF+h+8jFoVF/gkV+69sGJewBrGe+07DAT9zHAg5xO9w9u0V/i6RmJG4+gs/9I 2hxhHlyFAzg2NnqHplM848DRfNOahgozATyfKutZoZXvDrqUek4HYMlUero0B9WebCFV 3dwh5unKwJgUoPE7hOBJFzpocG+w6JCcxpigmz0ir2ZvK1xSptxbsmdBKt/LheH2XP+v R0lNVCOID7VCQJ7YuEvHY+NyUaWraVcGbcgNsgUoXQSCwNIzaBYIQ8xejNF5g2bcArYQ wsV2VMsM9zieC84f5+esPg28/kWzcI5QZg4psZTpjl7IzgxJLx4ImMyVeD6sfP3uUgyr NtGQ== X-Gm-Message-State: AOJu0YxsO+1EOeeD2GD+hizZ3y3cjkZGkHZabX0tWs0dLNYEo70Mz7iL ugJ9AeJdiGHktLNaJTky3MEDXZW/Ieu2O+ngWryTwPJda1taHtYQLZT3hdQdRzQ0r+P2fFsgWQp BxdU= X-Google-Smtp-Source: AGHT+IFkxB0eObbzUmDdMk7n4oHb9c6UmFKkOHtFlLVrwZMbgS3KsF1U4a6gFND4BqKzngzgGvXWGg== X-Received: by 2002:adf:e390:0:b0:367:33b1:e82b with SMTP id ffacd0b85a97d-36733b1e8b7mr2566041f8f.68.1719506060714; Thu, 27 Jun 2024 09:34:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 1/7] hw/sd/sdcard: Introduce sd_cmd_to_receivingdata / sd_generic_write_byte Date: Thu, 27 Jun 2024 18:33:57 +0200 Message-ID: <20240627163403.81220-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506095849100001 All commands switching from TRANSFER state to (receiving)DATA do the same: receive stream of data from the DAT lines. Instead of duplicating the same code many times, introduce 2 helpers: - sd_cmd_to_receivingdata() on the I/O line setup the data to be received on the data[] buffer, - sd_generic_write_byte() on the DAT lines to push the data. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index cd308e9a89..690a3f275e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1100,6 +1100,22 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *s= d, SDRequest req) return sd_illegal; } =20 +/* Configure fields for following sd_generic_write_byte() calls */ +__attribute__((unused)) +static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, + uint64_t start, size_t size) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->state =3D sd_receivingdata_state; + sd->data_start =3D start; + sd->data_offset =3D 0; + /* sd->data[] used as receive buffer */ + sd->data_size =3D size ?: sizeof(sd->data); + return sd_r1; +} + /* Configure fields for following sd_generic_read_byte() calls */ static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, uint64_t start, @@ -1953,6 +1969,19 @@ send_response: return rsplen; } =20 +/* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdat= a() */ +__attribute__((unused)) +static bool sd_generic_write_byte(SDState *sd, uint8_t value) +{ + sd->data[sd->data_offset] =3D value; + + if (++sd->data_offset >=3D sd->data_size) { + sd->state =3D sd_transfer_state; + return true; + } + return false; +} + /* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdat= a() */ static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { --=20 2.41.0 From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506101; cv=none; d=zohomail.com; s=zohoarc; b=D7AIF9oCffm22gA7XIUmJ4RLVz8MiLeK55L1kGxXwCitFgV2pOwhI+O/kz1q62UbeVnDsMwINyMJxb7PfpN64v2+0nZZ05xXy9HmslDpay6AH8QNAL6sKElKb8rQx35h4N6QZi14We6Qdom/MtZ5nXYCC/VUofTH9rJ9eiL4Mpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506101; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3vBMoM//nVZe9CjYveKRdhPX/dFzNyrTxzPZ8neKDDk=; b=oDnQTiITo+DWKBJKPMiYCHelyTihbi0oUGitOmfyx/YNdFOsaZhkUBrX1YFM6Tnr2ukcLRocdinBN0psYzIwwRo/Xd93LzucXAHy+BtsYl3+QhfvnsTyoiibjzlb40ZW7pOjmb1V/uLy/UyurnBnrrGVy2PUi199oappYi2vHgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17195061010635.16246432117623; Thu, 27 Jun 2024 09:35:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs4w-0001Y2-DM; Thu, 27 Jun 2024 12:34:34 -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 1sMs4u-0001Xd-U2 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:32 -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 1sMs4t-0004Wn-CA for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:32 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so63812855e9.3 for ; Thu, 27 Jun 2024 09:34:30 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c837a958sm71106395e9.27.2024.06.27.09.34.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506069; x=1720110869; 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=3vBMoM//nVZe9CjYveKRdhPX/dFzNyrTxzPZ8neKDDk=; b=JiCddBWrglWdXlEz/eMnm2CAMaEA1zViytrpsENmb+qahURIp8UY0JJv4UUTwSZsrU uHhRntqiSAonTAU9wTFgY3WS9TXAfPF47RfKehgGkkwUurbbYO5P4W9y/N8mDDXd5I2X y7JYu1Fn6TC7pQ7F7UkDLLwkwlRA/p7JWH1RGQYQbbzmOr2A1OemRJs/dvnQC2WaVmIC mcRuwVUUYsEjaZCE/JCIVyYgqF8Cc62Y1H/ryVm8fTGQUPDmj8Mr5GFbFskXU2cirOXo nssCZc2OhFxrVF7ckSqTa1FCkPf8O9KPH5wZiltJEEopHIHn6wmp8xKrQE2eoNKTWzlj dmyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506069; x=1720110869; 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=3vBMoM//nVZe9CjYveKRdhPX/dFzNyrTxzPZ8neKDDk=; b=FbZSTMTSWpIPkKt7cqyhxcN1vog+UksAQf9xAIfUy4qBN7QnGIaJAX6Zam9xw5K151 NIxSvFbDP/tB3fYFl1w/Ey7+NJmxWG7NYvmdJLXmVzZeLvIfKs2oNroU9ppVIJNs8YNu gMYMh/MWOFFgIbpI/JHqQyFhodFiD8yDg5l6h3N0XPXJke435+2eOSEDhov/+zgM8sR/ YMvQdjpSa/LmoBa4ZuSMoHrJTpozEUsaBUOON80n5uvY6h5aa22b1PdbTG8Pu3dIcjpN MJlNARjPSoUDozNK0+Moi90kpq+VNNXEJiaqylxtvHiBc8kfDVYz1sNyw7j5uhd7tfkP 9/Tg== X-Gm-Message-State: AOJu0YyZ+mehjLeAQw0CBxru2w/Ixw5Yl2owL9Fnl3sz88YI9XQnmyVX sM2AkUxM4AVbarcGXVOdYs//Qb+VcsA7UTTz7thezLPJJjgi9a0HMiTh7YFFkM+BbUFFRLaAMK2 3DT0= X-Google-Smtp-Source: AGHT+IFL2lh8jczBTPXoaTUIchyMuIhJJHm6yjhzuitt97QvEz8C4+BRijZYX7Ecit2llpmVytu/IQ== X-Received: by 2002:a05:600c:4851:b0:424:abdb:9c67 with SMTP id 5b1f17b1804b1-424abdb9c84mr40851815e9.40.1719506069544; Thu, 27 Jun 2024 09:34:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 2/7] hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK cases Date: Thu, 27 Jun 2024 18:33:58 +0200 Message-ID: <20240627163403.81220-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506101744100001 In order to modify the WRITE_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 690a3f275e..5dbfc8000b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1461,6 +1461,35 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ + addr =3D sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, + sd->blk_len)) { + return sd_r1; + } + + sd->state =3D sd_receivingdata_state; + sd->data_start =3D addr; + sd->data_offset =3D 0; + + if (sd->size <=3D SDSC_MAX_CAPACITY) { + if (sd_wp_addr(sd, sd->data_start)) { + sd->card_status |=3D WP_VIOLATION; + } + } + if (sd->csd[14] & 0x30) { + sd->card_status |=3D WP_VIOLATION; + } + sd->blk_written =3D 0; + return sd_r1; + + default: + break; + } + break; + case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ addr =3D sd_req_get_address(sd, req); switch (sd->state) { --=20 2.41.0 From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506146; cv=none; d=zohomail.com; s=zohoarc; b=ig0czZIqcJEBEA+iMj8zD5aAOfF1SlGkQsvqLj7opgWyoXZRw9QoSf4UfdWLHuvLGvMB9HfK+sBvUfKAHo+QmzrbQYvc60eMIzgRhYce+ZJznbUSYCGTGHzb21mp/sSGMoP/OBuXd9+mDEUDCTU2493G6uZMSZnASwTSSi6N7ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506146; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6OC5ZZTN2g0zXo+PgkNXxQ15/x/Un0F32fTNODaUpCo=; b=Qw6TLpot8yBTC35CK5onaBUfd9jtRNlGU9YpcjedFKLVE8Sq/ZiVZ8ZO+sM4WEQZYU1ms3KreWyH8Uvmh/ROWJLaSQYQA63MyusT3QOQXWaZ/mL9lYs9YmHFmdFPE9bLu3zWZ94Z5+73Y9AmzL+GGZvWslxJQ9ZzDoYCB3dX+vo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719506146252633.2619713220532; Thu, 27 Jun 2024 09:35:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs57-0001cV-4x; Thu, 27 Jun 2024 12:34:45 -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 1sMs55-0001bX-HB for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:43 -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 1sMs53-0004Xp-TF for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:43 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4256788e13bso4476365e9.2 for ; Thu, 27 Jun 2024 09:34:41 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bb6cccsm34736665e9.35.2024.06.27.09.34.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506080; x=1720110880; 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=6OC5ZZTN2g0zXo+PgkNXxQ15/x/Un0F32fTNODaUpCo=; b=rcf8ox58YZWChJUnHR7hZr1l7eWrvp2bxXw+qa2eBeZGkfQOGudn3z6+fv53un/lER o+gxM4IXreEbzLuFLMQlc+SM7fTPObaPgXAlEnJoc0wQ7zAd80+HVTMl64/+crlae/t/ ID+uZi+dbxnn0BQ8y3oqOek6310yMZyiEz6lEUaVS4N+g3UeEhwyFlizPVjgujbG/KYs vEQKzrnlOijrixlsCdO1EOnjZDbwlukWbsU3OHW9MxfcMFxsMvZjwnDa44G8nau++y/B MZZONam8Z+QOln9UJL+5KpdrP5gx4Xf6JvcHdscCpzfPhYJ88bSLd+Xw2U0iFbsdqLay 5p5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506080; x=1720110880; 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=6OC5ZZTN2g0zXo+PgkNXxQ15/x/Un0F32fTNODaUpCo=; b=lt/L5QcZ2xYXcyRTL7PM1ItPQytaUbVQExrf5z/QGkOOW2XTSo+r/EeAW04mjGPIgr yEFlhhgl2BnRkGd2dH+0fPHeZFDL63VSpVk3aWtbWd5HE7dOhY3xmLhn0EMblLyKosUy VeRbZ4GEAFgKqT/hl/w/zTT7flnNXkwSxbz5OK39Y1JxYUmP5osephX/ZnKci8KQFyHH 5ijSCiCMjwQfl6z078nIpwqmKtdn/NBdHMtxOzK0/eyyRozLkCgDah2HJy4rnWD2b3oL HZe/ZmRfaKWe3BY8tFJ9w/rNd1SFMBHoUpPGROmO1G95EAz0OCmJ6VJ3XYGMFA/vzFHc TVFA== X-Gm-Message-State: AOJu0YzrYXXtVWFWR3sAMkfXB8ZftOzbaWNwlKroejo5Z1oASP2zpFF9 6Z+lNP627Rz5eU42b4VXv5iiMh9UX4ToGiComRkrropcBP1osXbkZlfi/bU2WRIgt9M6HC1g2cC 9phA= X-Google-Smtp-Source: AGHT+IHmWB9cBJ6kB0a4Z7vpIdBao1tKUnFDosAx5eK6F3ndMypCrF/ked2M8wQLRrLDQAtC7/LUlQ== X-Received: by 2002:a05:600c:6b16:b0:424:a3d7:2a89 with SMTP id 5b1f17b1804b1-424a3d72b27mr54802075e9.4.1719506080055; Thu, 27 Jun 2024 09:34:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 3/7] hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24) Date: Thu, 27 Jun 2024 18:33:59 +0200 Message-ID: <20240627163403.81220-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506147881100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5dbfc8000b..4a03f41086 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1101,7 +1101,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd= , SDRequest req) } =20 /* Configure fields for following sd_generic_write_byte() calls */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) { @@ -1470,10 +1469,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) return sd_r1; } =20 - sd->state =3D sd_receivingdata_state; - sd->data_start =3D addr; - sd->data_offset =3D 0; - if (sd->size <=3D SDSC_MAX_CAPACITY) { if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; @@ -1483,7 +1478,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) sd->card_status |=3D WP_VIOLATION; } sd->blk_written =3D 0; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); =20 default: break; @@ -1999,7 +1994,6 @@ send_response: } =20 /* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdat= a() */ -__attribute__((unused)) static bool sd_generic_write_byte(SDState *sd, uint8_t value) { sd->data[sd->data_offset] =3D value; @@ -2045,8 +2039,7 @@ void sd_write_byte(SDState *sd, uint8_t value) sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; sd_blk_write(sd, sd->data_start, sd->data_offset); --=20 2.41.0 From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506130; cv=none; d=zohomail.com; s=zohoarc; b=PovGV6M4LEmGEHuu/UyIDInC8S1YmNLgqG0UvXH+pG4y8hgMbv7PONShSRh2+mltAIMBqfq197+w3k02BJ9F88XbVDOjQ59DWxg0NDjlNdL18KoSdwGLGorRfMM7gTsQwC3NHbYHVKdikhoqw4euSk2sdPLZh10uOucf/jsI4I8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506130; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wBDncTLnw5e5+FewhpyrEtD081BWahb+ptMB4QhJVa0=; b=iRmP8meA8jNNejmaUuJgPFDC2uqKG73z04IThI5VAQuRQ0QFxwSUY5PbSMR96mD5HX4DtbyXbpyqDaoV6/Xt/c9LH8EwJY/yvyJx458jE/QEzxff47dt46HbC1yW4Dmne8t2E0DftGwn8Dc/JQDUabXq7CyTHcRisfWlKfKr2bw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719506130922546.3749369465633; Thu, 27 Jun 2024 09:35:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs5G-0001lL-Je; Thu, 27 Jun 2024 12:34:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMs5F-0001iz-NB for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:53 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs5E-0004Yq-7G for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:53 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4256742f67fso5169205e9.3 for ; Thu, 27 Jun 2024 09:34:51 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8280a87sm75720715e9.24.2024.06.27.09.34.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506090; x=1720110890; 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=wBDncTLnw5e5+FewhpyrEtD081BWahb+ptMB4QhJVa0=; b=SN24iFVgfiw6f7qwlWKvnatbwKFQe2pfysgT03Bdn3W/bGZ1LQ5vIlBHqw6YQEJJuc +9y3umArY3lxpVjT+BZJUNmXapQVzh6vMIZXu8VjiuDDf+O3q2i78jQliEkaLA41DPjj EsKt5a8zgVS9U92BS0qLO1VEi4aFrikD65yp6PRKdQiNIrnXH4IjggNFahIoEzWve6UE QhumdqmmBTBQtXe8KgqzoVVzo6Yeqz8r1HyJrDcErhX8iboRKE4yIyysCf8f1Ttjsif3 XmxOxRr4x+6ASjNOB9fCL8gjOTjUDCV9AkRM3GRbbU1ZETp+VlygStDxzUARU480hBTc M7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506090; x=1720110890; 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=wBDncTLnw5e5+FewhpyrEtD081BWahb+ptMB4QhJVa0=; b=ieMiWCItWAvQFF0n/v/C3ib7Wn9hY9YXzFuWKAFEbS8KhCprwoZLjTzW0lsyodPzU6 c5I2uEIdSbuDzKVWpwzxTJg5tWjvlGCLyd/TA8JPbKzdZmz9OPnQe85sLSNbZMO+Xtqt q7XkH3yClXHS9yghU8ELz7cyb2Znv6N91zTVm12fLk/w+YHifAx1Z0hXpS016s8L9AKq kDPo16OL8KEw51VYMf9awixdvHlNbLhnWClrLH7vxUP7kKEr2mdqBfW/hkh1VRz+4awv Kdfd2JGaxrL41esp1wOPLSOrZLSjlS02t84FtndklIAdND/ZmH6DIL6011h4G9voGCS4 sAuw== X-Gm-Message-State: AOJu0YzsDCJJxU2MLtg/Fi2bzpiMVlFP64thRxHDxJa4r9k2YAVXdFLO x7dviyAphkmYWRCAbX0T5CKnRQ24O3yOrMiSb456skJsv/ap/s4IrMD4mysZwNL4Gt9UoMSMiyY Ytt8= X-Google-Smtp-Source: AGHT+IFjycMFJtbYfQl9HQFXWBtd8TCgZNDgCxPjnUDWj9n+mk7A5OlGhpY1UmXkfHOje0QBJR4iUQ== X-Received: by 2002:a05:600c:22c9:b0:425:6275:f7a with SMTP id 5b1f17b1804b1-42562750fbemr28834225e9.15.1719506090468; Thu, 27 Jun 2024 09:34:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 4/7] hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26) Date: Thu, 27 Jun 2024 18:34:00 +0200 Message-ID: <20240627163403.81220-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506131819100002 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4a03f41086..b9c72a0128 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1515,17 +1515,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) break; =20 case 26: /* CMD26: PROGRAM_CID */ - switch (sd->state) { - case sd_transfer_state: - sd->state =3D sd_receivingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 case 27: /* CMD27: PROGRAM_CSD */ switch (sd->state) { @@ -2088,8 +2078,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; =20 case 26: /* CMD26: PROGRAM_CID */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sizeof(sd->cid)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; for (i =3D 0; i < sizeof(sd->cid); i ++) --=20 2.41.0 From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506130; cv=none; d=zohomail.com; s=zohoarc; b=f+gQ3Wv59iBbtLFyTuOvjrmevewNz7z7MFIRGsiGmQKxvzVMi/CddDuMZIS2k4q4ixVFUW7o3zKrAytediz2Q1ecrGVr/5e2C187IXFE4aurzjKd413q9ZrRfAqnBHH/KasL6cWPDhls9A+a3Z738b49Vn840IMaeC0txUOV5vM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506130; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=R6Piulxoj8zPwW1Yv8YFFcFYZqBjXPSZ0pu/dRDGp6Y=; b=QjOWhyad//CUI50kFRKSadm0TUk1naSptYuyDyGDTgb7itx7RaBqcWZK/KFeE9jX5s24Ox/NPZPo12RaVv6gOX07m0u73waWOJq1jBOVv/dcygf0ShvPgKhjpPlIztvCGLoToOUOdZxsjCwuSkGctWG03k3s+y/NPzU9NZUNGsM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719506130969202.02126702939688; Thu, 27 Jun 2024 09:35:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs5N-0001t1-UK; Thu, 27 Jun 2024 12:35:01 -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 1sMs5L-0001p2-No for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:59 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs5K-0004ZS-7I for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:59 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42563a9fa58so9513805e9.0 for ; Thu, 27 Jun 2024 09:34:57 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674369eb17sm2371070f8f.93.2024.06.27.09.34.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506096; x=1720110896; 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=R6Piulxoj8zPwW1Yv8YFFcFYZqBjXPSZ0pu/dRDGp6Y=; b=S3l07bbL8wEOFBG6Egt5VJE6JmoOuuP+AO3jZ+FFb8mlWGC0MPhAbkEV5mpNsXXYU0 ueli/iHLuYCRKuAmK8k12FKcN/DAUylcPTPyKLWFxOPUvNQnGB3xf4eJ1niXKGq7jamv qAMDWS8M4BdnrZQA4lR1WroEQxSRDKdZs80QIM3yZzS8HBUOobdJ9rj+Wz7kvis+clSt c9LaatXjIqZKG12+bHYKkS/UvUcx8/kMfixhXEGx+S+Dje/gjQYkmWX1oMHW9ApNkuj8 lTSGf3RFvR1VgBkL0jyVSCx4FsCkXt/eJeMqdVD4vFzjKlZxNQsHKZlWxorJmyOePJn7 /DEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506096; x=1720110896; 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=R6Piulxoj8zPwW1Yv8YFFcFYZqBjXPSZ0pu/dRDGp6Y=; b=pVBSjXZvRtRUpZH/wNQaO0GGGwsKPCtFFfPNK5LRYFdY0jTaQzuZlzqMgS9TnJ9SvD vnX4cMD2D9yCGAzFConKZbLZe6gG33C+xWMimvwVI032od3fHlDXAWwqHDSfJHaqYx40 cQjXvjbGToPq7PK17HMFwxopqVJ9QLH1mAuGU2hAsHZ6gxBNoeJFHjBuPTVyOMNdS4Z8 pyg/BH4+BznacLznsmO7OD1X0UnVcbhFxIYauIoF+QXJszCVS2ks+pOsbJommLIO0v8R gbJEF2brhg2jcAxaJwlS+Xd6Nosxx8qK59PSctIfyxJOgjePBLme3l/1bMy2hjJ+czvy 971g== X-Gm-Message-State: AOJu0YyWE02NKZTlMxlDk9zowenWVt+bTBwtvGBqLD8CIFJ0kxhnyyn1 isKamnrXTJJek9PoD+yy5lyHUY7MvLW9AcXxrU9myzswLx6oF5iyICHo52ZILfJcgH65lJd4ZvQ zsj8= X-Google-Smtp-Source: AGHT+IHlrHip9w5BYhhMjlc9mdGK3epxwEAlEqYQqvm3FijUbRCvul2ztTlvHEhpN+oCeSsvw/43+A== X-Received: by 2002:a05:6000:2a8:b0:367:4dce:1ff5 with SMTP id ffacd0b85a97d-3674dce21f9mr1772490f8f.32.1719506096486; Thu, 27 Jun 2024 09:34:56 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 5/7] hw/sd/sdcard: Convert PROGRAM_CSD to generic_write_byte (CMD27) Date: Thu, 27 Jun 2024 18:34:01 +0200 Message-ID: <20240627163403.81220-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506131789100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b9c72a0128..bdd5f3486a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1518,17 +1518,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 case 27: /* CMD27: PROGRAM_CSD */ - switch (sd->state) { - case sd_transfer_state: - sd->state =3D sd_receivingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); =20 /* Write protection (Class 6) */ case 28: /* CMD28: SET_WRITE_PROT */ @@ -2096,8 +2086,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; =20 case 27: /* CMD27: PROGRAM_CSD */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sizeof(sd->csd)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; for (i =3D 0; i < sizeof(sd->csd); i ++) --=20 2.41.0 From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506127; cv=none; d=zohomail.com; s=zohoarc; b=ia6yqd2rreWPOgIOQzx8Q+S22B57xFskyVdFf5siYSzVFz/iKkBEiQz+4IWL2hc+vfAsN8pcj3gBDkWdLZWaKuUAk9f60uKF3bBRePHbiID4M3BU6zw0GvON8/6ClfD8CbSALAD3Fwb4rUtz2gFD1VH/WYLv0ii1V71XsyOqfVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506127; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a+swjnqxsHD9ZmAL3ZynjQXwZx/kNtJr6qmfanG6zVA=; b=AZCysGXuCiY0tDzdm90k7Hrfe0dy1eC6jOGsZcQ/K8dAdbWjKriYVMRF3DA4iVaiCg035Dx3Izh8iTMA90UeiBZ2cjHTiqvVR4Oegl9FYBtU0BfhF3KwDfPHVtnZbNVKuZiX3+SqyHqMQx+vFUtgt1rj3bam++mdfk09C0WgH/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719506127092711.9478805849684; Thu, 27 Jun 2024 09:35:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs5Z-0002WB-0F; Thu, 27 Jun 2024 12:35:13 -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 1sMs5W-0002HB-6T for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:35:10 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs5T-0004mo-TO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:35:09 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ebe40673d8so95851901fa.3 for ; Thu, 27 Jun 2024 09:35:07 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8251149sm72609445e9.11.2024.06.27.09.35.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506105; x=1720110905; 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=a+swjnqxsHD9ZmAL3ZynjQXwZx/kNtJr6qmfanG6zVA=; b=Emeu5zSIabq4XP6eST5d8z1OaaeWQi7dkn1RV409IFizg3EGbun0HUQd0TxAYyDLud QTuuVcMkHaxlVG0fE0F8Us7ZjkBtwZjIFHc4c5Fbx4981j5fKnffzGO5qKRnU9s+BX4M /sBr0OwsQJLGyQBgZ59Y4s9F8NO9wzdBBZQD23ANuf2mvu9zwhWQI2MbCnwFpNWUs5L0 QW686wJXvR31oa/XwO5Zqz/g9hpVcLHnxuFq0NPtqw78PfgYITzJT6dO0dEksMmNt+Nl dXB7qLXBZikxVlfrpjEpIiHuN5xtc2Tl+IUyGkymRhXvyez1cCnPSAgDsnSxqaQ27foM ka7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506105; x=1720110905; 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=a+swjnqxsHD9ZmAL3ZynjQXwZx/kNtJr6qmfanG6zVA=; b=NPO03oFtlUz7WRJrwR1P/NzOa7ZGDbCpHymxdpSpBrc3jkqZSgN76hHAVCzQHUvn65 MS+w1vGbAYkWIho9MjoQkwOY4hDDXwLGa7Dn6HS3PCaOnwUDgNFVm6NHUqHOv4Wg5+X5 YnyqwOKMO0nogz97UuO6Wt/crsFQRRkK/O5xPoiQn7+aZek2rlB7E+LHXYBMjP/qAor3 PzMAcG89iS0sesAZF90DIxaXt/5zydZC5v65N0FJnVbq4WyrCZRRoMntL2PVFPXTbS+u nTOTGlgQDSt3gxQuW31DlJ25MNqod5xLfKfncQrZ8nI0U/xqGXyZ8LDdAUqR1Han8tTi SISw== X-Gm-Message-State: AOJu0YxkBH09KdZFRLButoXBz/nq/S2eQAW6gwahD1eft+e89KOXmiGm z6tzOzm5PPOKGxkocGUbS+JNrlNg92p3M7fuKfQ2T1nUNwBYGtCr294b7R3Pz01F9l30v5aUz6S v22Q= X-Google-Smtp-Source: AGHT+IGWuHlIIZhNOn6Hh7/HE7qxG6JlUCUkhBL/XICXQ4brt02t/hs7OglGXPwY23XUEHfj80Roog== X-Received: by 2002:a2e:b0f5:0:b0:2ec:419b:429e with SMTP id 38308e7fff4ca-2ec5b3180abmr84573371fa.2.1719506104865; Thu, 27 Jun 2024 09:35:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 6/7] hw/sd/sdcard: Convert LOCK_UNLOCK to generic_write_byte (CMD42) Date: Thu, 27 Jun 2024 18:34:02 +0200 Message-ID: <20240627163403.81220-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506127768100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bdd5f3486a..0cb528b0b2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1628,17 +1628,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ - switch (sd->state) { - case sd_transfer_state: - sd->state =3D sd_receivingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, 0); =20 /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ @@ -2109,8 +2099,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; =20 case 42: /* CMD42: LOCK_UNLOCK */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; sd_lock_command(sd); --=20 2.41.0 From nobody Sun Nov 24 22:38:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719506159; cv=none; d=zohomail.com; s=zohoarc; b=PVk12oI/GVDAvQqLJJEiX8Cos45iO7zAuLlDw2nX8nzzpsNeze9lxH98otPQzp+Xz3yai14teMi2C0HDgwlPteJ2Uuae+NixFmjxWyuwF7p5OJvylWdYt3sThfnuO6Jn1I1tlI0jXYDgx3VeEsewutJZubT9oRfgxjLrGI6X+zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506159; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lRVCvBojEsyxAg7JZRES3P5o6lr6YCg7S7r2PnPDGt0=; b=hieSvhTvpYLPm51Uvp/CNBvEeIze1LuJd1lmnxsEuv4MuttidUjsU3GR5FQLPtf5VTj4W3xyNO6qvTutnUfgqkfi9x7nkoDc6bGxkmTOLKLCZPKB66nyfZQUu31nwVmTi47BRfDJFZ5vFgEaR0bOORk6BZny+n3XhEiruKTmWDI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719506159104101.40187655775298; Thu, 27 Jun 2024 09:35:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs5i-0003gn-3T; Thu, 27 Jun 2024 12:35:22 -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 1sMs5g-0003Yb-Em for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:35:20 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs5e-0004ol-IH for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:35:20 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so63818825e9.3 for ; Thu, 27 Jun 2024 09:35:18 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36743699b02sm2397663f8f.85.2024.06.27.09.35.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506115; x=1720110915; 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=lRVCvBojEsyxAg7JZRES3P5o6lr6YCg7S7r2PnPDGt0=; b=OHJusDm1jYbJJqnoTky0JjpTS6JHYNfwEdxtCyM4Y0n90VBg8hCUB20yPGjYySuttc BxLQJcXdCduLX/9PIgjaTueAv3Uf7qzbIozr2L0DFHXi3BBAkmhbDen5/6FupsGPY/1Z kHdE1XM5Z6iQ03dtXNuANgBotbFLm7FQaqNeOF0nmdJeXDx2RbKLVzrrgAlLTP2oV7rI Oq/AWr8v1rxF2TVQOuvUm1Sl67dSmKIwrPHaEPjKU7ZT/JV7LkVyLiRHh6JK/C4aaZbV +5gq1w4VirPcKgEmQWvL3RCYDcRPXCiozfRq5/tJl1ANjAh08kmbhpmCK2D7DIvyiVdh 8Uew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506115; x=1720110915; 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=lRVCvBojEsyxAg7JZRES3P5o6lr6YCg7S7r2PnPDGt0=; b=orR9DZZtK780za8VLbllDVSM5KRoU0Xm/vkj06dYklkht9W2SZqVyQtqU7p8OHmNWL VzUe7jOq0E8dFzVyJ9lya4KNA+TXAq8Cgi/xcTiFaIGFOke/T2byMixbW4Hgk1XaWFKB M7F/2QQbjeClgYj+6KUZk0ZojDSaN2OBJTiXL21YIUr3KUiYcNm6D6nBu9KoYeqENlf9 sbqliUDlOcxS7JgJYWPcEKvnIhpACduFQezZ+7Y/XTJGPfQG9yqrOeBB60C5gtEk6WyG Zaxz4X9Xx7p9ocUWXdJtlXorgz5D+a4AAtKnZN7HpF5Zi8IPJiWVoUf6oqwMqJEUHGaU cZlA== X-Gm-Message-State: AOJu0YyUqmpMqlPpVbMn4Idjyd/wckH7AaHDc6IjwoUlyoXzgMH7GxTW ukh2WpfD3k7v75bqGKqjVYM1zHN3WYqooMUy1DmK6cBI3qGrTChrAicgt8i8wMZZ1E8v/MUWHfy IS8Y= X-Google-Smtp-Source: AGHT+IEFjYJbv1wzdz6tE0MLXFPWWFazOYp5YmTZJNwxitmGZekDSAtJ5HL/nP8g+oH+ZcwZxJKT4w== X-Received: by 2002:a05:600c:26d5:b0:425:6262:1cc2 with SMTP id 5b1f17b1804b1-42562621d7dmr25305875e9.34.1719506115535; Thu, 27 Jun 2024 09:35:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 7/7] hw/sd/sdcard: Convert GEN_CMD to generic_write_byte (CMD56) Date: Thu, 27 Jun 2024 18:34:03 +0200 Message-ID: <20240627163403.81220-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506159914100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0cb528b0b2..f9708064d0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1657,14 +1657,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) case 56: /* CMD56: GEN_CMD */ switch (sd->state) { case sd_transfer_state: - sd->data_offset =3D 0; if (req.arg & 1) { return sd_cmd_to_sendingdata(sd, req, 0, sd->vendor_data, sizeof(sd->vendor_data)); } - sd->state =3D sd_receivingdata_state; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_d= ata)); =20 default: break; @@ -2109,9 +2107,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; =20 case 56: /* CMD56: GEN_CMD */ - sd->vendor_data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sizeof(sd->vendor_data)) { - sd->state =3D sd_transfer_state; + if (sd_generic_write_byte(sd, value)) { + memcpy(sd->vendor_data, sd->data, sizeof(sd->vendor_data)); } break; =20 --=20 2.41.0