From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957360; cv=none; d=zohomail.com; s=zohoarc; b=X+oGdjRLgBn+s5aTtMRA+UWWb/E0+HPk7FMT8dJXhK8KnbQRhLA7GTwG4mI642qu0FDxSkgOG5PF15Smw0+BFp+TK00eZy405kk/lmeYtjk1j1Hb+AOWRsrTkua4ZEnbILwe8Aq5OXwLR0XasXi3HZzSuhtarEyEXD4MyGx+1Yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957360; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4c/usVrkl8YKkr8RnXE4rYu6P4lZW+FXlANdR7STD3A=; b=I3Iw1h9/V0C3sLhS1j/JtkRGolXUdWoZ8qkKCmJ73RlBlWvGC+nAtaf5SxAzEqzTVGyANvzvcET09yuD13ORWmpdFr0X9Gga2wUaeItzNYRztluehW/mMvKy5Zsw/bCUUWWyRA12HdKrF/GPtUiEwwZfIngFvrWmNCItdPOARZE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957360044855.0236025126339; Fri, 21 Jun 2024 01:09:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZHc-00054e-7T; Fri, 21 Jun 2024 04:06:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sKZHa-00054C-HF for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:06 -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 1sKZHY-0008Ey-P0 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:06 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42165f6645fso15641215e9.2 for ; Fri, 21 Jun 2024 01:06:04 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248179d982sm17070775e9.1.2024.06.21.01.06.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957163; x=1719561963; 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=4c/usVrkl8YKkr8RnXE4rYu6P4lZW+FXlANdR7STD3A=; b=ZuS2TuxppI1j00p7VVy2TC5FNuzruBF+SMvwlJWGM4nCzhgoKF5IkZtpGe0uzFKtew 6Mb2iRmrfxM4gIRWh0AFlpD887mkQz2OBmGbADUtcTXes6OOsSZ67aZrAnU4FQDcPUdP oXej5F+LwRbra5dXOIYs+x9rznUrF12fqlGa8F4Wu1X1RXkKQq8pnvHGUA+0ni0O06FY eTUtBGD4PYAJ8W+sT9bfjzMQAByp8aOqZF+aFNGP0XZUYweKmZTmP12JAdf+3cxqL6+h 4W08if0uDSeo2ts4DPIhipio+5u+6VxPt3nlt9b5NChJ6B6dGqam7bBjfZk7xUIVp5xx 7Usw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957163; x=1719561963; 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=4c/usVrkl8YKkr8RnXE4rYu6P4lZW+FXlANdR7STD3A=; b=eUGAxM/rDIxkwFD4hoMiMapkHtPy667JYK5D06biGPXSPVaReNcWiHUb0hFVb45msJ XgTu/C4+Mfu+qiYSl9joZ6OI0yQUgZq7Jd9T7frxsOAPkItYiJ5abbvhlgP3MuUVcamT HWe4g6LO1ZJoeYkXP1JaOk9ylc4+HtevwyOGyjuG1mFrwfZKbaHOH2buhKVYvDHvSsT7 tzVwY9pHEvfgvUbPvy5DTnJOFNSKFkQUgFT45+xCkGamZfepMfBq5KBXZd7GbzrZ/G++ GuTX77rNQOanO3fvEIWbhFdHeayrkyiC3XsjtEb7wp6WK0eszlgztLsGbaEgjpclCnx6 a4Cw== X-Gm-Message-State: AOJu0Yy/s3i0x05KKiJkBh4U6SehViD8QQa45d8gKsqE/DMKY9bun/IZ Z7HeCGStjnLEiGOz8ojD7wHD9NRXo1An9oRRurILLbROIG9SiXswJevl4f5FOzEetj2tR5BKwH4 O X-Google-Smtp-Source: AGHT+IHcd/mD0AQsb+hbMx8H3KeN11iekchbc+pLPX/KX/3DAMVaO5FJp23Qvipp06K5s10rnBwc/Q== X-Received: by 2002:a05:600c:4447:b0:422:7996:3f3f with SMTP id 5b1f17b1804b1-42475174910mr63841185e9.11.1718957162942; Fri, 21 Jun 2024 01:06:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 01/23] hw/sd/sdcard: Correct code indentation Date: Fri, 21 Jun 2024 10:05:32 +0200 Message-ID: <20240621080554.18986-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957360794100003 Fix mis-alignment from commits 793d04f495 and 6380cd2052 ("Add sd_cmd_SEND_TUNING_BLOCK" and "Add sd_cmd_SET_BLOCK_COUNT"). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 16d8d52a78..626e99ecd6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1069,33 +1069,33 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDSt= ate *sd, SDRequest req) =20 static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { - if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { - return sd_cmd_illegal(sd, req); - } + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + return sd_cmd_illegal(sd, req); + } =20 - if (sd->state !=3D sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } =20 - sd->state =3D sd_sendingdata_state; - sd->data_offset =3D 0; + sd->state =3D sd_sendingdata_state; + sd->data_offset =3D 0; =20 - return sd_r1; + return sd_r1; } =20 static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { - if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { - return sd_cmd_illegal(sd, req); - } + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + return sd_cmd_illegal(sd, req); + } =20 - if (sd->state !=3D sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } =20 - sd->multi_blk_cnt =3D req.arg; + sd->multi_blk_cnt =3D req.arg; =20 - return sd_r1; + return sd_r1; } =20 static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=zohomail.com; s=zohoarc; b=HOmAWgbIy6x6yCHKT/qQYWthb5tQ/2QDSuMvPm4bvuFpLpEP0jNCRBj8LXQqrt8nFLXlAu0pBHNogQjwewDfqEykJS1kZBOfTsDcgmzChxgo04Eri18hM8KPCYKxquHKHk7gm16L4VzIbwazp0NUTOawFPz4g4gI/18Albv6lkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957227; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P0JRQjH2+2iHubv4pv2oDVEMyEJlpvL6A+oovFUXEtM=; b=RDjmrW+8wCtTSEb49GmJ62yFedHdfouaqPvajZQkPBMNd1kMr/bjPZwq3RNxq6ctzvNijh0Utvffw3lc7gt7VjcSWzhBrW+S9DDFxMfTpp6I8d7IfUb8NUYKwdf+NKU/eTHsnxhfiTsV4XiYSr5zJIP7YFAXBLvxMOUL1R7GdoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957227531209.78291103399158; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZHh-00055k-PQ; Fri, 21 Jun 2024 04:06:13 -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 1sKZHg-00055M-GL for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:12 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZHe-0008FO-Rn for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:12 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-361b376236fso1359233f8f.3 for ; Fri, 21 Jun 2024 01:06:10 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a8c8451sm963793f8f.101.2024.06.21.01.06.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957169; x=1719561969; 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=P0JRQjH2+2iHubv4pv2oDVEMyEJlpvL6A+oovFUXEtM=; b=m1fP/5+pJgOEEkKCQyCckKKH/4BlHhZIvrNV0M8B3jB3ODvVrNb0COBPI/C3HSGAE2 TwR2YwS/wKaRI5tEN7XyYAAqCBe7evD0DPQntn332WQA3AGsp+qNtiFn9A01/ylCHlLQ gL7lmtAIAPEmk8C5dYXR3XxEFVY/HgMMawzBXBW7yO8gYF+9OlN/gwAxeNRoUrZgA5Uu DxhxXdTcO3qfG+dw/jjNPR64CjnzetTcJOOqUOpFhbPRFoSuXbueJ+2FjvHsJaPy4zU6 Qkm+eKjS7ZVSVr+rqe0rv0V7YfGPBJ5s75jhur6fYnOB6tLWBMw9O1WeZ5PoOkOFbn02 FLiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957169; x=1719561969; 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=P0JRQjH2+2iHubv4pv2oDVEMyEJlpvL6A+oovFUXEtM=; b=jnL19XlYjwgDJhWWdL7s2lSM5LZ2sEquzN9IogcCRROoltNmg+lwVnxxNy9ngULLPB grUBtTdThC/mEOsJrnDaMDEmadnjND9hoySSmZL7oPTjz3sLdLb6M9g55kywU3P6zzTG qu8T2BRxXR1c8T93G445G9jl8PnYAUaTVUcbPxtzo1+69HTiT20hm1v6LZIPAzYiakE8 c6KEjs6kEUPq/fI/QD01Y2ZDZGKfRNTdAMWZTQhUhCJR8BN6ajEF/7v/mmsvdII3l9ff 9EzVv1byT+25OkR7RXzFXe3OsHuC7N7luo6BIHapAOb8dBzeRtWNGgoEg1hAAT5uxXxS 8reg== X-Gm-Message-State: AOJu0YzFdRFeB80VX1DyFgdvGVQkN1AgieYgI3B3diTDVgRKqu7DbdWN tsyxh2QEaYW9T17U6TguRyon4vF61OeW7+Mv0mGvr1fs+0KI9vann4TzUnlUvHRokwxjvTme/4v 1 X-Google-Smtp-Source: AGHT+IH5TT3+lDR+GsaOnFLP2PjzHVMeAkgwomSDXLjdB5ZspNRReLQf3vRj0sDhdQlv2C208SGp+w== X-Received: by 2002:a05:6000:1107:b0:364:e290:c60b with SMTP id ffacd0b85a97d-364e290cbf5mr3280674f8f.38.1718957168962; Fri, 21 Jun 2024 01:06:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 02/23] hw/sd/sdcard: Rewrite sd_cmd_ALL_SEND_CID using switch case (CMD2) Date: Fri, 21 Jun 2024 10:05:33 +0200 Message-ID: <20240621080554.18986-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957228122100002 Keep this handler style in sync with other handlers by using a switch() case, which might become handy to handle other states. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 626e99ecd6..addeb1940f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1044,13 +1044,13 @@ static sd_rsp_type_t sd_cmd_SEND_OP_CMD(SDState *sd= , SDRequest req) =20 static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { - if (sd->state !=3D sd_ready_state) { + switch (sd->state) { + case sd_ready_state: + sd->state =3D sd_identification_state; + return sd_r2_i; + default: return sd_invalid_state_for_cmd(sd, req); } - - sd->state =3D sd_identification_state; - - return sd_r2_i; } =20 static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=zohomail.com; s=zohoarc; b=jcP+xQ17QDuwBqUDi8JTKmEyt2sYD9qCRwodZcY4jT2HdOVhXScheOp6pbpFb9kMZgWYKtebwkw32Y4H1/SlZ0m3gPHRAUmoVH4jEzZQKjM2GYE5YMw8wN/7dIBHsxbPB+oQFa5Z494IOpQuEDLgiOV7GhpEfi9ZUpvCThWdF+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957227; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pu4cWh3N72k6gRC8kFx27gDVkEmn2smaKl61IHZHwJg=; b=g69BagMRDvGLR8Cdduuup8W20XAMjdzEmGUc69a7cp3j4CMcf4S11IrsmBjsy5d7DX2YZrbO1nI1dYQoTj5u0MdTzHrsTAjllb410wE6sKRhCozHfOr3CT108b31pwF8rHyE114HLijOLsuxMQwCTGZ8DyEb0H/Y1hgF2vB2i/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957227105922.5358416296201; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZHo-00057C-La; Fri, 21 Jun 2024 04:06:20 -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 1sKZHm-00056V-BQ for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:18 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZHk-0008Fw-Pb for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:18 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42172ed3487so13302575e9.0 for ; Fri, 21 Jun 2024 01:06:16 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0beb08sm53830685e9.17.2024.06.21.01.06.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957175; x=1719561975; 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=Pu4cWh3N72k6gRC8kFx27gDVkEmn2smaKl61IHZHwJg=; b=Ov4sQ7DMrQY8biM04HD4OZjf9Zecy6zEKusPFlAKSppX5DpswFUCLb8uNdQpf0k3Ib SLfnsJicF/qDABTSZ2drRU5fb9smhlAzZWzlmnL2Qa5acKA4xKOwMP6JaJefy54F9hxc 2GO+fMe+ocxEMgOgZ0Tm2quAW1+1aXPz8DZCgufqOgiP6FRNgqr15X6KoMDrJ4zoJBpQ rzUDTVUHlI0S6Nz+wLBvqu4P+x7aMXXdhZKxA8ofKDv+QXGDMkaKktnV/COWHrOiVKwZ S5N/DbX5MnDcAgB0KJ7Mfq5PASBFtnQVOWGvvZ/Rxs7C+LgWoWfy1L077Jqzucq/+RzE SFEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957175; x=1719561975; 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=Pu4cWh3N72k6gRC8kFx27gDVkEmn2smaKl61IHZHwJg=; b=rsLB/St8KfO8DoGD2sG0Q+ntxKe6Z5Mlm6KB1YT8cUZuwqxfbfOYTIdwbiw5Oh6gGD VBiMPZpp1T+1gM0j1ImOG9KSSzksBee5BAPo6/ACriPjNpclv5chZXvoTFZaqRnCNxvV XLEwvDoTOoq/26FpIAp5Tp/S0VWM1cDEDjAAY8jCDcLas2KtKhm2WxEpQztU/2Z4cjSY EhAw4QbchdLs2fThtVfvnmX8mdyy4fPjPA+yipe8P8H4tEEyjtnCs7LaRWeF9j3gydex BeWvdNCF20OmAVj/OvDakZXmc2BBJK/oRAZju9QtAIXfSRSFMSh8/X3owA2YCeG+qpI6 NGvQ== X-Gm-Message-State: AOJu0YyYvVpwbI+XCDK+tL3+CDjksabKXYBiBX0ap1/7Z1ltJkf0HhEe isXpxMEuAdbI25tsYw1VyRlrXytpf5NbpbmxJNDY12EzKilXQc6CXL1XJOdM4jyk9jWWJ71MXZ5 8 X-Google-Smtp-Source: AGHT+IHw9UIkgCZdS2jUur/imsKcxb6Fz2To7eE/eQyypDnA00AViuCKXyVoXeWAdWI9Ezd9IDJ64A== X-Received: by 2002:a05:600c:1608:b0:421:8e64:5f23 with SMTP id 5b1f17b1804b1-4247507a472mr51467355e9.5.1718957174775; Fri, 21 Jun 2024 01:06:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 03/23] hw/sd/sdcard: Fix typo in SEND_OP_COND command name Date: Fri, 21 Jun 2024 10:05:34 +0200 Message-ID: <20240621080554.18986-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957228187100005 There is no SEND_OP_CMD but SEND_OP_COND. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 6 +++--- hw/sd/sdmmc-internal.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index addeb1940f..331cef5779 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1035,7 +1035,7 @@ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd= , SDRequest req) return sd_is_spi(sd) ? sd_r1 : sd_r0; } =20 -static sd_rsp_type_t sd_cmd_SEND_OP_CMD(SDState *sd, SDRequest req) +static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) { sd->state =3D sd_transfer_state; =20 @@ -2149,7 +2149,7 @@ static const SDProto sd_proto_spi =3D { .name =3D "SPI", .cmd =3D { [0] =3D sd_cmd_GO_IDLE_STATE, - [1] =3D sd_cmd_SEND_OP_CMD, + [1] =3D spi_cmd_SEND_OP_COND, [2 ... 4] =3D sd_cmd_illegal, [5] =3D sd_cmd_illegal, [7] =3D sd_cmd_illegal, @@ -2159,7 +2159,7 @@ static const SDProto sd_proto_spi =3D { }, .acmd =3D { [6] =3D sd_cmd_unimplemented, - [41] =3D sd_cmd_SEND_OP_CMD, + [41] =3D spi_cmd_SEND_OP_COND, }, }; =20 diff --git a/hw/sd/sdmmc-internal.c b/hw/sd/sdmmc-internal.c index 8648a7808d..c1d5508ae6 100644 --- a/hw/sd/sdmmc-internal.c +++ b/hw/sd/sdmmc-internal.c @@ -14,7 +14,7 @@ const char *sd_cmd_name(uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [0] =3D "GO_IDLE_STATE", [1] =3D "SEND_OP_CMD", + [0] =3D "GO_IDLE_STATE", [1] =3D "SEND_OP_COND", [2] =3D "ALL_SEND_CID", [3] =3D "SEND_RELATIVE_A= DDR", [4] =3D "SET_DSR", [5] =3D "IO_SEND_OP_COND= ", [6] =3D "SWITCH_FUNC", [7] =3D "SELECT/DESELECT= _CARD", --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=zohomail.com; s=zohoarc; b=WShcqTXZA6AnD7ZuOHDiWvvUTyYnvIkR7bYFUiJDXAgHr+/zdTimPW6pBZrBr/MTEe1S/NTOjQhTchjDav3NZ1Y7ZUa42UaPhUDRAulpPJbiMGSoi96Xo8Af7Ft1npEyPN8x9QpD2BE2blMZVJj9qwU8KMmAXNey8XlzjS7PNvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957227; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fbChd25f9YN3YwZXuq6CJAvDiqEwoBqyQKCDjART3V0=; b=B+I7x9yaRllZpTBsSx+Sif8nzQl46BatU5UKEx/LWyiNlRLl2b3/W+bJrzqvjqYs8Rtvb0uxm/DuyUgpZMvrErQMSGvM94Je5/nluPHVr+9tHaCa+iDcyzTM9MnDtoHJKO2MsLjnLcOWexNDfJm/tCAO/EGLqzjPzazuKraJ/Y0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957227559699.1555396167009; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZHv-00059p-3L; Fri, 21 Jun 2024 04:06: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 1sKZHr-00057W-TH for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:23 -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 1sKZHq-0008GQ-7r for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:23 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42249a4f9e4so12843885e9.2 for ; Fri, 21 Jun 2024 01:06:21 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0c5485sm53288665e9.21.2024.06.21.01.06.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957180; x=1719561980; 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=fbChd25f9YN3YwZXuq6CJAvDiqEwoBqyQKCDjART3V0=; b=AbaGj36m5az4uu41ve9BC/Tim5s49yR3lsoIRdJYgwN5imTmxraE8cf5X6yM3xZay6 IZcZmX4zZ+b1QMIcNWrFo4gSYjZ3i8at4buHDdyp779x2z9BWrZX/j+qrBdWrsM+7pgD 9sCVtmake10yGvBBV/5U5jhTkNhi+C0Jo6b6idrlqgAGcP5gLSOmBGApHx0cZM/K05Qi Hr7q9yXQWBcmLPmtHx7RtbukcPzJg/LZ+UMCl4T3OWeAKEnLM9ygn6OFdpG8/GMFM+7R dti9eZfyeaJON6V2MBgM1u5pVueI5AuxvBRfdNXQrGqSIthUzqjexmQ3UA5m8Y8/BgZl o0iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957180; x=1719561980; 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=fbChd25f9YN3YwZXuq6CJAvDiqEwoBqyQKCDjART3V0=; b=aXUCYf+keP7Ldcaoi9KljzCXQrwq+n9N2M232O8N6Hi8yhnj1I8NjIaL+0ZLLNIz2x Qu0y/7jGQV/89Afly76HeEHEoXg4trfbXfoaeLHKMuoS6yTY/TpbPXENPnbL40cv/yX8 i7IBCccL9kGAWQW8PbvC/4MgsmF72W9LHYYhrZQNykGZPLwGO/4Fg4iNsrEzlpiZKdog BuD5mpxi5dIfTSPVpDqYCha3haWDayGW8Ja+8MFaEYy2DMx7Hk7SW26s2rUm5YPzZqs9 vUw8d0fRoiIYmf02IXjnoLxlMLuC2dpZiAFhRDST9nT7ThHlcX6MxcMJiusZBWjq8PiN 0POQ== X-Gm-Message-State: AOJu0Yw4wsR7wvcJIcn5enP7jG+Rzzoqa23360A3xUnMAFW2WpUD220E +kbPqhhW1Y5QUeCS0alpLBtjZ5jAqjNtyrzjBmi1Q10GR+Y1Zdes/xuto7qnCJvgzTHnd+82Bgo b X-Google-Smtp-Source: AGHT+IHhhcXzKikBEYhnnB91GXmWdkc2LnzpwmX9DW1wKCZyBJ4p0NyCnqyrNxsQZg5X2a/H5AR4fg== X-Received: by 2002:a05:600c:1615:b0:420:2cbe:7efd with SMTP id 5b1f17b1804b1-42475298bd5mr61901915e9.31.1718957180681; Fri, 21 Jun 2024 01:06:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 04/23] hw/sd/sdcard: Use HWBLOCK_SHIFT definition instead of magic values Date: Fri, 21 Jun 2024 10:05:35 +0200 Message-ID: <20240621080554.18986-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957228104100001 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 331cef5779..c528c30bcf 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -596,7 +596,7 @@ static void sd_reset(DeviceState *dev) } else { sect =3D 0; } - size =3D sect << 9; + size =3D sect << HWBLOCK_SHIFT; =20 sect =3D sd_addr_to_wpnum(size) + 1; =20 @@ -822,8 +822,8 @@ static void sd_erase(SDState *sd) =20 if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { /* High capacity memory card: erase units are 512 byte blocks */ - erase_start *=3D 512; - erase_end *=3D 512; + erase_start <<=3D HWBLOCK_SHIFT; + erase_end <<=3D HWBLOCK_SHIFT; sdsc =3D false; } =20 --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957278; cv=none; d=zohomail.com; s=zohoarc; b=j/1lnQO8pRL18U1oQIh3gV+SqVEOyOuG1QfyLGXFHmTIHvXoOIJKjrXlomMvW9HkLoUcsREPiCtUtsRv5I5arBkKdRZ8OGuEL9AOdVBvSp1y2PwHcL05XYKGyZzyOShuH1Q5Czucqe1XB4ZLjnp3lB3YGao/v/bk4oE+a+LJzg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957278; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AsqEi0yMZfaJd1hK4BOnT6B+zva2T6NVwv7/H2dxiDs=; b=CIyk9M8TN7mIzS18OYRTnmOClkLux9Bt2NaD1o91/rVjOkJhapgrLxwKDu+82SMQrA0QGiL3MpXrUxDRihIf4rP4esWLnn6TMurgqWos+GjQgJMMaTDWLIMc8p4lH7YtQUBjK4NnmTJt/keyopX5mzvWzw2aAiXJfIXt6W4slWc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957278210151.67657527405834; Fri, 21 Jun 2024 01:07:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZI0-0005BS-DE; Fri, 21 Jun 2024 04:06: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 1sKZHy-0005An-Ce for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:30 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZHx-0008Gx-0d for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:30 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52bc121fb1eso1935628e87.1 for ; Fri, 21 Jun 2024 01:06:28 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0beb13sm52737585e9.14.2024.06.21.01.06.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957187; x=1719561987; 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=AsqEi0yMZfaJd1hK4BOnT6B+zva2T6NVwv7/H2dxiDs=; b=oxgfh8HExCZk6IENBaMrpTqBaLEPkglxxT4ecUs6CvFnf6aQvzcN/3AL8G7HGJT7g/ K/GufHu4HEtsPLCmpl9OaIvIgW4PhiS7DQkRZ50qD3oyQHe9qr0gHE/AiUfPemTImxXF 5JCZ+lf/cB7fh4pGTKRmKL0aSeZY6PYItJRFv/R3PRq7Qy8Zqbu6qbRUxZga9Xj6+CSj M4bRa/QyZ2VM5+lnacaDrSbLUG87Nz3MrXkaccbAimeuZ929uxdyY87N80iO7UtmaWvr xCq2PD+r8TwbKcWaUTE8FsX6LkAKd2mgOKQW9lUBB1w7SIoz118S2ReDxpbrzqx9zop+ m5qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957187; x=1719561987; 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=AsqEi0yMZfaJd1hK4BOnT6B+zva2T6NVwv7/H2dxiDs=; b=Qy+Ufv9OIrRHGhzCiTGPdSmFiH1vNS6iiNAEnu4XJgu8a4ULVlGAs8c6nUMSHIfEmZ kUTZ3T6Wt6cF5HNDAYgzWBSyJof3a7HRGG0BwXg4Z62olx57NjVkyUD1EISrwBcIuczT g8W8YeqIdllh6enuEOIV0DwGDxy4mS2MPZfwzcDrq7ep50kX+1EAWdfh7gUPGKLT/J4+ uoFmf47grMbFX4ekH0lDPjsuYQazdCw1EXc74URI+OrdwJv5nYqcsBA/UFXOQXDEn8/2 QO8aKfxnOm1VNoE0NlR5KjUn/cd7TW6FU4nza4KJY+RaaLjFMjTXhvJrq04rNYCii3kO nE5w== X-Gm-Message-State: AOJu0YxMgzmzUzFT4pLbVlcqDXHLiGy6P4C0LDRtCQE/ehofRDyWus29 p80oxVI7To13rn9KE4AWol+2l0UqUs9v7GTdExk7KOtt9Uj2qY4ZEkISHZWqdpKVOxiuhKnUoso h X-Google-Smtp-Source: AGHT+IF+oecqc0QCYs+h4dF4w6KMDPV6yo2V/Jq6b9Wq4b60F2vqMqvZYuMOC5p2ZKmdzvY8GpUQrA== X-Received: by 2002:a19:e048:0:b0:52c:dac0:59f8 with SMTP id 2adb3069b0e04-52cdac05a32mr75707e87.53.1718957186790; Fri, 21 Jun 2024 01:06:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 05/23] hw/sd/sdcard: Use registerfield CSR::CURRENT_STATE definition Date: Fri, 21 Jun 2024 10:05:36 +0200 Message-ID: <20240621080554.18986-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=philmd@linaro.org; helo=mail-lf1-x133.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957278376100001 Use registerfield-generated definitions to update card_status. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c528c30bcf..24415cb9f0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1788,8 +1788,8 @@ int sd_do_command(SDState *sd, SDRequest *req, * (Do this now so they appear in r1 responses.) */ sd->current_cmd =3D req->cmd; - sd->card_status &=3D ~CURRENT_STATE; - sd->card_status |=3D (last_state << 9); + sd->card_status =3D FIELD_DP32(sd->card_status, CSR, + CURRENT_STATE, last_state); } =20 send_response: --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957265; cv=none; d=zohomail.com; s=zohoarc; b=IGqnpkC5NHIzVVJXRm88/f2CzQQrynLily89mDhLWV8MboQ/bhTlZVOvSMQ8C8FDcwmEzDnNqFH7ATh7giT9xrvicNchkxKb/xR1UPr7fMyRUej9krZRYiP87i0uPygvmjWYauHLbzrHpprV52OXXO7lWJVRHxnZaDvaOOdJK4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957265; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=724kW79TXJGwyxkrPpGmpC8jMcTbNAzL87slxzj18o8=; b=l/FPyxMQMSpsCXLQOckAJmfbW+3uUlAWjqEtxN5NeklL6GOrWaIhrVyima/rnGr8qC2GUP+SkZNuIt/0lSfFe/3XapVe4JzaSvPF6nk8zjWUB9f2PMf/gV85P6+6sqsOu/oiGpQDsm3Zn56WVXSPTbu631Zq5pSnHH1LJ3qdMhk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957265938208.29012363094694; Fri, 21 Jun 2024 01:07:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZI7-0005Gn-Vj; Fri, 21 Jun 2024 04:06:40 -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 1sKZI4-0005Bo-EY for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:36 -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 1sKZI2-0008Iy-TU for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:36 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52cd790645eso283956e87.3 for ; Fri, 21 Jun 2024 01:06:34 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a2f6f36sm968427f8f.71.2024.06.21.01.06.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957193; x=1719561993; 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=724kW79TXJGwyxkrPpGmpC8jMcTbNAzL87slxzj18o8=; b=z4ZdYyxHEcoC5Km3cyQh/tWqGz61JDUhMzY/mAAIUiTw/FyFoXlWUXyfKPWWhWBa2Z rE8Q/7HwYpnTH0aJS+uGEsIs/lZC2hiP0vrm6UExuG5DCc7G6233Y2CqLgIwx5hwIegK c6egxQpnofpiH2fRpyM9jskAByMKYTtHfwXkSdKSULJnWgMQ3mlNfVxAdyq1+Pbs6PnH Jq5nfoj25R1N6c1a5eOiXzb1bk7QwJNqO4LpdsgIlwuwVSajpN4MUjpCdJ1U/1TgDVqM vF7qMdITnTj1DDfFHFBD1LPrvhYKoI0cFOZTrd93CuPLF/7Q8AJZndyTgtBp6oVFeaS6 WFEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957193; x=1719561993; 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=724kW79TXJGwyxkrPpGmpC8jMcTbNAzL87slxzj18o8=; b=ZMkBq7cbN0mG2FPeZbRr9Wm03dOiJCWe/DfXj6zPZDQV3PZrdbXQ9ky3x9QvF66min Ekm+iMqHEzRMh0v4Q5mn0Cex971e+0ofUgCePUxRQq0MVhiEgGUV3T3LCUvbKyvqUDj9 kvfENNsrp8fVjPJPisHC9frj0wdaLyCOcw2cJOnztRG5oq2QAxVFJA06zHo3UuL45R14 avGMMUigEI1UUa8sIem/VtDwyCkPTe3EyC5cI07WI3b7hFMiABR6qVcemeRMROGgy46X xj19oxA2k2KSx8/MdyjhEez//YVoG/2XbScRqFcy714hPqpdV3gk+C2HdDUIrOPF7HrB RTTw== X-Gm-Message-State: AOJu0YwE+/1X4gSGv4tBf+x+brRzZ5AJ9c/a8KalLxcGpc3FXO8Nrz+V iRKSGJLzphJQsIGBOoq5Xp/Imeef9oWfzEXjHUu7z3VzUlgLxVTWJWiPocxeaxiyJO21xQNUgAy b X-Google-Smtp-Source: AGHT+IGF+RXH6ISxE641vWAocQv7AwcSVCSODQbtcRZUwnMSOBm0UvFeguDTovwJ67ffv527nJtiSg== X-Received: by 2002:ac2:558e:0:b0:52c:c953:3c1c with SMTP id 2adb3069b0e04-52ccaa600dfmr4509217e87.36.1718957192959; Fri, 21 Jun 2024 01:06:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 06/23] hw/sd/sdcard: Use Load/Store API to fill some CID/CSD registers Date: Fri, 21 Jun 2024 10:05:37 +0200 Message-ID: <20240621080554.18986-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957266310100003 The ld/st API helps noticing CID or CSD bytes refer to the same field. Multi-bytes fields are stored MSB first in CID / CSD. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 24415cb9f0..b0cd30c657 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -393,10 +393,7 @@ static void sd_set_cid(SDState *sd) sd->cid[6] =3D PNM[3]; sd->cid[7] =3D PNM[4]; sd->cid[8] =3D PRV; /* Fake product revision (PRV) */ - sd->cid[9] =3D 0xde; /* Fake serial number (PSN) */ - sd->cid[10] =3D 0xad; - sd->cid[11] =3D 0xbe; - sd->cid[12] =3D 0xef; + stl_be_p(&sd->cid[9], 0xdeadbeef); /* Fake serial number (PSN) */ sd->cid[13] =3D 0x00 | /* Manufacture date (MDT) */ ((MDT_YR - 2000) / 10); sd->cid[14] =3D ((MDT_YR % 10) << 4) | MDT_MON; @@ -462,9 +459,7 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[4] =3D 0x5b; sd->csd[5] =3D 0x59; sd->csd[6] =3D 0x00; - sd->csd[7] =3D (size >> 16) & 0xff; - sd->csd[8] =3D (size >> 8) & 0xff; - sd->csd[9] =3D (size & 0xff); + st24_be_p(&sd->csd[7], size); sd->csd[10] =3D 0x7f; sd->csd[11] =3D 0x80; sd->csd[12] =3D 0x0a; --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957249; cv=none; d=zohomail.com; s=zohoarc; b=GZiNl5Vzv6mCfQSMmsN5T7GNKBpmynGPHNaTA996JrYEQ5/gNbE9AaIewYEMX9qfnIDrEycVnCXPMrGcUsDVuKxxdNMsJ4EJCKuy8g8muti04bRB9FPbvCUv5BfC5blBPjxucRLlRmshdDzNohHM1J22k3mOsKFEHf4FTeMNoZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957249; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5/RgyhQBn7T7/7BrixgsTi+BC7Dln0yA+HQ13ohYUUo=; b=RiTHUmBD9a/Qxz0djjYUEGN5obAND0Y/YWouDpE/jv50lE5+eDmS3whO+5CccgrlyJVBazFHRg5r6uAbHUiGfUDm6/RMxq8DN4Wjx4Q2jo5x2/sNGcTDz64gy4oG1Valng7FrFRm4Om77GaSmLl88KdzFXI/nVpf49BvjLs0yo8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957249884755.5052171344748; Fri, 21 Jun 2024 01:07:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIE-0005Kv-G2; Fri, 21 Jun 2024 04:06:46 -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 1sKZIC-0005It-8c for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:44 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIA-0008Ji-2J for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:44 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-364ff42999eso1301282f8f.3 for ; Fri, 21 Jun 2024 01:06:41 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a8c8aa6sm962550f8f.105.2024.06.21.01.06.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957199; x=1719561999; 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=5/RgyhQBn7T7/7BrixgsTi+BC7Dln0yA+HQ13ohYUUo=; b=ERdp1tgpQ0CP3m0+t/dPTumLnSj1jKZ4hfzDu9xvA9cytya1wnlMkXBS1JatlnF/+V 80oJ3SLcN7yQO2uuqi4Cwbfis6mSljWZ010K0gYvX9HRb8yBoBQcbfh9+Ow0G0L4caOH unnYgqs0EQYqpSg+xIAGc60BtjqUaLkmAgHPgrYi0hUlWE0wsntcsE/j+ICbkEqDKT3N eRgX3Ut2e4UoE19C0WKTqisSCLNKhgVBxGB23Cha6AFhTdrCLwb7Bb3qjS4iLAyUxF7M Zq9Z/cuCLgOwOsjLFhfTzQI+rqAHSfE0AJJMujpjIOw/vhuHtwYcAQ1kT7r5BkJvbAcI H3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957199; x=1719561999; 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=5/RgyhQBn7T7/7BrixgsTi+BC7Dln0yA+HQ13ohYUUo=; b=gRXUfbEcX2MUk873cS3C1/zYx2rzmqDN7Fl+RyubJWoz5ugKZ30+TPipZ/FaNf7kgL vAoR1jfUPyfm0df9uu2pP47aVmV6nGOAYhH0fb6RC5N8tBobvudBOD20jfO3LRz0OuKT EQDw5W9lLsiUe/+7H6xQxh0OrpWCOiNd+YRevv6hx13rbQHSS8L4Hb6TwNVr4/6vvVmv bvv1rS/7b0V13zMiXvlghEwRU69u0mGAns6WV5c8gtqNf4FQ+7WTOFdUer2UCEehrkVV UF9JZThpfmolCBv8Um9s0KFhlSh3Qjvv8EFKqhmbzItSbZ190lYAP754pkK5Nsdz/oUg L98g== X-Gm-Message-State: AOJu0YyzmtdbsottZRhv7/7KYj3XYNbOC69Q0982afTrU4rzGc+93SjY I2c8vxj5xwy52ms2moqotJD4cFZlg7hmDWT9RzX4y6p+Vv+mXxYLEL6kOUt5vzEoS5caFTUWai2 / X-Google-Smtp-Source: AGHT+IGeRbmY4LdJ/gNJBgZWLBPlfAf6117+uKh/sO4vbzQ+GFfWHwuDAwrHgYiPV9LOHHQo23I9sA== X-Received: by 2002:a5d:590c:0:b0:35f:1eba:cf66 with SMTP id ffacd0b85a97d-363199905dbmr6916611f8f.61.1718957199119; Fri, 21 Jun 2024 01:06:39 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 07/23] hw/sd/sdcard: Remove ACMD6 handler for SPI mode Date: Fri, 21 Jun 2024 10:05:38 +0200 Message-ID: <20240621080554.18986-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957250197100004 There is no ACMD6 command in SPI mode, remove the pointless handler introduced in commit 946897ce18 ("sdcard: handles more commands in SPI mode"). Keep sd_cmd_unimplemented() since we'll reuse it later. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b0cd30c657..e9af834a8c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1012,6 +1012,7 @@ static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRe= quest req) } =20 /* Commands that are recognised but not yet implemented. */ +__attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", @@ -2153,7 +2154,6 @@ static const SDProto sd_proto_spi =3D { [52 ... 54] =3D sd_cmd_illegal, }, .acmd =3D { - [6] =3D sd_cmd_unimplemented, [41] =3D spi_cmd_SEND_OP_COND, }, }; --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=zohomail.com; s=zohoarc; b=fchYNdGSP0OodbNkpyYfpy8MFGsTXryArGlEJ52o6ND1eOSwSypOu0ctJbv8k3lYwt+uYhvCgXJ7YBm4On2O6FGbcBd3TxRHy14qOQVQ0iASYcYBsDlhqzljlJPs2Xei/lB6mPACgPFVG3gc8/I9SzCnLQcE+mV5UtxhCzU9yxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957227; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YQaHBopgwSjXudC8k46XwyUf5aDsciZs6MaYovNVcw4=; b=X6SQ5xhaAL0u+T9IKALzoVxH2Aklq3+9skqhQvHZNvOybM6UlIZWgPfyICTWzkJiKgzxV3G6cyZZXrdbSUAvo58UPeJX/Idovr/I+j8MSTqDs816CuUbCcafKyskKitm1MAf1KXt8IQVpQolaD6QcqWXhAZPWnsUMEjSpgncq7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957227099407.1782237581857; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIJ-0005do-Tv; Fri, 21 Jun 2024 04:06:51 -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 1sKZIH-0005Vc-R4 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:49 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIF-0008Kb-L2 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:49 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ec50a5e230so1567201fa.0 for ; Fri, 21 Jun 2024 01:06:46 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424817a8ec8sm16809315e9.11.2024.06.21.01.06.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957205; x=1719562005; 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=YQaHBopgwSjXudC8k46XwyUf5aDsciZs6MaYovNVcw4=; b=mXPUmOmDtmSfLqeFq53zrSLbHowcI3hZHkqQyVcZ29wboFKUz8p00P6cWI0KDcPnqH Hq1Ep8sDbjFineYi/ld50+HUpH1nRE09PGYFTNnOOBLIaitUwjyr7YiACELZhnS0H/lV MoHXU5GekmZuFCooFEmrus4WupHeBtg4eN2YLiP3dr9H46amo2j2jcE2++ZWN0MonEHj oc2cAZlrA9VytREER94o0tQCoDazN51iAwYQCzqpl1E3m4Rn87WueHQgBOkRyd7H3EvZ Qmi17xp1pkKDo/orcLF17L7zUz38JDT6waSE/KL2t29Z0EMoeQd6nCeeoiSzf/f0Ld2o LVjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957205; x=1719562005; 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=YQaHBopgwSjXudC8k46XwyUf5aDsciZs6MaYovNVcw4=; b=fRbF4KlOAHYiT1Fw7x7azNza6mbwyYz2W1JsqpfMPYg9aBeBry3PItO4nT1KBB+Cx1 GgusGSGCvOlsRhGkJrr6stuorCio3Pb4F2EEinRWH80kwRTA2tjIK6ISN4asn8DiK5jA jSxi+bhu4H0EVeZ6RJd6y8E0u7iGPRftELrDQPSzhSQJfdvlXeOtiXcLQ7AZg9iStcAY vqa7V4QzPCpqXyGyTAsCpEzXQngM3zsRpCCiMKkOdHEydsR5Al7rvkcB64+xlQeR4mPm ctw8QiSlf8c0pOPoc9boI+svqQ9djgKPmDPXQ13wTHzXNGq8uxg14g1zRQovkwC75oll DJTQ== X-Gm-Message-State: AOJu0Yw02FW7ZUcsC2pDwgMfJqY1x9E5Uo7h0L6GQ+0tw7x8vqKlkxQj ahv8BGJYJ1AsfL3CaP/HK3YqSI/LePsvHCbJuvMoI/XJAtw7fn3adwGflPwXxjPC/+yycmzFr3z 1 X-Google-Smtp-Source: AGHT+IHC36reLkPQEaKj3Cld22JOWPAHwya+F/z+KxieWbZiqTLfC59sBHN/1YungtgqqTyw03hiDA== X-Received: by 2002:a2e:8701:0:b0:2ec:f68:51de with SMTP id 38308e7fff4ca-2ec3cffc8c5mr49170631fa.47.1718957205286; Fri, 21 Jun 2024 01:06:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 08/23] hw/sd/sdcard: Remove explicit entries for illegal commands Date: Fri, 21 Jun 2024 10:05:39 +0200 Message-ID: <20240621080554.18986-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957228139100004 NULL handler is already handled as illegal, no need to duplicate (that keeps this array simpler to maintain). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e9af834a8c..30239b28bc 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2146,12 +2146,6 @@ static const SDProto sd_proto_spi =3D { .cmd =3D { [0] =3D sd_cmd_GO_IDLE_STATE, [1] =3D spi_cmd_SEND_OP_COND, - [2 ... 4] =3D sd_cmd_illegal, - [5] =3D sd_cmd_illegal, - [7] =3D sd_cmd_illegal, - [15] =3D sd_cmd_illegal, - [26] =3D sd_cmd_illegal, - [52 ... 54] =3D sd_cmd_illegal, }, .acmd =3D { [41] =3D spi_cmd_SEND_OP_COND, @@ -2162,15 +2156,10 @@ static const SDProto sd_proto_sd =3D { .name =3D "SD", .cmd =3D { [0] =3D sd_cmd_GO_IDLE_STATE, - [1] =3D sd_cmd_illegal, [2] =3D sd_cmd_ALL_SEND_CID, [3] =3D sd_cmd_SEND_RELATIVE_ADDR, - [5] =3D sd_cmd_illegal, [19] =3D sd_cmd_SEND_TUNING_BLOCK, [23] =3D sd_cmd_SET_BLOCK_COUNT, - [52 ... 54] =3D sd_cmd_illegal, - [58] =3D sd_cmd_illegal, - [59] =3D sd_cmd_illegal, }, }; =20 --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=zohomail.com; s=zohoarc; b=ATRDgahCswSV8+zEYsT9e7bEv1qNjesoJHpirLAloNL+zS7PRaTTRVhs/cL+U2HIa2KNXI5O2qxu3lkpCkxjYNaE6Lk+D/GqvTFv1BtZ5phNvCUQqCq16HcelXMzaE740MpnVUEXaBef9FfTwfJT8coyt9E3vrprYyZSnftZlhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957227; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wIA5ZIlGPiIpZ77uW3DTdXqmrUImGJ4SmShsvIo62CI=; b=XjdTkdgNDzQJ0GoSjvHDVfUYXJSI/b76Wdxdhp64gd18IMmeVSEexIQdGS4pHzyH1MuFsQ5NY3YNW1FVdJUmrNSxfDMhIqIDZu17UOqQiuWWoj3UMwqr8xaLRezG6RjODNmCDNRm5AaCVQvTbmm9W24NevLusIxzQzQ1aw4qurw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957227695633.6033376079071; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIN-0005hN-P8; Fri, 21 Jun 2024 04:06:55 -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 1sKZIM-0005gp-Er for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:54 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIK-0008P3-VQ for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:06:54 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-365663f51adso897835f8f.1 for ; Fri, 21 Jun 2024 01:06:52 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36638d9c16esm973840f8f.57.2024.06.21.01.06.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957211; x=1719562011; 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=wIA5ZIlGPiIpZ77uW3DTdXqmrUImGJ4SmShsvIo62CI=; b=IAAxos6cLzcOQArJ3kHJodAxu5xFdVovG6rH+QGAFElG1saFPi/5JSienlQmbZ1h++ JVduLjshz4b8RX4PUb8k1WroN4ybWjNA+8iCbPFapJBbtULoiAqsvMX/jRh3aTLHBHjP RL6UiEhS3AgEYmIaWlxKpNB+T6Y2lyqyPmSDwUpXekwp7zpZbdu8Uix173ryHBodVx+C YHePwZejzRw/sOfNdY/3zilcJtHA3u3JQqZpmvobniOKjYQRXPQIfzWGh2Uh80ywXoP+ Mq4dqrqTBC1dxsqdpp4ess12L5yosYSSTMYn7NUodfkDx80kAextFZhiAOtiZTjWURT6 cauA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957211; x=1719562011; 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=wIA5ZIlGPiIpZ77uW3DTdXqmrUImGJ4SmShsvIo62CI=; b=S/lbCcX8dgelflMt3DSwUySrKPzOiAYckN+P4vnMp9+1QAp6PtFsj+uNPT3waBJQ4D FVDgxAB5m8JuWn49qLny5irYgjNXn0aSw9KFSWiGi7LrZZ33ZWVpRXzDW9OQaA+i7y0U 5EwO/MC44yN0zvusH0JS7WZc+ik8/oglZQn56D+00aVKS6g4ez0eHLVkwb6TGRHF3pyu sTwLcokwGROXAU4Usjp3r8B4RBY7edkR68zp/NO7BJWAIJ51xas4JKqV3KuWzZRKq/4o G8Fxl4FozMOlhDLq15nYy+7Y+EnlWZc9M6zwWLdjzjYPjaqzzwV7pYORNZsrjcwijovg wFjQ== X-Gm-Message-State: AOJu0Yy9cML0nL5czh+0jQGHsTVdTvEwQ2IvtOMjstvbsqeWv1iN7YQ7 5oU0/45e8xf275qXmOcCGf+d4DHgCZ0ABGYG0Aqhujd38Z9PjDuUWZdgiKyFX1qCCElEM5cNdTH 5 X-Google-Smtp-Source: AGHT+IEgQ1U2aTmFKSvB+qWycUFCCVBOuolfpfJ25lZvfbLp7WlHJCPNuJSVNa/DAErVveirNroNDw== X-Received: by 2002:a05:6000:9:b0:360:775d:f917 with SMTP id ffacd0b85a97d-363171e2c36mr5350833f8f.4.1718957211381; Fri, 21 Jun 2024 01:06:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 09/23] hw/sd/sdcard: Generate random RCA value Date: Fri, 21 Jun 2024 10:05:40 +0200 Message-ID: <20240621080554.18986-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957228124100003 Rather than using the obscure 0x4567 magic value, use a real random one. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 30239b28bc..e1f13e316a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -46,6 +46,7 @@ #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h" +#include "qemu/guest-random.h" #include "qemu/module.h" #include "sdmmc-internal.h" #include "trace.h" @@ -469,11 +470,6 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[15] =3D (sd_crc7(sd->csd, 15) << 1) | 1; } =20 -static void sd_set_rca(SDState *sd) -{ - sd->rca +=3D 0x4567; -} - FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) @@ -1055,7 +1051,7 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDStat= e *sd, SDRequest req) case sd_identification_state: case sd_standby_state: sd->state =3D sd_standby_state; - sd_set_rca(sd); + qemu_guest_getrandom_nofail(&sd->rca, sizeof(sd->rca)); return sd_r6; =20 default: --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957248; cv=none; d=zohomail.com; s=zohoarc; b=U0P9KZks5LtRYe/ixWBnVtAuNy9dvHxt5clu+0Jf5gw4qT9cYTScDYicDDkYIaSNKcLZees4rTyHn80Cr3+sDFSSH10Lx0A/kHg+JptYZo2FJWeun5d2gJKGYV7VPbqraQpynjrLRqWFpqbcPB/IxIah1iHU2hZvRSIwB/upCdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957248; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bU0wem6sZ7huq6N/EuEaJYYIPtKn/tCwdXKOteR3RBw=; b=JyOR4HYVcV0u3hIs1C+xYruZxLdu04Tt2a0/BDhXuj169LKhr6lxJ1rZEf3gvX3HdlJkhQwZvZRy54Kf9hZFi8+Y1W/fP+jgajGL8BUCEvqLW3gXV4dnSLuZLWOP6WJYKpQ8o52ChWdBxZs7j9Bssa/9rilU909JsVC+3ZJROW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957248438439.2362831928168; Fri, 21 Jun 2024 01:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIU-0005jK-CV; Fri, 21 Jun 2024 04:07:02 -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 1sKZIT-0005j8-LH for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:01 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIR-0008Qp-V0 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:01 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ec50d4e46aso1168761fa.1 for ; Fri, 21 Jun 2024 01:06:59 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42481910d5csm16921775e9.36.2024.06.21.01.06.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957218; x=1719562018; 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=bU0wem6sZ7huq6N/EuEaJYYIPtKn/tCwdXKOteR3RBw=; b=qdFlEIBf1EOdYJrikiwG6axKT8Oq3zyRsWCC5sIaPWMIerANW7Vw0iSfggBhB9QzIz 6ofGubggogFmhQASB85p3FyIGHdveYoYdPsRKnKa2gbiq1TMFOIAOmM8f4jUNHWsaxCr a0n1u6/uBh6yJwu+od007A34M0PuxfRyMSMYjAi5UbnI1vLLaVbPkMFH/IDbxQglelOv b8t+2GhZS7rSCJJMf8akueqUa3O1LO+DSkchSsOFjbtSlPQ4CsPEGdjVEmibtLP7LCiJ 83iUIuOmXS7Vpdng3RyFT0xvq2IpsBrdKoydXu0ybM60+LNk3J7I9F3xNfbcOBPLjJg8 OuLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957218; x=1719562018; 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=bU0wem6sZ7huq6N/EuEaJYYIPtKn/tCwdXKOteR3RBw=; b=jkCkX5Ha01cNLKyvYQhL584c4egB/WeneB95sSFOPz8awqSitbGTqgCofoca40lxl6 efEYVNsF/NamaxLaTivtd81V15eIpNpySDdaX5t9+ZgBBbV8vXf8Gw9bZqkWZr+0lB7s G1EGQkXXC67OE2sqGdpuWMngy6ah9BNAM6lcsHwKk+q9bKDp7Yv3mSLiRIMVOmefsa/q 1eys884bCpbGL/H8O6UsqG75EXWv7Tjrla6sBGn0TrYLei7DQ4cBVoGqNk+DVFdXvyuF fWpsSUXFp+bVskoSjxX9mUIvDGdIqNWzgCQxnJYyxN942XWkwfmfRSoJ5vKUDe+akt1x l6zw== X-Gm-Message-State: AOJu0YykUC8zqZozmYl1YPPxi7FI2xELMHNHFUMrJNSs6ZM4tE24faEU PfRmrPIoEONIRnHCjZsDgwxSTkNB2gEAMkpINi+VnXmft3gE4UID3G2j/5QTG8IoC4IbdYlGX3Y I X-Google-Smtp-Source: AGHT+IEDx7ks0Bbwcet536NEuNgxMW89KRZaFDVd9rPc9ZQ9IFcBkQp3vRe9VWpXc9fAWtV1Uf/zLQ== X-Received: by 2002:a2e:87d7:0:b0:2ec:4529:9690 with SMTP id 38308e7fff4ca-2ec45299761mr26448331fa.3.1718957217896; Fri, 21 Jun 2024 01:06:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 10/23] hw/sd/sdcard: Track last command used to help logging Date: Fri, 21 Jun 2024 10:05:41 +0200 Message-ID: <20240621080554.18986-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957250232100006 The command is selected on the I/O lines, and further processing might be done on the DAT lines via the sd_read_byte() and sd_write_byte() handlers. Since these methods can't distinct between normal and APP commands, keep the name of the current command in the SDState and use it in the DAT handlers. This fixes a bug that all normal commands were displayed as APP commands. Fixes: 2ed61fb57b ("sdcard: Display command name when tracing CMD/ACMD") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e1f13e316a..4e378f7cf7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -134,6 +134,7 @@ struct SDState { uint32_t pwd_len; uint8_t function_group[6]; uint8_t current_cmd; + const char *last_cmd_name; /* True if we will handle the next command as an ACMD. Note that this = does * *not* track the APP_CMD status bit! */ @@ -1095,12 +1096,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) uint32_t rca =3D 0x0000; uint64_t addr =3D (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : re= q.arg; =20 + sd->last_cmd_name =3D sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular cas= e. */ if (req.cmd !=3D 55 || sd->expecting_acmd) { trace_sdcard_normal_command(sd_proto(sd)->name, - sd_cmd_name(req.cmd), req.cmd, + sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } =20 @@ -1571,7 +1573,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - trace_sdcard_app_command(sd_proto(sd)->name, sd_acmd_name(req.cmd), + sd->last_cmd_name =3D sd_acmd_name(req.cmd); + trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |=3D APP_CMD; =20 @@ -1863,7 +1866,7 @@ void sd_write_byte(SDState *sd, uint8_t value) return; =20 trace_sdcard_write_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -2019,7 +2022,7 @@ uint8_t sd_read_byte(SDState *sd) io_len =3D (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; =20 trace_sdcard_read_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ @@ -2163,6 +2166,7 @@ static void sd_instance_init(Object *obj) { SDState *sd =3D SD_CARD(obj); =20 + sd->last_cmd_name =3D "UNSET"; sd->enable =3D true; sd->ocr_power_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_poweru= p, sd); } --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957248; cv=none; d=zohomail.com; s=zohoarc; b=egPkX617zGwOBKxae/hm8nI3WPIBPcsor0xBDUjZqmlywdAQdkE/aQqVEGLVmCCcZup9jdDUSlgMrFEmh0A1TAMdaHZJAyjiGiENmJ/VWF1+yUgKAOrLaW+Tmxt4bc1Qb0K+eTtcd6kOjHerCHLTPP5zKVT0n5wFSJc5v9IsgiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957248; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rbyk3UWFgM2fJ2qZVnBwxOBfAjBIau/lAmmpzLCFWnw=; b=RuQSy09JdZQAfmLE/yV/Wpqbulxs54K75slTIMpvVHBtmfXtQLg2wVZpKb9+OcCGBZ24YFrMZ3MiH4vk6BEmjfedHsncU0ajqvLDpAfl4U3ayV+7r0MegYWSoPQev2WCXNNXLQg6W2xraqmEheGnyGGvEY7yuxBoxYGHTcEcNyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957248672669.4728381769413; Fri, 21 Jun 2024 01:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIb-00065S-5q; Fri, 21 Jun 2024 04:07:09 -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 1sKZIZ-0005tA-5U for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:07 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIX-0008RQ-Kw for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:06 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ec10324791so18847291fa.1 for ; Fri, 21 Jun 2024 01:07:05 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42471e66013sm90039585e9.1.2024.06.21.01.07.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957223; x=1719562023; 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=Rbyk3UWFgM2fJ2qZVnBwxOBfAjBIau/lAmmpzLCFWnw=; b=bJBMf9dxKyzAgyzihFLFZH8SPPYh2kMP/y9tLOIsPBeP67f9Uxn/1mB0bo8c1GXJM1 e5ZpEDFWomTWnIJ0YMpC0NrldInZesAD+mcVhEHqnycT1IB9X10jxY/TnwvLAmcF1Lh8 VSPkbfEwe+SVjJEKVb7lnlLjzIEiULXKoo6mGW0h2gN4xocuUJqFuoHzcv8ZYeUVO/Gi hnTg3B19n/V0UKS8LMRON/LxzOu6Xd5r4voN0I1Ys9Sa8bOd/ZwYV7YHmGifEm5rF0wT BG9S+AiTuaFXpg+XBP4MXvyGQYKu2/pj5vmAu7WFpKk1HpBd5gsfbAiCBtGk+7QIskWy E3Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957223; x=1719562023; 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=Rbyk3UWFgM2fJ2qZVnBwxOBfAjBIau/lAmmpzLCFWnw=; b=qtYpXqruTaauvexR7qg6VoBf2F0Uffv2RS7QciPI1fd1NMIRu7ABiiZMlW54uVnkpW Lx59h5eDc7Km06TN/YqfWDkE3HU+tB72EfuWSyJKnRBNsNhVLleI1f6BhOKWVrAh3cL+ Jf1eO7cey5YY6ArUrUGRl3k/SE7SMfPsHNFEYjcDjp1aRZVtVEmwGEJr/VJ6Able5Blv yiFj5Fib9jbwVb9wDV6nX5WjdV25Lej8EDapukxcSEEziqts0DnnVjyy0VWGQfDiDCAg o4SH4PenlGlTiqSFC1zzNZZdM0a4CxgR9BWQo98MI+Kh3dM3++jP99mGxppqTtkBBb3F JE3A== X-Gm-Message-State: AOJu0Yy39IpzNwdkY9Sf74L6t9xE7haTTdi/frEv97PdM6UlCSgVc0Lq Wkp6tUP6uI+CWhZspSOFh66Tk6ySdeOrIRsqpUrXQdvB39uVLkxenECM2hHiQmPD037SP2JRboV l X-Google-Smtp-Source: AGHT+IGawaLYlGgk/gVLgzkpXV7SUK2EpYuj7y7wStFOwxJrgW0ZYHCThrOHSQyfGNS+5ZDdCj7hrg== X-Received: by 2002:a05:651c:91:b0:2ec:22c0:66e6 with SMTP id 38308e7fff4ca-2ec3ce9b78cmr51243561fa.7.1718957223676; Fri, 21 Jun 2024 01:07:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 11/23] hw/sd/sdcard: Trace update of block count (CMD23) Date: Fri, 21 Jun 2024 10:05:42 +0200 Message-ID: <20240621080554.18986-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957250212100005 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 1 + hw/sd/trace-events | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4e378f7cf7..2586d15cbd 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1087,6 +1087,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) } =20 sd->multi_blk_cnt =3D req.arg; + trace_sdcard_set_block_count(sd->multi_blk_cnt); =20 return sd_r1; } diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 94a00557b2..724365efc3 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -43,7 +43,8 @@ sdcard_response(const char *rspdesc, int rsplen) "%s (sz:= %d)" sdcard_powerup(void) "" sdcard_inquiry_cmd41(void) "" sdcard_reset(void) "" -sdcard_set_blocklen(uint16_t length) "0x%03x" +sdcard_set_blocklen(uint16_t length) "block len 0x%03x" +sdcard_set_block_count(uint32_t cnt) "block cnt 0x%"PRIx32 sdcard_inserted(bool readonly) "read_only: %u" sdcard_ejected(void) "" sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last = 0x%" PRIx32 --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957307; cv=none; d=zohomail.com; s=zohoarc; b=D0f1VHyJ8aEds5XyrTF2xDqzS9U8lCG1kZbDkj4B/az2gcVGTI0vgw/5mWp0Kq9WvP4VhqQn2Jl3KKNPuUGzoSjt0PHCVTe1/9U75nFGH7/ckEeW9Z6Y7XVfAQgJu7bIWHbDdeAz7DR7Q/dGAxdHyF2zmoLX1aixqogtacnt8Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957307; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; b=BSmIcahWvQviHuTlZvYbxMiaj2SrmN3Em6M32Gg1ru574qdyntN3TRArhof9Fzf8eH+yPW2NY2oHQnonlwlixF3ofxy4IOfW4dO7Kz9m0n3XkpopYf+2DhUIDtATXQcl4hxLvB6Hb5tzQJ4PhsSJc8sJXVLEYh4J309UA5FgY1E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957307188341.95977715345725; Fri, 21 Jun 2024 01:08:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIi-0006e6-9m; Fri, 21 Jun 2024 04:07:16 -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 1sKZIg-0006Tf-8D for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:14 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIe-0008S9-Dr for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:13 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so20467061fa.3 for ; Fri, 21 Jun 2024 01:07:11 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a8c8e51sm961432f8f.93.2024.06.21.01.07.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957230; x=1719562030; 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=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; b=R3X2IGN+vUWZo4IiSlxJ9vtqLqn+buTVbx6KbrZJhoaGB03TXPuz2s9lvJW8Gb8h3I Uqev++PRyB+epOnnvDVubILnRWCNf656O/U9/RjTSnQ2mEYawjVvk09cc2SapPKNnMIJ AtPezlXs+JeK4bvlXfY0HRNSdhfTlPIE00eE7mnG36X6QyfPU/vngWeVCAW0qFbnAJ60 TbVTCRBru1UB3ilcM7lw1ZYfSiswfv0TQgufZNYJ59DMRkOJRBFx5DReaF45CjIf+raC SWIIsSAR3oLGuA8JkwfSuq+OMz8CIFqIjkMIGPxvdWDqvL5T6BWQM+0gx4A/k6Ni17un lIhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957230; x=1719562030; 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=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; b=VhlOvJCrmgjniUOAhSFbtvkAklkWgUEF2Cg6oPiIRuV/+EmeI6xNhAtDI5LzIpDvon 4GuxiOAJGR73uZ/TKZzEqcQ4sDgHor4hk9qEsZPFqKtlcnRyiXop9ZFirkab4+WRTryp MUOSrg58UgGupzoKzq7YgSV9NMsHOx+PrDnDSClF4FXPhoqazAUFBwTUGy8CSdpLnKeH z0vnSWQksdmdbrNzULNYNdCLGwLyZ1ahsxm+nnkWobmVWpz77sLKOojThIwo1NeivLXW oJ37f/iBcOUaqBP3uNxV9Qlk1WHENRvKiEU8w9LRaD2wvNyH+D9gwngNVP6OxzfPU86z mmnQ== X-Gm-Message-State: AOJu0YyJ8Wez5stMtQqAezkR+VA1tEUQ11IAXhKZj9dU6EVYlalozZp/ 7UoJx/mARBRnHCys7a8c7xUkjqRhOsQshlyrQkx1tX2FGZkgMcwrklN1sn5TkQL5T9q5IvXvTsd C X-Google-Smtp-Source: AGHT+IFDDcOs6k8d34TgpM+nJdOdBuYqjwNunGoL5RFaLeRSkNaiT+FuCvPj04Z0+Hv8kd4muYtDjg== X-Received: by 2002:a2e:9acd:0:b0:2ec:4aac:8fd8 with SMTP id 38308e7fff4ca-2ec4aac9280mr16514161fa.1.1718957229703; Fri, 21 Jun 2024 01:07:09 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 12/23] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Fri, 21 Jun 2024 10:05:43 +0200 Message-ID: <20240621080554.18986-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philmd@linaro.org; helo=mail-lj1-x232.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957308543100005 Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2586d15cbd..c6cc1bab11 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1868,7 +1868,7 @@ void sd_write_byte(SDState *sd, uint8_t value) =20 trace_sdcard_write_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, value); + sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] =3D value; @@ -2024,7 +2024,7 @@ uint8_t sd_read_byte(SDState *sd) =20 trace_sdcard_read_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, io_len); + sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret =3D sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 724365efc3..0eee98a646 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,8 +52,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" 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 0= x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, ui= nt8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uin= t32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, ui= nt32_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, uin= t32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" =20 # pxa2xx_mmci.c --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957429; cv=none; d=zohomail.com; s=zohoarc; b=M/LsdWMOve9u5xH3C1eJqvlMPZ4sUNGv5yUFqmCl1lMCwWL/hTThFLQzQhFCiN83rYQ2QUmCeNfZAdepr+iBbDiCRTOaJcK7PF7+UkWuXn8gTi/m/M2ZnUWdqNdm0xji6B8Prn4DCKbW408ipDzviCjypy/Ge4vAXZkry91y2co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957429; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RPBvU4uriaq93lgSEpi40j13P7YTd0f6Hz6KWjEoVBs=; b=Ud7siu9IveTZAVwneKByh7ph95/SMu9dthV9dzXJD7ufREQTmvVIzPGb721PRD+BLDI07g62/bb9pyzLSqsX3maqaVPKEMjsJm7U6fC1x8/KBHcWCsVYDXiWZ2m+Pur0wXs1d9R0BPltBMCZOXJQQXPRThwN4XmprtrmRhCYzCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957429666812.7028571658557; Fri, 21 Jun 2024 01:10:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIm-00078k-JN; Fri, 21 Jun 2024 04:07:20 -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 1sKZIl-00073p-B1 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:19 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIj-0008T0-9F for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:19 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so12978345e9.0 for ; Fri, 21 Jun 2024 01:07:16 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248179d3basm17504175e9.4.2024.06.21.01.07.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957235; x=1719562035; 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=RPBvU4uriaq93lgSEpi40j13P7YTd0f6Hz6KWjEoVBs=; b=io9rc+hsFIpk3MIVkYySyNTbnru7F1uJ61uNaeR8Cs003Wnpul4Jdfgwpa0xi1vbDg wX94P7452MtDTMr4XttxNHZzehyI72aSGJ5ffuzHwASPLS3dK9ThgWtnbQVv2SoWhYzy uT7IEYuAGjV4vxtmJ0wdYggae7XYXI+iX8QG963nxCHfze6Je11EozjWh6/hjMYaqEtX 8YmnM1KXGqoFm42NIKwm5fwyJ6xsr0Rz3HV4sA8Sfmz6JBZEmM3s+Cr9ltDSYEL6bkR/ MVU9G2Bsg3oJq5v10cTb9BdILaH2BpsBCc7eQf8Tzv35pJpcKiixglJJ/1jvgot1zYOf QqWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957235; x=1719562035; 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=RPBvU4uriaq93lgSEpi40j13P7YTd0f6Hz6KWjEoVBs=; b=uKyw15ig9rOD3p8IRQPZMNBLpBtLHKi/W/gK2GWJDM+frJmgnBt8S2kApaOM1SvfGq 6YlpB/zHL6kbtR0ykfVaw/Tckg+1z9Crs6IqY6I/4vxe8MmLU5I1Khb95HxrOtLZF1ew FIA5oAnO2SlbVpMrM3nIk3/xC26A/ZHXKlzHmc9nS+HaT88MFoW0I4P9yRLdI1N37egt mOI90nZvgRmVBK8zhI4dzz4gcpzBlXU5d8Ae/JANagNWUNgCHJu4zRevqV62rikhAn+a nP8cnEU18aXBHR5kxZGAbDmOiZVESpJuNwuRJ4Qq/xzXB9ZkVZPoSWSVByjJ3DvqIA2D pt/A== X-Gm-Message-State: AOJu0YzEj8pdAE4CvjqjqTC5TDVFezpKoH5v4at0orKS2htLO9137mUX WnM+nD3CRpcQDMTUK44jtH9VfmIqPelvxAoIi5BoagI6WaeFYVaQa7Htu65hqeodJ2ummdKiHIM 2 X-Google-Smtp-Source: AGHT+IHLBSHzLICc5EqZWmuIRKUfUq213U/Ldad1rze3v+cTvRX4eCN3pTHD4FNdwb2pP+8+ETSVOQ== X-Received: by 2002:a05:600c:4aa9:b0:421:f88f:4ec3 with SMTP id 5b1f17b1804b1-42475178817mr55522395e9.14.1718957235533; Fri, 21 Jun 2024 01:07:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 13/23] hw/sd/sdcard: Have cmd_valid_while_locked() return a boolean value Date: Fri, 21 Jun 2024 10:05:44 +0200 Message-ID: <20240621080554.18986-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957430965100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c6cc1bab11..510784fc82 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1716,7 +1716,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, return sd_illegal; } =20 -static int cmd_valid_while_locked(SDState *sd, const uint8_t cmd) +static bool cmd_valid_while_locked(SDState *sd, unsigned cmd) { /* Valid commands in locked state: * basic class (0) @@ -1730,7 +1730,7 @@ static int cmd_valid_while_locked(SDState *sd, const = uint8_t cmd) return cmd =3D=3D 41 || cmd =3D=3D 42; } if (cmd =3D=3D 16 || cmd =3D=3D 55) { - return 1; + return true; } return sd_cmd_class[cmd] =3D=3D 0 || sd_cmd_class[cmd] =3D=3D 7; } --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957400; cv=none; d=zohomail.com; s=zohoarc; b=KzEpmKOUmIO6rSj21fWg5T9h2qFewxxKFZWG34s0027PShyXbX+H3vaq7LiVL6TVTYQ3NENLZxApGHpiU/ZLwtPXbbX28mbLD77i3jX/zLNYmS8w/JY9ZJ/5ZDlGLUoZunvHNcUTNd6ofhlAUHa0vvvpdib6tTtBBphsMCOX9bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957400; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=udWWj272g9nUODajXENG5MjPbFRaI4fbT7wamp0YglI=; b=nlhvvqrER8bhyhN/HA4VOOOvmq3jn2gYZCtSUK1xHJcKovFwyRU3b6l1olj5xPaefFBksehVERKH0nt/PGTFWoqYYV6OiIWPefNktiGFGYozGV2r6vZZs37+wKkPiTupwZeeJ4/NVXqF4RhMXRE+GRjKl3ituPAF7BxphoTPoX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957400468721.5439333074778; Fri, 21 Jun 2024 01:10:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZIt-0007PL-Ow; Fri, 21 Jun 2024 04:07: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 1sKZIr-0007Fa-Rg for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:25 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIp-0008U0-DE for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:25 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4218008c613so15603365e9.2 for ; Fri, 21 Jun 2024 01:07:23 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d21225fsm51975745e9.42.2024.06.21.01.07.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957241; x=1719562041; 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=udWWj272g9nUODajXENG5MjPbFRaI4fbT7wamp0YglI=; b=fFkYC12Qwzn4AFZL72k+EJ/gVAQ3uO2+NbxJG2gmy9WLZvFr+8f/TLq7Vb4h4zc0ay CUCX/IlKNUQMvjWXigY5EXdO/f/0izP/2FVTTJgWMo5FSJO3r9rL2FPLfSJN4pfeZ3KH n0c17iiffMc1Dlj7+z3osEHyNbJzabMmmuiJX97iYTuCcoJc9nE3+2ORNpmiTgLOYFUX 7zKKR2uVyYmHFh7SSZZY+mPeMvb/Cc6qs9pVFz9SbzjlXWgNJHLJokUr7kRKymYpDbF3 tVkfsTs+t7+T0D+ND6Qu+SXcBkvz8xPriG1sK4LoV1M/phICXJJ8GANZxcXzI6lEyMdK /m3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957241; x=1719562041; 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=udWWj272g9nUODajXENG5MjPbFRaI4fbT7wamp0YglI=; b=OSp2/E2MSiZcaj4/jj7tK5tp6nnKGRd73CaSZL6E6W3qQ2STGTJPWvkD2h/b8VdD+2 bcVYijzHzN99naeIeU5E7WraoTuNPGq86G5ex20n8nZLlNJfCF0rITfqbOt2CufyJ89D 1pWIvrepO85bTaEggh89cTMLouZjX6+6tpfMmOfufoAU6NDLqkCDJh5Gy2P1jvFmbz5E pDQAJqRiwock1+Mt92zxRRtMm4DSuFoX2WB6twJ+EeHSN0y9vBgizMdWdJOxII7R7Rbj SgM4Vbz2W49lAIFEenkDtRor1O/xW7o8YkJ851Hoz/iADKc8oNu/TkhBMUFEhYKZNhVU HFow== X-Gm-Message-State: AOJu0YyjdX+pu3em8+jMVViMf3TN4lTMkqJ+3/8tZtyLY9Hs/vzMbCf6 87Br7N7hGq2RAhvmvonm2EChtsz+Y3z6OgOV+jyW0qCmBNnHAMtxFSX+elFlxOZDN6ZAk3UXbZS v X-Google-Smtp-Source: AGHT+IFXanEhUXqVengTV9gDjzhJvsGEFQayGRw2kyH8U6xphhj8u5YxikBlrABG0zISHdO+NyLkHg== X-Received: by 2002:a05:600c:1d17:b0:424:760d:75ce with SMTP id 5b1f17b1804b1-424760d777fmr56755815e9.7.1718957241673; Fri, 21 Jun 2024 01:07:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 14/23] hw/sd/sdcard: Factor sd_req_get_rca() method out Date: Fri, 21 Jun 2024 10:05:45 +0200 Message-ID: <20240621080554.18986-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957400880100003 Extract sd_req_get_rca() so we can re-use it in various SDProto handlers. Return a 16-bit value since RCA is 16-bit. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 510784fc82..bc47ae36bc 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -471,6 +471,14 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[15] =3D (sd_crc7(sd->csd, 15) << 1) | 1; } =20 +static uint16_t sd_req_get_rca(SDState *s, SDRequest req) +{ + if (sd_cmd_type[req.cmd] =3D=3D sd_ac || sd_cmd_type[req.cmd] =3D=3D s= d_adtc) { + return req.arg >> 16; + } + return 0; +} + FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) @@ -1094,7 +1102,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) =20 static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint32_t rca =3D 0x0000; + uint16_t rca =3D sd_req_get_rca(sd, req); uint64_t addr =3D (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : re= q.arg; =20 sd->last_cmd_name =3D sd_cmd_name(req.cmd); @@ -1110,11 +1118,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) /* Not interpreting this as an app command */ sd->card_status &=3D ~APP_CMD; =20 - if (sd_cmd_type[req.cmd] =3D=3D sd_ac - || sd_cmd_type[req.cmd] =3D=3D sd_adtc) { - rca =3D req.arg >> 16; - } - /* CMD23 (set block count) must be immediately followed by CMD18 or CM= D25 * if not, its effects are cancelled */ if (sd->multi_blk_cnt !=3D 0 && !(req.cmd =3D=3D 18 || req.cmd =3D=3D = 25)) { --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957388; cv=none; d=zohomail.com; s=zohoarc; b=jXwL/jkpQp7JUdE3z2qeQGlqJFNtFnmEIU8t6+UK8UKlQJPg2eaneSpi5uCzKIC0iqwJDhpb32TLcu35hSgm22S1cwhgd3CYwG44+Z2D+xxq6Rr4SNf7WjbDRylSVY4V62mfy1dGc+PJB27lFEwPUq4ezwqrwyUM5CNMspAaXhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957388; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BD5fgdTJlgw33/dLpV9SeOJ7ak0nlluyPy+d+qp00Qk=; b=KzNedGrmAPikuENgk7naYbXipd+bVVGqanhXloyADMNXqPT78IpRcZ6cYmKbVJ42X+S2AZmmIpxPl1+8w1EUw5HF8EQ5H0AmnLwEtjf3m8VvO9g8bn+ZB8YRSDbP4aCOyIgq10ZGFDJqu1NYNu2JuykPRaNhmFVmonyS0bIJ0rQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957388743192.085906893029; Fri, 21 Jun 2024 01:09:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJ0-0007xV-1x; Fri, 21 Jun 2024 04:07:34 -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 1sKZIx-0007rj-IY for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:31 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZIv-0008V2-Jz for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:31 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-354b722fe81so1221535f8f.3 for ; Fri, 21 Jun 2024 01:07:29 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a8c7c6esm966353f8f.103.2024.06.21.01.07.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957248; x=1719562048; 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=BD5fgdTJlgw33/dLpV9SeOJ7ak0nlluyPy+d+qp00Qk=; b=hM3GHUMJ9PdoqSZD++4sL3kv6mxU3qSv0iZiqa3INmwKsYMdCHvN/K6c7MvpIPVBDy vO9ZAAHpnPH9CcYlKCP8VUBv1sq7uKFyIr96PqMW50DOxLHcsM+RUVxUcAWGp0Sy5mdb K8Mm5omdnTwou4K3/s193qRye9mfh0pk5uq9Cidxi5yyYS1uunVdJnVyWpl4x1zzJsLg SRJc0TRuP/k1WQPxs3IKkYuRvsLJjkTO/EWEiQ7X1V5SwnJquAodYZH+ps1nBY9L0NOe xc40+OksW3OHR8oNQSwVu8e4w6qDL9VnN+OppJvGnM7q5U0aZr+byLCsAnxQCR64NnLM XiDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957248; x=1719562048; 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=BD5fgdTJlgw33/dLpV9SeOJ7ak0nlluyPy+d+qp00Qk=; b=kMEsyuizBOXW9OKZMcumpPR8RkMVNysStaW0usTuXZDSrI5Ijtcoe0efy9QOIoXgC3 sNdfWimCEwfdjNfwWF+3jU08nDPVAqNCRuSf++hxlouFh+gCmt/LnqtRmDzBDHTHcQyI yl15KaJ1zc1OVji1Y78SVOREcYZ1XZ9Ic8V7HRSrV4vB4qwY8AYS0hAJowRMDKn6xkv4 5YWqhRI7NABP3z8LY3FT3X6oe2egLevQE9F6pXgrz7DcvYHJRV1CQmf+l/6MSZQYnmPE 2HltKiReaTqiIxSn2GfdEeix5EUUcn4/1tjMoAf2eb5j3zWnTYlWZvoGGgAsXNrmgLRW aKOw== X-Gm-Message-State: AOJu0YxUDgo35+NrxzfoZYCM01tIwetryDY9hHAvHz1YYmdpIon0J0y3 YeW+CfLys3n6mwJSON2dpuP5pdlS5oaP+LlLFMmagmCxQ1IPLSlMN8TZqaze9RS1eDJXz4wwPQi a X-Google-Smtp-Source: AGHT+IGs1dUHmkoTFTraeGbYeE5Zge/cXEHuVGEngA0g1QEe1p9s5TZgeMuTVov03vxwy/TJtm0jaQ== X-Received: by 2002:adf:f04e:0:b0:35f:10cf:6068 with SMTP id ffacd0b85a97d-363178984bdmr5650663f8f.27.1718957247616; Fri, 21 Jun 2024 01:07:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 15/23] hw/sd/sdcard: Only call sd_req_get_rca() where RCA is used Date: Fri, 21 Jun 2024 10:05:46 +0200 Message-ID: <20240621080554.18986-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957390886100009 It will be useful later to assert only AC commands (Addressed point-to-point Commands, defined as the 'sd_ac' enum) extract the RCA value from the command argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bc47ae36bc..cb9d85bb11 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1102,7 +1102,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) =20 static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint16_t rca =3D sd_req_get_rca(sd, req); + uint16_t rca; uint64_t addr =3D (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : re= q.arg; =20 sd->last_cmd_name =3D sd_cmd_name(req.cmd); @@ -1160,6 +1160,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 7: /* CMD7: SELECT/DESELECT_CARD */ + rca =3D sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca !=3D rca) @@ -1214,6 +1215,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) return sd_r7; =20 case 9: /* CMD9: SEND_CSD */ + rca =3D sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca !=3D rca) @@ -1237,6 +1239,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 10: /* CMD10: SEND_CID */ + rca =3D sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca !=3D rca) @@ -1277,6 +1280,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 13: /* CMD13: SEND_STATUS */ + rca =3D sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (!sd_is_spi(sd) && sd->rca !=3D rca) { @@ -1291,6 +1295,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) break; =20 case 15: /* CMD15: GO_INACTIVE_STATE */ + rca =3D sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (sd->rca !=3D rca) @@ -1523,6 +1528,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) =20 /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ + rca =3D sd_req_get_rca(sd, req); switch (sd->state) { case sd_ready_state: case sd_identification_state: --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957283; cv=none; d=zohomail.com; s=zohoarc; b=DJ90IaYbZky4UwN+j9WI62lDNoS+01vfAcWBixPVmqosHBHPi0i1qBYOwwg9lzvpo/1Hxo6XIYK18gPk9F/3aLBMxp9z0qOsFQ6UfjdS0Gga6qdEwHTU7gA+ER/P/Ysdf+Zi0GtNKZQbMkfS+IWUMHQSuCYdJaRmOIEbQcBEj8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957283; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dkx6RwZS43D0XJ3kR94XAto+d+FvcMQ26elVXwwNzdM=; b=VMqYlKUg0VwpfFoiED3OLbNC+1k8heKqg7Teg/FAJh2HD0BsDsNZ6ApeEKlmSastr86+Ew8jCSbUeHDt8V9FPP8mMg2EE9wTelr5yxewHWjcolEhH8eIs2V04l70LnATkB3c4sSp1eUkV0WNTv16Ppcv2Tp16JqYyYu20yuVWxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957283808348.8011866510409; Fri, 21 Jun 2024 01:08:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJ5-0008DN-Oj; Fri, 21 Jun 2024 04:07:39 -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 1sKZJ4-0008CT-Di for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:38 -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 1sKZJ1-00005i-Ij for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:38 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so12979725e9.0 for ; Fri, 21 Jun 2024 01:07:35 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a2f6af9sm973358f8f.73.2024.06.21.01.07.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957254; x=1719562054; 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=Dkx6RwZS43D0XJ3kR94XAto+d+FvcMQ26elVXwwNzdM=; b=M9y7L6eo8u1SSzlwjG3bPeA80ItpwZFFacZjGqLha0GUja05FVW4aZv7MncCRa7GXe 6XB025H2HuH7MM33DAAgothUNaBbwpk1uFeW86A6fh4Gqkvcr7nKad4N6cT8FmpBK5he lf1Wa5AmkrulNE+BgusxD+fvKE7VluyncyhV2TISiOTnBV5J1URHlScQBSgoyTYzvjoY NZeAE2BwxxCtihivdWjAWTpFlgojF0dTwk0S39DUEFjqiYQdw6mQ04Z91HGIgr+SgnSa Eyug75Fn94kpVMIjS4jpbSfR84yCPPQ0xvFW+llylTsMVN5Y+Q52wHK7iQsN4jbKJf17 8BDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957254; x=1719562054; 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=Dkx6RwZS43D0XJ3kR94XAto+d+FvcMQ26elVXwwNzdM=; b=Cr4sxLZXlY2EnJZySbWABpYwYF49P9BDlrnHRZi83qEymp70QHmMqu3mu5yFmdRvxJ UvorEiAgoLN9hTbyN2aBebrRAqM7fzu746ktPXWKiMm/OnqNc1jHkQ7Cp2U3eNVS8fva A7GOTHJZChDt6wQTOKbX6t7i8/V98QHaSTjLIupVEQwaO4lt8lVKGfTgxBQk3m1QM3CO GJFU4nHhGKc9hgOVcS0bQI0+Sv64gAPazSi+HX9Xc1WlfUH4AjQOmQ6k/zhvHJnkUKS3 haDvn1ONQ4/ne7es59xbo4WB7E5M9zMbOPBuUo/wmYoCEY67EzUBqIw6Rau+v5pNlh8g 8pLg== X-Gm-Message-State: AOJu0YxI40vbUT3ejQrTSLIaRUmS9xiQQtAKxxjTLZ0FhKuq3Lxgbiqd +wIo1rru4J8fSbL/5JvMEvEfgFhn8UurGkbnpG6P/coFYgvmUr5AVwAdOdIEmWWJlMoiJJyjBrk W X-Google-Smtp-Source: AGHT+IFJQOMpC4zv82QEusGi/eTvPb05vUrvtRBhLpsRHM0N3kBIGIFITYvRVi/HjymsC6gz6bR7Kg== X-Received: by 2002:a05:6000:9:b0:360:6435:b40 with SMTP id ffacd0b85a97d-363171e23e3mr6249258f8f.7.1718957253950; Fri, 21 Jun 2024 01:07:33 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 16/23] hw/sd/sdcard: Factor sd_req_get_address() method out Date: Fri, 21 Jun 2024 10:05:47 +0200 Message-ID: <20240621080554.18986-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957284392100002 Extract sd_cmd_get_address() so we can re-use it in various SDProto handlers. Use CARD_CAPACITY and HWBLOCK_SHIFT definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index cb9d85bb11..a0193a46ea 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -579,6 +579,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *= response) stl_be_p(response, sd->vhs); } =20 +static uint64_t sd_req_get_address(SDState *sd, SDRequest req) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return (uint64_t) req.arg << HWBLOCK_SHIFT; + } + return req.arg; +} + static inline uint64_t sd_addr_to_wpnum(uint64_t addr) { return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); @@ -1103,7 +1111,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; - uint64_t addr =3D (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : re= q.arg; + uint64_t addr =3D sd_req_get_address(sd, req); =20 sd->last_cmd_name =3D sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957305; cv=none; d=zohomail.com; s=zohoarc; b=aaFqlWcuba3rBtceUnleQBVHpyHZTB+KVapHbL9Vt2/eQo8gkNEqM8W5+OybMnld7ulMrtrDFqdigqnMNgjTW2Ma1b449dITW2lN6m5/eRMmjBuu7Z+HCddmNVAfmk7EgIb8ZYB08npF/OorFlXl2tdgs4wMK9rAnU38ljew5Q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957305; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; b=QvAWZCBliIKYuuEkhSY2xSXqW9Yc95B0reES+kvexI4j5khCQJBhPYclCN+Ly1UGWmR3Uw6nNGIC4O5exusiHhxr0SSxdNTX0EjVNWItmgbYygHDkxZzHdnKADjmkDMbC1KF7ZlS03qhLpenqYDbwCFS9tb0H+KGJbbYZOlFXQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957305283135.17648066586491; Fri, 21 Jun 2024 01:08:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJB-0000Kw-N2; Fri, 21 Jun 2024 04:07: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 1sKZJ9-0008Vz-Pb for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:43 -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 1sKZJ8-00006Z-3L for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:43 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42172ab4b60so17211685e9.0 for ; Fri, 21 Jun 2024 01:07:41 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248482f1c4sm2254535e9.10.2024.06.21.01.07.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957260; x=1719562060; 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=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; b=uoNsCivAPtjTeqM24po4apHb2hxNWXhF4njNivfLACjkapEqJCzQoe1fhPazTKnV9W MA7IOJ9M/pOoy40bD/ERRxHcd+Qy2bfvXuBG8N5EWImmjxUd2yWd4g3i3zf+c89Og441 vzDC8H+U91L/p/vGjhJmr34fGsidSs50XeORG91QA4Mchz90SsBpTAW64qW0yKiIlrPs brqJ/Q5gK1TmTNcMKhNb5aSb7r9R9WqcwI+jmS0O2wwJYVonLC7c5xCIkCh55MCg2sq1 uU+dt3vM/5P6NC55pyigab/LF8EIMYkh0XDVgM+k2yJ2jhkGWrGwLpYr7r1dQ1+qtfg7 E9rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957260; x=1719562060; 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=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; b=t4fbXyeBtchMZa+4nTqA8SMAD6Db/bvMpsz36kWmtDejbyunbwM12gCtboHWzEx3nz i/l3eQO31yqqpGsohe+sUhLhOnxwmX6FPzWZZs/cjlDMYYIGqjqqjr/TzZEPyr6iOu25 lSn3vtvWgmkfmKNB4fuLIg8Kjqf8+asqMCM8QnFkRmrVL+Ql7yv9nwSkI4TOiMLWuGip hCfkXmq1k6uhxylYhIdsKNacnwYA87oPG6mAuq8oee+r2B9DniHRLsYF4PB2WC2NWtLj lOeLdGRinXLXJArcUIvTtPaDbtrZNG3baK37Yby3kJHPXNl6lNMa4vLxSGXzgpI5NavC 7F6Q== X-Gm-Message-State: AOJu0YwvjXouNqKODgMg787EjCYFiRx04bnxvcENX+/mP8am05rvJT34 KN+FWWlGykyEUWP8OQobyyG2jKrIUQ259eOKiKoMSfOIuotzbGwprRjXH/cfSW3lh8gPmQym0/C S X-Google-Smtp-Source: AGHT+IH31r+630bHuYtx5aBzBCMVZY8YoyyQJepeU1WQHAMxpevFgHrzUcOCAGM0QLWu5KI3hE3itQ== X-Received: by 2002:a05:600c:3b25:b0:422:7dc7:fc23 with SMTP id 5b1f17b1804b1-424752a5639mr51335615e9.41.1718957260063; Fri, 21 Jun 2024 01:07:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 17/23] hw/sd/sdcard: Only call sd_req_get_address() where address is used Date: Fri, 21 Jun 2024 10:05:48 +0200 Message-ID: <20240621080554.18986-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957306576100003 It will be useful later to assert only ADTC commands (Addressed point-to-point Data Transfer Commands, defined as the 'sd_adtc' enum) extract the address value from the command argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a0193a46ea..1df16ce6a2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1111,7 +1111,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; - uint64_t addr =3D sd_req_get_address(sd, req); + uint64_t addr; =20 sd->last_cmd_name =3D sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1237,7 +1237,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) } sd->state =3D sd_sendingdata_state; memcpy(sd->data, sd->csd, 16); - sd->data_start =3D addr; + sd->data_start =3D sd_req_get_address(sd, req); sd->data_offset =3D 0; return sd_r1; =20 @@ -1261,7 +1261,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) } sd->state =3D sd_sendingdata_state; memcpy(sd->data, sd->cid, 16); - sd->data_start =3D addr; + sd->data_start =3D sd_req_get_address(sd, req); sd->data_offset =3D 0; return sd_r1; =20 @@ -1337,6 +1337,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) =20 case 17: /* CMD17: READ_SINGLE_BLOCK */ case 18: /* CMD18: READ_MULTIPLE_BLOCK */ + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: =20 @@ -1357,6 +1358,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: =20 @@ -1415,7 +1417,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SET_WRITE_PROT", addr, 1)) { @@ -1437,7 +1439,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "CLR_WRITE_PROT", addr, 1)) { @@ -1459,7 +1461,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr =3D sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SEND_WRITE_PROT", --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957322; cv=none; d=zohomail.com; s=zohoarc; b=AY1d6voHp/2xVAwSsl0lDih8oY80IY+6NHunulQw3Wzq3Gk/xC6Si1eR2oRb3Flgi2mVKLRkj9V/ud7gyfxsjsB2Y7tzE3tW/vGUi2JOMwnfqNpOHbIPoxKng8UMlQ5Szo64R5BLIH7B419xKttFBIiTGsvRFKLXUtf+GpL4Mu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957322; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SZVdw7g4FFY2EyPpj/GEhmJmZqJuSFbYAj+AqUiDdB4=; b=Dk5f8OUI+jemE4cXRn+YbToREypuDmid+MqFL3nZXvLyEA9DxNsV066iUNtrneMCWj261Yl5s2K2njZG67ZZtWfHRrp27L/0BzZ7aHCWMinKtdfpusW6UCozFSW2twv7cj9iTGwgEpMMmwan5FUW/V3wYjPMPCMwiZUfjcIW/Os= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957322130172.7396270414854; Fri, 21 Jun 2024 01:08:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJH-0000r5-Sk; Fri, 21 Jun 2024 04:07: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 1sKZJF-0000iH-Ac for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:49 -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 1sKZJD-00007E-PP for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:49 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4218180a122so12903105e9.1 for ; Fri, 21 Jun 2024 01:07:47 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36638d9c158sm977420f8f.56.2024.06.21.01.07.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957266; x=1719562066; 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=SZVdw7g4FFY2EyPpj/GEhmJmZqJuSFbYAj+AqUiDdB4=; b=ThyGybpkX6USi5XO9h/o3RA9MADSAZd2ZkiNEQB3/if2BMuWtkRt/cz6oTf/7GDuvh idk2jRYd7J384BNqB6sEXJxdpopYCufPk0C8wLq7EXtDe1GvVXw/3H5jGljCGaGCo96x tj9fE2OA9ntLW/oiC2fTL5v5mV7tmoup2EGiCLYu7pVYMrlwo1CwQt45NwAeqT6WpvjT Nt7RDvCqm+k+p0L+EBXaNdhWalIq602mGkZ8q37JyfTwF5vbe4UODQHa1LCCXnMq+g2y YIQFLJ4Ji4xOa5ikWQSXWTauojChSKiRNNHW3E+DWgc0Zk5riLjoHV87As44ZtawWC+z 1xEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957266; x=1719562066; 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=SZVdw7g4FFY2EyPpj/GEhmJmZqJuSFbYAj+AqUiDdB4=; b=I0KEEQ5ZGykww3uG6Jze3p4F96toCjs49YTHCgCAI3W6PwwMXzwzocTT7OujYK7CL6 RjjCpeJH6n4Yd+QuMPd1N6+SrW64nK3oQ6R0TZ11Hap9z5Jg3Rl4QESaDJGjyDtoskFU JW9/idgOTkfX+HURlFWGgRuZLb6JLSPZlDApnL74T32isn5nBlkkeLLt77ev0HcLoIed UkgvcHgHiKewNXVEoumV5xUdNHyOK87sW9G9IrYJNygi5VAJQGIdGDLwE1H39NW9Y9wl YZX+fpqSfFf7sfF5eFbooLgZ/2qx6TAktQoIZANsf5VB/5/g/39HgihrRuuwQ5lc40MZ HJGg== X-Gm-Message-State: AOJu0YzxsqFttmPSGMKbDncuhXSLw2yb4d9boz4LjJD/GFiWmiWLasgP GYopGeoNhCK1+mMEvR9H1rpHXxds26TfHG1Cbo0+LlnMvyhRTkEMF2FEhZmAjfqG+ku6an7YOup z X-Google-Smtp-Source: AGHT+IHhVh1/7gwxlIA1WJjOQSjlj/YTHTc0qn/ahDv3YxqFUhtRDOs82oiAy2kjym8Z5BhM3g+MCA== X-Received: by 2002:adf:f6c5:0:b0:360:93d4:c4e0 with SMTP id ffacd0b85a97d-363171e1995mr6478167f8f.5.1718957265914; Fri, 21 Jun 2024 01:07:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 18/23] hw/sd/sdcard: Add sd_invalid_mode_for_cmd to report invalid mode switch Date: Fri, 21 Jun 2024 10:05:49 +0200 Message-ID: <20240621080554.18986-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957322636100011 Having the mode switch displayed help to track incomplete command implementations. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 75 +++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1df16ce6a2..8d63a39a54 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -180,6 +180,17 @@ static const char *sd_version_str(enum SDPhySpecificat= ionVersion version) return sdphy_version[version]; } =20 +static const char *sd_mode_name(enum SDCardModes mode) +{ + static const char *mode_name[] =3D { + [sd_inactive] =3D "inactive", + [sd_card_identification_mode] =3D "identification", + [sd_data_transfer_mode] =3D "transfer", + }; + assert(mode < ARRAY_SIZE(mode_name)); + return mode_name[mode]; +} + static const char *sd_state_name(enum SDCardStates state) { static const char *state_name[] =3D { @@ -1015,6 +1026,15 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDStat= e *sd, SDRequest req) return sd_illegal; } =20 +static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong mode: %s (spec %s= )\n", + sd_proto(sd)->name, req.cmd, sd_mode_name(sd->mode), + sd_version_str(sd->spec_version)); + + return sd_illegal; +} + static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Unknown CMD%i for spec %s\n", @@ -1154,18 +1174,14 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) break; =20 case 6: /* CMD6: SWITCH_FUNCTION */ - switch (sd->mode) { - case sd_data_transfer_mode: - sd_function_switch(sd, req.arg); - sd->state =3D sd_sendingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; - - default: - break; + if (sd->mode !=3D sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + sd_function_switch(sd, req.arg); + sd->state =3D sd_sendingdata_state; + sd->data_start =3D 0; + sd->data_offset =3D 0; + return sd_r1; =20 case 7: /* CMD7: SELECT/DESELECT_CARD */ rca =3D sd_req_get_rca(sd, req); @@ -1289,33 +1305,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) =20 case 13: /* CMD13: SEND_STATUS */ rca =3D sd_req_get_rca(sd, req); - switch (sd->mode) { - case sd_data_transfer_mode: - if (!sd_is_spi(sd) && sd->rca !=3D rca) { - return sd_r0; - } - - return sd_r1; - - default: - break; + if (sd->mode !=3D sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + if (!sd_is_spi(sd) && sd->rca !=3D rca) { + return sd_r0; + } + + return sd_r1; =20 case 15: /* CMD15: GO_INACTIVE_STATE */ - rca =3D sd_req_get_rca(sd, req); - switch (sd->mode) { - case sd_data_transfer_mode: - if (sd->rca !=3D rca) - return sd_r0; - - sd->state =3D sd_inactive_state; - return sd_r0; - - default: - break; + if (sd->mode !=3D sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + rca =3D sd_req_get_rca(sd, req); + if (sd->rca =3D=3D rca) { + sd->state =3D sd_inactive_state; + } + return sd_r0; =20 /* Block read commands (Class 2) */ case 16: /* CMD16: SET_BLOCKLEN */ --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957405; cv=none; d=zohomail.com; s=zohoarc; b=Z1ViCbe12uSXwToPn/RN1VzTD3dJolx64TAwmkjND/UuJUclw7i63t1sG16nd/I4gIb2L/J9w7aGU8ogffStV02VNmqRNxWrDt06MlKNUtVVJL28YkiFJBa25tSw0cd3EgrBgT1jYKUgjq+0sFjBwDIS/EVJyHp0lAEMQJdoNYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957405; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kNBeXm9P/Ml80/yN91/eWbfFz/hJLMpAuct+ZmQTshg=; b=hWwUCCqoJtSW2QR70gv+G6gu1RKxTvsE8aTsuSsX010AR05UuZMO0TmAQUGzWZ5KfbvY8lLGJ9mxEN8vxrBpiLBpgWOVOhC0VyELZBAtebZaANFEkpFB3EPdZdP50L4vKUVNjeBrqHui+POKwGb7llmLMOvFYhn1L5BSe+66tPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957405899766.833946355638; Fri, 21 Jun 2024 01:10:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJN-0001GA-Cx; Fri, 21 Jun 2024 04:07:57 -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 1sKZJL-00016W-46 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:55 -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 1sKZJJ-00007p-BS for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:07:54 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so12981345e9.0 for ; Fri, 21 Jun 2024 01:07:52 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191c65asm16698085e9.40.2024.06.21.01.07.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957271; x=1719562071; 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=kNBeXm9P/Ml80/yN91/eWbfFz/hJLMpAuct+ZmQTshg=; b=OrBh0QKF5202eZgpnj4VVSsUmsZ3Ac0YN/BkJjSwIJYWzJgUIOpL5B4JP7rvigrgw9 xubpYvPoJlCtDl2+D9qzhjSXRHvbteKr1sPYhNi70sFfVUsatTKtoO5ou5QoUSExy1E8 k803Zj8As0Q4yqwjomyBpRCGuHzxK9FYEanff+eXxjSqqFM0hPAH3UoAuZ9VcvfE+fzc Iy668CH6aFKPFvsWU/Zj2DWCABqwwY/yCCFpmTv0XTGYwJ1haYQ+WGQZZJZzrxPxuTip Y+BQ3LdBtx6knaWDdmVk9g1BAguYu63RvvH0BDRSZIW7kgIotiMnfAeG0ZaYQxCWjMyT CnNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957271; x=1719562071; 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=kNBeXm9P/Ml80/yN91/eWbfFz/hJLMpAuct+ZmQTshg=; b=a2VFm6O1lP7AQvoRFlmBvgNJxp+5rBNOddrBDXwSgumvOAG1LaNumiFhM8NWFJuTe1 Amg7bZ7x92Mk638RwxfWnIvx/uvwOtXIp4CEH4o7bnSvTzD4IUQvSj74vgjXEp5Yr2mR vQk/AOg1wFGOKZyGTVaw3oxH005wFKxPitpctOrVVJEoBeVufoEuv6SmlC5lB3HegC8q peW7wju0PmxPmzsgbzo0g5UeSe96tvjEnBFVS47KUuLrjujJMSsuW8mUjhnrnpbiBoNB dNy8HZeEqYyZK0y/yR4TES7umDY+BwPZsBXx4/qzxaXioXU7I/84evvowzWgUVeEay0k fnFg== X-Gm-Message-State: AOJu0YxYiQ8FZj63rpxTWakNzI1QDgnyK+cTJHMWnuEiMpdbVtbDcgpI b0v4z93r6Wx2bbC3PkkkHv4AkqyHYfJ6aWk+Obl3HiVpxmRX7rfk8o5QZ0blMmUbMKWWRdeZ8T2 5 X-Google-Smtp-Source: AGHT+IEqdyrdTUH8xzFAJeTGgMv41+cTdI7kRLqldWZsa0rWZmaGFn7XEb+ExxJeN1QhIbDeIIQiuw== X-Received: by 2002:a05:600c:2d93:b0:421:182d:9232 with SMTP id 5b1f17b1804b1-42475185a23mr56228875e9.18.1718957271702; Fri, 21 Jun 2024 01:07:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org Subject: [PATCH 19/23] hw/sd/sdcard: Inline BLK_READ_BLOCK / BLK_WRITE_BLOCK macros Date: Fri, 21 Jun 2024 10:05:50 +0200 Message-ID: <20240621080554.18986-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957406909100003 These macros only save 3 chars and make the code harder to maintain, simply remove them. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8d63a39a54..ca2c903c5b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -816,8 +816,6 @@ static void sd_blk_write(SDState *sd, uint64_t addr, ui= nt32_t len) } } =20 -#define BLK_READ_BLOCK(a, len) sd_blk_read(sd, a, len) -#define BLK_WRITE_BLOCK(a, len) sd_blk_write(sd, a, len) #define APP_READ_BLOCK(a, len) memset(sd->data, 0xec, len) #define APP_WRITE_BLOCK(a, len) =20 @@ -869,7 +867,7 @@ static void sd_erase(SDState *sd) continue; } } - BLK_WRITE_BLOCK(erase_addr, erase_len); + sd_blk_write(sd, erase_addr, erase_len); } } =20 @@ -1901,7 +1899,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->data_offset >=3D sd->blk_len) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; - BLK_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd_blk_write(sd, sd->data_start, sd->data_offset); sd->blk_written ++; sd->csd[14] |=3D 0x40; /* Bzzzzzzztt .... Operation complete. */ @@ -1927,7 +1925,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->data_offset >=3D sd->blk_len) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; - BLK_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd_blk_read(sd, sd->data_start, sd->data_offset); sd->blk_written++; sd->data_start +=3D sd->blk_len; sd->data_offset =3D 0; @@ -2075,8 +2073,9 @@ uint8_t sd_read_byte(SDState *sd) break; =20 case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset =3D=3D 0) - BLK_READ_BLOCK(sd->data_start, io_len); + if (sd->data_offset =3D=3D 0) { + sd_blk_read(sd, sd->data_start, io_len); + } ret =3D sd->data[sd->data_offset ++]; =20 if (sd->data_offset >=3D io_len) @@ -2089,7 +2088,7 @@ uint8_t sd_read_byte(SDState *sd) sd->data_start, io_len)) { return 0x00; } - BLK_READ_BLOCK(sd->data_start, io_len); + sd_blk_read(sd, sd->data_start, io_len); } ret =3D sd->data[sd->data_offset ++]; =20 --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957318; cv=none; d=zohomail.com; s=zohoarc; b=X0LG95WGMs7Ob/1KhjVon4OL+wjblWnJEm+/oA7EfSSt+IzFf4Q7MOVMIwsa90wumoLVHubBe/aSkDkbKeUyvTd+mGMVu0O5cHHb5e8u4cg3pqRfJvKY26O2qhAw9dkIqh/NRAiy9XxDI+JlLXGUgki9b5fPRGX80xPOIpE1Na4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957318; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h8Diio2eGtW+VRAl1Her+CVl5IxHLJh1wYmmEzpfRJ8=; b=HkfFM26+YquLsmi/zuyodwtEmllOu5GOABbEJE+I7sxVRpnw9X9wgKFL5weAwyGXRWJS9eMcGdgvU2GVgm6/96GRae4xL55Di5zxR/ihT9A/FHiQnMCB1BSj6yrbvBQfTJoX9Ib6d7rIUxJHnA92fMmgTmnnJsG7RQK5tESS3Ww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957318676182.11177786536462; Fri, 21 Jun 2024 01:08:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJS-0001b2-4d; Fri, 21 Jun 2024 04:08:02 -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 1sKZJQ-0001Vf-Ra for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:00 -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 1sKZJP-00008I-AZ for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:00 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42189d3c7efso20039705e9.2 for ; Fri, 21 Jun 2024 01:07:58 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d21264fsm54273835e9.44.2024.06.21.01.07.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957277; x=1719562077; 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=h8Diio2eGtW+VRAl1Her+CVl5IxHLJh1wYmmEzpfRJ8=; b=Iw73BHqqr3CHBjFySjYhwQKNHbBVkuoBgFzUPNwDoTmg4L7MTmn+jr0hhoOEzYaOst vk+lrrvRCu0yFzlqQiMUFvKMFuEIbHl8iItQ+evk9+HqyeofE5hZoNFdNzY3puu/54OP mPOld4QDWfZOwY+ORuWai9Xarfr7H/20d4ssH3lMgTnOku7qIrUpFKROOZhNjl2LYceN zkIOYDHlnZ9qfYZlYcTQ7V9RI7u5EQkSlHl8EooUezLNgmcJ0ZZSphI7ri99jd46+fTX mEsagSwgoY5Ug4IHG5rTsLu8nbBHOwDk2/GMtjJzIoYSj74FeJ1Ws/Vf8hjMNXA+qJzj y5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957277; x=1719562077; 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=h8Diio2eGtW+VRAl1Her+CVl5IxHLJh1wYmmEzpfRJ8=; b=Z49toVBGlRIY+YWc64iH7+51tadGahjdBXMk+UQCntkqpOs7kLGbdTYiuceHlywu/R If+9X5iTwnSfLROWliceUUd1Bv63Ai90OwoKeGb6c0CjVMKbMdiEU7CYZSO/zPAjkZNC ekiUibzCmK+iQfNloGc9FOXR3e/EZaAgGi4B1IEp4tPhwxnT9sfgSgiXbN6O3111N3SQ O4DNDMu+6mnVpj6nLbCzfsh2tCUfYigowSLNl8Cnny+IJEg6mzsf8f+XLKSzwFjegcEu OKbHmHr8Y/Bce4T4eKdEkJ0hpXqAFtxlAibUc6GgFeUPRP5Yi13Mnv6a7/ZU9GQ2m8b+ BFRA== X-Gm-Message-State: AOJu0YxfTQzNtKJc4ZSSP1RKQHBPhp/EX08Pde/S2zMbuLK9ZeGYO1et hygGT7dxpQaQO3LQ5mnBCjCzEcdsEwIbZ99VWUMlRpBf9o0satAhz4jBG4HCZAXtOdiwgbs6lEu 4 X-Google-Smtp-Source: AGHT+IEGY/sOffNAlm0L6hs1HCXOupAQBozXZQvWcSSu1BvrD+/CmgdZLG0doOIOn5ib8WTG/fYKSQ== X-Received: by 2002:a05:600c:4244:b0:421:f43d:dadd with SMTP id 5b1f17b1804b1-4247529bce6mr76484775e9.33.1718957277672; Fri, 21 Jun 2024 01:07:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 20/23] hw/sd/sdcard: Add comments around registers and commands Date: Fri, 21 Jun 2024 10:05:51 +0200 Message-ID: <20240621080554.18986-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957320694100006 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ca2c903c5b..95e23abd30 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -317,6 +317,8 @@ static uint8_t sd_crc7(const void *message, size_t widt= h) return shift_reg; } =20 +/* Operation Conditions register */ + #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ =20 FIELD(OCR, VDD_VOLTAGE_WINDOW, 0, 24) @@ -366,6 +368,8 @@ static void sd_set_ocr(SDState *sd) } } =20 +/* SD Configuration register */ + static void sd_set_scr(SDState *sd) { sd->scr[0] =3D 0 << 4; /* SCR structure version 1.0 */ @@ -388,6 +392,8 @@ static void sd_set_scr(SDState *sd) sd->scr[7] =3D 0x00; } =20 +/* Card IDentification register */ + #define MID 0xaa #define OID "XY" #define PNM "QEMU!" @@ -413,6 +419,8 @@ static void sd_set_cid(SDState *sd) sd->cid[15] =3D (sd_crc7(sd->cid, 15) << 1) | 1; } =20 +/* Card-Specific Data register */ + #define HWBLOCK_SHIFT 9 /* 512 bytes */ #define SECTOR_SHIFT 5 /* 16 kilobytes */ #define WPGROUP_SHIFT 7 /* 2 megs */ @@ -482,6 +490,8 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[15] =3D (sd_crc7(sd->csd, 15) << 1) | 1; } =20 +/* Relative Card Address register */ + static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { if (sd_cmd_type[req.cmd] =3D=3D sd_ac || sd_cmd_type[req.cmd] =3D=3D s= d_adtc) { @@ -490,6 +500,8 @@ static uint16_t sd_req_get_rca(SDState *s, SDRequest re= q) return 0; } =20 +/* Card Status register */ + FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) @@ -620,6 +632,8 @@ static void sd_reset(DeviceState *dev) sect =3D sd_addr_to_wpnum(size) + 1; =20 sd->state =3D sd_idle_state; + + /* card registers */ sd->rca =3D 0x0000; sd->size =3D size; sd_set_ocr(sd); @@ -1052,6 +1066,7 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd= , SDRequest req) return sd_illegal; } =20 +/* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { if (sd->state !=3D sd_inactive_state) { @@ -1062,6 +1077,7 @@ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd= , SDRequest req) return sd_is_spi(sd) ? sd_r1 : sd_r0; } =20 +/* CMD1 */ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) { sd->state =3D sd_transfer_state; @@ -1069,6 +1085,7 @@ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd= , SDRequest req) return sd_r1; } =20 +/* CMD2 */ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { switch (sd->state) { @@ -1080,6 +1097,7 @@ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd,= SDRequest req) } } =20 +/* CMD3 */ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) { switch (sd->state) { @@ -1094,6 +1112,7 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDStat= e *sd, SDRequest req) } } =20 +/* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { @@ -1110,6 +1129,7 @@ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState= *sd, SDRequest req) return sd_r1; } =20 +/* CMD23 */ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957418; cv=none; d=zohomail.com; s=zohoarc; b=jbd4mDWSX+7ioAYBPejkyMjgQGZuKIeCaOuBomI10+Wr0FSrR2Ktv6OsUKEX1mUnuKGtioRrXXG057AZ2cxNnCVLxUSsHCimsy6wvXaEVOHIGZSf2A/LGZDd49QPP3lLLmN+KD/If8ZFufcbxkg5HPIUizpxiG1pLosHeTIy2So= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957418; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qHkD/9LfuqpSjqb2mzBbMf8GF2z2q7mW//xxpk6LGc4=; b=eJsqnQn1yjWdmI72XpKRNlyRXz07wFI95eouyW37fjhcls6yRssy0NcAfx9EqqZ0wA6x0wO6/OAJi/Zc8dNOEH2AsY6VGW1vpqlGCGo2XTnwsKBKwJ/X/e+rbW6QvTYazB9Y2CVrf8Rv5DACh5RvXS3crnX/yIgbndAGMGFOER4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957418783469.91393218829126; Fri, 21 Jun 2024 01:10:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJZ-0002HZ-0D; Fri, 21 Jun 2024 04:08:09 -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 1sKZJW-00026A-TY for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:06 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZJV-00008x-91 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:06 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42198492353so15656125e9.1 for ; Fri, 21 Jun 2024 01:08:04 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248482f1c4sm2264205e9.10.2024.06.21.01.08.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957283; x=1719562083; 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=qHkD/9LfuqpSjqb2mzBbMf8GF2z2q7mW//xxpk6LGc4=; b=nEOrne24IypY8qe9EB8u2LxFPLrRTv3lnOPw3oqicn1HEKtMFhpInduKz19c1z9tLL aAE6vTUyAyxiSAK8oTWT+Fjcz1YUEB/QZKwdS8ZcR1KeYa7mt9FP/6byFp9o6OluNXJS JUH4PwKceDLDPUlGhasBEYmbkjN4FPeVLi9b3Gi6MuLbmVzqMB43kbRiG1uDPitAzwE8 hipZjbdwbrLt6MAevT+5ZfZDZ53xX2efFOE0YMkvdb491i5Q9Qktkm4Uwl2hm5Mi4kNz AUkwd5OQkkYLfCVfiQLuiH5g/pqIxF2/k6bNJXN6zMjJ4HMU6qkLxQn3vt+vqsOaL/sD qfBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957283; x=1719562083; 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=qHkD/9LfuqpSjqb2mzBbMf8GF2z2q7mW//xxpk6LGc4=; b=gjVP/vdoAXN99rhIPz3sCrMFu+Pon9iSPt+8pjF5Zg8hKdGPz8+XUzPLbRlVRSdeKI aIh92Z7z4BrAfRrL3E9iMZIlqZERM+mW1v/wNuUEtnZubQe2ojlMb9UhUUTxKKKiXPKA ZNGAqGFKP4jYs2hmGYIH4iq5fpC9/RdD1Sm7VC0mPbHuwd0+6FnT4Ux3ZgUHAsG3Y1an oCWOZ7m1y2dLnM2wEp5JNJybfa6Xo6stRx1/D25teoJFURqi5/5BUxW0YJhoh0oy8knq NHfS3HAsBVsKWMPy3+XpSeqEcci/XZQS9inwFg60uSEpFoyH5bR4wxNJWRjsBaeg2b2q WFBQ== X-Gm-Message-State: AOJu0YwGKdqR9wEMAMazdskHccb0G046GoQKlkHt0mLKzQnG3naELEqc jE2OxoX7vQWG5FBgAbZinhJhhnzV7TymNkQrqz+dciYdc2ZHMWM202zj3shVRGboHUTkwFbZDoY P X-Google-Smtp-Source: AGHT+IE+07FWD1HD+iLXztwcy908d7cHYMN3e4/OV1PssO4as9rMtk5a2We2Haoa+wkRzyMpCyN3OA== X-Received: by 2002:a05:600c:2e09:b0:421:79c8:dd37 with SMTP id 5b1f17b1804b1-4247529d570mr50153715e9.40.1718957283661; Fri, 21 Jun 2024 01:08:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, Peter Xu , Fabiano Rosas Subject: [PATCH 21/23] hw/sd/sdcard: Do not store vendor data on block drive (CMD56) Date: Fri, 21 Jun 2024 10:05:52 +0200 Message-ID: <20240621080554.18986-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957420966100003 "General command" (GEN_CMD, CMD56) is described as: GEN_CMD is the same as the single block read or write commands (CMD24 or CMD17). The difference is that [...] the data block is not a memory payload data but has a vendor specific format and meaning. Thus this block must not be stored overwriting data block on underlying storage drive. Keep it in a dedicated 'vendor_data[]' array. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: C=C3=A9dric Le Goater --- RFC: Is it safe to reuse VMSTATE_UNUSED_V() (which happens to be the same size)? Cc: Peter Xu Cc: Fabiano Rosas --- hw/sd/sd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 95e23abd30..712fbc0926 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -143,6 +143,8 @@ struct SDState { uint64_t data_start; uint32_t data_offset; uint8_t data[512]; + uint8_t vendor_data[512]; + qemu_irq readonly_cb; qemu_irq inserted_cb; QEMUTimer *ocr_power_timer; @@ -647,6 +649,7 @@ static void sd_reset(DeviceState *dev) sd->wp_switch =3D sd->blk ? !blk_is_writable(sd->blk) : false; sd->wp_group_bits =3D sect; sd->wp_group_bmap =3D bitmap_new(sd->wp_group_bits); + memset(sd->vendor_data, 0xec, sizeof(sd->vendor_data)); memset(sd->function_group, 0, sizeof(sd->function_group)); sd->erase_start =3D INVALID_ADDRESS; sd->erase_end =3D INVALID_ADDRESS; @@ -762,7 +765,7 @@ static const VMStateDescription sd_vmstate =3D { VMSTATE_UINT64(data_start, SDState), VMSTATE_UINT32(data_offset, SDState), VMSTATE_UINT8_ARRAY(data, SDState, 512), - VMSTATE_UNUSED_V(1, 512), + VMSTATE_UINT8_ARRAY(vendor_data, SDState, 512), VMSTATE_BOOL(enable, SDState), VMSTATE_END_OF_LIST() }, @@ -2019,9 +2022,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; =20 case 56: /* CMD56: GEN_CMD */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sd->blk_len) { - APP_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd->vendor_data[sd->data_offset ++] =3D value; + if (sd->data_offset >=3D sizeof(sd->vendor_data)) { sd->state =3D sd_transfer_state; } break; @@ -2155,12 +2157,11 @@ uint8_t sd_read_byte(SDState *sd) break; =20 case 56: /* CMD56: GEN_CMD */ - if (sd->data_offset =3D=3D 0) - APP_READ_BLOCK(sd->data_start, sd->blk_len); - ret =3D sd->data[sd->data_offset ++]; + ret =3D sd->vendor_data[sd->data_offset ++]; =20 - if (sd->data_offset >=3D sd->blk_len) + if (sd->data_offset >=3D sizeof(sd->vendor_data)) { sd->state =3D sd_transfer_state; + } break; =20 default: --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957319; cv=none; d=zohomail.com; s=zohoarc; b=PUbgIodWi9OGIwCsrOcr4G4Co2FY51jxkaMzzH10sRS0SuukXgz3JwSxWwT6CYIpep+WNIMPztOOZRBAc33ywodpaP5pYxxLPeNGi38l7ht46ZbRs+b7iHqO5y3cqf5YK2b+AG6A48j0Y6L1Mob7ptupSJm+G7LKnMi2PdV9B/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957319; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pelbEr2AzQbex87Y1dyscTbX85voHzWIx5qB/yXa5yg=; b=QdfjLu9cvJKOVGI35RXU1GhaR9+b1EdSFu3/99fv9wUWEpnpXdDFim9/QVyWlLApiadoT+ZaFh6zdZUjPupqb+FLKGZGF3b8p4Ehau/tmN1WGEd/PvDXB2VuB6ygMSFdzlL8mCTjgOtxEt0L9k1h/oOIiI3L2PdyA9ocGCoEcno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171895731961748.93495843985181; Fri, 21 Jun 2024 01:08:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJg-0002fa-L7; Fri, 21 Jun 2024 04:08:16 -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 1sKZJc-0002Uj-I8 for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:12 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZJb-0000Dt-3y for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:12 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so12982905e9.0 for ; Fri, 21 Jun 2024 01:08:10 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191c65asm16705925e9.40.2024.06.21.01.08.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957289; x=1719562089; 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=pelbEr2AzQbex87Y1dyscTbX85voHzWIx5qB/yXa5yg=; b=HoI9SVXLrXqy/wsEWAsCjfeEi8Mm6jg7UtizbH1gFOElN05aQadxmeP9MohJQ4tmUi 2k6XyHYoM6jroj1aUmL1E65aDp/4kGKTAO6IRKTGbFddY93DSu4FF3JwlM8TeExU18EC RQpT/EcwlISDbyhkOUC7FOH/R67K0sxDj8S/qgYkzsKNwXVmr2xDJHNTgyCEUkw9CAHe /rDOoxGsFKTHGBDy4FvODt1RKj0hVf0cCORK+59EB9LcqkYe+4sK89mdUKYnoz/sCd1X AfKlqmG5jTO3pI8HQ6T09O9pJQcpmC1kecCMVSaVrM4EpSfbTBvvcM4nU7nsRiROHMkT QI6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957289; x=1719562089; 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=pelbEr2AzQbex87Y1dyscTbX85voHzWIx5qB/yXa5yg=; b=WK62jEG5qVW3sgv+paGoQoQGBWyJbcuNdnCMZx24kKY0Xf8E5dMyOhQsB7iLvEbmTU z9skXTFTVk92kAMqX/iS7Je61LFN05pfoSOUjD6qX+38u88XhneatnTr7V6PIKr2PCt6 BT4RrP4MJl1UMNSehm0Cu+Ge3u6d6X76MG8+nBu2S//7kZjWzyDSL1BENEGZE6X38I/x jpbndMZNMVqMO9I0AosV8DVLFv+CvNpIF+QUnmYn9R4jZjfdi18s8WJDPfSPfLtVesfW r1TI3EPUJSuRDvuus9Fj1YKD8edufCSAMPEuh8SdFauuDbI29BswTpkDBoUyUHWsGfJh erMw== X-Gm-Message-State: AOJu0Ywi3h/xGTwUqLDblrZR9Nv8g5W8n3Jc4xiq+/uWsP6E2Fs1xEVd Z2HbxZnpfaN4gBEp79qA8XD5fXcsji3W9kLLFmBpEmlh5IN0VGT9a/KemOd+NakYiRgmB4Ygos0 s X-Google-Smtp-Source: AGHT+IE9NLCoFogMKxc41GruYUxJ/LnariP6TkJrVPG/jMTYiOqYH3UqAB2Qb2WyuhEtZ1ims+LMBw== X-Received: by 2002:a05:600c:2e07:b0:421:ec3b:b7f0 with SMTP id 5b1f17b1804b1-424751854f8mr58514115e9.17.1718957289523; Fri, 21 Jun 2024 01:08:09 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, Peter Maydell Subject: [PATCH 22/23] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30) Date: Fri, 21 Jun 2024 10:05:53 +0200 Message-ID: <20240621080554.18986-23-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957320669100005 Per sections 3.6.1 (SD Bus Protocol) and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: C=C3=A9dric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 712fbc0926..601a6908aa 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1498,7 +1498,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) } =20 sd->state =3D sd_sendingdata_state; - *(uint32_t *) sd->data =3D sd_wpbits(sd, req.arg); + stl_be_p(sd->data, sd_wpbits(sd, req.arg)); sd->data_start =3D addr; sd->data_offset =3D 0; return sd_r1; --=20 2.41.0 From nobody Mon Nov 25 01:28:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718957387; cv=none; d=zohomail.com; s=zohoarc; b=XhYGw9hWxhonrc6JLvWADAGLvV460yz1TDEqQDPA/meZeXmF/2NPeoG99x/Ek4UpJv60NbmrBh9WoVOAeLy1mxOEorsrvX7WjKFib9jYjg3dwbYe+QXRu1DW4+mwpru8ngfmaeXSmI+ZqqMGISDd8tepR+rudYVb/f/2WTtX2CQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718957387; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hrM3efyRCu1QkbrTwevnMmKic+tLELy+xxKVC8SkWoM=; b=UfD8wP23ockgAs3xJIChJsuD2kRc62NrhvAlixJoANrMscjOhqd9LNbpWnRcqRZiVwwV+Kd8FGgdkK+LaQfaX8nJc9Wl8zntf9ab4pV1IFI87kgHE3Ql/dq6sx5F1f+CvyXmOxVd/z76DnjyxbK+Gh0cBu+tne9rUsHAaQEAkmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718957386991291.60311822504514; Fri, 21 Jun 2024 01:09:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZJk-00038f-3B; Fri, 21 Jun 2024 04:08:20 -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 1sKZJi-00030v-VJ for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:19 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZJh-0000G0-An for qemu-devel@nongnu.org; Fri, 21 Jun 2024 04:08:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-361b376236fso1360213f8f.3 for ; Fri, 21 Jun 2024 01:08:16 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36638d9bd0fsm974292f8f.52.2024.06.21.01.08.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 01:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718957295; x=1719562095; 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=hrM3efyRCu1QkbrTwevnMmKic+tLELy+xxKVC8SkWoM=; b=AUgC+bQW7p3JbY6N072B346iISSL8atQfujr3DFDIvIdghVX0q8ncbvT0W0YxZz8Hs KNK/TfHLDxNb/yxHgyovUnmw9+B1eNEFbHoCSAR8kQEkUtvH86V4QzRMJiUV3foyNX8l La9ozZqQ5noS0PdgSkMJMMNc0bfaT6BgzmW7RZZcdvdZbbk42a7aweKgyWosT9uQNFGn h3PhrnFCr4v3YZyZO+rFaNHxpWLZSqCag0zouCd/83FHuvL4vwfcI44bk4PIGTQ1OIg0 hffD5sVOKlzfIYrnSbEygWhagctgwCBKxwTONLOGXIYLSSPonZKZ6CnTnL4a7S9phyYv tEmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718957295; x=1719562095; 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=hrM3efyRCu1QkbrTwevnMmKic+tLELy+xxKVC8SkWoM=; b=EayiECJ5UoehaJJ0p2U5Ft6Iy+vsl6me1nd3PXrKhNSVRZBo7KPw/9ZWsYxzYACb5m 4q5wyU6psdVAgTU6WVtJk/qw1V2yeRzsIq8OGy5O2vnCWYXyjx976A0Mb1DG/imzKvWg ES9wroB7EFumUb30+DwHrj+djp0U6c+7545ibefRSxY9RPXOZxxonE76wG/a111x5Q06 6QBpV7qRs+nDpVJAgnQWEHia1JoSc+NO2ZOO5JQ6fniPXSLKkYscNqij1SyA86QCG2Lm zXiJgWFbbLOAvGhjEKo/UFKwmuGU48+7R/HtdjUhFVIY+lKRtkqx21uwr0N0JsIgHng0 c2NA== X-Gm-Message-State: AOJu0YwrCbisWQHzT+hesIuKmBTVs+CtLRPwVEFQ/HHxlAzVQlvB2mtc hPuYsxJ3nqh60t++weips94wjfO3CrAqhSNA7cALenUlrzshXZzimGWP37Uw6Hjny4BOap3PuRR A X-Google-Smtp-Source: AGHT+IEcHYEoyqhybdTGHtCZvNI0/lSR1E3tQrPwQw8kmuEc56BKpn3N+cApRVJk/2a++N7ZqvQ1Wg== X-Received: by 2002:adf:f24a:0:b0:35f:10a0:9b7 with SMTP id ffacd0b85a97d-363195b2213mr5220400f8f.46.1718957295460; Fri, 21 Jun 2024 01:08:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, Peter Maydell Subject: [PATCH 23/23] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Fri, 21 Jun 2024 10:05:54 +0200 Message-ID: <20240621080554.18986-24-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240621080554.18986-1-philmd@linaro.org> References: <20240621080554.18986-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718957388881100005 Per sections 3.6.1 (SD Bus Protocol), 4.3.4 "Data Write" and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: C=C3=A9dric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 601a6908aa..5d572ad13c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1659,8 +1659,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - *(uint32_t *) sd->data =3D sd->blk_written; - + stl_be_p(sd->data, sd->blk_written); sd->state =3D sd_sendingdata_state; sd->data_start =3D 0; sd->data_offset =3D 0; --=20 2.41.0