mmc: block: Add check to mmc_blk_part_switch
Sometimes after failing RPMB access due to card in bad voltgae state,
If issue USER parition access request,it fails as card is already in
bad state. Fix this by adding error handling to mmc_blk_part_switch()
and by resetting the block whenever partition switch fails.
Change-Id: I245683b0b0a06b13938036dbc37e87ed1ef70b89
Signed-off-by: Pavan Anamula <pavana@codeaurora.org>
[xiaonian@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Xiaonian Wang <xiaonian@codeaurora.org>
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 0bcbf05..221d403 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -135,6 +135,7 @@
#define MMC_BLK_DISCARD BIT(2)
#define MMC_BLK_SECDISCARD BIT(3)
#define MMC_BLK_FLUSH BIT(4)
+#define MMC_BLK_PARTSWITCH BIT(5)
/*
* Only set in main mmc_blk_data associated
@@ -1431,6 +1432,9 @@
EXT_CSD_PART_CONFIG, part_config,
card->ext_csd.part_time);
if (ret) {
+ pr_err("%s: mmc_blk_part_switch failure, %d -> %d\n",
+ mmc_hostname(card->host), main_md->part_curr,
+ md->part_type);
if (md->part_type == EXT_CSD_PART_CONFIG_ACC_RPMB)
mmc_retune_unpause(card->host);
return ret;
@@ -3951,6 +3955,7 @@
unsigned long flags;
unsigned int cmd_flags = req ? req->cmd_flags : 0;
bool req_is_special = mmc_req_is_special(req);
+ int err;
if (req && !mq->mqrq_prev->req) {
/* claim host only for the first request */
@@ -3964,7 +3969,17 @@
}
ret = mmc_blk_part_switch(card, md);
+
if (ret) {
+ err = mmc_blk_reset(md, card->host, MMC_BLK_PARTSWITCH);
+ if (!err) {
+ pr_err("%s: mmc_blk_reset(MMC_BLK_PARTSWITCH) succeeded.\n",
+ mmc_hostname(host));
+ mmc_blk_reset_success(md, MMC_BLK_PARTSWITCH);
+ } else
+ pr_err("%s: mmc_blk_reset(MMC_BLK_PARTSWITCH) failed.\n",
+ mmc_hostname(host));
+
if (req) {
blk_end_request_all(req, -EIO);
}