From patchwork Thu Jun 27 16:48:03 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: 13714856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E792CC3064D for ; Thu, 27 Jun 2024 16:50:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsIy-0003nc-J4; Thu, 27 Jun 2024 12:49:04 -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 1sMsIW-0003Iw-6i for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:48:41 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsIU-0001MK-D3 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:48:35 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5295e488248so9700184e87.2 for ; Thu, 27 Jun 2024 09:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506912; x=1720111712; 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=1Ij5pjsDB8qqEoSZ8JFKxxVUAdb9cjcc9vXzXqWT+4A=; b=e57gx9OoF/TpjB0MXM8eKiIuGpIc2MoOKv68hXg+vwC0jQJIPApNctIl1NsAiOireS o2o8+ihlCoY8xB+PGsLb8cwOMQoELhSR4URPYEtRCcb4RgOci9Z1Ky+8z/PlKpMBh3l4 K2eCtv7/+tOMtWdxw7qKBMUfHOh/xxP3M1D7d5wL96KFUBeU6j2jrpvX192YJdnq8vR6 1Fc+UgJDzxjfM0AdkJEEEeD05YiQyCdVQhGNyuRbOILw6jWgRJF39oXotTIzi+GdQKcQ 8rv5i1rna+GhuBi/ZwEuWrotiWwy84RoN6mPEzV8gd7ZQV/402YVP49pmzSQEiWkwsY/ RinA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506912; x=1720111712; 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=1Ij5pjsDB8qqEoSZ8JFKxxVUAdb9cjcc9vXzXqWT+4A=; b=gOr3u6bn6vjrurNb1Yb/V9S1wMoQELFsA6MJQVFzUwMRohnxibQkN2jzXn2+T8FIT/ N55IPyaIcuJSf00ZIyIdWF9hymtFScj90tLVkgq+LSPw8KU2tozF4SsL40Pvs0Ti7fhW rvYN2n0t3muHd0eGY7hBdUzxCuFbbm5H+ERKYgiJMzaWWbUWupm1bM6NhokyNAJ5wLx7 Rp6HjYeVVt6EtehmLLM/yI21mqIc+5A3/LkwiXIzu6lwQdEZYi5vOQGUZmxn8gO2R7jf EqY+io/6Z6Ro41k8C4OUg45D2XS4EqxL7kL+d8IoqjS80td2Ddb0LBsn5Lp4WaJYEDm1 XBTA== X-Gm-Message-State: AOJu0YwKXpLfrMu7Vb/0PJhuz1b8SjZnasjrXQDu/o3XgTnUJVg1mAau PEdrOhWTDSb2/xmFfazbmXT+G/9za8rzsVCaCCa8ptKYVhdg8zvkiGIIozxrW1n63ad2HyJZgoE kKSM= X-Google-Smtp-Source: AGHT+IFiwYt587NSyqOJ5rwwySHKEMWtgq9ROMygwkdC1L0QUxuIPIAfXAuo74ca24j4W/8GACvaWQ== X-Received: by 2002:a19:6453:0:b0:52d:8356:f6b9 with SMTP id 2adb3069b0e04-52d8356f710mr3846079e87.38.1719506911667; Thu, 27 Jun 2024 09:48:31 -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-4249b132fd1sm86086595e9.0.2024.06.27.09.48.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:48:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Sai Pavan Boddu , Joel Stanley Subject: [PATCH 01/12] hw/sd/sdcard: Add sd_acmd_SET_BUS_WIDTH handler (ACMD6) Date: Thu, 27 Jun 2024 18:48:03 +0200 Message-ID: <20240627164815.82606-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=philmd@linaro.org; helo=mail-lf1-x12c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2f853a89d1..0310a5a3a1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -260,7 +260,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SET_BUS_WIDTH", [13] = "SD_STATUS", [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", @@ -1672,6 +1671,18 @@ static sd_rsp_type_t spi_cmd_CRC_ON_OFF(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD6 */ +static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + sd->sd_status[0] &= 0x3f; + sd->sd_status[0] |= (req.arg & 0x03) << 6; + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1780,18 +1791,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 6: /* ACMD6: SET_BUS_WIDTH */ - switch (sd->state) { - case sd_transfer_state: - sd->sd_status[0] &= 0x3f; - sd->sd_status[0] |= (req.arg & 0x03) << 6; - return sd_r1; - - default: - break; - } - break; - case 13: /* ACMD13: SD_STATUS */ switch (sd->state) { case sd_transfer_state: @@ -2385,6 +2384,9 @@ static const SDProto sd_proto_sd = { [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, + .acmd = { + [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, + }, }; static void sd_instance_init(Object *obj) From patchwork Fri Jun 28 04:53:13 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: 13715426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AFA9C3065A for ; Fri, 28 Jun 2024 04:55:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3cG-0008DN-J5; Fri, 28 Jun 2024 00:53: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 1sN3c4-0008Al-86 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:33 -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 1sN3c2-00083r-Ax for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:31 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so1887815e9.2 for ; Thu, 27 Jun 2024 21:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550408; x=1720155208; 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=9vrkGwBcqZVZMukUtGlLs/nHFLle6eNwrj7janh4+hs=; b=nIiDPMkHIaq9c/7QxbDC4b+/Jty15PrIMFR9kMGXT2uQX+UIU4kPLESG2CpNPy7hpr B1RkwGaUohdC6mWz19h9DX1gaN4O8wslxsVN2XmoKZSkitLahX/XPRnU3O3FbtJw/4py zzOjyiKbayxUR4ICa8K9zNgKjDtefTBFuya5iPYwxJ+/prSmE6L20Xore2Ay8WNf3V0a qXN5K4pwVgMagvO8wm3HClapMjPp3SL9iK+Wl1rlmS2KBaeOLbF4gGkM3E/HwBEG16SE J631Mn5PVnMXBgDLr7QSVpSby/ho7h66dCLzUr+fL9X5b2itlcc0E2w/i9kzQz8SyffJ /ZGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550408; x=1720155208; 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=9vrkGwBcqZVZMukUtGlLs/nHFLle6eNwrj7janh4+hs=; b=O+cvkr3A09ducrnbfO6hETkTYmV4piVNVSDC07g5Omd92RQRpK35T6hmJIdUcEGhq+ KSBH5T543/ukdRiugGXMiwzcF58ykC1K2qXATjKTI/5wKHhczHX7VuG/nT0lSGMlMGxA VSzWU0UBUuYHrAlhekwHXf7wvusalTZKaLLkxsnLFoSXukzkBEMDxkj+GTEp1JJOhpUc XOYlL7yPI1bsAw+aIUxLCJ5pacCK2rppcKbp8AoHOMu+pnxtLgOmXP5YX0B2tiXbuC2y B2TEAEdUEuLyGCjxUiuN3iZJ1AetAs41PZJjnhieDaCtv671G1IPYfsAeSayHNvHix0P fcnw== X-Gm-Message-State: AOJu0YzfWHx9O72+/GCjeAoFJKfOpFb+OzLKBKSLGd94v3+xwBPdk1Um QFTYfLFJPG4M1E2EASCJcu/OqZafDTthH6JMD6oQIWt40rSruw17p9jG2Y49V1gYX27wNNGZEeG g19CAdw== X-Google-Smtp-Source: AGHT+IF53qg/ECt1wXE7W7DeylbxfI5udPBJGVPBPA8HXv1Qm1q/Q70vB7/YT53N1cT/dtFikAUoFQ== X-Received: by 2002:a05:600c:12c5:b0:425:5fe5:f273 with SMTP id 5b1f17b1804b1-4255fe5f3d0mr42043715e9.26.1719550407561; Thu, 27 Jun 2024 21:53:27 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a32asm17899595e9.31.2024.06.27.21.53.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:53:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 02/12] hw/sd/sdcard: Add sd_acmd_SD_STATUS handler (ACMD13) Date: Fri, 28 Jun 2024 06:53:13 +0200 Message-ID: <20240628045323.86308-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0310a5a3a1..5323a42df2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -260,7 +260,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [13] = "SD_STATUS", [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", @@ -1683,6 +1682,13 @@ static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD13 */ +static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, + sd->sd_status, sizeof(sd->sd_status)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1791,18 +1797,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 13: /* ACMD13: SD_STATUS */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, - sd->sd_status, - sizeof(sd->sd_status)); - - default: - break; - } - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: @@ -2329,6 +2323,7 @@ static const SDProto sd_proto_spi = { [59] = {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF}, }, .acmd = { + [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2386,6 +2381,7 @@ static const SDProto sd_proto_sd = { }, .acmd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, + [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, }, }; From patchwork Fri Jun 28 04:53:14 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: 13715429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D947DC30659 for ; Fri, 28 Jun 2024 04:55:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3cR-0008Fe-FG; Fri, 28 Jun 2024 00:53:56 -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 1sN3c9-0008Bn-Mw for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:38 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN3c8-0008TP-5z for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:37 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4248e28de9eso1960775e9.2 for ; Thu, 27 Jun 2024 21:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550414; x=1720155214; 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=JLfOaKjryvDgm8/tAb2iA3e2u5r9x8cBXXCm9JQWcag=; b=MGniMHVbfPFwk4ZmDvn/1W9t2cXnNsxkadB0mqVki0ArGPfLK5E6Gec9ctx97tyqvc 0WlbRS2IMNx5LiKkqh2nvUI7oJQKg5Q3NKMg4OK+4cmQEJw6y0+8p2tdGbMasDLWo1q4 //P9DYkxyJWxP3mS/9lW8PSiRwnGjJOToaRsDjZmH/JLQC2dbAbGXoWx3lbc8ognX/5l R2wa7vGXLTqbhy+zgIJ8g7327ZtG/CBL7ETrObOS3A5zHIPx+A7RQZmKwZOR7sPWCV6T I5X5ooXGtUsd8ob0EzoydQR3tB15mDnnu/IdejfnV1f/be7kVDf+31Q4rwBaiji4Qxxd y4WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550414; x=1720155214; 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=JLfOaKjryvDgm8/tAb2iA3e2u5r9x8cBXXCm9JQWcag=; b=kJZRpbXekDovjOq/O+WBMLRZ1AnlmZAeSVdRPTZIM7QLb7SC8XnEzlimnSWtfiaebT v349UZ8ZKrTGp++JjouAn8R+uk/snlM5dgg1ZSHzKn3C/9eauWqsy6ZNJYbXRJ4kSVxq AXUYAYRklzfQngCyn32I7S3hepj/c9ReBw7bWhucXDMYdJjQFfIZRbNc2mkKakzIB0SA c0uJcPmKHi0uBTIBHEwlAYoKQYWaTI1ekbxS7JEArKWLWIzgqA7ZkMRA7VFaMTv1yauc OLh2+VV/hrvW8pI9uuuEnAzwEWXenUXnz8tQqTr/nGE4nZ1IDJ+Y5QdavPCTsuYKmFVE gN/Q== X-Gm-Message-State: AOJu0YxcnwIwhTFiMHhBpdwNTOmot6a+mLymzdT1HVByzMWIwBR8UUmI +b4laggOIbTqlqXd4zWyXCZRketV3xKJZfVaCoNMPxS1eZlUu5UJdNCRZMr0ENw2XNlnm3cnUlI 7NEG05g== X-Google-Smtp-Source: AGHT+IFf8zCe7rLf6YyxQ08v5dLuzr9h9IEbQHaOKi+JzQFKgLNQpxjEI5GK+Cjx5g6mZMP2ZchVAQ== X-Received: by 2002:a7b:cb17:0:b0:422:9c91:a26f with SMTP id 5b1f17b1804b1-4248cc3426bmr107515545e9.19.1719550413994; Thu, 27 Jun 2024 21:53:33 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0642acsm18165885e9.25.2024.06.27.21.53.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:53:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 03/12] hw/sd/sdcard: Add sd_acmd_SEND_NUM_WR_BLOCKS handler (ACMD22) Date: Fri, 28 Jun 2024 06:53:14 +0200 Message-ID: <20240628045323.86308-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5323a42df2..9d66c3715a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,7 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", + [23] = "SET_WR_BLK_ERASE_COUNT", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -1689,6 +1689,13 @@ static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req) sd->sd_status, sizeof(sd->sd_status)); } +/* ACMD22 */ +static sd_rsp_type_t sd_acmd_SEND_NUM_WR_BLOCKS(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, + &sd->blk_written, sizeof(sd->blk_written)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1797,18 +1804,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, - &sd->blk_written, - sizeof(sd->blk_written)); - - default: - break; - } - break; - case 23: /* ACMD23: SET_WR_BLK_ERASE_COUNT */ switch (sd->state) { case sd_transfer_state: @@ -2324,6 +2319,7 @@ static const SDProto sd_proto_spi = { }, .acmd = { [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, + [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2382,6 +2378,7 @@ static const SDProto sd_proto_sd = { .acmd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, + [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, }, }; From patchwork Fri Jun 28 04:53:15 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: 13715425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54324C41513 for ; Fri, 28 Jun 2024 04:55:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3cU-0008Ge-JH; Fri, 28 Jun 2024 00:53:58 -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 1sN3cG-0008Di-0D for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:44 -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 1sN3cE-0000Wq-EC for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:43 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-424a3ccd0c0so2035135e9.1 for ; Thu, 27 Jun 2024 21:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550420; x=1720155220; 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=if+k3pC7/tUCTUn2xmGg3zarIgu5LY5GHs2T467fbqI=; b=rfxyJ8Wd1lYrO0/S+FMK/iNcQa28OsAdX7QZIpR/NaMFUKaXAoe9Bf5F/aIKuMHOiO D1/Qk89vLQGyZbxyfdgPFWFVZ0dz+yT90JHsRxMnTQYKAPdsSh2yXpn9X4deMWhFN0DG 4NAZk0T3GmxcPuhErZQO6lSVn25P3hHaz/f98xkPgm2YOJErwKoVt8uCRdaH7qc6FsPc yS8MjwrqvlW2wvCagin5XcNQ7t5G+/Q9U5M9hwOcWgu7P9QPPw53+xicOvB+xqzQPQLv 55BP4atz4faUSHGDhcykHcggmsI1f+35T/M5iz616RayWOB6i3Nh5jqKk56Mn0U5+jos 5DBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550420; x=1720155220; 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=if+k3pC7/tUCTUn2xmGg3zarIgu5LY5GHs2T467fbqI=; b=s275s4KpcoZ2pmgpmjT52/ve9RP3aV8iFZvLNcAYWfSN4SpfL2tGrGRlsR5acFRGzw QvgbZfZk1wmh4JZCMYb1pkUcGSPEWra6JR5Xv8BBbs1Q+U7tKonhix9uUh0K/CxG/1KA xd2YKBDicloB7qz1HubsPKMbxPyci+mxt7W0zGllPogG4hpeyI40RP7bB+FhMgnAHcJm oRpRH6mR197FCmcvjNj1yB+SzTrRQW3Yr8suRiWKGX/ssSFd5fWDYrhewA16wBkxG6Ui fLLcAbCKCXRiIj/bHr6hFePQdOkqG2xrTtGICMElKK41pZBy6qRCu9PLKG7g8X/WDsMT 6U4A== X-Gm-Message-State: AOJu0YzKk4m77TfRw4IgwC04qPk5ESem2gTGsGdzOSlWHq58RtdN1oX+ O1T+Ma4Gi9VGqvCtgnws1+zmnFYZd8V9vUbz/OufM+6KaFg2PVDTb3jV08W14OYCErU+IX//ebg qp/gtBw== X-Google-Smtp-Source: AGHT+IGDmXtiWX2jJDTWU+jla3epsGjUJndSoFrVb5uDaux98SHygVlvGjOldNv8xum+ZAWzmKhoUQ== X-Received: by 2002:a05:600c:3b8b:b0:425:69b7:3361 with SMTP id 5b1f17b1804b1-42569b7352bmr10751715e9.18.1719550420364; Thu, 27 Jun 2024 21:53:40 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af54ecasm17849165e9.12.2024.06.27.21.53.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:53:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 04/12] hw/sd/sdcard: Add sd_acmd_SET_WR_BLK_ERASE_COUNT handler (ACMD23) Date: Fri, 28 Jun 2024 06:53:15 +0200 Message-ID: <20240628045323.86308-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9d66c3715a..cd207a3090 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [23] = "SET_WR_BLK_ERASE_COUNT", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -1696,6 +1695,15 @@ static sd_rsp_type_t sd_acmd_SEND_NUM_WR_BLOCKS(SDState *sd, SDRequest req) &sd->blk_written, sizeof(sd->blk_written)); } +/* ACMD23 */ +static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1804,16 +1812,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 23: /* ACMD23: SET_WR_BLK_ERASE_COUNT */ - switch (sd->state) { - case sd_transfer_state: - return sd_r1; - - default: - break; - } - break; - case 41: /* ACMD41: SD_APP_OP_COND */ if (sd->state != sd_idle_state) { break; @@ -2320,6 +2318,7 @@ static const SDProto sd_proto_spi = { .acmd = { [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, + [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2379,6 +2378,7 @@ static const SDProto sd_proto_sd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, + [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, }, }; From patchwork Fri Jun 28 04:53:16 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: 13715424 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57460C3064D for ; Fri, 28 Jun 2024 04:55:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3cf-0008Hu-1E; Fri, 28 Jun 2024 00:54:11 -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 1sN3cV-0008Gt-52 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:59 -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 1sN3cL-0000yR-Jp for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:53:51 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-424ad289949so1693045e9.2 for ; Thu, 27 Jun 2024 21:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550427; x=1720155227; 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=bYEYJ2Wwx71dNKsAcy31SFsnrP/uSxrEAbuXlnudJVY=; b=NvKkGR4dZX69TRUprAurmT7zjgRF6itDIG4N8cZ6Fdb7fj/nmB7WmjWK5Qcf3GueMr TPKisfaQDmPcTI9IncGWzZhsDDpjhisWfhdFWGTjYPVcjZPe5tIO1OfPSFPB8bQGPH8h 4KmF8SvYAdrvCjtUhfbYCJ+2MQPVKjoNBvcm1sEnzBAVLAbFRN+SpAvDoFqY3sVQkRBM N9dT5NvzThcD4Ssleif91C3O9/hGM6DbxWVcqDicaiUS5rw2edgvAUtTj1F3ybeEwCuE wLVHJJOoEUG/yry7oudRVg+EI54AQYyt0G+qIj07lpIcaqsEm2xBi/8+7Iiz6J9muwIA AGSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550427; x=1720155227; 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=bYEYJ2Wwx71dNKsAcy31SFsnrP/uSxrEAbuXlnudJVY=; b=vOOQvWFvDQyA75KxdiMQTy69OAzVnyijTvqAzvguzTy9rjDlhNzx+/Dm2TVyC75X/B qFwNBtVmKxDrg0GMjZnMHrzzs9a3sixrsUJ7oCvivk2w2N6u4qur272EnNKU/UfYp3U+ TVk43w++9CdmEh5Se6U79yqGeZ6gRjFhu9/x3H6ezXrV5tQvS3zFTPHCVo6B082uQAzp Ci0iQMgbjUb8xBgPk3lz1Ypl0m8FoaSVMH0bneSqNlRp2jV3ZrNgFFvpdDmzmbBpYfj+ Ockr/G/4meCVG4CCYfYsNpVVGuUa0IIeCwsnChQzSYKvAySYyiRotd+jyXbG9GNo8Woc u/kQ== X-Gm-Message-State: AOJu0YzuFilUbyx/SSE59d2G4rSNOBLcVzXVYvSylii2TR0RuaVF3yaO exadjFANEMB0NkBLykcpUiHK6SNXdlfY/dvGfb/SnJQYPwyeWRgOLxzw+79RbUKkrYQGlrxC0SM 90xZAEA== X-Google-Smtp-Source: AGHT+IF2wuR/EsTUKhqwrXuCXID6JTSa05iGcVduS3p6PIItAp+gB+5A9DPsB9AKT/9iM3ekks4VEQ== X-Received: by 2002:a05:600c:1c90:b0:424:eeca:6bd0 with SMTP id 5b1f17b1804b1-424eeca6c69mr42766655e9.13.1719550427208; Thu, 27 Jun 2024 21:53:47 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0676a3sm17725975e9.28.2024.06.27.21.53.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:53:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 05/12] hw/sd/sdcard: Add sd_acmd_SD_APP_OP_COND handler (ACMD41) Date: Fri, 28 Jun 2024 06:53:16 +0200 Message-ID: <20240628045323.86308-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 82 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index cd207a3090..167e1c517a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1704,6 +1704,50 @@ static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD41 */ +static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) +{ + if (sd->state != sd_idle_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* + * If it's the first ACMD41 since reset, we need to decide + * whether to power up. If this is not an enquiry ACMD41, + * we immediately report power on and proceed below to the + * ready state, but if it is, we set a timer to model a + * delay for power up. This works around a bug in EDK2 + * UEFI, which sends an initial enquiry ACMD41, but + * assumes that the card is in ready state as soon as it + * sees the power up bit set. + */ + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { + if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { + timer_del(sd->ocr_power_timer); + sd_ocr_powerup(sd); + } else { + trace_sdcard_inquiry_cmd41(); + if (!timer_pending(sd->ocr_power_timer)) { + timer_mod_ns(sd->ocr_power_timer, + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + + OCR_POWER_DELAY_NS)); + } + } + } + + if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { + /* + * We accept any voltage. 10000 V is nothing. + * + * Once we're powered up, we advance straight to ready state + * unless it's an enquiry ACMD41 (bits 23:0 == 0). + */ + sd->state = sd_ready_state; + } + + return sd_r3; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1812,43 +1856,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 41: /* ACMD41: SD_APP_OP_COND */ - if (sd->state != sd_idle_state) { - break; - } - /* If it's the first ACMD41 since reset, we need to decide - * whether to power up. If this is not an enquiry ACMD41, - * we immediately report power on and proceed below to the - * ready state, but if it is, we set a timer to model a - * delay for power up. This works around a bug in EDK2 - * UEFI, which sends an initial enquiry ACMD41, but - * assumes that the card is in ready state as soon as it - * sees the power up bit set. */ - if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { - if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { - timer_del(sd->ocr_power_timer); - sd_ocr_powerup(sd); - } else { - trace_sdcard_inquiry_cmd41(); - if (!timer_pending(sd->ocr_power_timer)) { - timer_mod_ns(sd->ocr_power_timer, - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - + OCR_POWER_DELAY_NS)); - } - } - } - - if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { - /* We accept any voltage. 10000 V is nothing. - * - * Once we're powered up, we advance straight to ready state - * unless it's an enquiry ACMD41 (bits 23:0 == 0). - */ - sd->state = sd_ready_state; - } - - return sd_r3; - case 42: /* ACMD42: SET_CLR_CARD_DETECT */ switch (sd->state) { case sd_transfer_state: @@ -2379,6 +2386,7 @@ static const SDProto sd_proto_sd = { [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, + [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, }, }; From patchwork Fri Jun 28 04:53:17 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: 13715427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C02B7C30659 for ; Fri, 28 Jun 2024 04:55:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3d2-0008Tg-3r; Fri, 28 Jun 2024 00:54:32 -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 1sN3cY-0008Hz-Gt for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:04 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN3cU-0000zH-0S for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:00 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42561c16ffeso1875085e9.3 for ; Thu, 27 Jun 2024 21:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550433; x=1720155233; 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=V0gZMlOJcmhezdd4Yk1lqkQI7yCyPoJydtauFHQrfjI=; b=usV2tdS7nqPVEOAl4conk4qZ/m2RHB6p9xOgQLBsDzGxFXoVAokRfgsfSeiytRBZq1 +g+FSjeQRN7FfUCcg7+6Pf7qXrB3mCxvkdIOS53kmdT5nGMH4EnIByikTJDUmK0vGnvS 5FZA+XeUFWDJkcIm14enr7JwY+FyE/bcvTlISzMmrFPjSG9U1x4ixDdhIcMQtICtKwGR FcPxevBGNSQqQlCY8alJtkjNvMGJxxlvzbHuuvoQslUPt8qEaO42an40oEA+ki+kGYb+ mBYSeuyNFuetfAkfDxprZtzsCzgsnELx2Ig/sSzxb4vler/dBE6/+g/4tg+REzl2o/0O zFMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550433; x=1720155233; 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=V0gZMlOJcmhezdd4Yk1lqkQI7yCyPoJydtauFHQrfjI=; b=FcvctY1gRjN5wS72/tD25Dppb2cxZwMgD+0NT5Hu/XOe17D6rA5URVOkVD6lFKBEaI FP8GMgAUpsjrfXY9vfHCw9CDvZ/ORU/awKh2fnQUU7HZLNbXR6ie9SWL1lip7vZf1+f8 0EUZYwAU38kb8X7+0HSh1UkY/Ntt1csd6OXOMKSXceNNImjVe/Rc0kM2DwXp7/YeNKu+ WeTocyUM+GY1wZO7rOCBlXo/gTJs2MNwBJ55ssLd5eKrvOTrBMyhiHoj4zNXYbIytw8r JgtUtAS8enWWskED+R7IQSvbeTkem4FjQMeRnbOAAZi18QDRHoba17Leudq7LZLZUaxa mMDg== X-Gm-Message-State: AOJu0YwuC+9GeDCFwwKxS32sKqGWjhf3dtv68WiNkCzIN7f3ds2KDyVV 863KSx4ykyYwZ6hLL4ib0R5nRxQrj5aSiySXlmXsG/u2Otoel342fiuOM1PdOghqkefhdCL5nzy NphA2pg== X-Google-Smtp-Source: AGHT+IFjZet+FWymQKxFtUYPOH65+BK/+GeCnJm/tCxrawI0AMd/5T3D5FPNza8eU++P9DM1khKcoA== X-Received: by 2002:a5d:58d2:0:b0:367:437f:1774 with SMTP id ffacd0b85a97d-367437f1ae7mr2505882f8f.14.1719550433476; Thu, 27 Jun 2024 21:53:53 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d8df0sm1064540f8f.29.2024.06.27.21.53.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:53:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 06/12] hw/sd/sdcard: Add sd_acmd_SET_CLR_CARD_DETECT handler (ACMD42) Date: Fri, 28 Jun 2024 06:53:17 +0200 Message-ID: <20240628045323.86308-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 167e1c517a..a27a7e0f24 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", [54] = "SECU_spec", @@ -1748,6 +1747,17 @@ static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) return sd_r3; } +/* ACMD42 */ +static sd_rsp_type_t sd_acmd_SET_CLR_CARD_DETECT(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* Bringing in the 50KOhm pull-up resistor... Done. */ + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1856,17 +1866,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 42: /* ACMD42: SET_CLR_CARD_DETECT */ - switch (sd->state) { - case sd_transfer_state: - /* Bringing in the 50KOhm pull-up resistor... Done. */ - return sd_r1; - - default: - break; - } - break; - case 51: /* ACMD51: SEND_SCR */ switch (sd->state) { case sd_transfer_state: @@ -2327,6 +2326,7 @@ static const SDProto sd_proto_spi = { [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [42] = {8, sd_spi, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, }, }; @@ -2387,6 +2387,7 @@ static const SDProto sd_proto_sd = { [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, + [42] = {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, }, }; From patchwork Fri Jun 28 04:53:18 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: 13715428 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B49EBC2BBCA for ; Fri, 28 Jun 2024 04:55:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3dK-0000PB-SC; Fri, 28 Jun 2024 00:54:50 -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 1sN3cc-0008JX-OS for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:11 -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 1sN3cZ-000107-5D for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:05 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42564316479so1597695e9.2 for ; Thu, 27 Jun 2024 21:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550440; x=1720155240; 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=eSwX8/t3OMl0d9bqgd19YFhdT5y/t7Myi2nZ/gwkh2s=; b=yKHNNxKgY7ZX4YFKqfbMD5eiGC34iqqHsHNwkO6bFTSoIjKZURlX9+mcMApLMx1GSq SFqZDf5wG9IivNZVq/t8Oko+fT/OfVWnM3MrNj4RNN8pbcIn2VoKCVtCp08jG4Np0s4u Zihdc4VriTHx1hkYyIQ3thtKcvRD+bFU8WU/Nqd3Ua5PBSE5Gtbqj/tE31nbShfHFjeB nUWiHXF5OMaUyPzebbibFHwdU+JCWFyxfNa4gmsyZUZ25GIIDmZt7sCK/udn5/gm0QGV iUiC0I2BKy5HwukolIYHyjYcOLmXRNzpfoSYDZrIHeZJAc3EKr8FQ5aFHPqwqYk0gG6N PzLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550440; x=1720155240; 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=eSwX8/t3OMl0d9bqgd19YFhdT5y/t7Myi2nZ/gwkh2s=; b=kK/x0Wdy34wpXswITOH9gyQDJycyLY0GE/45evQucunTlZmhcQjR+RQ7MxjCQv7XZd slMVMdPndvGdAHuI6Z65gwZIvDegnWDUCYpHCvV707YeJ1m73U7btvHz4gKtQyoO8kP5 z4Ia0T28cBieaYMtBvOqxaTkezI6o+H0efpWW6u1/pHs4NCwOnrJWBFr99SjFuZem9iq uCOkMoUW/g+BUbmIVQ2THAjiG37atcUB6VqLdIwgZ0D73ecdIrj/oxjUA4PNO+86JlMD Mlw46YIOuNOz6GPYJyaZKQ4SQ7Y9Zpo8q0v/u8uUaFR//3XEvj+R4MPr/E6PnogXf5hP 7xbg== X-Gm-Message-State: AOJu0YwLbbWxpYdtjBR2c0wc4O7gdYPgMsVfZAfK2DMRJVEv2Z3Eob6v 3kjoWxXhtCwEHEZp9x8SGCbP/7KU18iWssnV34smlv4ZD0M5y4BA1/IB3gpvA79VfrKiLn/0ILr SHbQNkA== X-Google-Smtp-Source: AGHT+IHlXD0zkgfjs3w0IFmHdT1snza8t4ijzjhTrqN0Ae4teZsL+Nz44JFBZ9GgY1GkVKY/QXL9vg== X-Received: by 2002:a5d:5745:0:b0:364:81e7:3917 with SMTP id ffacd0b85a97d-366e946480fmr11211294f8f.3.1719550440322; Thu, 27 Jun 2024 21:54:00 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af59732sm17977125e9.11.2024.06.27.21.53.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:53:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 07/12] hw/sd/sdcard: Add sd_acmd_SEND_SCR handler (ACMD51) Date: Fri, 28 Jun 2024 06:53:18 +0200 Message-ID: <20240628045323.86308-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a27a7e0f24..6a9d611429 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", [54] = "SECU_spec", [56] = "SECU_spec", [57] = "SECU_spec", @@ -1758,6 +1757,12 @@ static sd_rsp_type_t sd_acmd_SET_CLR_CARD_DETECT(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD51 */ +static sd_rsp_type_t sd_acmd_SEND_SCR(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1866,16 +1871,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 51: /* ACMD51: SEND_SCR */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); - - default: - break; - } - break; - case 18: /* Reserved for SD security applications */ case 25: case 26: @@ -2327,6 +2322,7 @@ static const SDProto sd_proto_spi = { [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [42] = {8, sd_spi, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, + [51] = {8, sd_spi, "SEND_SCR", sd_acmd_SEND_SCR}, }, }; @@ -2388,6 +2384,7 @@ static const SDProto sd_proto_sd = { [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, [42] = {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, + [51] = {8, sd_adtc, "SEND_SCR", sd_acmd_SEND_SCR}, }, }; From patchwork Fri Jun 28 04:53:19 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: 13715433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80270C2BBCA for ; Fri, 28 Jun 2024 04:55:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3dM-0000dE-5Z; Fri, 28 Jun 2024 00:54:52 -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 1sN3cj-0008KN-T2 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:15 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN3ce-00011D-My for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:10 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso2210035e9.3 for ; Thu, 27 Jun 2024 21:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550446; x=1720155246; 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=l1JW4AJQQbgrb8lXxKMuM1qRbY1uuDZlLJblyEzxQh4=; b=aFESUId6sKGtJtgaXKIHOEJqEOToclK7vaP0a2vvvdDTQvVvh6tXvmlX0RMOpNnsha 8Zacrs2ZhUOC9D/m82JdSIp7OTmKvkn8AWIoScqatOUSw6Sk2F5uqaF8Ew3tgNYqRML6 Z86p43D3AvfAetapuAmM4LAV0On2w2tgYID7TSDwSqzlP2+4AjCd12p1ASzX5AmPon5G h5cFVFuuil5vvKghLdctZJhCXMiYtfCM9d7yonfoEL0IZbKnRKLQkOXWOs7oVR6KLO+A gyrifAbO/1PRg+hKPhl1ntzGUIIX6aEYlB5ow0x8VVnjtrRTLonZa1EfXwUxbtXgnnxU jqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550446; x=1720155246; 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=l1JW4AJQQbgrb8lXxKMuM1qRbY1uuDZlLJblyEzxQh4=; b=canzC4hrhZLVsaTuPDvKeJgrGg0sGTYE9t+vqNO4XN65+FMPCQOWlMErHeD4UaAix4 mAeEXX2NIGlTq3+mz1khIdP4RrmqCCb9eHvYNEm3VC11IInA1aQj3Td3XI5aIAW8+Rk+ KvvTC0V9uk4DPYxZ7BNiLP24FEDDwLgDAs+So+YtSE0ELAUEBdCCO2L1fiLhwgrvWye7 AG5kNqt8Cu70JzjikRVrO2mWDkcUcKA9NTt5Zuif3Lm0Jlm2hPAJxCgBdZA0wsIjsLtY dinh7NoahcDXawlTE8bKHqqLEJsmFOsdOQJgxgdzaR2Asrt/7hICUzObzZZciDe4fF9p uraQ== X-Gm-Message-State: AOJu0YxSv0cW4a7+DJMF9jUwnB100LjQT1etXsTO6d6eyzNDviC4e9Di 79LdXIoKbDWRnBSnW4WtKx0BWqf/63v5FA0AacJq+z8dd5iO0VqzgHtakwGFv/m+6bx/HRWkdjX pBIl6ZQ== X-Google-Smtp-Source: AGHT+IEWhmOU/D81BdfjCCs1DKW3lz2N1esxm3YQTepoMqzfPFaTdNAaXFPuCLpaPaO4WPynixn0lQ== X-Received: by 2002:a05:600c:68cc:b0:425:5eec:bb84 with SMTP id 5b1f17b1804b1-4255eecc517mr62922505e9.36.1719550446815; Thu, 27 Jun 2024 21:54:06 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3c2afsm18117245e9.2.2024.06.27.21.54.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:54:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 08/12] hw/sd/sdcard: Remove sd_none enum from sd_cmd_type_t Date: Fri, 28 Jun 2024 06:53:19 +0200 Message-ID: <20240628045323.86308-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All handlers using the 'sd_none' enum got converted, remove it. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sd.h | 1 - hw/sd/sd.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 29c76935a0..c1a35ab420 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -76,7 +76,6 @@ typedef enum { } sd_uhs_mode_t; typedef enum { - sd_none = 0, sd_spi, sd_bc, /* broadcast -- no response */ sd_bcr, /* broadcast with response */ diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6a9d611429..7f93d363c7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -526,17 +526,12 @@ static void sd_set_rca(SDState *sd, uint16_t value) static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { switch (s->proto->cmd[req.cmd].type) { - case sd_none: - /* Called from legacy code not ported to SDProto array */ - assert(!s->proto->cmd[req.cmd].handler); - /* fall-through */ case sd_ac: case sd_adtc: return req.arg >> 16; case sd_spi: - g_assert_not_reached(); default: - return 0; + g_assert_not_reached(); } } From patchwork Fri Jun 28 04:53:20 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: 13715423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 483F7C2BBCA for ; Fri, 28 Jun 2024 04:55:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3dJ-0000NZ-8q; Fri, 28 Jun 2024 00:54:50 -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 1sN3cz-0008TU-Ge for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:30 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN3cn-00012A-Hu for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:24 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42562a984d3so1762645e9.3 for ; Thu, 27 Jun 2024 21:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550454; x=1720155254; 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=KLGQaIGJKgcmO8Q0mlDn8rOb//ZdpOwWSY8cFandEdQ=; b=Y3CaqbJeXpnIB3ilJxyv90CVkxVjqwYgcy5Rh90JkMcU0zpHXvWu9vplkFrvsyaSHU KoxJ8Nt0dIGpWryr+KgQWkM/TXKBD1NfC8VdCzMziJ4ZRTsDcR7/pe07n0OCYJENPdON JIrfBg7fOivjDXmylZ7JSlsHNBDhVBmYez14zDn4U6e1NXJo1bzfqsLWrLRpKvyMdDnP z/JLqiBrWW/kpI9QZq1MragMWxh7fb+uu37W+6iyKt8cWOghHYXRi7vCpv9fZFtdQCe4 YItczNC/zpMUL2iCJTMM56N4viiKniB58ked3dOrSZhbS1cqLSMxkKjVzLphJ5cEaodQ KvAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550454; x=1720155254; 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=KLGQaIGJKgcmO8Q0mlDn8rOb//ZdpOwWSY8cFandEdQ=; b=mQm1j2y6xJ41h9lZanpQ4ZKV/zgVQhS8p8N2jOtTdIVkfGZyKPYnkZ52L5kBbjsXxz DWieY2RDFgi0X0rjlegn9FbnTCsUevt3IkQGGBMfuExxxZAT4P5PXQplREXykEiTr1Ig 2sZVayIM4UB14ZqPlvjtpHQt9ypGa3nLYlSWpUmcJi6Gwb+mcAlgUiuget02Rxpg7El2 XDEHx04X4OckCE9L8XMiU4zbinI5cPtluP0pcZuIuwJSqnURDYY0/llh7uBqfr02ocqm pEFfJbLFIi362qkwMIIWs2DC3kxIaSfGHBoycxhVhxcjaZk//y9YquHrwgEEu8KcxPBf vSVA== X-Gm-Message-State: AOJu0YxjxnjqkW4rTg66ZjS723EUJEcMSZGT4Mf7Mhcr/pWYDv16q9Qm zhvq3oaO2YYC6zmflInhLC5L/0wYdbn/5PLhu2ZWKcU7od17AoElbT3d0TXZvC4CyYMuxFapsEa mRf01Gg== X-Google-Smtp-Source: AGHT+IEzs4V1l7GJ0ciXSMktqi9UN+/b0nixvcq6WFqPsklpgTETUzMjmjeH/by1vNmbqk+DnsR+Vw== X-Received: by 2002:a05:600c:929:b0:425:65c5:79b4 with SMTP id 5b1f17b1804b1-42565c57b9amr26202885e9.26.1719550454028; Thu, 27 Jun 2024 21:54:14 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5ba67sm17879975e9.19.2024.06.27.21.54.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:54:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 09/12] hw/sd/sdcard: Remove noise from sd_acmd_name() Date: Fri, 28 Jun 2024 06:53:20 +0200 Message-ID: <20240628045323.86308-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org These ACMD names weren't really useful, "UNKNOWN_ACMD" is simpler. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7f93d363c7..19322c558f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -259,23 +259,13 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { - static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [14] = "DPS_spec", [15] = "DPS_spec", - [16] = "DPS_spec", - [18] = "SECU_spec", - [52] = "SECU_spec", [53] = "SECU_spec", - [54] = "SECU_spec", - [56] = "SECU_spec", [57] = "SECU_spec", - [58] = "SECU_spec", [59] = "SECU_spec", - }; const SDProto *sdp = sd->proto; if (sdp->acmd[cmd].handler) { - assert(!acmd_abbrev[cmd]); return sdp->acmd[cmd].name; } - return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; + return "UNKNOWN_ACMD"; } static uint8_t sd_get_dat_lines(SDState *sd) From patchwork Fri Jun 28 04:53:21 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: 13715432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DEDE8C30659 for ; Fri, 28 Jun 2024 04:55:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3dO-0000yk-L6; Fri, 28 Jun 2024 00:54: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 1sN3d2-0008V6-AG for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:33 -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 1sN3cz-000135-1s for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:30 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4256aee6d4fso1582405e9.3 for ; Thu, 27 Jun 2024 21:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550460; x=1720155260; 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=Qw+zxMHTEIwsFcpzBJxdUQmKFi6OrynqizbQoSQ84sA=; b=dTrd7ZsAyUIBRbfatnGcOSRC9nE7bleqU04iGxbyKLHjmtiAwQhXiCvVeOKicrUMX8 tmHkV2sXBkOsPqeRyB6q0SKFrNX2g67UTa3B0eCdBxfpeD5txWDE+frLny1AUrzMmP3W L8OsGsYqTrlLvruASYL5Ff7nVbhysE4v7/5zY3jo70avy5tiOvjFDztG9J+gUppuoM38 6dIb75a1ScWUGauu4hGB166GROZeROel688NCcWc3QcpmNTLh7ZOs17B8QeVZ9+OxraB /ATQ5ZEMq3ZWiN2hCuigt3OE/BbRyO0qzaIRyc3FBVNwefmn1O5hHTTj1OPDMdoJT3PM SMuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550460; x=1720155260; 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=Qw+zxMHTEIwsFcpzBJxdUQmKFi6OrynqizbQoSQ84sA=; b=X4vi35ld1HuYhTw4aO5Z+EqluYLCl2HAwc27onX1YRNnwWnwajqppPeaEsC3pGkrvY uW7kMSATs/CmOmKgjdzE/WTX4z1Ew7CYYa87UEVQNFVWh6dRY5IJ8FWS/RHh+QvR/obj pHSC2r4igUWz39ROhe0tadYoksAkrWrOkAzSII1LGe8NbSulT+YT80WKUmo2fH0hMgSg fa6fOWE/ixrwnr9YeKX7iugF7XF0E7lm7rraz/ciprPUPpQJY2W8/xDzdfDjZcBx7UOx kErl9HLk5t5TuWFLg3To5VMS779DYaCY9q9KnR1xrT2eUOXOMwcLwkD7eDlkfpZtFfhB 8AXg== X-Gm-Message-State: AOJu0YwPFmr48eDiBw8cQVyFLaNcl5ijmNlH+P7UTquNtycUbjQQko7t FbhTwSlFyHPLtz5doiOi0SJjLxEEfbOCxEELRj7cUDPNahIet98Eyv5M4TITasi/81EUa2JAV16 MUBjYxA== X-Google-Smtp-Source: AGHT+IHPrW9G/FKMivbec7Oc3hjDbhQmupvP7KoNCLYPEIM+BcEnWTpPDR6qBOEhBIwZcgG+Tdk4mA== X-Received: by 2002:a05:600c:511b:b0:425:6510:d8ec with SMTP id 5b1f17b1804b1-4256510de8fmr25303495e9.23.1719550460708; Thu, 27 Jun 2024 21:54:20 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3cff9sm18049765e9.3.2024.06.27.21.54.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:54:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 10/12] hw/sd/sdcard: Remove noise from sd_cmd_name() Date: Fri, 28 Jun 2024 06:53:21 +0200 Message-ID: <20240628045323.86308-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 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=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org These CMD names weren't really useful, "UNKNOWN_CMD" is simpler. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 19322c558f..0a7b422b2c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -241,12 +241,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { [18] = "READ_MULTIPLE_BLOCK", - [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", - [26] = "MANUF_RSVD", - [40] = "DPS_spec", - [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", - [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; const SDProto *sdp = sd->proto; From patchwork Fri Jun 28 04:53:22 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: 13715430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 564F7C2BBCA for ; Fri, 28 Jun 2024 04:55:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3dM-0000bw-2i; Fri, 28 Jun 2024 00:54:52 -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 1sN3d3-0008WB-QE for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:33 -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 1sN3cz-00013i-AV for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42562e4b5d1so1751335e9.1 for ; Thu, 27 Jun 2024 21:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550467; x=1720155267; 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=t05HoVB9l7/y3jswyRpww8YiOUTnZmazAh4RttVAsxI=; b=XSCbUt99pRUHV2PB23piMtX6CxmHJAARni9MDY3d1X7vkcd/e0LBjV7SoQyhicXGG0 DxJ6atxvemE7EBMTng36R70nQIf21DMRgLFxgtvywqEx1jJhP/gzXNwI3qujKLDruOEE 5/oGoqgVH6bgy2lkmb+/JzaNXfLtn7LymNR2MAj6uzvkgFSeJ8jXujsHiqUvok14zykX bk5F8j1AWT7jrzgQeKe6RxdH6iy/Sz2PefPI4TKOCXywwmba85VeU04qbxAgGIWfwDgF uI8IB619Yoluu3i2cNnsDTSHyfJ5loq6CRB4wUthCaeYAoOxD+DYU9/xMCGBQT1qY4TU arRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550467; x=1720155267; 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=t05HoVB9l7/y3jswyRpww8YiOUTnZmazAh4RttVAsxI=; b=lJcBOiWG0cwML7aJ32hiHEzg9t4k/CwM5Kq5kgyRgnLkcroctZneQHe4MTmr26TSUV r/V7O19LxEyiUwtOMJj5XT3j8JrNlOc6tfZtPSp+0dV2Mam2OAwVys31WmX4TZHPyvwl RvUh46y0uLrsCF+pEvmYfZup2eQcq8WVnWat6LSTI0Kgkb4iajX0EmWC1wno1iRA6Dhf OOeSNduMZmE+kd8LYcHWQlAzmF1SM976uvPXpHWwrT1TkXpLWxQWBIUGx/mmVDBoC4jh /6OGxMLDx+mc7pggzhN6fep6IhwYsmB2uiNQcLbUFudmzP/iA0Wdu83Z4CMlqKJ49+o/ Kr7w== X-Gm-Message-State: AOJu0YwuwBUJI76wZ6unXaiizeX6cMNR4aG9+QDYXHQXStkYrqq0HE72 +fCyjpgQTxLTGFRTcIYSukVO4eCSr8Lo7L/FNsiNjkU03aHDYoTiXeQgp6PrUsHQqqg79E8gWNZ +IdQzpQ== X-Google-Smtp-Source: AGHT+IFFZV82gn2R5E+XeFgXRHfMeLpy8h1fvx7x9HN/YzKD/iJl6QsSsTULJJ4ZEgFCXpz9tWWqRg== X-Received: by 2002:a05:600c:138e:b0:424:7bcf:2486 with SMTP id 5b1f17b1804b1-42489e3708fmr106929975e9.4.1719550467159; Thu, 27 Jun 2024 21:54:27 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5a3b0sm17938285e9.13.2024.06.27.21.54.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:54:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 11/12] hw/sd/sdcard: Remove default case in read/write on DAT lines Date: Fri, 28 Jun 2024 06:53:22 +0200 Message-ID: <20240628045323.86308-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 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=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All read/write on DAT lines are explicitly handled. Reaching this point would be a programming error: replace by an assertion. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0a7b422b2c..64621d4340 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1951,7 +1951,6 @@ int sd_do_command(SDState *sd, SDRequest *req, /* Valid command, we can update the 'state before command' bits. * (Do this now so they appear in r1 responses.) */ - sd->current_cmd = req->cmd; sd->card_status = FIELD_DP32(sd->card_status, CSR, CURRENT_STATE, last_state); } @@ -2016,6 +2015,8 @@ send_response: qemu_hexdump(stderr, "Response", response, rsplen); #endif + sd->current_cmd = rtype == sd_illegal ? 0 : req->cmd; + return rsplen; } @@ -2171,8 +2172,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); - break; + g_assert_not_reached(); } } @@ -2238,8 +2238,7 @@ uint8_t sd_read_byte(SDState *sd) break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); - return 0x00; + g_assert_not_reached(); } return ret; From patchwork Fri Jun 28 04:53: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: 13715431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DB7DC3064D for ; Fri, 28 Jun 2024 04:55:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN3dN-0000ki-5z; Fri, 28 Jun 2024 00:54:53 -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 1sN3dF-0000Lg-F1 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:46 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN3d7-00016e-14 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 00:54:39 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-362bc731810so153381f8f.1 for ; Thu, 27 Jun 2024 21:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719550474; x=1720155274; 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=G214GiZ6GoHQbuSVeY1gM0sNgUJBhdD0Klfne+Cmhik=; b=RnU/JVJeMCLHmjCZE4W6ZnLLOqT4Dq9HEqJ8Oym3k87zOF+JF50Djm82F2DP8WTCjJ NyBfoICtIbf6LYAwKSNFDUahlhhMu4glmj2s+XjL7VHXGSMoEmMUbHdniUd3eEeIVmqC eLMgr8JxGw3GunIYUdGpdK4G/D0Oeuy08dNdNVueyEn3kPPKylf8kGU7xWz/zzZmAk6b a9uoIAVm0ztcBeTTMBBT/RTWpNIIKXZ+Pji9mAs52O6w4FzimyFzIpHcZdFmimyu2lm3 jcUHGEu1sm259k7jyATJhUUg/s0XykLQgL47Crl67YXhmgbzvr24QqJvLLrScuhUf12S ZRog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719550474; x=1720155274; 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=G214GiZ6GoHQbuSVeY1gM0sNgUJBhdD0Klfne+Cmhik=; b=MSIMkAK9Hvl0tDcFWOyGy2/XLRhopVrZyXJHgGCAIeE6np7NwX238t/WfydJKsCZff ctdQRhUHM0NplWCOH3TWFVVPHuDy7Zgmjm10EXK5AmEpOS1x5Xr9Kn7fZ6NAdU00xTg8 +7bWCwL4TW3iWOLLJv5qdnt2Ud/O6asmQnPCc1ZenxnGkAgaLCMTfMOr22bz4jOZkQsw opAioRKQ71E794U5Wv3/RPI84yHumdjvbV5LtdgaMDU8ajLZ9TkhM5IVuylZ8H/lcByz B1IfNEArNA7nTIOixjgZYZUbWPvhfA8YKaBttbwR3rrr1RLrvuH2YwyR6ylQAZo7VSvX TxOA== X-Gm-Message-State: AOJu0Yxs1ezdpj8Gadwxy680uFEyvlVYfJ/Fx7EoMHtoAN9DjRlINc2J rqItny/tb4yZQvE+LWvfQgKfOif72BySedK1IMM7+QuN6L2tMRulV3zRmBu2glTgkn2NkBybUve P/LuoAA== X-Google-Smtp-Source: AGHT+IHYkBpse5piUiPKertkIwuXZHCuOiVZeo8C1GO8glaK8B15ageFzCHi+Jilc+35UZ4eZi0y5w== X-Received: by 2002:a5d:4b87:0:b0:366:f04d:676f with SMTP id ffacd0b85a97d-366f04d68f9mr11382349f8f.12.1719550473957; Thu, 27 Jun 2024 21:54:33 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0ce6c9sm1077729f8f.22.2024.06.27.21.54.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 21:54:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Sai Pavan Boddu , Joel Stanley , Bin Meng , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 12/12] hw/sd/sdcard: Trace length of data read on DAT lines Date: Fri, 28 Jun 2024 06:53:23 +0200 Message-ID: <20240628045323.86308-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164815.82606-1-philmd@linaro.org> References: <20240627164815.82606-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some commands expect less than BLOCK_LENGTH. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 64621d4340..a0da06e017 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2197,8 +2197,8 @@ uint8_t sd_read_byte(SDState *sd) io_len = sd_blk_len(sd); trace_sdcard_read_data(sd->proto->name, - sd->last_cmd_name, - sd->current_cmd, sd->data_offset, io_len); + sd->last_cmd_name, sd->current_cmd, + sd->data_offset, sd->data_size, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 6a51b0e906..5dfe6be7b7 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -55,7 +55,7 @@ sdcard_req_addr(uint32_t req_arg, uint64_t addr) "req 0x%" PRIx32 " addr 0x%" PR sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint64_t size, uint32_t blklen) "%s %20s/ CMD%02d ofs %"PRIu32" size %"PRIu64" blklen %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c