* [PATCH-for-10.1 v2 0/3] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected
@ 2025-08-12 13:49 Philippe Mathieu-Daudé
2025-08-12 13:49 ` [PATCH-for-10.1 v2 1/3] " Philippe Mathieu-Daudé
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-08-12 13:49 UTC (permalink / raw)
To: qemu-devel
Cc: Guenter Roeck, Weiwei Li, qemu-riscv, Alex Bennée,
Palmer Dabbelt, Bin Meng, Daniel Henrique Barboza,
Alistair Francis, Liu Zhiwei, Alistair Francis,
Philippe Mathieu-Daudé, qemu-block
Trivial fix for the issue reported by Guenter here:
https://lore.kernel.org/qemu-devel/5b2dc427-f0db-4332-a997-fe0c82415acd@roeck-us.net/
- Return dummy byte when no card is connected
- Add a test
- Document ssi_transfer()
Since v1:
- Reworded patch #1 description (Alex)
- Removed '_' test method prefix (Alex)
Philippe Mathieu-Daudé (3):
hw/sd/ssi-sd: Return noise (dummy byte) when no card connected
tests/functional: Test SPI-SD adapter without SD card connected
hw/ssi: Document ssi_transfer() method
include/hw/ssi/ssi.h | 14 ++++++++++++++
hw/sd/ssi-sd.c | 4 ++++
tests/functional/test_riscv64_sifive_u.py | 22 +++++++++++++++++-----
3 files changed, 35 insertions(+), 5 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH-for-10.1 v2 1/3] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected
2025-08-12 13:49 [PATCH-for-10.1 v2 0/3] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected Philippe Mathieu-Daudé
@ 2025-08-12 13:49 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-08-12 13:49 UTC (permalink / raw)
To: qemu-devel
Cc: Guenter Roeck, Weiwei Li, qemu-riscv, Alex Bennée,
Palmer Dabbelt, Bin Meng, Daniel Henrique Barboza,
Alistair Francis, Liu Zhiwei, Alistair Francis,
Philippe Mathieu-Daudé, qemu-block
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-12 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 13:49 [PATCH-for-10.1 v2 0/3] hw/sd/ssi-sd: Return noise (dummy byte) when no card connected Philippe Mathieu-Daudé
2025-08-12 13:49 ` [PATCH-for-10.1 v2 1/3] " Philippe Mathieu-Daudé
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).