]> granicus.if.org Git - esp-idf/commitdiff
sdmmc: don't whitelist the opcodes when handling response timeout
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 17 Aug 2017 16:25:17 +0000 (00:25 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Wed, 11 Apr 2018 03:06:50 +0000 (11:06 +0800)
All the commands which do not have a response must have their flags set
accordingly. Therefore the host will not send RTO interrupt if response
is not expected. It is a bug in the code logic if it happens otherwise.

components/driver/sdmmc_transaction.c

index 78e3e287230483d066f400fcb748be42a3c66d94..7039b74e72c1fa1a9e59396db15be21f00fbbff6 100644 (file)
@@ -287,18 +287,16 @@ static void process_command_response(uint32_t status, sdmmc_command_t* cmd)
             cmd->response[3] = 0;
         }
     }
-
-    if ((status & SDMMC_INTMASK_RTO) &&
-        cmd->opcode != MMC_ALL_SEND_CID &&
-        cmd->opcode != MMC_SELECT_CARD &&
-        cmd->opcode != MMC_STOP_TRANSMISSION) {
+    if (status & SDMMC_INTMASK_RTO) {
+        // response timeout is only possible when response is expected
+        assert(cmd->flags & SCF_RSP_PRESENT);
         cmd->error = ESP_ERR_TIMEOUT;
     } else if ((cmd->flags & SCF_RSP_CRC) && (status & SDMMC_INTMASK_RCRC)) {
         cmd->error = ESP_ERR_INVALID_CRC;
     } else if (status & SDMMC_INTMASK_RESP_ERR) {
         cmd->error = ESP_ERR_INVALID_RESPONSE;
     }
-    if (cmd->error != 0) {
+    if (cmd->error != ESP_OK) {
         if (cmd->data) {
             sdmmc_host_dma_stop();
         }