From patchwork Thu Jun 27 16:27:26 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: 807833 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891433wrn; Thu, 27 Jun 2024 09:29:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrqCU9970LCJSlHkb0HHl8ZIRejRqWjKTxMgUOsh7y5f7inSuLdKIb7Fg6p+NADjxPyQbgvBPNkl8MucoNFzHd X-Google-Smtp-Source: AGHT+IF4EjdAi5/y35fWnDaVhxtNHMByc/C1m45fc66DfhpcGQY4Vf9XvZDy1QCWK72jkR42J7qF X-Received: by 2002:a05:620a:564b:b0:79d:5b0e:fa9f with SMTP id af79cd13be357-79d5b0eff82mr284291685a.29.1719505756479; Thu, 27 Jun 2024 09:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505756; cv=none; d=google.com; s=arc-20160816; b=AFHF4Z6EWX3dzFuNM5hTZVG1p06+sK6o/Hk7sCE/FIZScvRR/Uac3Ikj89Rx/LjF2u fP9QyAq8dSlUDDe7Hyk7LbsSsuRtVazpkZWMFZF6APeyKhKTDzQeBKOb7pyNa3ygpC5s YYIhxE/YzKa5sxCrGhbmKZXhc8jsQUgqtgLvRax4Thj8cThxFKByhSXTCUY6w4CvPfTF anRaVV5aahhtegkSoQfzIn0Xh8ogmEi9+shU+QBqDK4hdQ5SPY+9onlX1pyDxvRJkWs/ Ue460CqoGmSlT6nblwiY1cXe++MYPSN5j8lUk1Zfq6RTJ+eF0NF5/mnRM6dJp4JcjSme iHLA== 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=YFcu17tDfahEqd0nWcM4QNDjKuDYW6mA06GxH1+cI+qo6ImIkGk32efVwa8ohrtsSz LXwcTKJs5HQOHpGs4bMM9SmhUVNxDujjiqVXy8IK026KE5ewseUDc6f9ocK3jpGaGeIY GmR9qX8YRJKIcSfVh//GCc8unv7jitQnnO5cnHnqZoHZ4qRXouEEebpf89rYE6EedeUV xKjKTougedrOVNWMusVTqL2PYyR9AERofbysS6wCF4D4Z0IBg/9FNOvvMq8v2bKfrnB6 66YLVQ5La0kghVRLThq4PjF/9liPz5q9okUmnx5vfz53QqnVQ1PpLDYpBq1MsMM7qwWr +bSw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NkximAbf; 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-79d5c8b681dsi169410085a.452.2024.06.27.09.29.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29: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=NkximAbf; 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 1sMrzZ-0004Ft-1C; Thu, 27 Jun 2024 12:29: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 1sMrzX-00042I-7W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:59 -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 1sMrzT-0003W4-0f for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:57 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so12999345e9.1 for ; Thu, 27 Jun 2024 09:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505733; x=1720110533; 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=NkximAbfHZwrsZZoe9aAeCHIaepMoqrCaL2jukDcY5odVc5+ojfRdJzRY36C+BJJ2m iN332BWvqs3VM+Ii6/lwYsI8Q94jnu1aL1kA4aoPqDSEyuXqfI04MrNo+SwqKqh+km1M 7pYuoo8fSON8WYWoCxsq1s+pggqRgXWnuWIyrBENLXKQxsk9PfSjEG28HrqGPwKAdwmN KsJDAJHlfWW3h94bkD3aa/FyLEckTQQ80V2Zti5Z6FNGLu7tuBcsha+gEzhUoWxjkAEP /onhrHWa0le9XOUGWeDCk1tFEG34OMGJ/Fffo+khIPW6dlpbZjoxVGl3PLESZbaFrILY Ljzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505733; x=1720110533; 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=tpFi2lPqiKp2S4jBeICmq08F09/yqfTnPhSreg7GF2+wIcUAKUMNHjkW28mn7uoJMT SVV7ZMcCU99e7IoVJzy60CeG/8i8/XysQICEWMLWKxbw41lIFVIH1ZUjSCrBdeFLDcF7 PFUkfTQktH7T5FMSkWYlWo5EMHHA8YwEWGNG00HEnPMSXkEEWOwzaRa/wsvaQ1cbprTR FTrc86PWGXTJwD28Ss68WDEZoOiHG3aOWDwV0esUHmRFGGOkT1qTlXa4spWieotoyRfR TI8fpaXXFOg6UQaJVBEXSpv68m442EP+IDhsq+K3ZWCXKGOCoBIkjW8mSeBPwor+aPlZ nElA== X-Gm-Message-State: AOJu0YyvjlEOZcE86GIDTj5oCLMPc55j4JqHpBKyok5FLQWrEF9ftHCM /I+q90xF9x9kwgg51sjUdM9rUiCWx9a2TxIkog1+8LpPTxU5VT9+P4w5RQv7GHFmqb+KKGivY1E AatQ= X-Received: by 2002:a05:600c:5104:b0:424:8836:310c with SMTP id 5b1f17b1804b1-42564316399mr24158445e9.5.1719505733307; Thu, 27 Jun 2024 09:28:53 -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-42564bc59f5sm35576815e9.42.2024.06.27.09.28.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:52 -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 08/11] hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56) Date: Thu, 27 Jun 2024 18:27:26 +0200 Message-ID: <20240627162729.80909-9-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::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 bf922da2cc..ccf81b9e59 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1648,10 +1648,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: @@ -2137,6 +2139,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; @@ -2185,14 +2188,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;