Skip to contentSkip to conversation

hw/sd.c: Add missing state change for SD_STATUS, SEND_NUM_WR_BLOCKS

PATCH Applied Peter Maydell 2 participants 2 messages Feb 18, 2011 – Feb 24, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/sd.c: Add missing state change for SD_STATUS, SEND_NUM_WR_BLOCKS

The SD_STATUS and SEND_NUM_WR_BLOCKS commands are supposed to cause the card to send data back to the host. However sd.c was missing the state change to sd_sendingdata_state for these commands, with the effect that the Linux driver would either hang indefinitely waiting for nonexistent data (pl181) or read zeroes and provoke a qemu warning message (omap).

---
 hw/sd.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
hw/sd.c +2 -0
index 789ca84..5e29752 100644
@@ -1168,6 +1168,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
     case 13:	/* ACMD13: SD_STATUS */
         switch (sd->state) {
         case sd_transfer_state:
+            sd->state = sd_sendingdata_state;
             sd->data_start = 0;
             sd->data_offset = 0;
             return sd_r1;
@@ -1182,6 +1183,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
         case sd_transfer_state:
             *(uint32_t *) sd->data = sd->blk_written;
 
+            sd->state = sd_sendingdata_state;
             sd->data_start = 0;
             sd->data_offset = 0;
             return sd_r1;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 11 lines · Peter Maydell

The SD_STATUS and SEND_NUM_WR_BLOCKS commands are supposed to cause the card to send data back to the host. However sd.c was missing the state change to sd_sendingdata_state for these commands, with the effect that the Linux driver would either hang indefinitely waiting for nonexistent data (pl181) or read zeroes and provoke a qemu warning message (omap).

---
 hw/sd.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Thanks, applied.

Quoted 25 lines
hw/sd.c +2 -0
index 789ca84..5e29752 100644
@@ -1168,6 +1168,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
     case 13:	/* ACMD13: SD_STATUS */
         switch (sd->state) {
         case sd_transfer_state:
+            sd->state = sd_sendingdata_state;
             sd->data_start = 0;
             sd->data_offset = 0;
             return sd_r1;
@@ -1182,6 +1183,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
         case sd_transfer_state:
             *(uint32_t *) sd->data = sd->blk_written;
 
+            sd->state = sd_sendingdata_state;
             sd->data_start = 0;
             sd->data_offset = 0;
             return sd_r1;
Signature · 1 line
1.7.1
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net