Hi Manuele,

On 4/11/26 12:16, Manuele Conti wrote:
When a write start token immediately follows the R1 response,
the SPI SD controller may still be in SSI_SD_RESPONSE state
and discard the token.

Recognize single-block and multi-block write start tokens
when the SD card is ready to receive data, allowing the
write operation to proceed without an additional dummy byte.

What guest is being run? Can you share the reproducer?

Unfortunately I only have access to the Simplified Spec and this
seems to be covered by the Full one.


Signed-off-by: Manuele Conti <[email protected]>
---
  hw/sd/ssi-sd.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index a3a9f0c7efd..13c87c49cfb 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -185,6 +185,12 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev, 
uint32_t val)
              s->mode = SSI_SD_CMD;
              return SSI_DUMMY;
          }
+        /* The next byte after R1 may already be the write start token. */
+        if (sdbus_receive_ready(&s->sdbus) &&
+            (val == SSI_TOKEN_SINGLE || val == SSI_TOKEN_MULTI_WRITE)) {
+            s->mode = SSI_SD_DATA_WRITE;
+            return SSI_DUMMY;
+        }
          if (sdbus_data_ready(&s->sdbus)) {
              DPRINTF("Data read\n");
              s->mode = SSI_SD_DATA_START;


Reply via email to