From e262646e12acd6c1132e03d57fea20680a503251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 8 Aug 2025 14:57:44 +0200 Subject: hw/sd/ssi-sd: Return noise (dummy byte) when no card connected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Fixes: 775616c3ae8 ("Partial SD card SPI mode support") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Guenter Roeck Reviewed-by: Alex Bennée Reviewed-by: Gustavo Romero Tested-by: Alex Bennée Message-Id: <20250812140415.70153-2-philmd@linaro.org> --- hw/sd/ssi-sd.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hw') diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index 594dead..3aacbd0 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. * -- cgit v1.1