Merge "platform: msm_shared: Retry on data timeout error"
diff --git a/platform/msm_shared/mmc_sdhci.c b/platform/msm_shared/mmc_sdhci.c
index 3bc7110..20eb840 100644
--- a/platform/msm_shared/mmc_sdhci.c
+++ b/platform/msm_shared/mmc_sdhci.c
@@ -2178,7 +2178,7 @@
 	 * As per emmc 4.5 spec section 7.4.27, calculate the erase timeout
 	 * erase_timeout = 300ms * ERASE_TIMEOUT_MULT * num_erase_grps
 	 */
-	erase_timeout = (300 * 1000 * card->ext_csd[MMC_ERASE_TIMEOUT_MULT] * num_erase_grps);
+	erase_timeout = ((uint64_t)300 * 1000 * card->ext_csd[MMC_ERASE_TIMEOUT_MULT] * num_erase_grps);
 
 	/* Send CMD38 to perform erase */
 	if (mmc_send_erase(dev, erase_timeout))
diff --git a/platform/msm_shared/sdhci.c b/platform/msm_shared/sdhci.c
index bfab9f1..f114b47 100644
--- a/platform/msm_shared/sdhci.c
+++ b/platform/msm_shared/sdhci.c
@@ -441,7 +441,13 @@
 
 		if (int_status  & SDHCI_INT_STS_CMD_COMPLETE)
 			break;
-		else if (int_status & SDHCI_ERR_INT_STAT_MASK && !host->tuning_in_progress)
+		/*
+		* Some controllers set the data timout first on issuing an erase & take time
+		* to set data complete interrupt. We need to wait hoping the controller would
+		* set data complete
+		*/
+		else if (int_status & SDHCI_ERR_INT_STAT_MASK && !host->tuning_in_progress &&
+				!((REG_READ16(host, SDHCI_ERR_INT_STS_REG) & SDHCI_DAT_TIMEOUT_MASK)))
 			goto err;
 
 		/*