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;