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

Commit 2d319658 authored by Sahitya Tummala's avatar Sahitya Tummala
Browse files

mmc: core: Fix unclocked access in get_xfer_remain/stop_request



The unclocked access could happen in the following scenario -

1. mmcqd thread is waiting for previously submitted io to be done
2. before this io is done, it is woken up due to is_urgent event
3. mmcqd thread is running and is processing the is_urgent event
4. Just about the same time the previously submitted io is done and
it sets is_done_rcv flag, tries to wake up mmcqd thread and release
host clock so as to gate the clocks.

If step 3 and 4 happen at the same time, then clocks will be gated off
before is_urgent is completely handled. Hence, make sure to hold the
clock before invoking get_xfer_remain and stop_request host->op.

Change-Id: If03177bf5e28cc217cc8e86b10d81d4adbab78b9
Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
parent 3311f658
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -621,8 +621,10 @@ static bool mmc_should_stop_curr_req(struct mmc_host *host)
	    (host->areq->cmd_flags & REQ_FUA))
		return false;

	mmc_host_clk_hold(host);
	remainder = (host->ops->get_xfer_remain) ?
		host->ops->get_xfer_remain(host) : -1;
	mmc_host_clk_release(host);
	return (remainder > 0);
}

@@ -647,6 +649,7 @@ static int mmc_stop_request(struct mmc_host *host)
				mmc_hostname(host));
		return -ENOTSUPP;
	}
	mmc_host_clk_hold(host);
	err = host->ops->stop_request(host);
	if (err) {
		pr_debug("%s: Call to host->ops->stop_request() failed (%d)\n",
@@ -681,6 +684,7 @@ static int mmc_stop_request(struct mmc_host *host)
		goto out;
	}
out:
	mmc_host_clk_release(host);
	return err;
}