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;