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

Commit 247b5213 authored by Siva Kumar Akkireddi's avatar Siva Kumar Akkireddi Committed by Gerrit - the friendly Code Review server
Browse files

msm: mhi_dev: Do not flush events to host if channel is stopped



Do not flush completion events to host when the channel is
stopped or closed as the flush function might use invalid
data for the channel. Also add a check for channel state
in the write API.

Change-Id: I0e882fab4891cac60ddbb17f4be1dfeb502ecf92
Signed-off-by: default avatarSiva Kumar Akkireddi <sivaa@codeaurora.org>
parent 37c2499e
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -444,10 +444,11 @@ static int mhi_dev_flush_transfer_completion_events(struct mhi_dev *mhi,
	struct event_req *flush_ereq;

	/*
	 * Channel got closed with transfers pending
	 * Channel got stopped or closed with transfers pending
	 * Do not send completion events to host
	 */
	if (ch->state == MHI_DEV_CH_CLOSED) {
	if (ch->state == MHI_DEV_CH_CLOSED ||
		ch->state == MHI_DEV_CH_STOPPED) {
		mhi_log(MHI_MSG_DBG, "Ch %d closed with %d writes pending\n",
			ch->ch_id, ch->pend_wr_count + 1);
		return -ENODEV;
@@ -2124,11 +2125,13 @@ static void mhi_dev_transfer_completion_cb(void *mreq)
			req->len, DMA_FROM_DEVICE);

	/*
	 * Channel got closed with transfers pending
	 * Channel got stopped or closed with transfers pending
	 * Do not trigger callback or send cmpl to host
	 */
	if (ch->state == MHI_DEV_CH_CLOSED) {
		mhi_log(MHI_MSG_DBG, "Ch %d closed with %d writes pending\n",
	if (ch->state == MHI_DEV_CH_CLOSED ||
		ch->state == MHI_DEV_CH_STOPPED) {
		mhi_log(MHI_MSG_DBG,
			"Ch %d not in started state, %d writes pending\n",
			ch->ch_id, ch->pend_wr_count + 1);
		return;
	}
@@ -2976,6 +2979,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq)
	size_t bytes_written = 0;
	uint32_t tre_len = 0, suspend_wait_timeout = 0;
	bool async_wr_sched = false;
	enum mhi_ctrl_info info;

	if (WARN_ON(!wreq || !wreq->client || !wreq->buf)) {
		pr_err("%s: invalid parameters\n", __func__);
@@ -3024,6 +3028,14 @@ int mhi_dev_write_channel(struct mhi_req *wreq)

	mutex_lock(&ch->ch_lock);

	rc = mhi_ctrl_state_info(ch->ch_id, &info);
	if (rc || (info != MHI_STATE_CONNECTED)) {
		mhi_log(MHI_MSG_ERROR, "Channel %d not started by host\n",
				ch->ch_id);
		mutex_unlock(&ch->ch_lock);
		return -ENODEV;
	}

	ch->pend_wr_count++;
	if (ch->state == MHI_DEV_CH_STOPPED) {
		mhi_log(MHI_MSG_ERROR,