From patchwork Thu Jun 27 16:43:32 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: 807861 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp899125wrn; Thu, 27 Jun 2024 09:45:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZugAGYtFmE3mzAYLa2y2sxM2aU7Hg0uK0lZTJULM6Ij66ROFjiWs5jBn7i0zVeoP3i2Q8aEPkkjWlepv3ViHV X-Google-Smtp-Source: AGHT+IGaCELqRX6LZ/V09m7kr9/OKeL/QGit7eDp9R9L1m0yIu93ZQJrYXtniqE1OFFo6wAT5TQj X-Received: by 2002:a67:fc92:0:b0:48f:38c8:28b0 with SMTP id ada2fe7eead31-48f52ad9862mr14468443137.16.1719506732773; Thu, 27 Jun 2024 09:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719506732; cv=none; d=google.com; s=arc-20160816; b=meHf2n95sieNbKC1QoOXu1BaaO+wHiwH4eJ4kMiRj8sHuX1PqLWHgtYtc8pm2cFulN SLwufE0v/OewXtvEMPHoTCMrR4Kwa24CAVWVFU5uVS3XVllPz/kkZwCXMeg+AHLJbI7P fTFemlHqTUlkNV5WSvXuoMsiPta/qSU1krGrXnzPgVMd1jgKQgZ9xBkGyCwp9+WiBI82 g+5kBRDGIKR1LsgeOLp0YGuyvA7TvcPVne2KnN0CohMd/fkzPLQP07jtX5G/Du4mVPQh d+1xKhUCs0yJ9Bg8WSsCjsIFJ6yXdX+14RgDPXN3pCnuxXw5LSfg4TPSSVg0UHv/46XU 8JTA== 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=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; fh=v4x9Oqm5dSIIGNwhX3iTRsusFrFNP2dDaR6uZLPgHBY=; b=C1l4JAIbL/CstDP0APX4GINXrr/WwDYJPSyg5tZw7xt2c645d5le1s7AEJn2tNmeuv ju4/mfmED/7jZZcOVblbhvChbCtOB5QUI0mrRPQZVHe0s9j2TcICCjZX5H87zYDhN40N vgUIO1p+2krTL1k2Mpo+kXAG5TF4plcNol+gJfB4fnHmHaijTprSgibA8sAB9+mzisP0 ESmEqEBA+LesBGTMVE+iYJ6Taa8NJUeHa+hEsI/V2M2hD0VcH8720nsIHwPrlHFZDzCl QilX77HLgK0cMO0bstUxFvG3+tUTq2kZ1cDw0IOMRCVafoyUPnYd9DuJhRcG6Dv+Y2uk A0nw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbOMYOx5; 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 ada2fe7eead31-48f8e5c6b3esi286026137.809.2024.06.27.09.45.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:45:32 -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=SbOMYOx5; 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 1sMsFT-0003uL-O8; Thu, 27 Jun 2024 12:45:27 -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 1sMsFO-0003bR-KT for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:24 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsFL-0008Uk-Al for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:22 -0400 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so92254721fa.3 for ; Thu, 27 Jun 2024 09:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506717; x=1720111517; 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=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=SbOMYOx5MAvlT7xfXBfWPXJqzZelgjFJZndZ4xCxemYh62UMUKMX3HjOzDYux/G4Nl HhA+99i7GomZ3wOghdigkm2Xhi/90eq4BtG1bFDyinL4bYn2YGaBTEfuLgi6uN0dyDqe 2U4slS0fQaTzUDXinwrS25tCbXOtavz+A9qGkyn65YUYlvtHynfhuNd4/2EOkJDxrdT1 gI6X9N/haKKy368Qvy4DZ0stC0lbNVey9JpNAa+/k0YYqPKDRIPQD22ZOsu2RNlUdhH+ J0mHAnW3y6YqG/OW8kM7quf/AGWCRFjpjoFnhOrrjBLZYfpALl0AN2zF+htndkOvqTre DOoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506717; x=1720111517; 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=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=FIN5Kjo+24fXGt+4Moo5Mu1EgK+lByhCN7vrOGrG2FvPVajTWsitGbSL8dAF4gj3yX F1c/09CXTpdYmoGkcyWH1JS+FzLY7MQhCJOWq83OLJ0oSTd9ih6qPWBYwxOOCPuO56/e MuxIENNvR7kVcsBzDm6wWzT6HurUgtEGWDFesOcqrnS3qRBkzWT6k8+mI4AKqgXErp7s pwPaQPyv1dZ10yMcZiV3TPDQ941eKUuUGEbaKz6CsERxZplHQa55mXerToeXUNmMqdvi 3JBlFAyaMdpeASys2IEKPPiJ3dHhQndwnDdGeYYhFg25sdl5Bg8kWJM1FEgBpa5nTcKC KagQ== X-Gm-Message-State: AOJu0YwSfDuZhyiNc/VwYAqi5cz4T48vXz2wTUzpCKVEQK2rNt45SN2S n20OsLeaVmqC3xRCGY31l0Hc2UkhXMpblNC2OLRnqskqJnua+Y6CSI32miBFLdG8dxpaytpfLoD WvzM= X-Received: by 2002:a2e:800a:0:b0:2ec:4e59:a3de with SMTP id 38308e7fff4ca-2ec57967be5mr94810931fa.10.1719506717191; Thu, 27 Jun 2024 09:45:17 -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-42564bb6d28sm35291065e9.31.2024.06.27.09.45.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng Subject: [PATCH 09/21] hw/sd/sdcard: Add sd_cmd_SET_BLOCKLEN handler (CMD16) Date: Thu, 27 Jun 2024 18:43:32 +0200 Message-ID: <20240627164345.82192-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=philmd@linaro.org; helo=mail-lj1-x230.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 | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d7ed8aee73..d731c3df58 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", + [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", @@ -1425,6 +1425,22 @@ static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) return sd_r0; } +/* CMD16 */ +static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (req.arg > (1 << HWBLOCK_SHIFT)) { + sd->card_status |= BLOCK_LEN_ERROR; + } else { + trace_sdcard_set_blocklen(req.arg); + sd->blk_len = req.arg; + } + + return sd_r1; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1491,23 +1507,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Block read commands (Class 2) */ - case 16: /* CMD16: SET_BLOCKLEN */ - switch (sd->state) { - case sd_transfer_state: - if (req.arg > (1 << HWBLOCK_SHIFT)) { - sd->card_status |= BLOCK_LEN_ERROR; - } else { - trace_sdcard_set_blocklen(req.arg); - sd->blk_len = req.arg; - } - - return sd_r1; - - default: - break; - } - break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2306,6 +2305,7 @@ static const SDProto sd_proto_spi = { [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2337,6 +2337,7 @@ static const SDProto sd_proto_sd = { [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, + [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT},