Skip to contentSkip to conversation

hw/sd/sdcard: fix SEND_STATUS for SPI cards

PATCH In review Ben Dooks 2 participants 2 messages Jul 24, 2025 – Jul 29, 2025

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 hw/sd/sdcard: fix SEND_STATUS for SPI cards

When the code re-organisation for the SEND_STATUS command was done it broke the ssi-sd code which is now throwing the error "ssi_sd: error: Unexpected response to cmd 13" or a similar one in newer code.

Fix this by returning sd_r1 instead of sd_r2_s

Fixes 807f6adac3773c18772bf ("hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13)")
---
 hw/sd/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sd.c +1 -1
index 80b59c8ff9..4472d101f2 100644
@@ -1388,7 +1388,7 @@ static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req)
     }
 
     if (sd_is_spi(sd)) {
-        return sd_r2_s;
+        return sd_r1;
     }
 
     return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0;
Signature · 1 line
2.37.2.352.g3c44437643
#1 lore raw
Quoted 18 lines · Ben Dooks

When the code re-organisation for the SEND_STATUS command was done it broke the ssi-sd code which is now throwing the error "ssi_sd: error: Unexpected response to cmd 13" or a similar one in newer code.

Fix this by returning sd_r1 instead of sd_r2_s

Fixes 807f6adac3773c18772bf ("hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13)")
---
  hw/sd/sd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sd.c +0 -0
index 80b59c8ff9..4472d101f2 100644

hw/sd/sd.c static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req) · line 1391

Quoted 5 lines
hw/sd/sd.c +1 -1
@@ -1388,7 +1388,7 @@ static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req)
      }
 
      if (sd_is_spi(sd)) {
-        return sd_r2_s;
+        return sd_r1;

Yeah this is what was suggested to Guenter previously:
https://lore.kernel.org/qemu-devel/[email protected]/

hw/sd/sd.c looks correct w.r.t. the spec; the issue seems to come from hw/sd/ssi-sd.c "implementation". I'll post a fix, let's see if it is acceptable for the next release.

Quoted 1 line
hw/sd/sd.c +0 -0
      }