From patchwork Thu Jun 27 16:27:23 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: 807830 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891226wrn; Thu, 27 Jun 2024 09:28:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXAWqxb9B5d7EqQFIAueXZiCdUPnOshiYFz270KCvNeCjs+PDbUVV1mlUcncM+w1Nml74rvk/qb9n/8LpflY08u X-Google-Smtp-Source: AGHT+IEfGl6hvxZxn3LRx0s8JJBTPstmJS3JV2j04bjTlu2B3jG+E+UPyEWDxTEpWSmyCBK7TW2h X-Received: by 2002:a05:620a:254e:b0:795:b289:bf35 with SMTP id af79cd13be357-79be47cce1amr1485449985a.65.1719505726191; Thu, 27 Jun 2024 09:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505726; cv=none; d=google.com; s=arc-20160816; b=J6fWlZS5KGvmkAUck2rc3sFnu13t6dk+F350yfERpVZS8/AFiivs5BhCVq8KYJP0oe grvTNfUuXC/qVKZ2/NTtJhDxlEz6ZDVZ9ZmVZi1oY757k9daC5MZXY1gFX+XnU3p5/Lq YtoAFB9n2j3ezJXISqH0RT2M46+OvQnhyo81y89HwMW9OK8iL9LYukhxnOi1Zsnca0nT GddzYtfc84v+YHsLjDSV3idXt91mJImExG6h5yO2jRPbgiWe+aco5ZAzQthmqYSMT1Wo Y2WDeRXoUb0TiK4k4a0I5DEa6iCyYX2bWFPBqAmG5U7mFmcsbccJVpDpCjajJDs42wtp WuWg== 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=J/vnsx5tTBHBmnk7pBA4+j+yWL2B6reDo7sF6GjpseGkgro6eq3YJeMpFV088B2NN5 SGWPBTJuEAoYWEgQw5sm0AlGHskfq+e6zHv7erERL60TtY9pYMZCvESijfn0N7mbU4Xr 43arRDevIfZuSmYRrZAsW6l9JUQkHeRDaAmiR9LU7r1Sh6Y+J9eYbqlpRFoNDrIBpZol DsPkc0G9jZMAPME7O6woFlFbtxjR0Aq4L9GT0SN/Zp7LzFDAPfPX6g776kSXc23MJTbS ZevVZuAzrsjZkl6t+fbwMngFAy24qVV/bxkUGbrRoWoDmEgpyPrZnnCto35aWU68lgUE H7Jg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p6VBLk6S; 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-79d5c7aa4absi166725585a.96.2024.06.27.09.28.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:28:46 -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=p6VBLk6S; 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 1sMrz9-0002Ry-6H; Thu, 27 Jun 2024 12:28: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 1sMrz6-0002Kw-Uw for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:33 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrz4-0003Sz-6v for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:31 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-364a3d5d901so5382498f8f.0 for ; Thu, 27 Jun 2024 09:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505708; x=1720110508; 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=p6VBLk6SzLc8jyl2mIYxsz2jOv2+5CE/LYekPRKVsWZuP60H+BdfPdClSvhU3JiN9T JonknX+PHpwWPGIyID01yIMfKG78veT/p89nNV9QONccS9pc+le66sZIw6M4+YiQhp9O eyV+BdB4vw7z7NjNJX6FWmE1csT31aeQOhZ6BCBqIAisjqnMqqpeDPUKlIhXWi+HuLCQ n3sueN1gM3fjkeNUMJcmhhop9u1XrTNezOf2MVUnrqfucEUH1i72pSzABeHouCSNqj+5 P9nF6GV7ND++q1lXujpJkWZGpZdhsS8UY7tsJTDT+LkKWEpa9C83CSW0zbU+4XG1yF1k J0xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505708; x=1720110508; 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=sDfVuayQqjTEFRV0utCUlv1PCYuq7lQMxtLKJOUc0pRkcA8zt4INVj6pid8CfWTYV1 NeARguE9/PJ9NQmCDeogZ8NVoYIca0ObEPKeuEF8nIDpHnKRSXoq0cKX9mAdX7k8UMQi nQtUDL2YyiW7+nDHftr5P+iz8RatNzDKABGxAyc5V2rq3Iea3TRdNfU87OGWG3ik8K/z Om/jkeE9KGcOcga3p80zKEqdrnj2feLw+wr0IXvMZ+6aOV320EZy6LGaPtICqLFIkLYr TqxPCEhIetVaJBg055dMzxJ8K2JnGmhfWX8bfW+aVxal1hPtqsd0/ksqPkl3D17pEkBh W0fA== X-Gm-Message-State: AOJu0YzXfY77Ksl6FIPsdQb8TT5eLvPBwpkhfdxOXJOwtHKp3+QbT4HT BCVhNLLZBCa3L6ta6D0gGlNmtz1CN3nHiA977lIgxyn84eVTpjBsHRHQhtbY1IPOjbj224GW12x CUwM= X-Received: by 2002:a5d:58c7:0:b0:362:69f1:a08 with SMTP id ffacd0b85a97d-366e948fa96mr9537647f8f.19.1719505708589; Thu, 27 Jun 2024 09:28:28 -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-3674357c1c8sm2402704f8f.9.2024.06.27.09.28.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 05/11] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17) Date: Thu, 27 Jun 2024 18:27:23 +0200 Message-ID: <20240627162729.80909-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index dfcb213aa9..605269163d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1405,11 +1405,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { return sd_r1; } - - sd->state = sd_sendingdata_state; - sd->data_start = addr; - sd->data_offset = 0; - return sd_r1; + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); default: break; @@ -2144,6 +2141,7 @@ uint8_t sd_read_byte(SDState *sd) case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ + case 17: /* CMD17: READ_SINGLE_BLOCK */ sd_generic_read_byte(sd, &ret); break; @@ -2154,16 +2152,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset == 0) { - sd_blk_read(sd, sd->data_start, io_len); - } - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= io_len) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK",