From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Gustavo Romero" <gustavo.romero@linaro.org>,
"Bin Meng" <bmeng.cn@gmail.com>,
qemu-block@nongnu.org
Subject: [PULL 1/2] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected
Date: Tue, 12 Aug 2025 18:56:41 +0200 [thread overview]
Message-ID: <20250812165642.81157-2-philmd@linaro.org> (raw)
In-Reply-To: <20250812165642.81157-1-philmd@linaro.org>
Commit 1585ab9f1ba ("hw/sd/sdcard: Fill SPI response bits in card
code") exposed a bug in the SPI adapter: if no SD card is plugged,
we are returning "there is a card with an error". This is wrong,
we shouldn't return any particular packet response, but the noise
shifted on the MISO line. Return the dummy byte, otherwise we get:
qemu-system-riscv64: ../hw/sd/ssi-sd.c:160: ssi_sd_transfer: Assertion `s->arglen > 0' failed.
Reported-by: Guenter Roeck <linux@roeck-us.net>
Fixes: 775616c3ae8 ("Partial SD card SPI mode support")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20250812140415.70153-2-philmd@linaro.org>
---
hw/sd/ssi-sd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 594dead19ee..3aacbd03871 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -89,6 +89,10 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev, uint32_t val)
SDRequest request;
uint8_t longresp[5];
+ if (!sdbus_get_inserted(&s->sdbus)) {
+ return SSI_DUMMY;
+ }
+
/*
* Special case: allow CMD12 (STOP TRANSMISSION) while reading data.
*
--
2.49.0
next prev parent reply other threads:[~2025-08-12 16:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 16:56 [PULL 0/2] SD/MMC patches for 2025-08-12 Philippe Mathieu-Daudé
2025-08-12 16:56 ` Philippe Mathieu-Daudé [this message]
2025-08-13 6:16 ` [PULL 1/2] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected Michael Tokarev
2025-08-13 7:22 ` Philippe Mathieu-Daudé
2025-08-12 17:02 ` [PULL 2/2] tests/functional: Test SPI-SD adapter without SD " Philippe Mathieu-Daudé
2025-08-12 23:36 ` [PULL 0/2] SD/MMC patches for 2025-08-12 Stefan Hajnoczi
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=20250812165642.81157-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=bmeng.cn@gmail.com \
--cc=gustavo.romero@linaro.org \
--cc=linux@roeck-us.net \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).