From patchwork Tue Jul 2 09:19: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: 809057 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116710wru; Tue, 2 Jul 2024 02:23:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCvEBz+iOy2eqytGHdDZ0DlHYI7iXwJJ9oLs5oHvimo85N1pHXDbCaEkc9b8PAaux91osJvWV3P1cZ7pvjADcQ X-Google-Smtp-Source: AGHT+IEIzobXW4IOyj0Ddaj4cnVDQmLmi4YYhkSw5Hrp2KUWYxPZkxE2GIKbO/WQzA1hTlBTNIYn X-Received: by 2002:a05:620a:1373:b0:79d:65ac:dbb8 with SMTP id af79cd13be357-79d7ba82429mr920336785a.52.1719912213686; Tue, 02 Jul 2024 02:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912213; cv=none; d=google.com; s=arc-20160816; b=MGreuJExAysiwWKy0muTojhRA+GtRwnwFA/EbR3srsh2fLH2FNT/P7AGaOcEC8pPxw rwDJBo14vFnaamsyxqYitrzwjku5W5b7FVGYplqoRcuFKBE7AWnuMhlH84sfgEFW5QUr 1zCbEt3TE5gdDx1SILyGHzXzwJDjOSTaNbUQKN8pQ1KOI211FgPHOS5BjLK8JQLMw7dx LpSWp9GMPZRIA+C/wsjznWof7mSkQyqUxLrDAMEeVDpXZVbQfNXOZ7rWah9CLlMPHjeA xzRM8MQPGYcuJRxCrfYG0Zw3tvpzYc1cWqywdcxzzQYeoKWcEBx5A/s/SiTXfl0gnr+I vR/w== 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=+BJVqbuDB73td3icnKEL+Hn1IcWwELHqxD1Mx9jzZME=; fh=ewxdS7CPFYTNGqGRyltnxNKJTn3/a8RG3KK2A4AdeHA=; b=dswrP6M38QeH7ZW7BdtrB+hGENBLP+qvugYuWhMuFcmonDFgFps1MNr1DSXRjodZKy MgqNiGWScze5tAg8y9YIkbqwr+3kB1EZjibmT4ismrISjZ9nG9/Mt8MOPREeVzQjuPmg /ERNK+hWFxRw9UOFW8+pyLl+8snjoUi3gtZdmf/bvmhkrSCCXs6RLH38zfYbnOcSDFH/ neGg0oCKwhfYv6VqTKbBBtSeyDjxno1V2J8Lv546OeYlNRe3nltZ2JeutMu+xI6fHA95 qZFqIZ8Fi0UPs71o8nXOTZ++N7Tz2qAQSTJMr+ez3unPY9RFqfdAMEXyrfw7AgMPBV7D doGw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SN9ZqQb2; 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-79d6933d377si967709485a.647.2024.07.02.02.23.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:33 -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=SN9ZqQb2; 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 1sOZhu-000187-Bh; Tue, 02 Jul 2024 05:21:50 -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 1sOZhq-00017X-Sq for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:48 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhm-0006R6-8M for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:45 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ebe785b234so40005991fa.1 for ; Tue, 02 Jul 2024 02:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912095; x=1720516895; 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=+BJVqbuDB73td3icnKEL+Hn1IcWwELHqxD1Mx9jzZME=; b=SN9ZqQb2ehnCRFlBL5bHkWdxGBIhpsiuuNYFscBAzs1Fd+JisZiijgV/OR8iAe2YP3 rqSOyMpXj3va7W3GCmZhEQAQjfySW37nppdZdmxb38cTLC1OB1W/9ApwTtAJ+kIJMSS7 qfbgYueMvXnt8pjIKAmt2CoolVcBVwb/GOj7pspDZCO8Ex8MOM+NuNiIkYpE147D929D eFR5F2mKLFMCrl40zNDbSzHsTUZMSbQS7RRi9f2Tbkdoe77ePHVqxiFZ24op+OZrQiVQ Df53Ko84p/Q41zsfarf1LkAN4aGKtwZB6QX0fOb4z9xMnHsamKsOlScFtwwB5+/SJKBp Z0bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912095; x=1720516895; 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=+BJVqbuDB73td3icnKEL+Hn1IcWwELHqxD1Mx9jzZME=; b=htDGm6ISl4Es3h7u3bAffGLD8kEDQaIbP1XW47QhWhQy8iADKiqcREOkB7JupYlJNe uyBKJ2MaK6U6/AWcmQ2oNoEZkAVSNrTkx153b8o6npX4pAVK196sEosKDmyAWr28ZPRn OtbGDOfPRpiBSnIGkNo3RuIRwLTEM4KX3Y/2Pz01M5rwQJ+AnmCi5FI9L4ErpkGJBZVB WXXo+t/5NzNRhTkByPmV2ZhZafiDoHc65hTScgXGXbc1uMQcqe8rDnq5wOfwyQj3iwtO 6PmOcTOdBH0qXCGKkQEYl7+Op8IPzkxxrxDAJsgnruw77mxCyzpxgiQ0dkkhOIJhTDSA fYVg== X-Gm-Message-State: AOJu0YzbPNETf2VL8/EVj+nMo2uLILqgVKzKPvy4JSnmtaNNGMVA72Cp yvNPmiBp4MINhiKpTHBVlVhoe7c+aTBikIEuc7OvazE4Po1asIN2daaeX224S6zl5uXjiqUTeEU T X-Received: by 2002:a2e:9793:0:b0:2ec:5518:9550 with SMTP id 38308e7fff4ca-2ee5e390c38mr55097991fa.10.1719912095005; Tue, 02 Jul 2024 02:21:35 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a2bcsm187830895e9.36.2024.07.02.02.21.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Peter Maydell Subject: [PULL 07/67] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Tue, 2 Jul 2024 11:19:50 +0200 Message-ID: <20240702092051.45754-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=philmd@linaro.org; helo=mail-lj1-x22f.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=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), 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. Fixes: a1bb27b1e9 ("Initial SD card emulation") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Peter Maydell Message-Id: <20240628070216.92609-9-philmd@linaro.org> --- 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 1e9530f9ae..54bb0ff1c9 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1669,8 +1669,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;