From patchwork Fri Jun 21 08:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806335 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654212wrt; Fri, 21 Jun 2024 01:09:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWzuduKREZFQnbbkl60EwY5trpwAp6x4/eLpeuCLgccPU9wYnvTc0LCkD31B+Ng/QHtaaklkCiqewnr7Uga2xp X-Google-Smtp-Source: AGHT+IEg4R7LvKbdtMOvNEh4hDLGr/LdcltQU4UwvXV23OkLaEzsp2/phO22+gHVxutLLW9QV7lv X-Received: by 2002:a0d:e649:0:b0:631:4dc:f6e5 with SMTP id 00721157ae682-63a8f523ba5mr83261007b3.36.1718957359615; Fri, 21 Jun 2024 01:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957359; cv=none; d=google.com; s=arc-20160816; b=tcjko6JSAHcGd/7/do9QjW+ej7fh4GiCbu4qdZoX9Vpz8PgX4NUWxne3soKYiOp+3p UtV0mUMZiLApxp2SurTyqV7wx21DEzGmVc2t21HNCoaRpQ8oaBYqp9+rNnSfhn3TB/RR vsw6ZAzeEJi8Nm2TfaaaJTLcSZ8Uxo8pByFsvX3hY5AlGiV8uIiWkDYr8e/8tINV8e2z 9UPWm5m4j9MEAe8hXTm5F/xz1/dWtgHLAN/wmlImb26i9HTDbN/P7A7ilghprWVaqr0/ kDne9EbvI1kcFSjvoM2bcMg6mpplCH218xMfXg0im781rSNJ5UAFeQRqnb7KrJ9FgRGu j7fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4c/usVrkl8YKkr8RnXE4rYu6P4lZW+FXlANdR7STD3A=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=l2rzseQyGy0CsDt7lclIZzwO7Qb/WQhhUbzhL8LBFcb/Pok6Tx6hWIukTaBtuktGrV fI4dvcEGcODuYCIlPeO0+/r7wa3xOJTTz/gg3mhbpbeZg5WTD1SFb7gZy93dz2uY5jqu /5ZURgEyhrbZ6QEB2Pr8lOHA8tlhj3pf1ykXED1ZKIKLNkH+L8piSuzGiQcdq7BddYDd 8S7AKM+Uz6GHyQJk91Q7ozwp2VhwqDMtEI6EZvGpnRJYR9bGfBlzdrkapC/0JwuTFy+C jU4hZun3BJq552p1IDq3zz6C001/vtYfF+XmAg1XlELNvAut1q1CZ135vT9iaM6sHJYO 7Kmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZuS2Tuxp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ef64ca3si10107326d6.592.2024.06.21.01.09.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:09:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZuS2Tuxp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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(SDState *sd, SDRequest req) 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); + } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } - sd->state = sd_sendingdata_state; - sd->data_offset = 0; + sd->state = sd_sendingdata_state; + sd->data_offset = 0; - return sd_r1; + return sd_r1; } 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); + } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } - sd->multi_blk_cnt = req.arg; + sd->multi_blk_cnt = req.arg; - return sd_r1; + return sd_r1; } static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) From patchwork Fri Jun 21 08:05:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806322 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653504wrt; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXV5G8i7BUhxMELWSh+mNu3CBWUfImV50h+wNoDV7Ntl5ifwsR7ewKMAQK/P8rsIdT0euAQvqeBAgIWEduq/639 X-Google-Smtp-Source: AGHT+IG6Z4S0a6S7Z75IZTK76vr6Gbsv8VjSJtZZeu4nMm9/hlQTLtSTADZpPFBKBJITALsOEoYB X-Received: by 2002:ad4:598e:0:b0:6b0:87cd:fdd6 with SMTP id 6a1803df08f44-6b501eb21c5mr72148706d6.55.1718957227523; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=google.com; s=arc-20160816; b=kMga/WaQ9lxW7X2s0eIvXpqLAwR7nGKk0WJcoM0KZ5UJjik8vKseB2o2BxVAG8gojk B4xf2uQzrvJEH/0qC8gM8drnoo+Msc3N4TcAEOuAsvcyH6ACkE4FDqgGARMM7MmMHJ6W cRJ56EgTyRhBXj5LykQHfRuGxnqPQI2aBow1axoO75Z8N2ktTIhacDepKIairJXMi5Mq rCPWu2nm/upOXk4wOtNPEQg/P/29nb2gdu3NqjU6Bl6kyHuJAXry1Vr97cXSDwDrn263 ffR2Z4Q/NVw4+rj9lKFM5TzNNO0WOA+AegiGe3W9HgLAVYseHUX1gZVwVhd+4UqrN8+e NR2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P0JRQjH2+2iHubv4pv2oDVEMyEJlpvL6A+oovFUXEtM=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=eoJgycePGC0QzZGKdxiLfQ4YPi7A7YiTqHKSD55pbA6JboWm3ou8GJsUla7HyqxVFg H1dopU5iRcKKTDRPOp93whmNxf3RYnG+gNq3gRBqjbgHkTZBz4kQRBBb2pH8QMqEZlrX UyEF6fOgn+jsQ8MaU8NNyhsQ41OkmP8vbKJERy/kEoZ+VLd9xw1Ff3SD7GM23qn3dmCT lSWpbMyRlPRT+mUSjdMgT42gGfYFzDDMt+PjXIxSQmVHpXkI+fMaiR2pf8TOU74bYr7D bIlc6vgY9ng8mNC2BtiPyyuIwCmiUhOZHK75yNfkK3xjJS7/pFMdpi9FrJ2/uJvQSOzl eRlA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m1fP/5+p"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ef16bccsi10334356d6.429.2024.06.21.01.07.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m1fP/5+p"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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) static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { - if (sd->state != sd_ready_state) { + switch (sd->state) { + case sd_ready_state: + sd->state = sd_identification_state; + return sd_r2_i; + default: return sd_invalid_state_for_cmd(sd, req); } - - sd->state = sd_identification_state; - - return sd_r2_i; } static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) From patchwork Fri Jun 21 08:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806319 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653486wrt; Fri, 21 Jun 2024 01:07:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTUmLBPFlg81PTq3WZ4YZmJp65Qq4RipD0Z3bOA64Mwl1UmNvbzLYab3RoAA4qjxuy4k8DEZrC7XcGZio+LgNs X-Google-Smtp-Source: AGHT+IEJNOD9YmEGJlSigP2E+m8saVVbHpRDXtG6uuQ0H/h+eUDnlw+F2xyr9ndrHjkm3pZAAZgg X-Received: by 2002:ac8:5902:0:b0:440:51af:2977 with SMTP id d75a77b69052e-444a7a66945mr92638991cf.59.1718957226718; Fri, 21 Jun 2024 01:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957226; cv=none; d=google.com; s=arc-20160816; b=QHSHjxR9dmtA8EpxCzbhaK3J6cd04bojGf3KfBtk7l1eI5N/gG8QjZt6d79c+LRR48 5NH3GfO+YRaXQcVEJ82wEPau+TwlmP57HGMwnhwSzXeKXBHtdpBA2+6+Ca50SqpoCjnn vwhp2ghgmFcsdDQkVFYMMuPbH523w22pNuOp62Fkq8/lYGEXAaHKO86pxuyPRur7xu/Y YyXlnA/TTne163HwCngmC2ZOq2sjdtEnQ1nwiFnwjX6wXzTvZzKTxTmsdDUpLKw97BKu 6SytgDHAETTWTus5J+oAsIR/n58CkPI3ljprpJT1OxGcYRH625+tINW3JDBth4dAJBJb 1FUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pu4cWh3N72k6gRC8kFx27gDVkEmn2smaKl61IHZHwJg=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=zr//Xt9Nf8h1Grqt9Yt8PLV83T7koI0DjcsZ8Z1X8R7fpHgk4kNtXXe/SF6Rycx+82 iCkvxFlGsnLQSVhcniV7NQjCMobtZBziLWjZFkdBdQPctSc1DC3b2taM5/0/j+0aggP4 K+NBku9wHDHcKj7FBTdedLOOREOpICdVhR5dAPTAYiMOuwXVYRdHprt0tvjo3CM0Mlxx PKu8c1uV781LILdpfkurohQQVevn0/xnS8/cVVAMXwQKiXo//1KNfGw6gDXe5GeyfrfC R7wODDN62d9UQPfwSK7j8eaS9Tfup6tJck2vGHTfZqAP5I68XIt/KiUoarpFsmPKaxvV 53Eg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ov4sQ7DM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c076dbsi13152211cf.365.2024.06.21.01.07.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ov4sQ7DM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There is no SEND_OP_CMD but SEND_OP_COND. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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; } -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 = sd_transfer_state; @@ -2149,7 +2149,7 @@ static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { [0] = sd_cmd_GO_IDLE_STATE, - [1] = sd_cmd_SEND_OP_CMD, + [1] = spi_cmd_SEND_OP_COND, [2 ... 4] = sd_cmd_illegal, [5] = sd_cmd_illegal, [7] = sd_cmd_illegal, @@ -2159,7 +2159,7 @@ static const SDProto sd_proto_spi = { }, .acmd = { [6] = sd_cmd_unimplemented, - [41] = sd_cmd_SEND_OP_CMD, + [41] = spi_cmd_SEND_OP_COND, }, }; 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] = { - [0] = "GO_IDLE_STATE", [1] = "SEND_OP_CMD", + [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", From patchwork Fri Jun 21 08:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806323 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653505wrt; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW13JfB2gkKhAp5/zbJAZl0/bRm9D4dLhHo2pRR4WMrOPevqMLd9HW9LPqeAsMlN5MgFlHMwXIk/Zl3poqmz1OO X-Google-Smtp-Source: AGHT+IHjFpantfhiWGEOjmP429zsGHpMxll6tNwh6BQFzdcHeyjZ2Rr7CGceAu90SGAWuG2etZIo X-Received: by 2002:a05:620a:4109:b0:797:a866:3a73 with SMTP id af79cd13be357-79bb3e2d683mr832952185a.21.1718957227465; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=google.com; s=arc-20160816; b=LBF4eK7+QcrO9hjDFq5xPbl/ca60ialJhQM4lbAq80nFsOBFbvQzemVn06a1b00VFY eG3uMp02ChxUqu/BZQ9Nn43FGfsO0ejiEdM48OQ6quoHkgxfFBGpb6uuvQwdY/ASWzPL I497ngUFWuASN+pJLOIMfGIvvcjwKLqlebKYYeNxHCRs+xxXPNW7D7rxbWeimJtJ8Nyv U2seGwwsirm4S0fHjFh5Zhbf4ADoSC4J2/WhRTP54JkxBxYbyOkPl1sbNDpTkA8KXQ6p 3o7pex3hDVkGgVPRuWNC2EOG+dOdi8qlUUAipIdf6oB+tIjXmNMl37c1SNNSD+ortHxA pswg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fbChd25f9YN3YwZXuq6CJAvDiqEwoBqyQKCDjART3V0=; fh=gToVv2rpbvSGQSdBDoLHAWz/Hn0LG3P3R0VsQv5U57A=; b=asJ5a0WwAo3O13IGCNCTnUisQoJxzwqI8z8l9SZwtipYKRIMO8fn0ootFEgr9lfGFT ZHkPuumlvKpw6YGpdJk57V3+yvZ4wg6JVtO/bE3+cIoMAtoDEPpYD4Rcurw2AquIACLo G77eJmWvLxV1GPvmdKkVonC77gOQKApLROJxZ3Pp8TrFY0oLzHHC7r1Q5qdtuJoRcXhT QE/yIrSOUg7QoXabwEZ7qSXh1gTZfTIYxO45/c4bnsYMmnZLXXNXoEuHyoBZZpOjsL1X fy2cV/RRddtfNUXUWsySh9kPTt3sFZtCUubH5YhyCK9LnKSbokODAqcBw8JG5TCPZSdP yuXQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AbaGj36m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce8814b1si134069785a.30.2024.06.21.01.07.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AbaGj36m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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 = 0; } - size = sect << 9; + size = sect << HWBLOCK_SHIFT; sect = sd_addr_to_wpnum(size) + 1; @@ -822,8 +822,8 @@ static void sd_erase(SDState *sd) if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { /* High capacity memory card: erase units are 512 byte blocks */ - erase_start *= 512; - erase_end *= 512; + erase_start <<= HWBLOCK_SHIFT; + erase_end <<= HWBLOCK_SHIFT; sdsc = false; } From patchwork Fri Jun 21 08:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806328 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653747wrt; Fri, 21 Jun 2024 01:07:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKTAvzoxM+oypDK30zoSyMLQ7HlVaNTEI9xOeQvql0bQBuKCzAIv+uhCmS1GfFVOBeRHLXoDMmWpfzzpWq3Uxy X-Google-Smtp-Source: AGHT+IHsLsWB3lIc3ryzMNRTY86Vhhf22hEKHbPwxsQLZpL9+Aqf4yRAxipoM3hUF1UxKkoyhEfu X-Received: by 2002:ac8:5a06:0:b0:440:27db:e84d with SMTP id d75a77b69052e-444a79aba35mr79981781cf.2.1718957277867; Fri, 21 Jun 2024 01:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957277; cv=none; d=google.com; s=arc-20160816; b=vIcQ5qIp/HPX+KuaRY6OWUd+ZW/PBRO6A0Z+v5pbH0Vi/nlZMetoQuzIUhaRxbaj/c J7Xr2Ih8KK8LhupadoeivB1dVVWF3IL2a1PUrakLRGL/GUF+G95B3PBykJQtMtJt/Fct /FCMD9whBB+E8+dg3DGOO082QRsO+hKc4ugtRtL/l1swYB4cGDorpLJ65ppfCtX84li7 bZUMssJgjddExWOwN+BPTCQ2dchTd2GgL2Z3qnYdMMfS/rNu/Q1sulKHl7O5NRLkatMA XGDEh0WAgBfxJYidSOD79kNrX/3hbW4dT3q+SO+3l+VGfGNucRF9+h/bs+fQafSb8zKb SvlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AsqEi0yMZfaJd1hK4BOnT6B+zva2T6NVwv7/H2dxiDs=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=t9Iu7pkD0RXlrO8cwLlgciBgcYUaRoSdgEyD9KasUpsiYJMCOY6a4YYW8qjmZdEXem tNMS4uJEG9UrcAZwnAX+OO/yODZsMSlBynzVkwethumxzvSiqKrhYxTLsHxmy1c4uMnX C4Fy2DCy3eAH79dk0T5PJlJEZw1aY943IheB+F/MO5bLUAWTTuzwbIKAQbzsVwnBOcq9 qFJJ9JNVCUc32UWM+KYn9433b5qTN8TnteardikrDCyCsLS7tbIHGweeUuQhtmZHj9GI 3od/0Ft6d6YblHUaqtkgV9YDIDVLZuiDDCQG7HkhIFb+z06vn8qsni0xqh7RJIHjKQ5h MZmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oxgfh8HE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c9f7d1si11844791cf.744.2024.06.21.01.07.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oxgfh8HE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use registerfield-generated definitions to update card_status. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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 = req->cmd; - sd->card_status &= ~CURRENT_STATE; - sd->card_status |= (last_state << 9); + sd->card_status = FIELD_DP32(sd->card_status, CSR, + CURRENT_STATE, last_state); } send_response: From patchwork Fri Jun 21 08:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806327 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653698wrt; Fri, 21 Jun 2024 01:07:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUTrRKfjySqWB+R4fnXOxGpoIpiDGXP6sOQ+izZqGbbEPxgBxsxXJkr2xohrKCbPDDzPph3C4Vs2nbCkVRPrYjY X-Google-Smtp-Source: AGHT+IFWk6J4dsxk4tL8Jnu3neG8iKwFgwLNiFZgNGQcnc1Bb7EykFfxJT1UmZqD7/Lh6erHfOW1 X-Received: by 2002:a0d:eaca:0:b0:62c:fc0a:bf15 with SMTP id 00721157ae682-63a8dc08b67mr79911077b3.3.1718957265548; Fri, 21 Jun 2024 01:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957265; cv=none; d=google.com; s=arc-20160816; b=okRwBnYjEWxIBeOs0iw7gPOiN8zyCpptt9DVbPcyaXoDXVT5jBItO9xVdIkToqN3qh /2lUqBnefsA/nRzactFpf3bUUD4sug3aVljtDlzBiuRJP7LizDt5jjINQ9ChBmH/10PM Q/IRSzN/Hok8RKV2TZEsFwRIvCoaniZXfuYFhKbm/F/yJdwU4b/Ru4VKE6/j/EHg56UQ rrC/2F/jE81rddV7GUJei/KQ9YexcK8JQ/FBGVosKs0totGkoR+ppTqfgBUNJVKshOsa Kz1TKT7FX1mURlleyKzl+vSFysP+cSdNdXH1vW2Yaxd4Y4hmcmZTnpa9fBpCCUXPIdHo pB0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=724kW79TXJGwyxkrPpGmpC8jMcTbNAzL87slxzj18o8=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=FEBQqrzttZ+gz/PzopWgDfuicYT/TP5CQ7Me1iBwNLHaLTCiUrMrPCDpl+7GYgi9yc UUmIqSMIpTPe5gvQkoQh0rnb5s4s33zi1EITQpw+qcSRpFwqBSYXDa6/A9vXdXU8m7Zz HjkW9ryN48tTUoWwobpWd4jShOkKMIuV6+f75OU6mP7stHUuzRVVl6bvcNxpuP1xq5zn 96cHgmJxB4SfHcERM1ScWt58D1Joo0jXMeYlsNNX8f5fPtvLHwp21aqIy9/5fZpkuq9j u2Qp+dKR2i59z18O9nbDctdwCqVtwbO4Vx3EnX95dFWDtbDZx72ZkMot3UwUo+ZvIG+B ZxUA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z4ZdYyxH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edbc6basi10364736d6.213.2024.06.21.01.07.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z4ZdYyxH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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] = PNM[3]; sd->cid[7] = PNM[4]; sd->cid[8] = PRV; /* Fake product revision (PRV) */ - sd->cid[9] = 0xde; /* Fake serial number (PSN) */ - sd->cid[10] = 0xad; - sd->cid[11] = 0xbe; - sd->cid[12] = 0xef; + stl_be_p(&sd->cid[9], 0xdeadbeef); /* Fake serial number (PSN) */ sd->cid[13] = 0x00 | /* Manufacture date (MDT) */ ((MDT_YR - 2000) / 10); sd->cid[14] = ((MDT_YR % 10) << 4) | MDT_MON; @@ -462,9 +459,7 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[4] = 0x5b; sd->csd[5] = 0x59; sd->csd[6] = 0x00; - sd->csd[7] = (size >> 16) & 0xff; - sd->csd[8] = (size >> 8) & 0xff; - sd->csd[9] = (size & 0xff); + st24_be_p(&sd->csd[7], size); sd->csd[10] = 0x7f; sd->csd[11] = 0x80; sd->csd[12] = 0x0a; From patchwork Fri Jun 21 08:05:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806326 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653628wrt; Fri, 21 Jun 2024 01:07:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXKNAAbKC1VKpesw1QmWqYcRIpERlObXIC7/mhAvj8XzeZXEm9G+Xj0n6r4Ehfyt6nxw3tgVPZqhmNQMx8JfAFy X-Google-Smtp-Source: AGHT+IGKIrU5Ofeg6jmOxrDwJglTcXZele+KBW1q0I1oGo5nNiPym4d9zpj1ZxgG2NiWbjxxAXNR X-Received: by 2002:a05:6808:1585:b0:3d2:26c5:9cba with SMTP id 5614622812f47-3d51bac440emr8547990b6e.46.1718957249607; Fri, 21 Jun 2024 01:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957249; cv=none; d=google.com; s=arc-20160816; b=wrj1Rdn5aB8e/md7kd8t8pokAFsVkDCoCATdk6YQr2L1XMqVCVTfrU/xVwitcI38pO D+ZFN8xLfXCRHygtxzak/P+tRRwGBPjz8eElwYzneF5aq39yJcEBEm66kuHd+8Dtd18L luvh5knskPtE1nX4kdT/H+Jh8DqMx66qczbn1Xz/kJVKtPSOdXJsbZVv//Bt33ttSpUl 0GndYY2g5t5bElteUjTKvIoxfHjA9DxGOy4T5BoG2h9evtqMZHGglms8OX2ThUtA80Qv rFLNCvNCNUNrQbsiduYtt4cqIGLRzoMKm4pDUVsQYFK4hVZSXWEOO3O5WWp+GY1hY26h aqlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5/RgyhQBn7T7/7BrixgsTi+BC7Dln0yA+HQ13ohYUUo=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=t6uD/jkf35mskdEE3Fun2if1B6Z70QP1pFQRhJeyShXwSqbG6/qlvIB0ejsJK1ZjKr QBFydszapKbKJkGxyX/6w8UHfqYDsXAFuWrKlMneCDnb83NdVN7WtS1rnGnvb2IQWiuC AdgCy5SjvGYvU/hUTJw1eLGttPTEIZikTx6vA6N30BmzeLBZ6Gig2b7WiP0lIVTv5uwX c4vLEVLSY6s0WDSoREreOLAv0hrSoy9EkXdxQ6NDlZ7HYjshbzR59ZHOH2emiFTS7Nom aKmvliA9A0HLvJRDoVqqAST6UXhQVdkTE6ZDTDzGB2RPJkX8etln2eG+yarMpt6WD8FU 4ApA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ERdp1tgp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce92e047si124896985a.492.2024.06.21.01.07.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ERdp1tgp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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, SDRequest req) } /* 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 = { [52 ... 54] = sd_cmd_illegal, }, .acmd = { - [6] = sd_cmd_unimplemented, [41] = spi_cmd_SEND_OP_COND, }, }; From patchwork Fri Jun 21 08:05:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806320 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653491wrt; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVCV8UwQDW/zVVICdQ4+RY/ZhcgJqpusXUJ6I14fWbhdeD7moqRio4WYs1ao4xrry3YcDoMIsaaOLATTvTeoW1f X-Google-Smtp-Source: AGHT+IEIpGZBDnusw0Rj/kQR5aaHqwZNSCB/xVXLwkMFcPLrcTfx8r5G5BqYiKvh1MQ21Bl7dSPt X-Received: by 2002:a05:690c:a05:b0:632:842c:d9f0 with SMTP id 00721157ae682-63a8d639043mr83524577b3.1.1718957226847; Fri, 21 Jun 2024 01:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957226; cv=none; d=google.com; s=arc-20160816; b=uDy6IhFSNiEmUCz2jaWOkxQXoW+Ul3jrD3Fr/qSQgIKNvXWlsAmiNqZ4fSTjaETNF/ db7q50BzY62DQjhwDvyYvL0UI3I8sFyF1WbrYNJawGZlLLGqsOBGibmBajVllaoxeD0o o3VBoEoJtafi5n8Cy0jG6fG9SXSctR6X/WqcMZVUFn61tSvsm3VlK4dxDHOg4/ZGc/xj mNNrIFqD5WCmEFpFPyWYfh8lPXxRRzaRYzgySds55ZPCQt8ewILS1aPVnyQR07AgMJLN bfUlYd7B3fVfQoHXlpdDfjuggVfgeanhBjXIYrJ3U9fHwliwnZ+eTy3RxS/K4K4KfL1w /EzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YQaHBopgwSjXudC8k46XwyUf5aDsciZs6MaYovNVcw4=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=VLYcCk9E0o2+SYNXlLvR5Lriwqau8Y+qX+UWtk5/HqA7PIojS+LRQSqpVguoIZNZ7x zaP8nsWN3cQyqVE8uuqMILwBbh1i2tOnEThFyd955FgD94JDdzE15gKEHxrGCdfCcbz8 oBhryZcziJIdjkJzxxtSe8XPUIHz0i1JSwzPJtDXm1Q2g6yc+6D/H45vbDNT6Bq5eMxh neJGFWUl+LScRZ+McWDxfQ4xLOPI6RzvTyWo43B748e8nHr36VoEw6MemEm2zA95PtfM gZRKMGlaBUb1gUgzhcgUp4/o76vJr7VddJ3ar1nldnBCWpCDFg9KwC9r6Y/qzAol87VD eUjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mXPUmOmD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edbb7fbsi10583776d6.240.2024.06.21.01.07.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mXPUmOmD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org NULL handler is already handled as illegal, no need to duplicate (that keeps this array simpler to maintain). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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 = { .cmd = { [0] = sd_cmd_GO_IDLE_STATE, [1] = spi_cmd_SEND_OP_COND, - [2 ... 4] = sd_cmd_illegal, - [5] = sd_cmd_illegal, - [7] = sd_cmd_illegal, - [15] = sd_cmd_illegal, - [26] = sd_cmd_illegal, - [52 ... 54] = sd_cmd_illegal, }, .acmd = { [41] = spi_cmd_SEND_OP_COND, @@ -2162,15 +2156,10 @@ static const SDProto sd_proto_sd = { .name = "SD", .cmd = { [0] = sd_cmd_GO_IDLE_STATE, - [1] = sd_cmd_illegal, [2] = sd_cmd_ALL_SEND_CID, [3] = sd_cmd_SEND_RELATIVE_ADDR, - [5] = sd_cmd_illegal, [19] = sd_cmd_SEND_TUNING_BLOCK, [23] = sd_cmd_SET_BLOCK_COUNT, - [52 ... 54] = sd_cmd_illegal, - [58] = sd_cmd_illegal, - [59] = sd_cmd_illegal, }, }; From patchwork Fri Jun 21 08:05:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806321 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653501wrt; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUSq2Qvdp9iMNCgUCwJ09OiuerN/jl3/qQmQDnMz3k98zQwZzL0HpPfkgOBgbFmTBZpuDmR57LzkNodcgYJ1GSo X-Google-Smtp-Source: AGHT+IG3wqVMZOxpjYRav1GhNzx2WVwAtyk6Zv/Re/t4AM5mVe2GQc4bZRuBK4Z/mpdswZRRD4Ke X-Received: by 2002:a05:622a:1394:b0:43a:d063:c8b1 with SMTP id d75a77b69052e-444a79d369bmr91052821cf.33.1718957227325; Fri, 21 Jun 2024 01:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957227; cv=none; d=google.com; s=arc-20160816; b=0omFiUqOFIqCxZenanDqxsjdK0zV21grpdjhZ8Woq44kg2381Iou4nQ0bKiyjOcxh3 frjC9ApB9ig3RSxAltNZV2N0wX96EOEM2Uu0nB/pD6MvPAYBQTrdYb7rSu6Q0Lpbp5BY 0tS2j037ljnIvWmgKp/q+wVJUHP8Jggd86/3gsR1KRGjOG3e5KAHwS6Y/j6+goXS7Mut EsvTIk9EA7l5ws97qiaYwi+F0Z25gp7qPrUrXSwFmx2nLsNcWoxZS/lgU+RDDAmtTe4Q EdVZFY8EFwMd02/F8OPrT/PBz9N7jI0hxtk/Fzkeu/mjJggzBqW9JYvAxXI7x2Ex+Q1X +2Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wIA5ZIlGPiIpZ77uW3DTdXqmrUImGJ4SmShsvIo62CI=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=wpJnyawX6oF61uIU0VqBWif2NPlyYFDEwHKLAV3wHjbFqv9m4EwQ7ZJ+4gLsuNElVl NBr2F4QN0KHggQPBTHGWVVIhEE6UxzLXhx56sk83wUxSCTofwQ95OlB80Vz/XbnTCo/h o7Kg+DnF6jOXElNFdOuuyGotchQ5Awv/44jiFa4kMQdH7CViLUdt+LTibaW+JOk63aFN jS+IOyi0q9RCen3YTzbKVMHxdo9VLdCQIecg2YFlLyjl/P2jQ6sUG96rdTEa7tVz42Qt kUMPzm4u99bt4a17OjYXjsZczuglLhDWywzcJ4Gm9XNP8r8M1xm6sAX9oINiXFSHzKGJ 6eDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IAAxos6c; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c65faesi11653271cf.582.2024.06.21.01.07.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IAAxos6c; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than using the obscure 0x4567 magic value, use a real random one. Signed-off-by: Philippe Mathieu-Daudé --- 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] = (sd_crc7(sd->csd, 15) << 1) | 1; } -static void sd_set_rca(SDState *sd) -{ - sd->rca += 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(SDState *sd, SDRequest req) case sd_identification_state: case sd_standby_state: sd->state = sd_standby_state; - sd_set_rca(sd); + qemu_guest_getrandom_nofail(&sd->rca, sizeof(sd->rca)); return sd_r6; default: From patchwork Fri Jun 21 08:05:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806324 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653616wrt; Fri, 21 Jun 2024 01:07:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXCVA8Cwbf6E9V+/x9uHtBBGj9RwzyNN3dZ2HM3ym+9GPBhxiRO6izD3faC1zBdogbO4/GkYa/wRGKM79cUtCZx X-Google-Smtp-Source: AGHT+IGiDLloyZ6aiQOB8WLCOh/+Yfj/qI9h9eSoGcCjNGEilpCT0sp9M/uB7rgsz4dZHBkQyqh2 X-Received: by 2002:a05:620a:4042:b0:795:548e:aeb5 with SMTP id af79cd13be357-79bb3e2f4c4mr942805085a.30.1718957248317; Fri, 21 Jun 2024 01:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957248; cv=none; d=google.com; s=arc-20160816; b=y/H+PVdsVD+clPWkaErylzCtupNpIKGiQxfftCHD6IhQb+doFyGqQ8SEfYhvPkoxP8 soCCL+flkRGxHS+J0nTJ8zGvt15DP6kdabD+r4H+mF4qFHHpOe6Xd/ETovoMAW11Mlht nPxTyYBJeEwdh/k4Jox/BQ591MorJbqwGvyxEw5qGF2Glls//9F5kfTUmls9omcyghRn UuC6vJoTvV0t/JVzJflJp17X1E69gyZL/Quc7xiWAwOh5GPlxrLTydtmyWp3SKI2nhve ffN334f1+xAppPLls48smGo5VR1KLNyRqjneGUT9IqjnrBY6Y2j7xS4sCPadR0eu9jTZ qmVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bU0wem6sZ7huq6N/EuEaJYYIPtKn/tCwdXKOteR3RBw=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=zkpsR2dX2OYLShUD99D5CvUMoigjf+x1fW+XpMwEKzRt8EcdkPdJx9FoX6Z8CIQfmX WN+jXk6rL8ck+bCkoENj8ju2ve0y6Jxq4BIB4XYb1bllyQIFNQ0GtjbonCgHuuE03XIW 9Jqh/5eqRr5LuhdwIVhoVful6ZNztohqVQKakCJ5GH7wQ/Yu9CNz9apzk6SGT7H0VfA5 xGaOv0ZzFTzyZuDwkuO/h9rW8iw6Y2eXGUMNhZYFcIcqZzrYNs8SF2WNo6KvvmUTdzgJ odW2gwYJdGqMbpgb2zgIDXvonQgkxfNFnysaW0cUVIqdLHLSS1nfDzh7ubYYHqKSV07H FgVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qdFlEIBf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce91422csi130405685a.245.2024.06.21.01.07.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qdFlEIBf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 = 0x0000; uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; + sd->last_cmd_name = 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 case. */ if (req.cmd != 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)); } @@ -1571,7 +1573,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest 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 = 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 |= APP_CMD; @@ -1863,7 +1866,7 @@ void sd_write_byte(SDState *sd, uint8_t value) return; 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 = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; 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 = SD_CARD(obj); + sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); } From patchwork Fri Jun 21 08:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806325 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653618wrt; Fri, 21 Jun 2024 01:07:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUhW5pFV77RxoBrJns93KnQCrk29myq55+WidhgDZxizGQZKjSuUQMEYPrCU+qxUaYu3wBOBmP/fCXSSm3e+RzW X-Google-Smtp-Source: AGHT+IFUpO/I9iW3Ac/Ib98OBsUkw8M1Ida8OfP4xwzQcqkyxU4onM9yF5jUVcicdNio2Fc/a/9e X-Received: by 2002:a05:6122:130c:b0:4ec:fe27:28e9 with SMTP id 71dfb90a1353d-4ef2780a549mr8847815e0c.14.1718957248404; Fri, 21 Jun 2024 01:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957248; cv=none; d=google.com; s=arc-20160816; b=A8RyuaLIXttnAIjETlHS/M5oJioSLmkn3iX5773gMq1AHI0FFvGP7yCezUJIptpYPW A6Y3Nt5dNnpfpX9N3STOQNTbrXkKUBhV8SEuy6VObkQQKalXAIzri4ryVyg1ZZ/wzLGL ACfRvx1rusLSu/ZE5lvi31SQTIVry08sAfP3JJ2k3ra8FsXA2F2WB+h87bWItkLuvJFn LiUtSYUFCYtNDv+Mkf5ZY4Wk/+x/XHow8avfdEetuLpTkR4WePeqnw9ntPSeODObcR5F MzDmS0Hwe5X1w1q5gS4aUurX4EBPsGi1jELnrNL04mRt/S6pChu55KfshJbsW+y4wtwk ihQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rbyk3UWFgM2fJ2qZVnBwxOBfAjBIau/lAmmpzLCFWnw=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=S1HUE7YVOnHdPvP7Ezs/pP8zCHPd6trKivr8HXfuN/WtgshoO4otnSPYvp9XMdrrZN t32rLCV5DQIyo6XXT22k7pFeWZ1SbUq0zW1Io5Za9vqULr5AwQsmI1aEDH6INphmYJ9P bujhr76cMuha+0imCb51B2El7F0PnBb1mk5SZafq1N3UU3BjC6csRahGao1HeQfshVF+ r4CJ8kfDEEMP9ySImEyWrz4SOJVoo2AIqKyRLcl2LM2qK1M91AtTMZzHKFIU6P1ArXF6 k7O4icsPuQIkmHr76VuY7e6plrrO/oA3TMY+50MLmvLhciWo0nqFmnr143CyrCDqKzhG wUpQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJBMf9dx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce882e13si128747085a.11.2024.06.21.01.07.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJBMf9dx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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) } sd->multi_blk_cnt = req.arg; + trace_sdcard_set_block_count(sd->multi_blk_cnt); 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 From patchwork Fri Jun 21 08:05:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806331 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653906wrt; Fri, 21 Jun 2024 01:08:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVsdJMonEZXaHQ++t56MYxtb3n6vxoo9rQvil7hZqbrM4QFXLeYjz0rM0oBprPb9Ym8+q1XvhOgIP8b1IEhTWKX X-Google-Smtp-Source: AGHT+IHFNlkiR/pQSIThsoBoW/oGh9RQATJEZOsD0eyC0f/ozFiIbR6yswAi+TGo2hAn9ef3IhOB X-Received: by 2002:a25:2e04:0:b0:df4:d65e:f519 with SMTP id 3f1490d57ef6-e02be2489d2mr7902396276.59.1718957306877; Fri, 21 Jun 2024 01:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957306; cv=none; d=google.com; s=arc-20160816; b=f5575OZRllJqydf6mlIAb9l+q/QKCUEKgOudQVWasSVjiSIsQH9VSccRn2OTDwqii+ 5iSW8kwjiY9IA7/xtH5G4CSgkLxtjIKXU7sCy1anxiyIdzjiUfnyc3tAdOe1HDnw6/hx mJzMcmIIQxRddt5ctewwfZFlqVMX64OJdGYCikCDj5q+7zMcERd+4thBVdG8d7Tkh/+z x/iNqsxol7oTFjaIRIT2XFY0dt7r3L8Tuc4l/9wxn6sdJSl6d1ukvbqDEi7fkSsWXbTd 2GP7IIHSVrKwNomdXdUWF7I0irg1RmJSmQ4XSb3SyzYwGnsSl7K1l3c99/JDzFsnH4IW NFBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zv2IPBSQdIdPeLuMZrnQwKNaEJe3N40sLNBQgal52uY=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=FoHIDwPRTu2YEKCJ7FhzpoaFAZTy0XGrdXjKwnis2csqOI5tTRQEhMQi8WvCSVDpr/ WuKLrqsKPmixwn0BvM8d9PEJlRJ91Wcp2fQ9e66u2mC+X/347ye7pIVZgCVUPStV+H3u jQMH/pdOpfBAdmprfrBAw1GXP8vWTUUH1G3JQIbSJOtH2riDffwj48JbhR7OtiLsHQvF YuhIYw3Ds7jvmUjS7S5fHaDQBge7mDGPEKKCXdjdZwn+tP6TzrRZlAlNe2xuBTeIbFm8 x+UrcAymoHzVsseFXLJp5sifzbTMTyHhSkgM+rEjB3HwgylnyyjIbbC6L2bVQXU9UeHM +mNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3X2IGN+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ed16c29si11063516d6.159.2024.06.21.01.08.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3X2IGN+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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) 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 ++] = value; @@ -2024,7 +2024,7 @@ uint8_t sd_read_byte(SDState *sd) 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 = 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 0x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c From patchwork Fri Jun 21 08:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806341 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654576wrt; Fri, 21 Jun 2024 01:10:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUW++HYUR04u5wWNDYdx6DLj52+FuQdWgmySPFh7chpwZJJMDrMuOz3UYw5W66lvqjA0ZmrBjKL8WHfeGzC88+c X-Google-Smtp-Source: AGHT+IGwtRDAlq0N44M5iQpEg0nivKxSeb6PAhQm+zQoflIpuXHBf5KCjPox/CGymGvCFiSgUboH X-Received: by 2002:ac8:5a4c:0:b0:440:279c:fa0a with SMTP id d75a77b69052e-444a7a5537bmr89984931cf.53.1718957429164; Fri, 21 Jun 2024 01:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957429; cv=none; d=google.com; s=arc-20160816; b=x3w89mxrRIhLuly0ozpvcrwKpdCKTUa4elL3+EbJdmSU4g6AFSpa3yPCkV168j3Zt7 Dj6VnzkyGGDXRDLN4V0ciqpZY5SPZZ8x+kfKPSG0mrSve+tonq0Z2MjPmOc+CnNI68G4 lI5M7FXMShW0XcoKacy0/qace21hjJRE1VMftkWeMpkrG1Ao6UL2CXirV208x20tGm0h SGbJuUiDmNKwLqKepwLbykrJoRQS34mYNpKZYiwYOXFRonco6VpKfyohToXbHI9uE12F DNqXzC/zCsrG8m0DWQwFIdjpbsA7D7FLol0zscACIFfFFuuFSJwISrno97XNqB5NQxVj b80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RPBvU4uriaq93lgSEpi40j13P7YTd0f6Hz6KWjEoVBs=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=rYhRZ95dSxKxGOPW0sZWluK5CbVnjemDlBrMo/jwZggTJwz0+lO8cI8YPr6mEXGGVl peoqZY6zM3O+MDOaEFXQmByZiG//GqlS3HY8WlqZu5YtBhs26CNGNcpObaPbbDkGChDg DKtYIFWNfCz4T6IgmhOCBQLpemwb1RZuHmXtOsaRB19iPgRt2hxqAgiG4/kyF3KArl5T 7ayWKFsZk4P9xdKPOPFJXqsNdcc+ef9g6gjJqQmnBsrXrXY8T4nlNNOZAoK4fXW+mCyK 8ajz6BjOuv/dDDMD1zj7coF+X6H5CLUH8ZSzD7n0rxw+cSYYXwOectn97x8a4DlaLmK9 OKyA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=io9rc+hs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c081d7si13047461cf.291.2024.06.21.01.10.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=io9rc+hs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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; } -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 == 41 || cmd == 42; } if (cmd == 16 || cmd == 55) { - return 1; + return true; } return sd_cmd_class[cmd] == 0 || sd_cmd_class[cmd] == 7; } From patchwork Fri Jun 21 08:05:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806338 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654409wrt; Fri, 21 Jun 2024 01:10:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXxyyrcc0uvXTObZfKZlAB8sYPkBWqVodNsD0GqavKdOizkIWcIHTqSDGhgYQQ4UMoCE31Q4hFaGe1IBuXHaxbT X-Google-Smtp-Source: AGHT+IHEUo0fda9ZhPKOXN76YU/gfzwPOiJ0spHSs9/09JM+EPQV9wG+0jUIftCiSBqzEcvcbIh+ X-Received: by 2002:ad4:4e0a:0:b0:6b4:fbee:3388 with SMTP id 6a1803df08f44-6b501ea372dmr77635246d6.43.1718957400181; Fri, 21 Jun 2024 01:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957400; cv=none; d=google.com; s=arc-20160816; b=E8TyogAl1t8zbkWmuTMuvcPqfzaD6Fvj+pRQnQDy2opXgMh112CQjD7Kgys6Z7xuPk 8BDYUPx+9ZuqtpBW79WcZnEJIgUa9Iv/U17L1wWsX3hr77PqXx4sTIdH2WsuP4Z+rZky eF8VBV2KvILp3puMOiGSMmu6j4EHSLfYJoEP/CYAgiKj/56HceNh9M2vgJAhN8DOwf+o x8n43jUwPt2sB7scRD9qOp2iyNuybqmu+oSpzYlElAgAgSIRy5E3UHsce1yW7KqWapQe vD9wig9dF7/KCN1SMnqRVF+BlWMEZrzdP3UK+V0k09oRgjKDnoaB3OOPvquN0u/jUU9z Ck6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=udWWj272g9nUODajXENG5MjPbFRaI4fbT7wamp0YglI=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=01utv1/W3LSdxfQXtRMnOw7HMkh3HETJ2+R/Y7P7IHI8v8ipbqlxPGBryJszrIbvoF W/TNXytU+ylnlG9xXpoqKMVERk2hB/AQCEjINrmmDiis+ZJXvrlnHdpSgRxf+NDtQ9IK +ZGGH0TzqMgZxoenlS2WL9hnjwm0eyu2j6JF5kArgElVDpslnFbmgQ3fHfHJJrwotgPG 1yHTXOpiW1ttpZMfOLZtaAol730vo+5991RGGYepyxvQhS6zVOYubKEGYMycoZGStF5g 6yIHgG2ZJ5SUSUkfHegn8o8rBssxkt/pMN0AOLa8q8Q58e7uLlkbRuZ/n9LExsD9uM/N tBhQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fFkYC12Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edbc97fsi10670446d6.229.2024.06.21.01.10.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:10:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fFkYC12Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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] = (sd_crc7(sd->csd, 15) << 1) | 1; } +static uint16_t sd_req_get_rca(SDState *s, SDRequest req) +{ + if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_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) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint32_t rca = 0x0000; + uint16_t rca = sd_req_get_rca(sd, req); uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; sd->last_cmd_name = 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 &= ~APP_CMD; - if (sd_cmd_type[req.cmd] == sd_ac - || sd_cmd_type[req.cmd] == sd_adtc) { - rca = req.arg >> 16; - } - /* CMD23 (set block count) must be immediately followed by CMD18 or CMD25 * if not, its effects are cancelled */ if (sd->multi_blk_cnt != 0 && !(req.cmd == 18 || req.cmd == 25)) { From patchwork Fri Jun 21 08:05:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806337 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654364wrt; Fri, 21 Jun 2024 01:09:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVd/hJjo2ATNuaKa9PN0XH9103LRB+R9e1NdghmF5otV/sGYTZa7DgqIaS3Fmo/N5bbCjox6VeaH/nOdmjSoc+I X-Google-Smtp-Source: AGHT+IGNWtwUGZ5a2Adg3pnTGnX76zKAUgcyTPh0iNMh7K6vXeYRm0lnDkkkYLfRkwKMxIkyCSNE X-Received: by 2002:ad4:4d09:0:b0:6b0:89ba:396a with SMTP id 6a1803df08f44-6b5104ad71cmr44704766d6.47.1718957388351; Fri, 21 Jun 2024 01:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957388; cv=none; d=google.com; s=arc-20160816; b=FYvzQcWf46KufReIzDtef96GOgwEfK+GslrxtOI3JxtO0ksF7Cw//e9HZWhjz1URad O/Va4M2BnvCttL5jSyo8Oe2Qy9toXJFhKwzKLVAew5IDAS6IC95Qf7DZNa4UJ7aUD2/k TlPD5wJ9agWZk0uB+3kMc3ttScgs07ZRPEvh0uyW4X4KIf6bjwUlzAPlgP/Sxt62Guhv LD4YAa5UKkPa9ATACN0rNItgDTJUXqaaXlayd3L7K773lXcZePE1dBzFkb/y3av6L9V0 uOzHhHkUpnZXrxTiA+QXFz4Ix6hUU3aynQEtbBvPobOdf8cKv7rv6fHk2R2SasehcQpe 301A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BD5fgdTJlgw33/dLpV9SeOJ7ak0nlluyPy+d+qp00Qk=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=xBfybi6rNUfyvCiRJNZ5aMBde6hMAiL9Prq1mlzkALWpT07ktySxiGUEXY1QZ47aJZ 1JBrmbuAH7RY0qDw3cIrammASSa2MEo64z/7wHK14wpgshM5aQAMUa6hPuJDJFERcAaB 7BGw1GL3YHOerWwDXyBEW3zLIXGTRssSSLkzW3gbKt9xUIIuQH1yxiIeDMYUeZ2VIdmc qqYoEwWmtZLf3W1F4lQmbJTZbHQfjx07kLTzG3t7Ro1ztzHz8qtf7sNkJ9Ry4pcXb2fN hwBUBKQdRt9XFivw8pPCiO7MEeUnLtd+FeM33/+PTwawpI8ZEeemQVPhmo/ECmZDSCP5 5G6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hM3GHUMJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ecfa402si10507646d6.67.2024.06.21.01.09.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hM3GHUMJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint16_t rca = sd_req_get_rca(sd, req); + uint16_t rca; uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; sd->last_cmd_name = sd_cmd_name(req.cmd); @@ -1160,6 +1160,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 7: /* CMD7: SELECT/DESELECT_CARD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1214,6 +1215,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_r7; case 9: /* CMD9: SEND_CSD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1237,6 +1239,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 10: /* CMD10: SEND_CID */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1277,6 +1280,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 13: /* CMD13: SEND_STATUS */ + rca = sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (!sd_is_spi(sd) && sd->rca != rca) { @@ -1291,6 +1295,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 15: /* CMD15: GO_INACTIVE_STATE */ + rca = sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (sd->rca != rca) @@ -1523,6 +1528,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_ready_state: case sd_identification_state: From patchwork Fri Jun 21 08:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806329 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653784wrt; Fri, 21 Jun 2024 01:08:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnuoKMMeD2V9Rw68Jw9l6c088SGIL+UCVQ778F5QkHmqhdo/qmgC3I2h6w71jeG1vvTKU2VAFtZzCF7pWfNpUu X-Google-Smtp-Source: AGHT+IESMbFL1Z4SkLzCWkprUOv07tkZ/zq8kI2AeFMHnTe9q3QAK6UDiy0gWt1pe0+YfjCRNzIg X-Received: by 2002:a05:620a:4101:b0:79b:ba1f:8c4c with SMTP id af79cd13be357-79bba1f9388mr960269685a.38.1718957283533; Fri, 21 Jun 2024 01:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957283; cv=none; d=google.com; s=arc-20160816; b=h6VipCWmkq37+x0tCAdo+Xud6ubg33xoWhNT5IOZg3qAxxe+ds96x9VTfC1UXgiELW 77VoK84zb9k4lGtJxsaIq8ZWOPy1HBXyyCzmiQJe+is18zpG7s0wqMSlr/KafU5+3vAR gJs+1hoFCj1EwHhuMOjazDNbVIyxsvqp+GtFg8HgH84t6m4N+a4aiuivvT/ShZhgVF71 GCITFaq6fzTqHb+m38v2aEs2NTmfGJelIfZvovmXHicp+cl7B7yTL/NE6vxeK8uBw6n1 YTDmAvmsVfJITMZEHVyH6EAqb8FlXVPHe8z1reGXG+xgeZwzeomBBJ0Xic4V2o1T1ihA 3jbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Dkx6RwZS43D0XJ3kR94XAto+d+FvcMQ26elVXwwNzdM=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=sOi+CFFMOS1rKeHpEpj8AD1AdwE1bGWcSApPpAv0SBTXYkyB5+HNdAenSRYJAv6obZ rQIgMr1+0SwYTv2E+lLzjqlthV+XXFmjKT9JXO91ggpYaxrwu5Wfn7v3dkoCCwMn7QB7 iQIZRpCQLHfoNMdE7BXSCfMdlvMNUvq0lExG+sNFLBRu9wnu21aUjtRLoS9MS1UW9BpR kMGfYpDsLTjuyzLpOU3aoTKIeA1+5hG4L/2pdSqOJyCzBiv1x7o5OqFAH1FN+p97TQxO Umf737cZwrmsyedGGsdke6cgpfSPasiQzSdpzSTlT+Vr4sAO+wn2ogFAP1o4tCtQ/2m5 ZlTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M9y7L6eo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce8ab62asi131314385a.217.2024.06.21.01.08.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M9y7L6eo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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); } +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 = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; + uint64_t addr = sd_req_get_address(sd, req); sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. From patchwork Fri Jun 21 08:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806330 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653896wrt; Fri, 21 Jun 2024 01:08:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXoYSslcFAjmLKD3dDO7te8m8cvg5fo+dtmOy4u5gNbg57pRSDnF/JiSj9y8idCFaifiL5wEyATJwLtCOjb1hPN X-Google-Smtp-Source: AGHT+IFytx2SHkAPGM4tacJqSpiimINodWsocSyD2/mwsJfmJYyeczwKdVswGTKQwl5nDof/oHwx X-Received: by 2002:a05:620a:4146:b0:795:4fdb:a78c with SMTP id af79cd13be357-79bb3e56785mr809708985a.35.1718957304944; Fri, 21 Jun 2024 01:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957304; cv=none; d=google.com; s=arc-20160816; b=Vl53+gDtcJzEkihjP4Obkl5Kb6N3olvDHWJOFbVGtPaQkaib9I0wI3s+9zw6Rj3rZF 1rVi9Y+aR5V12YfQbFqiQLJH3ie9LYo0rjl2t3danB7fqNcc9/ec7FqABiom32iBPh6t Vm73XWhgNv4R+v01RLTP/bcGqnPjTVkJIt5ZMwiGCAl179fejmEL/u4jsV6Br3pbeV/g e7COE0rHWub/2x7CKwLruAgiEwCLGzCA6Tm5Fwanm2zNt8R4A55dFoDOH4SP9efUny/2 41rkBN/iC2/KrfP76DafzP2N1JO+cfoThspxF0wlhYOfC4/2Kw8zJPVo42oLDvx4/ET6 6hhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DRY+1ohspoSd94VnPHqa3ped6qMZHLQr+fY7mqCBqOo=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=d8pRMc/QoaF0Na8ab4xvXyOcqag5ArmS6nkzYRnt9YL++6Xc5Sy7lq9XfGjQe9ql00 a4VZIGIAeK1AHVmEXPXxCWlq+Jm363fvipOx8Abg9HqQHonMk1tCksh5U/dDIDYalChk Yet60JOj2wcMw/WB4aaVuoPOK1kcLZVv4JMEWEyhOJKaHgVtg3BvaplbfPHnb5kRGH9x t0zFm+lq1cmfDZDcoqfVLW94T+tCwoBbrTujiLrngRn9e2aeO/MmgPZiw7d5L6eE6+IC mBvO94VHJk3PAjO0quLMBiVzeUiLZY9JD5687noZTrVJoH+3rYdwJrt3y7QEWoizi9lK zWPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uoNsCivA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce92b5afsi130738185a.414.2024.06.21.01.08.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uoNsCivA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric 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 = sd_req_get_address(sd, req); + uint64_t addr; sd->last_cmd_name = 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, SDRequest req) } sd->state = sd_sendingdata_state; memcpy(sd->data, sd->csd, 16); - sd->data_start = addr; + sd->data_start = sd_req_get_address(sd, req); sd->data_offset = 0; return sd_r1; @@ -1261,7 +1261,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; memcpy(sd->data, sd->cid, 16); - sd->data_start = addr; + sd->data_start = sd_req_get_address(sd, req); sd->data_offset = 0; return sd_r1; @@ -1337,6 +1337,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 17: /* CMD17: READ_SINGLE_BLOCK */ case 18: /* CMD18: READ_MULTIPLE_BLOCK */ + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: @@ -1357,6 +1358,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: @@ -1415,7 +1417,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr = 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, SDRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr = 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, SDRequest req) if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; } - + addr = sd_req_get_address(sd, req); switch (sd->state) { case sd_transfer_state: if (!address_in_range(sd, "SEND_WRITE_PROT", From patchwork Fri Jun 21 08:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806334 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653989wrt; Fri, 21 Jun 2024 01:08:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXL6HwN9FoGGJJpY57LwNPP6JiBO5xnt/kIe1jyJlxDa61FTJOZuzPuvOFzMPtJsThjLW6KjaMXYBP59gASzQbt X-Google-Smtp-Source: AGHT+IE5oHKKjPt3L42DyAyOlpY3h/O0Yu9b6Ug3WhArbu5QxU/H3Vbuw/O0KTZU4Rviw340wxn8 X-Received: by 2002:a81:b049:0:b0:63b:ab20:bc7e with SMTP id 00721157ae682-63bab20bf0bmr59666187b3.41.1718957321800; Fri, 21 Jun 2024 01:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957321; cv=none; d=google.com; s=arc-20160816; b=ewgmdxtwwFKU5p505el4x1IdUlg1ofHeFFuirP2XEBoV/SvtL9Y034aO9U6W/8aboP QVfIRaor1RS0y3HYvdDkoulBj+brzdUVluUvImrc932RnS/FmZTVW4Y1lA9hDW1j1eKN FLqxuGO6KRpdS8cuLrCjOZaF2GDtsMMlI160nMtvVZt5iHSHwiX1BTVKHb8Bi1gGaQUN AwWutbABsLwpJiGilqYmY7JJcjO2YtraMRC6T9on9Zxoi0AgfSDJB3nZ35bp4NVTFFdx OD8BIM36u/mrjDSJoi5bpQoXJAgTyQgbTHOfW53dY17eG4KVOk4LLP+XU015jzsxI1eH HEDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SZVdw7g4FFY2EyPpj/GEhmJmZqJuSFbYAj+AqUiDdB4=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=KJJ65/WPLob9vQnsw9nFjx8gp8fJyzqASyyLJg4CAIfM9z7xklXMvdC9zfG4RlP/rg jTUYFmOax2wvOFM6Yd5Jy8s/aTZc7aRLMp/aKefrbma7a88hS69R17J7zas1Vg1UzCvy uEBQltrJSmSCTX9URexKZeYYNVkHesGveGzIhUUDQMTaahqGuJ7/8uKxsc4YY4tB//vD 2zRex2KAWNa9+1WeDCD6nmlOaKLZebfMSskLkWMgjDFIgya+voDZcaToGDcey8BAylKt 2tIrQPpN19QRCFBiynfC9HInP24pzsJJ7HzgTo3A9IsMoPYalm0KiSmgsyt8OaLDh+Fi ZoDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ThyGybpk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edd3053si10147466d6.372.2024.06.21.01.08.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ThyGybpk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Having the mode switch displayed help to track incomplete command implementations. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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 SDPhySpecificationVersion version) return sdphy_version[version]; } +static const char *sd_mode_name(enum SDCardModes mode) +{ + static const char *mode_name[] = { + [sd_inactive] = "inactive", + [sd_card_identification_mode] = "identification", + [sd_data_transfer_mode] = "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[] = { @@ -1015,6 +1026,15 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) return sd_illegal; } +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; case 6: /* CMD6: SWITCH_FUNCTION */ - switch (sd->mode) { - case sd_data_transfer_mode: - sd_function_switch(sd, req.arg); - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + sd_function_switch(sd, req.arg); + sd->state = sd_sendingdata_state; + sd->data_start = 0; + sd->data_offset = 0; + return sd_r1; case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); @@ -1289,33 +1305,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 13: /* CMD13: SEND_STATUS */ rca = sd_req_get_rca(sd, req); - switch (sd->mode) { - case sd_data_transfer_mode: - if (!sd_is_spi(sd) && sd->rca != rca) { - return sd_r0; - } - - return sd_r1; - - default: - break; + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + if (!sd_is_spi(sd) && sd->rca != rca) { + return sd_r0; + } + + return sd_r1; case 15: /* CMD15: GO_INACTIVE_STATE */ - rca = sd_req_get_rca(sd, req); - switch (sd->mode) { - case sd_data_transfer_mode: - if (sd->rca != rca) - return sd_r0; - - sd->state = sd_inactive_state; - return sd_r0; - - default: - break; + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); } - break; + rca = sd_req_get_rca(sd, req); + if (sd->rca == rca) { + sd->state = sd_inactive_state; + } + return sd_r0; /* Block read commands (Class 2) */ case 16: /* CMD16: SET_BLOCKLEN */ From patchwork Fri Jun 21 08:05:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806339 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654433wrt; Fri, 21 Jun 2024 01:10:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUAScqY4/4E1LJtE/1/PVOPCKuHMJ8CXu3I9XMrTf/LXuOrtGH7Gwkh3IqDpZtUWf0GhrAH6/qDOOH9AsEeF+c9 X-Google-Smtp-Source: AGHT+IHu5/a6MBz+NcX9t4OVaqHj4SOpmnWCQHqVoQqKpSNtUdcX4S0QtDGVLqDPcwcAwz7yHCkS X-Received: by 2002:a0c:e950:0:b0:6b0:76e7:d3af with SMTP id 6a1803df08f44-6b501dff5b4mr79259926d6.4.1718957405604; Fri, 21 Jun 2024 01:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957405; cv=none; d=google.com; s=arc-20160816; b=ZMDPVtalCkhgdK0A7kBlt0uwwXwKxiOI32QmnEFEHQ0aBzmI826hlgs9QwaFO2AIPV ybRCI5TBEtY0eIgaMkT7SR2SvVlDauR8qkvSHuS9ONpn97XyNZ00cFqd6LTzQkAlZjBy NKODFUCqMFV+xmYKZrKu8HsF/bHDdjQA5IUJqmOhytOTMefSYvsCNPCPnRzZQ6rHVepK GHPEH3PXHVc//1wtPHHlQx2Dae3ghIZYHbjMXpkhbnJqng55MSbz5BskQl6p05lj4NcR dn0JA/nqTD6a+ZTPeTs///Z0vvXHsqBFoZhJYBDqCunr3KucxbrwnKUiKyxZBB/y7P6j znTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kNBeXm9P/Ml80/yN91/eWbfFz/hJLMpAuct+ZmQTshg=; fh=4tJ/d82yAWDoMCdtS7XMchCPfoLOmYo0Z8GLnfFVPIE=; b=jhHZZZs3BYIiPWqAQbFgWatWn8mRdJn+EZ7IlSk3AjQZKEDR7hYpP6QdNMd/p/aNfx Fwa9TAXXvoqmefEKapeC0LNdLlIwBiqdhp2H/ELH2iEw9ttHiVOEl82bxMFzBJiqvIXn ELzK6B6tBuDnoDCBYfZQzaNtkYmYH3u3UBGtQXEpvzWqwKHyf3euvrOpsfvXB56df8By rogD4bhtoLUggxQWmUEAmqIb3kKYyq/8/8Ed4GG3BogZPtkPO1IL907CtXstF0P9zNKP W4wNJ2qEMmHU4T2hYXk2dgzzU9OavZpntCnEgOnzPRf68VPHdx3bR1qYN4BwWzcZbWIw Z6oQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OrBh0QKF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ef16cd2si10364946d6.428.2024.06.21.01.10.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OrBh0QKF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These macros only save 3 chars and make the code harder to maintain, simply remove them. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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, uint32_t len) } } -#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) @@ -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); } } @@ -1901,7 +1899,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->data_offset >= sd->blk_len) { /* TODO: Check CRC before committing */ sd->state = 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] |= 0x40; /* Bzzzzzzztt .... Operation complete. */ @@ -1927,7 +1925,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->data_offset >= sd->blk_len) { /* TODO: Check CRC before committing */ sd->state = 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 += sd->blk_len; sd->data_offset = 0; @@ -2075,8 +2073,9 @@ uint8_t sd_read_byte(SDState *sd) break; case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset == 0) - BLK_READ_BLOCK(sd->data_start, io_len); + if (sd->data_offset == 0) { + sd_blk_read(sd, sd->data_start, io_len); + } ret = sd->data[sd->data_offset ++]; if (sd->data_offset >= io_len) @@ -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 = sd->data[sd->data_offset ++]; From patchwork Fri Jun 21 08:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806332 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653976wrt; Fri, 21 Jun 2024 01:08:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWnsKC5Oe1LxOagjOmh+wi32YbTp2Bq9bdgMsnzixTyIpfCYhSii9JoLd3cjeZfRoAIXQeM6l5selBMH1z+z5Ws X-Google-Smtp-Source: AGHT+IE3CWEEWqLD/Uv+mfqz/4huiqgkZFCHtoBhIHYX2U0CY3d5CEFsEFL2t7iauxFvaX7bTZxl X-Received: by 2002:a05:6214:252f:b0:6b5:198e:353d with SMTP id 6a1803df08f44-6b5198e3859mr42372856d6.10.1718957318430; Fri, 21 Jun 2024 01:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957318; cv=none; d=google.com; s=arc-20160816; b=ShpKt0En36YjIWQAE+djoJ8pv4gzKeSB5w1xgZg+1KNTJvHgItq3qQiphHgIG7bbwA GS025g9qFNkrtqvaNl5C47sKQuNzHKVRmHKM4KhIeq0CeTrxmC8WAeFbAyFmmqmsea6h LQ+eHfke6tgRPldbRxnQOl/vUoR93KpQXeBVNWOewq3jwmmGNmASvfJo7jkGJnSkb9nZ 27ZaPrZ+1LrL/qBjfGXqJC2Z9/+UUhOHTx7+C1JU7eZkszSO5AVJFGp9/HGNJZbw9oam 4lj6sDPEhEjMKZ/Lfx0KyMmoH3bCfpDMPBG424T+z2QqiBtAu2LfG62duSvOco7h6tao Z7/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h8Diio2eGtW+VRAl1Her+CVl5IxHLJh1wYmmEzpfRJ8=; fh=gToVv2rpbvSGQSdBDoLHAWz/Hn0LG3P3R0VsQv5U57A=; b=wAtggeqwyaDcr+oqy+dFUjbO7+ys0OMD00cP9NKwlcHTKP6xU8/ETgTI645xwkowlI Nv9CXgW+ZVsgCKIhjsf8QwkmvDQ0bw85YxWTI8z46ol1Ly4o7vGwJwi+7GlAuAuqIeci UAsCsKnC4MaSdloVGmfuecPzk/ZqlRCFWw8E6W+zlNPxoAed6IxTJmRgn6ctcvT32AzB b67LC0psWAyzpgecBJ6/1p/YMGGZdKfnjSQZwxAK0dB/jPUQ0exQUcKutWG21y0v+7Yd vX5Kpw0X2CeCwYuL5q3bn/EAYX9+Nl2GxIks5NhAQ5uHvREhmvCdfB/h7w9BMP3bzDRy DVsQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iw73BHqq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ecec0basi10965826d6.77.2024.06.21.01.08.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iw73BHqq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Joel Stanley , Bin Meng , Sai Pavan Boddu , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric 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 width) return shift_reg; } +/* Operation Conditions register */ + #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ FIELD(OCR, VDD_VOLTAGE_WINDOW, 0, 24) @@ -366,6 +368,8 @@ static void sd_set_ocr(SDState *sd) } } +/* SD Configuration register */ + static void sd_set_scr(SDState *sd) { sd->scr[0] = 0 << 4; /* SCR structure version 1.0 */ @@ -388,6 +392,8 @@ static void sd_set_scr(SDState *sd) sd->scr[7] = 0x00; } +/* 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] = (sd_crc7(sd->cid, 15) << 1) | 1; } +/* 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] = (sd_crc7(sd->csd, 15) << 1) | 1; } +/* Relative Card Address register */ + static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_adtc) { @@ -490,6 +500,8 @@ static uint16_t sd_req_get_rca(SDState *s, SDRequest req) return 0; } +/* 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 = sd_addr_to_wpnum(size) + 1; sd->state = sd_idle_state; + + /* card registers */ sd->rca = 0x0000; sd->size = size; sd_set_ocr(sd); @@ -1052,6 +1066,7 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +/* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { if (sd->state != 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; } +/* CMD1 */ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) { sd->state = sd_transfer_state; @@ -1069,6 +1085,7 @@ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) return sd_r1; } +/* 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) } } +/* 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(SDState *sd, SDRequest req) } } +/* 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; } +/* CMD23 */ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { From patchwork Fri Jun 21 08:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806340 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654519wrt; Fri, 21 Jun 2024 01:10:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXIE3y9JVn7odb2EP9chmg40EfeNp3MRz21OOiwOun7WFVjVa3C9DzHSQM0bg1ptAAgIbl11fFCe9Z8Buj7CMlp X-Google-Smtp-Source: AGHT+IH8i9qgdxK1qStpPFTVCF1lkFYHLrBY/re+ue90iMGJvHRaM6RxM1DiVKwTVM5EJ8q5HjHE X-Received: by 2002:ac8:574b:0:b0:441:2a51:70ec with SMTP id d75a77b69052e-444a79ab501mr84490981cf.11.1718957418460; Fri, 21 Jun 2024 01:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957418; cv=none; d=google.com; s=arc-20160816; b=ij8oSN59Glp47guY0/ksOo+NVj2ULdblPRGuizfRiumSy6/CC2+/uEL1Y2WhUw8uJx 2NcskRRyytVeDW65oG5hBJzcrQv/MXjldQDT+I2Z0DPM5aHePWukSvNhSv3wt3LT2cAO GNKXuDKt2DOMyX0rEYw3hpm3ywK+oW7mAzm7TULEb8IlgEeUpVDeQaUo8/nE6WJhY6HK SF8zl+l7bpvKQBD7GHUKTuIQ4vm6P0mfSw1+KPHgXcn1UdxCFTjYtw8UtpERoMlxLSfL B6FLBjdekx1TXaZ22n/Vqp7zvCgY/vKxRwTeoso74BEumQaorqSvHImhz2CN3T41CYXA aOwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qHkD/9LfuqpSjqb2mzBbMf8GF2z2q7mW//xxpk6LGc4=; fh=I3mZ75J1Oz+ffmW2UQgEAr7ZhOLElkfAzVZizRZhfCQ=; b=lFQV/g9CLiov1Z9IsYA4bLmcBjk1LLg4MMivwAnN6M875Zg3ppafgzxEJ7Cr9uuhG1 GRWx+vRylR+RcqKdvA7JLR+PD9n4uBGKw6COBcD8kGFJ2TuzBWIo4LkPcTlWIIC1vBwE 6uGZ3vafX2GeUiyODY1QdVooClVRVS27XIpG1G4H8g+xMe/vU5uvndb0fVG/fcmGSEGX jciXsxY443y+RWPLl1CXjD2Z11zorSNJHsOZV4Q/R4PIQ48ypNCNUd8358+ycCkTTwFY ePZvJq/jc8dnBowvv0nF8iHHDGb3zzw6pICa9FaBNkNoHOVRyl8K75m87Vl+PKFxGW4/ XCEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nEOrne24; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c096ecsi12175581cf.246.2024.06.21.01.10.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:10:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nEOrne24; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org "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é --- 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 = sd->blk ? !blk_is_writable(sd->blk) : false; sd->wp_group_bits = sect; sd->wp_group_bmap = 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 = INVALID_ADDRESS; sd->erase_end = INVALID_ADDRESS; @@ -762,7 +765,7 @@ static const VMStateDescription sd_vmstate = { 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; case 56: /* CMD56: GEN_CMD */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { - APP_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd->vendor_data[sd->data_offset ++] = value; + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; } break; @@ -2155,12 +2157,11 @@ uint8_t sd_read_byte(SDState *sd) break; case 56: /* CMD56: GEN_CMD */ - if (sd->data_offset == 0) - APP_READ_BLOCK(sd->data_start, sd->blk_len); - ret = sd->data[sd->data_offset ++]; + ret = sd->vendor_data[sd->data_offset ++]; - if (sd->data_offset >= sd->blk_len) + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; + } break; default: From patchwork Fri Jun 21 08:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806333 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp653981wrt; Fri, 21 Jun 2024 01:08:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX5IYVTXpurwTcaWO9rEkvCZjPmpMW85o8LSPNLSVbpVnD/zpTS7JgLZjgwWIGbqERAJdQpl+w0mZbiU4WaN14P X-Google-Smtp-Source: AGHT+IFt6j0OKgnB47bVwG9Y+P+hy1BtaxNDYFZSclfruZcXWNBlSX2bJjw6ir5R+r7zO+S3gEnE X-Received: by 2002:a05:622a:1a85:b0:43e:39db:35ff with SMTP id d75a77b69052e-444a7a882f2mr81159701cf.62.1718957319436; Fri, 21 Jun 2024 01:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957319; cv=none; d=google.com; s=arc-20160816; b=a4ADUAUee9inAX/FsR3S1cv1hE2qFbabJOvZIoi0gkJ8n/EifrFN4JZkzhKCJ2WQ8L PxvTusA/IIS538s4agNh6j6Ll2Tf9ZfyW7OcHKE30RZ2VLGEazgSpA1WsPym5gyEbZMl 4qnf15eE1MOxWakTBDp8f9o4vmn4nm4ORlGKeWq9rLUd3QWKcckGhoTVW/EKhEqNyRYg K5pAW83ESAFMUqt48X8bhpEWOM6xO82odksNedVa5wOydxjqf1pGuTLemJP5FkWPzfkc O37Rni/ZeNokGWKRbRMckkm1wo1kUF/+GJ8W0PaFAUI0OqoY1e9wR8XqJ2skxUNHApAc T52g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pelbEr2AzQbex87Y1dyscTbX85voHzWIx5qB/yXa5yg=; fh=5TqT0mQS5XUfVX1n2NweoTPHCSrscaUgysJT1iIyWW4=; b=kL5VnLUtpugpACGhe0PMi/Mb5dUR++4XEOtp+Dw5d7kg9Nb4P9iweVG63XrZfzbjGl rg0jaq12HRec9Bp7ilZJP2sQYyaGBWF/E9rvc9FK0UlCivmbaJQZNadXX6mynjVETCLZ sFLbZsonLpthycwA2gevSilxv9Ks1W4ZiMLAedZE/bs0btFFCL/f7RNwviYSHvrVCD7h KsBMRq02ZK50/Nfz589G1TR70JP7U/TRP/9YXbhSkUbckAZM2FSfofMievB+N0DYY2L3 DJjeFgZTv9LnecCnbq83xG2s9Ucq6uef0xDZMxyzuTX/wAQoQ+Mvr0nMia0cgU7sDBvQ hEbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HoI9SVXL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2b719acsi11946381cf.184.2024.06.21.01.08.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HoI9SVXL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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, SDRequest req) } sd->state = sd_sendingdata_state; - *(uint32_t *) sd->data = sd_wpbits(sd, req.arg); + stl_be_p(sd->data, sd_wpbits(sd, req.arg)); sd->data_start = addr; sd->data_offset = 0; return sd_r1; From patchwork Fri Jun 21 08:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 806336 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp654360wrt; Fri, 21 Jun 2024 01:09:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXpH1L07b/7nYDQb3wsOYGnlbPX6u1uQY/2fzlyRwaOsJQieApaInSJf6aRlNYi7c7ApJQlT2etDX2re8vYpSsb X-Google-Smtp-Source: AGHT+IEQ2E68P6HCRW+L9lpQRdS2hh5ODH8eW86IxDE6jVl5ppz0+hd/fHzVV9luiBNArSdZTJz3 X-Received: by 2002:a05:620a:29c1:b0:795:50c9:a283 with SMTP id af79cd13be357-79bb3e2df84mr912798785a.20.1718957386581; Fri, 21 Jun 2024 01:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718957386; cv=none; d=google.com; s=arc-20160816; b=RpBjGbB1uqtqV7vl3vTYn+fSb+HwwEmFchNZ0RcPDsYDpb7XOpjDpVUHfv7CxtPuxY /p1u50wH0wdILK+WYFTsk4i0VjPQvRBcKdGQIA8yFyCVNJcLp6/l+/cWpORaRuqNshIC /xRlrMANKAldGaHVnugnDHdTX/k2vSy9XRgzRfTcubLZM0QG3d71Ko4QR+BN6pm/9ymH Xcn3roecTfV8HZciTE5I4dvtU8/dv387EXGBrN52nXpb4sdtxZAQT3R9OlEgM9Y7yv9H XglSfnrllm9efuwLc4j4C9uU8KbTsjhN9I3CBm6WMWLP2L6uYhubAmDZ80JrBd7aipBD mO0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hrM3efyRCu1QkbrTwevnMmKic+tLELy+xxKVC8SkWoM=; fh=5TqT0mQS5XUfVX1n2NweoTPHCSrscaUgysJT1iIyWW4=; b=HIK132ndvIbmUJ34xyt/ElT6ju2Q1t/T1R0Sw3zm84nNUYZuGQWntf4brqrPFCTkZw 9Dkk7T77poy9UPZEMivWamVAW1jq6hhnvXRx/d2M8oG2I112CFtBinLD/S91MAlfIvfe MHgO3mwVfzNHYN1arhczQI/NUCQ+8oBoUP6kllKgl9flS1RjW9khRfFLX10IJgvUWhSz SUINgmPBduXXKctqMq30W8iJTxCZkP7LdvE4BEC6oOg9Nrua9Ud9d8pTiTkkbeU8lIeg cWS0vT+wZWPEGp+kEEEaNIhYIDX7hv4zk/k+6LG0WkJhK9gisMDUrq9hszfk0abB4ITe Cf7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AUgC+bQW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce92bccfsi133080485a.405.2024.06.21.01.09.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 01:09:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AUgC+bQW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 = sd->blk_written; - + stl_be_p(sd->data, sd->blk_written); sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0;