From 2ce873cba6043d2cc45e70e487f74851002c625a Mon Sep 17 00:00:00 2001 From: Ritesh Harjani Date: Thu, 8 Oct 2015 17:54:01 +0530 Subject: [PATCH] mmc: block: cmdq discard should use softirq completion path Currently cmdq discard requests are not using same softirq completion path as other cmdq request. So there is no way to detect any error and handle it in case of error of DCMD requests. Make cmdq discard requests use blk_complete_requests which complete via softirq completion path. Change-Id: I1e03c81bc6fee8266cf1c86bada015e548770d7a Signed-off-by: Ritesh Harjani --- drivers/mmc/card/block.c | 49 ++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 026886b949bb..6364a777db80 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -1602,13 +1602,12 @@ static int mmc_blk_cmdq_issue_discard_rq(struct mmc_queue *mq, struct mmc_blk_data *md = mq->data; struct mmc_card *card = md->queue.card; struct mmc_cmdq_req *cmdq_req = NULL; - struct mmc_host *host = card->host; - struct mmc_cmdq_context_info *ctx_info = &host->cmdq_ctx; unsigned int from, nr, arg; int err = 0; if (!mmc_can_erase(card)) { err = -EOPNOTSUPP; + blk_end_request(req, err, blk_rq_bytes(req)); goto out; } @@ -1637,16 +1636,9 @@ static int mmc_blk_cmdq_issue_discard_rq(struct mmc_queue *mq, } err = mmc_cmdq_erase(cmdq_req, card, from, nr, arg); clear_dcmd: - /* clear pending request */ - if (cmdq_req) { - BUG_ON(!test_and_clear_bit(cmdq_req->tag, - &ctx_info->active_reqs)); - clear_bit(CMDQ_STATE_DCMD_ACTIVE, &ctx_info->curr_state); - } + mmc_host_clk_hold(card->host); + blk_complete_request(req); out: - blk_end_request(req, err, blk_rq_bytes(req)); - wake_up(&ctx_info->wait); - mmc_put_card(card); return err ? 1 : 0; } @@ -1700,12 +1692,11 @@ static int mmc_blk_cmdq_issue_secdiscard_rq(struct mmc_queue *mq, struct mmc_card *card = md->queue.card; struct mmc_cmdq_req *cmdq_req = NULL; unsigned int from, nr, arg; - struct mmc_host *host = card->host; - struct mmc_cmdq_context_info *ctx_info = &host->cmdq_ctx; int err = 0; if (!(mmc_can_secure_erase_trim(card))) { err = -EOPNOTSUPP; + blk_end_request(req, err, blk_rq_bytes(req)); goto out; } @@ -1751,16 +1742,9 @@ static int mmc_blk_cmdq_issue_secdiscard_rq(struct mmc_queue *mq, MMC_SECURE_TRIM2_ARG); } clear_dcmd: - /* clear pending request */ - if (cmdq_req) { - BUG_ON(!test_and_clear_bit(cmdq_req->tag, - &ctx_info->active_reqs)); - clear_bit(CMDQ_STATE_DCMD_ACTIVE, &ctx_info->curr_state); - } + mmc_host_clk_hold(card->host); + blk_complete_request(req); out: - blk_end_request(req, err, blk_rq_bytes(req)); - wake_up(&ctx_info->wait); - mmc_put_card(card); return err ? 1 : 0; } @@ -3168,6 +3152,19 @@ static enum blk_eh_timer_return mmc_blk_cmdq_req_timed_out(struct request *req) else mrq->data->error = -ETIMEDOUT; + if (mrq->cmd && mrq->cmd->error) { + if (!(mrq->req->cmd_flags & REQ_FLUSH)) { + /* + * Notify completion for non flush commands like + * discard that wait for DCMD finish. + */ + set_bit(CMDQ_STATE_REQ_TIMED_OUT, + &ctx_info->curr_state); + complete(&mrq->completion); + return BLK_EH_NOT_HANDLED; + } + } + if (test_bit(CMDQ_STATE_REQ_TIMED_OUT, &ctx_info->curr_state) || test_bit(CMDQ_STATE_ERR, &ctx_info->curr_state)) return BLK_EH_NOT_HANDLED; @@ -3228,14 +3225,6 @@ static void mmc_blk_cmdq_err(struct mmc_queue *mq) } else if (mrq->cmd && mrq->cmd->error) { /* DCMD commands */ err = mrq->cmd->error; - - /* - * Notify completion for non flush commands like discard - * that wait for DCMD finish. - */ - if (!(mrq->req->cmd_flags & REQ_FLUSH)) { - complete(&mrq->completion); - } } reset: