From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Guenter Roeck" <linux@roeck-us.net>,
qemu-riscv@nongnu.org,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Bin Meng" <bmeng.cn@gmail.com>,
"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
"Alistair Francis" <Alistair.Francis@wdc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
qemu-block@nongnu.org
Subject: [PATCH-for-10.1 1/2] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected
Date: Fri, 8 Aug 2025 15:51:14 +0200 [thread overview]
Message-ID: <20250808135115.77310-2-philmd@linaro.org> (raw)
In-Reply-To: <20250808135115.77310-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 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>
---
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-08 13:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 13:51 [PATCH-for-10.1 0/2] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected Philippe Mathieu-Daudé
2025-08-08 13:51 ` Philippe Mathieu-Daudé [this message]
2025-08-08 20:12 ` [PATCH-for-10.1 1/2] " Guenter Roeck
2025-08-12 13:20 ` Alex Bennée
2025-08-12 13:27 ` Philippe Mathieu-Daudé
2025-08-08 13:51 ` [PATCH-for-10.1 2/2] tests/functional: Test SPI-SD adapter without SD " Philippe Mathieu-Daudé
2025-08-12 13:24 ` Alex Bennée
2025-08-12 13:28 ` Philippe Mathieu-Daudé
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=20250808135115.77310-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=Alistair.Francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=linux@roeck-us.net \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.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).