[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/67] hw/sd/sdcard: Simplify sd_inactive_state handling
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 10/67] hw/sd/sdcard: Simplify sd_inactive_state handling |
Date: |
Tue, 2 Jul 2024 11:19:53 +0200 |
Card entering sd_inactive_state powers off, and won't respond
anymore. Handle that once when entering sd_do_command().
Remove condition always true in sd_cmd_GO_IDLE_STATE().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Message-Id: <20240628070216.92609-12-philmd@linaro.org>
---
hw/sd/sd.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 824cb47856..30c1d299d4 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1078,10 +1078,8 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd,
SDRequest req)
/* CMD0 */
static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req)
{
- if (sd->state != sd_inactive_state) {
- sd->state = sd_idle_state;
- sd_reset(DEVICE(sd));
- }
+ sd->state = sd_idle_state;
+ sd_reset(DEVICE(sd));
return sd_is_spi(sd) ? sd_r1 : sd_r0;
}
@@ -1580,7 +1578,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
SDRequest req)
switch (sd->state) {
case sd_ready_state:
case sd_identification_state:
- case sd_inactive_state:
return sd_illegal;
case sd_idle_state:
if (rca) {
@@ -1801,6 +1798,11 @@ int sd_do_command(SDState *sd, SDRequest *req,
return 0;
}
+ if (sd->state == sd_inactive_state) {
+ rtype = sd_illegal;
+ goto send_response;
+ }
+
if (sd_req_crc_validate(req)) {
sd->card_status |= COM_CRC_ERROR;
rtype = sd_illegal;
--
2.41.0
- [PULL 00/67] SD/MMC patches for 2024-07-02, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 01/67] hw/sd/sdcard: Deprecate support for spec v1.10, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 02/67] hw/sd/sdcard: Track last command used to help logging, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 03/67] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 04/67] hw/sd/sdcard: Trace requested address computed by sd_req_get_address(), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 08/67] hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 06/67] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 05/67] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 07/67] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 09/67] hw/sd/sdcard: Assign SDCardStates enum values, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 10/67] hw/sd/sdcard: Simplify sd_inactive_state handling,
Philippe Mathieu-Daudé <=
- [PULL 11/67] hw/sd/sdcard: Add direct reference to SDProto in SDState, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 12/67] hw/sd/sdcard: Extract sd_blk_len() helper, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 13/67] hw/sd/sdcard: Introduce definitions for EXT_CSD register, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 14/67] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 15/67] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 16/67] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 18/67] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 17/67] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 19/67] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 20/67] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30), Philippe Mathieu-Daudé, 2024/07/02