From patchwork Tue Jun 25 05:53: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: 807240 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2195621wrt; Mon, 24 Jun 2024 22:55:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXYR5kI7vX738IlANEb5llveXPvu3pdDZBghuUly9lykXF9bXHeQEv3yERSSP6dvFhigUVpdsJYL5X+eN36+EeF X-Google-Smtp-Source: AGHT+IE+s40wKBxTGbk9HzjoPGpgldTKONxw/HmTulE2VBpphY1Of7vQdyC2NEuLx50S33aGUH5I X-Received: by 2002:a67:ec4e:0:b0:48f:3e67:78d2 with SMTP id ada2fe7eead31-48f52b50f0fmr6755391137.26.1719294914947; 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=Ymz2oKRAqyOMeEkaFxxtTC5YC4tfP086QyQ0kdgOkkeledIA5P3TOsqL4yqrbhLl55 JXFLkmVhe3xG++khRM3qEcQ5nnQmrpxfsopWVty1CM/h3xpjxDs2nYfq7hywx3QmIwzY duoiS+aSCpY2uzuO/aSjeKOeS3UP/BLUb/2T7msUFL2yHsUXc689UkzR9lZDX74PmIS3 D26vgQAx/1M3rqITr0m4jsQN65f0ELP/FkZSBGSI3tafbtexSiuRIZdpRkRzpAS+Sx+K jnY7yexLbnKzQV3lbapz8XKtEQyKxB+5Cs7zIFfMhPBOw4bQ7wXFPtq+3kHiAhT4Xs5h YrDQ== 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=UJN6KVZ4KFMiBqbYHgPGiBcO7JIk6P/og2YV9T7n/3A=; fh=GKTErd9AQuz8EtLVaBm0jy/HTz/AwRiMD9Bu+kmtebE=; b=RRLTOEh7CaGV6J7qNZ8QSWABqG8OetXRa2CpVY5iG9j27dmVuduOWkvlmHG3iR5OPs yZ3A7pIv1zYFHnN9zMrQbCpWSAJjUvnMDTKDAdtsRBsJfJvYQBejmc3SOxztC/KUoNYi rLu20L0i3k7IovEm42xCnzg4stuX6O5oua3MLbqHPwHtRz3FLrcs5EVKMpAuHr9Jz99E gsF27ybP91U8cYW3rjwf4nIpdbHiwdz27DP3G2YHZDFUgTLA9D1EJkGgiot6a7T0BkMq 3++/UIsW9paQr41ogU6wjTady8VOMk3C8fi/zQO5PKQUIBo0dS86DsGXmOkT4mZDkKLm +iOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u5Wt2HsQ; 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-444c2c0aa39si97630811cf.278.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=u5Wt2HsQ; 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 1sLz8c-0001yT-03; Tue, 25 Jun 2024 01:54:42 -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 1sLz8Z-0001tG-UZ for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:39 -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 1sLz8Y-0001dz-Du for qemu-devel@nongnu.org; Tue, 25 Jun 2024 01:54:39 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4248ea53493so14912805e9.3 for ; Mon, 24 Jun 2024 22:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719294876; x=1719899676; 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=UJN6KVZ4KFMiBqbYHgPGiBcO7JIk6P/og2YV9T7n/3A=; b=u5Wt2HsQpuXTs4R8DmoC9v0oQst0mwNwc0oj6NTwYKSyBpoNycK+d5ROAbT9pujyLV wo/TW6JTcLqvt3hWdFJgVrlmXZojVxSG3e46ewTPzKAXbXN9XiKa2tQg8fCdjpbqD73K Fi+6hpvFqPKS1QOa7tE8oKx9lL7kuL2CKo9DVROcwCtAI2ULb11p/vXKujJgTyvpiO1R tS6qpiOx8tqUbY8KvJMhPAqveiuiuSrlE7B+FNTrmfPSp+NrNloE5JAXTZPiNlXOLLss 3PvF8sHTznWobzvX0gw/BWGROrZH+mTHhZ3jieiPxgEFgcs3O8n/B3MdOUDFEJD3LL2A hqDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719294876; x=1719899676; 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=UJN6KVZ4KFMiBqbYHgPGiBcO7JIk6P/og2YV9T7n/3A=; b=mpVSjSzBCyeGM9MEY6CZa82fcPk+OSut1aexuT4E4apZ4TfM5Pnx/bC9aSahVuhv7r dAWpKR1sOZTpRka7O8eywOGf9b+g5uV8GVO68C85FSnWWujHPpNxrEHRffUkwkaWinlh OcHBoUtqzFYl+KqHBVynJzdn1g3/ETldupKImVC0zIS2s3fBtsQDSOa5febv1JYFYxsE BI5Cb/aEBpIFzXXg9csylMnN0I5vN/oQ7S1Bfa3JkbxUbuMxMYAa3DC1r6fHyR+KRZ7j 8+p1w2c88I72iUbX33qVDLyfERAC5vSccxRj97E3DxGVQaSR22XKdfkmp7iM66yxiEqA gEIw== X-Gm-Message-State: AOJu0YwqE/sGGxYpDJv/pimZPmDH2lyWwYQXQN4agE6oj/Np6rWeZNJQ CxR3gYIGxVI8962BK2dPzuDE3ZtBObjb8ixFzfeoJAD51ZidJJW6BgJZBCgNLWotByANBaXDVNR u X-Received: by 2002:a05:600c:4da1:b0:424:8e88:a6a6 with SMTP id 5b1f17b1804b1-4248e88a753mr53922045e9.8.1719294876771; Mon, 24 Jun 2024 22:54:36 -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-366383f6355sm11849035f8f.17.2024.06.24.22.54.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 22:54:36 -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 07/12] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Tue, 25 Jun 2024 07:53:48 +0200 Message-ID: <20240625055354.23273-8-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::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 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é 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b604b8e71f..0742ba8b38 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;