mmc: queue: fix the cmdq thread wake up handling
If request has to be requeued (due to any DCMD commmand pending or cmdq
being halted) and if we change the task status to interruptible before
going to sleep then thread may not wakeup again. Note that
blk_requeue_request() doesn't trigger ->request_fn() again to wakeup
the thread.
Fix this issue by making cmdq thread wait for the completion of DCMD
or until the cmdq is unhalted. This change also simplifies the
cmdq thread function.
Change-Id: Iebffc993241e5fadb2962fedc44576566dc66e9c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[xiaonian@codeaurora.org: fixed merge conflicts, changed
cmd_flags to req_op() to judge if a req requires flush or
discard in mmc_cmdq_ready_wait() function]
Signed-off-by: Xiaonian Wang <xiaonian@codeaurora.org>
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 029a98b..2e75e18 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1914,9 +1914,7 @@
}
out:
blk_end_request(req, err, blk_rq_bytes(req));
-
- if (test_and_clear_bit(0, &ctx_info->req_starved))
- blk_run_queue(mq->queue);
+ wake_up(&ctx_info->wait);
mmc_put_card(card);
return err ? 1 : 0;
}
@@ -2030,9 +2028,7 @@
}
out:
blk_end_request(req, err, blk_rq_bytes(req));
-
- if (test_and_clear_bit(0, &ctx_info->req_starved))
- blk_run_queue(mq->queue);
+ wake_up(&ctx_info->wait);
mmc_put_card(card);
return err ? 1 : 0;
}
@@ -3432,10 +3428,9 @@
out:
host->err_mrq = NULL;
pm_runtime_mark_last_busy(&card->dev);
+ clear_bit(CMDQ_STATE_ERR, &ctx_info->curr_state);
+ wake_up(&ctx_info->wait);
__mmc_put_card(card);
-
- if (test_and_clear_bit(0, &ctx_info->req_starved))
- blk_run_queue(mrq->req->q);
}
/* invoked by block layer in softirq context */
@@ -3491,9 +3486,8 @@
out:
mmc_cmdq_clk_scaling_stop_busy(host, true, is_dcmd);
- if (!test_bit(CMDQ_STATE_ERR, &ctx_info->curr_state) &&
- test_and_clear_bit(0, &ctx_info->req_starved))
- blk_run_queue(mq->queue);
+ if (!test_bit(CMDQ_STATE_ERR, &ctx_info->curr_state))
+ wake_up(&ctx_info->wait);
mmc_put_card(host->card);
if (!ctx_info->active_reqs)