diff mbox series

[v2,4/4] mmc: core: update host->card after getting RCA for SD card

Message ID ca874be0c6eea046d82dc85d66d4665d266cf8c9.1583470026.git.nguyenb@codeaurora.org
State New
Headers show
Series SD card bug fixes | expand

Commit Message

Bao D. Nguyen March 6, 2020, 4:58 a.m. UTC
From: Sahitya Tummala <stummala@codeaurora.org>

Make the host->card available before tuning is invoked for SD card.
In the sdhci_msm_execute_tuning(), we will send CMD13 only if
host->card is present because it needs the card->rca as its
argument to be sent. For emmc, host->card is already updated
immediately after the mmc_alloc_card(). In the similar way,
this change is for SD card. Without this change, tuning functionality
will not be able to send CMD13 to make sure the card is ready
for next data command. If the last tuning command failed
and we did not send CMD13 to ensure card is in transfer state,
the next read/write command will fail.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Bao D. Nguyen <nguyenb@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
---
 drivers/mmc/core/sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 76c7add..f0872e3 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -989,6 +989,7 @@  static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 		err = mmc_send_relative_addr(host, &card->rca);
 		if (err)
 			goto free_card;
+		host->card = card;
 	}
 
 	if (!oldcard) {
@@ -1100,12 +1101,13 @@  static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 		goto free_card;
 	}
 done:
-	host->card = card;
 	return 0;
 
 free_card:
-	if (!oldcard)
+	if (!oldcard) {
+		host->card = NULL;
 		mmc_remove_card(card);
+	}
 
 	return err;
 }