Skip to contentSkip to conversation

mmc: rpmb: poll mmc status after sending rpmb request

PATCH In review Ji Luo 2 participants 2 messages May 25, 2023 – Jun 14, 2023 MMC, SD and SDIO

lore
Share & tools
lore

Ji Luo

author
#0 lore raw

PATCH 1/1 mmc: rpmb: poll mmc status after sending rpmb request

polling the mmc status to make sure the rpmb request has been sent and the mmc is not in BUSY state. This avoids potential rpmb request failure during rpmb data write.

---
 drivers/mmc/rpmb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mmc/rpmb.c +10 -0
index b68d98573c..8bf19fd696 100644
@@ -94,6 +94,7 @@ static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
 	struct mmc_cmd cmd = {0};
 	struct mmc_data data;
 	struct sdhci_host *host = mmc->priv;
+	int timeout_ms = 1000;
 	int ret;
 
 	ret = mmc_set_blockcount(mmc, count, is_rel_write);
@@ -123,6 +124,15 @@ static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
 #endif
 		return 1;
 	}
+
+	/* poll for the ready status */
+	if (mmc_poll_for_busy(mmc, timeout_ms)) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+		printf("%s:mmc is busy!\n", __func__);
+#endif
+		return 1;
+	}
+
 	return 0;
 }
 static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ji Luo

polling the mmc status to make sure the rpmb request has been sent and the mmc is not in BUSY state. This avoids potential rpmb request failure during rpmb data write.

Quoted 32 lines
---
  drivers/mmc/rpmb.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/mmc/rpmb.c +10 -0
index b68d98573c..8bf19fd696 100644
@@ -94,6 +94,7 @@ static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
  	struct mmc_cmd cmd = {0};
  	struct mmc_data data;
  	struct sdhci_host *host = mmc->priv;
+	int timeout_ms = 1000;
  	int ret;
 
  	ret = mmc_set_blockcount(mmc, count, is_rel_write);
@@ -123,6 +124,15 @@ static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s,
  #endif
  		return 1;
  	}
+
+	/* poll for the ready status */
+	if (mmc_poll_for_busy(mmc, timeout_ms)) {
+#ifdef CONFIG_MMC_RPMB_TRACE
+		printf("%s:mmc is busy!\n", __func__);
+#endif
+		return 1;
+	}
+
  	return 0;
  }
  static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s,