From patchwork Tue Jun 25 05:53: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: 807238 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195617wrt; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2RHH67wrzm8uvVZ+zJ/r6t8IYkVJ6eOg3L9KpyZOAgyVEGe0SXp3L1JD4FXm9GWm+tg+e8EjFlT631muZLKhb X-Google-Smtp-Source: AGHT+IFoeuFJlFzJclvTsZyZlDOkLjYZn2ev9ZPLESxzcaHbgOiumCCkdwQwz+BSInUpbGmjWptv X-Received: by 2002:a0c:e0d4:0:b0:6b5:683:df5e with SMTP id 6a1803df08f44-6b5409e0b74mr57593386d6.32.1719294914629; Mon, 24 Jun 2024 22:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719294914; cv=none; d=google.com; s=arc-20160816; b=O7Ow3NRPI83IpPvXVq73SNJCaa6Cmo5eY8hXdfFqoNdU0trPTqvLwoL9dFA8SJlDsJ ASW2aAa/ujLtBqvUAqjNePUNcjdXiAS6oub4l12TJ75I6e2h7qvguJIXnvMrgt6QveKY +hbMsxBZbuzX4JZcvEsRcQa5vDSHRkwmJudzPwtFlGrTH6exgrvf6SpPjYvFOIvhNk5g E8w3AVUiNGtImWEmUq0Srv9Nujs5jzB3cm+0W4UnhZ8BcEW6xcnPXdFv+uqofKsyJjex NjWzjZHKHpAnS9U2Pxa3sEpi7uBF8mZlnujHPyb2zyXIT/xn9f15F6X6nZuRgMHS++pC iC2A== 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=Ee/yL80E0AWtVNbCxQaoN9WZIZ5QGojNiR7WBNpSOHo=; fh=GKTErd9AQuz8EtLVaBm0jy/HTz/AwRiMD9Bu+kmtebE=; b=L3TvxZO6u5UOlwDatO+/iXZnkgJJIb2g9Jz5xtSKPoKwbcyZ2R3cEljhqMnzwwgCNz 8ec0afKr/Y8NLF35a3upIiBp4/i0miguZ1FtIIN2qszGHHvJ13t2j78HdFkLFfWZBkWL ZXmKATDLoJhapSAkgy2JEgACNglZxm1OKTAAECV5iwbE0Qm4ULooIwpEMUjyXFAwM02J epJs1JQA54DbSrbgs9/Kn96/mCBYB3k9ruFq+xmQsY/xdmb6SoL9RD1gWdYoywtMxgj0 ePtgTqXqqxzm4g831XRTkq/QUWIXCQrSqJrvA3zhyr3dRBpS1Jx9PYW5sYLj/KtZXXeN B5ig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XzBJdxLr; 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-6b536d02f41si68995136d6.472.2024.06.24.22.55.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 22:55:14 -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=XzBJdxLr; 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 1sLz8U-0001ha-WF; Tue, 25 Jun 2024 01:54:35 -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 1sLz8U-0001hP-9N for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:34 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLz8S-0001d3-Pv for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:34 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-366edce6493so1544176f8f.3 for ; Mon, 24 Jun 2024 22:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294871; x=1719899671; 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=Ee/yL80E0AWtVNbCxQaoN9WZIZ5QGojNiR7WBNpSOHo=; b=XzBJdxLrNJSWQg8q1FGJcRJsNq+nwT/g8qQpaxeyOM+4Xjkplyex/5elNlXI5rjsVc GJxpQN4ldxDvDcttUD2RlYk2PuvmnWSe3BnEbnP8+hHeCWApT+6uWhan6t0Lw4fF+Ja5 NA17v22c0eslrn6qTl3YE5m3o6VQdCFn1BO4dTmUuIS8/wkfpazXRBTLZWN70GfUeFXa feqCpq7TkSEsy58sexDd0wFyuhMfXvCPo9Af2uUbrAvblkSNjaCqy3/c3SbEDkCc818t vN6xGFZfasLRZZFquGSJrEAHTg2mx/+Y+zzXnEI/GDVf2KiuZ3XcxKD5h8zQdwwArwJy a7GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294871; x=1719899671; 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=Ee/yL80E0AWtVNbCxQaoN9WZIZ5QGojNiR7WBNpSOHo=; b=sJWNQNIOGmT0duw3bhGh5fcuJuabfbLCYEQnI6awpl6C2tJvg48/yns6kfLlo8GIyC nUdN6uR/BjVxht5vEKPzbm3buNE3+inULvksSrD6kjzYS5ii0EvVMNEJXwM4NNX3rI/T fCPNL+Q67cEk9SqYkd3mGvOsrUJsEUUuEq5KosU/b7565WiwhNlFHRS2yoWdmDZ4lF/v wyOZoOVdGApkEwZKi6rO12iQUf7W/2HkJG42P/GOdywAH2oD50dI2qvA6EoIEZFpJyfQ JnY+bSlbSMwrWoDzOhVaLigu4JRX9CygUbxW/k7FKOSX7OCb+5Vlr40bW+XRoa24eSVK H3Dg== X-Gm-Message-State: AOJu0YxJ2yCmy0DDAU8Cp3B6/3+QTcNJ/x/8u34f1n12fno2JCIjXoos IKTHJOunN9NvPyKQA2PVxkV684r7rc3eve0ul0vjU296EyKkku2sDRe1sjxtb0kF3dEYJulciWr I X-Received: by 2002:a05:6000:178a:b0:360:7092:728 with SMTP id ffacd0b85a97d-366e95ddf7cmr5466388f8f.55.1719294871034; Mon, 24 Jun 2024 22:54:31 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367003b1fc8sm846275f8f.57.2024.06.24.22.54.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Bin Meng , Peter Maydell Subject: [PATCH v2 06/12] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30) Date: Tue, 25 Jun 2024 07:53:47 +0200 Message-ID: <20240625055354.23273-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625055354.23273-1-philmd@linaro.org> References: <20240625055354.23273-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Tested-by: Cédric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0f8440efcc..b604b8e71f 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;