Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60b8c133 authored by Ritesh Harjani's avatar Ritesh Harjani Committed by Gerrit - the friendly Code Review server
Browse files

mmc: core: Change wait events to timeout types



There is no point in waiting infinitely for
wait_event_interruptible_timeout. Add a timeout logic in
wait_events in mmc_blk_cmdq_issue_rw_rq &
mmc_cmdq_halt_on_empty_queue.

Change-Id: I5cced42b8c0c6a20dc92394af0a0d5245ea9d729
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
parent 47906484
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -2697,9 +2697,18 @@ static int mmc_blk_cmdq_issue_rw_rq(struct mmc_queue *mq, struct request *req)
	 * empty faster and we will be able to scale up to Nominal frequency
	 * when needed.
	 */
	if (!ret && (host->clk_scaling.state == MMC_LOAD_LOW))
		wait_event_interruptible(ctx->queue_empty_wq,
					(!ctx->active_reqs));

	if (!ret && (host->clk_scaling.state == MMC_LOAD_LOW)) {

		ret = wait_event_interruptible_timeout(ctx->queue_empty_wq,
			(!ctx->active_reqs &&
			!test_bit(CMDQ_STATE_ERR, &ctx->curr_state)),
			msecs_to_jiffies(MMC_CMDQ_WAIT_EVENT_TIMEOUT_MS));
		if (!ret)
			pr_err("%s: queue_empty_wq timeout case? ret = (%d)\n",
				__func__, ret);
		ret = 0;
	}

	if (ret) {
		/* clear pending request */
+14 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <linux/of.h>
#include <linux/pm.h>
#include <linux/jiffies.h>
#include <linux/sched/debug.h>

#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
@@ -346,9 +347,19 @@ int mmc_cmdq_halt_on_empty_queue(struct mmc_host *host)
{
	int err = 0;

	err = wait_event_interruptible(host->cmdq_ctx.queue_empty_wq,
				(!host->cmdq_ctx.active_reqs));
	if (host->cmdq_ctx.active_reqs) {
	err = wait_event_interruptible_timeout(host->cmdq_ctx.queue_empty_wq,
			(!host->cmdq_ctx.active_reqs),
			msecs_to_jiffies(MMC_CMDQ_WAIT_EVENT_TIMEOUT_MS));

	if (WARN_ON(!err && host->cmdq_ctx.active_reqs)) {
		pr_err("%s: %s: timeout case? host-claimed(%d), claim-cnt(%d), claim-comm(%s), active-reqs(0x%x)\n",
			mmc_hostname(host), __func__, host->claimed,
			host->claim_cnt, host->claimer->comm,
			host->cmdq_ctx.active_reqs);
		if (host->claimer)
			sched_show_task(host->claimer);
		return -EBUSY;
	} else if (host->cmdq_ctx.active_reqs) {
		pr_err("%s: %s: unexpected active requests (%lu)\n",
			mmc_hostname(host), __func__,
			host->cmdq_ctx.active_reqs);
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ struct mmc_card;
struct mmc_request;

#define MMC_CMD_RETRIES        3
#define MMC_CMDQ_WAIT_EVENT_TIMEOUT_MS	    60000

struct mmc_bus_ops {
	void (*remove)(struct mmc_host *);