qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: QEMU <qemu-devel@nongnu.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Subject: [PATCH 1/2] hw/sd: Fix incorrect idle state reporting in R1 response for SPI mode
Date: Mon, 10 Nov 2025 19:05:06 +0800	[thread overview]
Message-ID: <20251110110507.1641042-2-bmeng.cn@gmail.com> (raw)
In-Reply-To: <20251110110507.1641042-1-bmeng.cn@gmail.com>

Since commit b66f73a0 ("hw/sd: Add SDHC support for SD card SPI-mode"),
the CARD_POWER_UP bit in the OCR register has been set after reset.
Therefore, checking this bit against zero in sd_response_r1_make() to
determine the card’s idle state is incorrect in SPI mode. As a result,
QEMU makes the U-Boot mmc-spi driver believe the card never leaves the
reset state.

Fixes: 1585ab9f ("hw/sd/sdcard: Fill SPI response bits in card code")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2945
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 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 9c86c016cc..5aae541363 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -789,8 +789,7 @@ static size_t sd_response_size(SDState *sd, sd_rsp_type_t rtype)
 static void sd_response_r1_make(SDState *sd, uint8_t *response)
 {
     if (sd_is_spi(sd)) {
-        response[0] = sd->state == sd_idle_state
-                   && !FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP);
+        response[0] = sd->state == sd_idle_state;
         response[0] |= FIELD_EX32(sd->card_status, CSR, ERASE_RESET) << 1;
         response[0] |= FIELD_EX32(sd->card_status, CSR, ILLEGAL_COMMAND) << 2;
         response[0] |= FIELD_EX32(sd->card_status, CSR, COM_CRC_ERROR) << 3;
-- 
2.34.1



  reply	other threads:[~2025-11-10 11:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 11:05 [PATCH 0/2] hw/sd: Fix broken ssi-sd implementation since v9.1.0 Bin Meng
2025-11-10 11:05 ` Bin Meng [this message]
2025-11-12  7:55   ` [PATCH 1/2] hw/sd: Fix incorrect idle state reporting in R1 response for SPI mode Philippe Mathieu-Daudé
2025-11-10 11:05 ` [PATCH 2/2] hw/sd: Fix ACMD41 state machine in " Bin Meng
2025-11-18 18:19   ` Philippe Mathieu-Daudé
2025-11-10 11:57 ` [PATCH 0/2] hw/sd: Fix broken ssi-sd implementation since v9.1.0 Philippe Mathieu-Daudé
2025-11-10 13:16   ` Bin Meng
2025-11-18 18:19 ` Philippe Mathieu-Daudé
2025-11-19 10:44 ` Michael Tokarev
2025-11-19 10:52   ` Michael Tokarev
2025-11-19 14:31   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251110110507.1641042-2-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=trini@konsulko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).