From patchwork Tue Jun 25 07:34:37 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: 807269 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2222836wrt; Tue, 25 Jun 2024 00:36:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzi1UebHfu0mNLaj5Fidw61NAUsRqq85/Fu0f4I1DZKIGO9rVqIkleicMom2R2J6eFOjbaV0jkQbsZ4y2WDkSi X-Google-Smtp-Source: AGHT+IGgU36EkN0SvNlxD4Luwmg3A13DCiAkFOkHTywiNEMOHZy98hVMK8Lxi+Qsp/zb5yiMEqcT X-Received: by 2002:a05:622a:1b86:b0:441:5887:a04d with SMTP id d75a77b69052e-444d6441a2fmr65187591cf.11.1719300997709; Tue, 25 Jun 2024 00:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719300997; cv=none; d=google.com; s=arc-20160816; b=dwqFXNHooK7DaePhtyXjbUyBIa0WE+p/SlsgZ42YV3nI/hE6CwHTQzFXMoY73BFhbN jJ2T1PH7CEziZFeLpc17f5QLsgY1HQTq6WkYmGYmdnaM5HZ7RyNXNXkhbglXT93423J2 Bbt/OjSP2K5i6PLtA+dAyLUvCr3tv7CQss6dJKJI6bfjbCJWHHSF0UwY0aqTRBb6wphd KEcBE0KGgRfo77+GQUG6L369s/gsjRlgJQ9/X/nN0O5wbyBlHzjOQ9P8Mk4MDAa3vLCC lUOPv9kFaRAn7cjKEbkJqjjBtwiYSIG+7x8q/ROusOaQrogCm6/8HRZ4vCVdIgsvhJqd /YgA== 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=wK0X2J7xkzuOoEV+SXxI0L9Mdx2I1sNaqE4cl4V+Wxc=; fh=RCxNUJwt/amfcWvs/lXDf/JmxshGBXr892O+ARTFYyU=; b=JTU37w8ckveZyBC+QcjyPkFMhlSxMcN+MqNavFc80M4fpciX7C/vzWXRcf185n/Jpo 2ww3ilMQigFF3fuxVYTBoqs/VFcqngzVq4tByqhGRBcvOyJHUoxog50wCaN3nHwD+5OY mgZG2+Xztggo2mJtxYwj9FWxIcNHRZXGXXIXqnUHzzU2K9NHp789U7IZpZ3ablig/tWF arqSFzooJ26S1B+7USBIzJi3vTfgyKcCw+64gInjJDXbAZrKGC0EI45BRbVYKAwHxED7 0cTuE/+R2eSwUQ99Tf+Jiyk46fnCdklYWpVPXgxai0vi4XjfJagb8qDJ8JRCK2K+zHzo plFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M54iHxNN; 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-444c2b4c977si96703151cf.6.2024.06.25.00.36.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2024 00:36:37 -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=M54iHxNN; 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 1sM0ho-0004bX-7Z; Tue, 25 Jun 2024 03:35:08 -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 1sM0hl-0004ap-8h for qemu-devel@nongnu.org; Tue, 25 Jun 2024 03:35:05 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sM0hj-0003lI-G8 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 03:35:04 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2ebed33cb65so57158391fa.2 for ; Tue, 25 Jun 2024 00:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719300901; x=1719905701; 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=wK0X2J7xkzuOoEV+SXxI0L9Mdx2I1sNaqE4cl4V+Wxc=; b=M54iHxNN8SiAkNkVpD+eR/6SRzLjI7VrrwRmAlnkT8lvXMnJA3vEAJrOcXbOEDBSnZ xXo0fzjYLS8Dvcyp8HECvlUdIFhsVtw8Z9Ynf1ouwLrXkuQCN69Zxzls/dFBiNyJsXrI bF//SXHnZjSWBV16eYWmXD7b61PTlSXEAbmV/ZhnwfcG8yPeL6kjsKnIUwtWRlrC/PSu 5/cF8DVqzKUremXGJsuXUZKdhyRc8SgKpTnqiu95SfYpgr4V981BiQqPemQuO/9bqrlN 7vTz960Z9ge4jLneELiIKsZXLzMRHZRb2py3neIPOteD4A5Eu56k2Wifsq/TDQWV/kFr qgQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719300901; x=1719905701; 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=wK0X2J7xkzuOoEV+SXxI0L9Mdx2I1sNaqE4cl4V+Wxc=; b=D/veaiJVlIfdtUZRynHXt7y0XUAREuEp3uugzTCaNri5zkso+iNmUa2QR21pRwAYp7 phArVbRYuuMthrzboJnzaHgxPeYuRG8+V6hWiJkjiMESf/OEaSXT53smWc/LIIthaD8x ysSvIpijoW2XobeldR8aoTuC5GonqfV46nvg/pyQraC6KQZkhiQ6d/vPe8uxHSynNeeZ S1AYXXBJpAqapMl0RVyqjh5rKc3efcBQ6Uh5KgXlmontEl8Gnm4MH0Nyaixz/i3e4E4y YVk5NrF9yYkxbDcN3ED/LqZa3K5JMU2c8/pNL0NHpJ++UezYJNA1RGgu+TW7cTLfyT97 cHaA== X-Gm-Message-State: AOJu0YxrC1MnOqL3FRbKzANBarIr5CNCQH1qpbf4N58xKuojPq0qiIzc acLmCR06McneRCrM/q+eVjUcehBssnw9RHEzkN7deEx6+4i+H+yOPFQQljlYaU4Dvgn5mjkxPH/ E X-Received: by 2002:a2e:9859:0:b0:2eb:f0ed:a36d with SMTP id 38308e7fff4ca-2ec5931d44cmr56284711fa.19.1719300901360; Tue, 25 Jun 2024 00:35:01 -0700 (PDT) Received: from m1x-phil.lan (mau49-h01-176-184-41-129.dsl.sta.abo.bbox.fr. [176.184.41.129]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4249e48ad3dsm12591665e9.16.2024.06.25.00.35.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jun 2024 00:35:00 -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?= , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH 3/7] hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24) Date: Tue, 25 Jun 2024 09:34:37 +0200 Message-ID: <20240625073441.34203-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625073441.34203-1-philmd@linaro.org> References: <20240625073441.34203-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=philmd@linaro.org; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- 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 8c30826754..fff4be3ae2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1081,7 +1081,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) { @@ -1446,10 +1445,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_r1; } - sd->state = sd_receivingdata_state; - sd->data_start = addr; - sd->data_offset = 0; - if (sd->size <= SDSC_MAX_CAPACITY) { if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |= WP_VIOLATION; @@ -1459,7 +1454,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) sd->card_status |= WP_VIOLATION; } sd->blk_written = 0; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); default: break; @@ -1975,7 +1970,6 @@ send_response: } /* Return true when buffer consumed */ -__attribute__((unused)) static bool sd_generic_write_byte(SDState *sd, uint8_t value) { sd->data[sd->data_offset] = value; @@ -2021,8 +2015,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 ++] = value; - if (sd->data_offset >= sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; sd_blk_write(sd, sd->data_start, sd->data_offset);