summaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorKonstantin Dorfman <kdorfman@codeaurora.org>2015-06-09 10:56:41 +0300
committerSubhash Jadavani <subhashj@codeaurora.org>2016-05-31 15:26:44 -0700
commitc85443aa9797c2f2dfc52b9004fa14704ce1a479 (patch)
tree778a94bc1a896a197ded851ced55a51bfe67dabe /drivers/mmc
parentc6bb958c9b3c87f7a0f1015aefc1bd2583ddd0e4 (diff)
mmc: block: add card device reference counting for CQ mode
Since error handling could race with runtime suspend, increase usage_count for the card device will prevent this race. Change-Id: Ie95a3c631f519c7993b0032f0b674871b64e4cb6 Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/card/block.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index d1f95b57deab..5d95402c5fb2 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1599,7 +1599,7 @@ out:
if (test_and_clear_bit(0, &ctx_info->req_starved))
blk_run_queue(mq->queue);
- mmc_release_host(host);
+ mmc_put_card(card);
return err ? 1 : 0;
}
@@ -1715,7 +1715,7 @@ out:
if (test_and_clear_bit(0, &ctx_info->req_starved))
blk_run_queue(mq->queue);
- mmc_release_host(host);
+ mmc_put_card(card);
return err ? 1 : 0;
}
@@ -2941,7 +2941,7 @@ static void mmc_blk_cmdq_shutdown(struct mmc_queue *mq)
return;
}
- mmc_claim_host(card->host);
+ mmc_get_card(card);
/* disable CQ mode in card */
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_CMDQ, 0,
@@ -2954,7 +2954,7 @@ static void mmc_blk_cmdq_shutdown(struct mmc_queue *mq)
host->card->cmdq_init = false;
}
out:
- mmc_release_host(card->host);
+ mmc_put_card(card);
}
static enum blk_eh_timer_return mmc_blk_cmdq_req_timed_out(struct request *req)
@@ -2989,6 +2989,7 @@ static void mmc_blk_cmdq_err(struct mmc_queue *mq)
struct mmc_card *card = mq->card;
struct mmc_cmdq_context_info *ctx_info = &host->cmdq_ctx;
+ pm_runtime_get_sync(&card->dev);
err = mmc_cmdq_halt(host, true);
if (err) {
pr_err("halt: failed: %d\n", err);
@@ -3050,6 +3051,9 @@ unhalt:
mmc_cmdq_halt(host, false);
out:
+ pm_runtime_mark_last_busy(&card->dev);
+ pm_runtime_put_autosuspend(&card->dev);
+
if (test_and_clear_bit(0, &ctx_info->req_starved))
blk_run_queue(mrq->req->q);
}
@@ -3101,8 +3105,8 @@ out:
if (!test_bit(CMDQ_STATE_ERR, &ctx_info->curr_state) &&
test_and_clear_bit(0, &ctx_info->req_starved))
blk_run_queue(mq->queue);
- mmc_release_host(host);
+ mmc_put_card(host->card);
if (blk_queue_stopped(mq->queue) && !ctx_info->active_reqs)
complete(&mq->cmdq_shutdown_complete);
return;
@@ -3363,14 +3367,14 @@ static int mmc_blk_cmdq_issue_rq(struct mmc_queue *mq, struct request *req)
struct mmc_card *card = md->queue.card;
unsigned int cmd_flags = req ? req->cmd_flags : 0;
- mmc_claim_host(card->host);
+ mmc_get_card(card);
ret = mmc_blk_cmdq_part_switch(card, md);
if (ret) {
pr_err("%s: %s: partition switch failed %d\n",
md->disk->disk_name, __func__, ret);
if (req)
blk_end_request_all(req, ret);
- mmc_release_host(card->host);
+ mmc_put_card(card);
goto switch_failure;
}