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

Commit e43901b4 authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: qcom: rpmh: Use wait_event instead of wait_event_interruptible



wait_event_interruptible() breaks out of wait for all sorts of signals,
which is undesirable here. wait_event() waits for the completion events
that we want.

Reboot issues a signal to all waiting threads and once the wait is
complete, we wind up the stack and the RPMH message objects that were
allocated in the stack are no longer valid. wait_event() solves this
issue by continuing to wait, until the completion signal is received.

Change-Id: I3a0e8da5a317a4bc5c0599c30aa2f745890259db
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent cb6b743e
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ static void rpmh_rx_cb(struct mbox_client *cl, void *msg)
	struct rpmh_msg *rpm_msg = container_of(msg, struct rpmh_msg, msg);

	atomic_dec(rpm_msg->wait_count);
	wake_up_interruptible(rpm_msg->waitq);
	wake_up(rpm_msg->waitq);
}

static void rpmh_tx_done(struct mbox_client *cl, void *msg, int r)
@@ -151,7 +151,7 @@ static void rpmh_tx_done(struct mbox_client *cl, void *msg, int r)
	/* Signal the blocking thread we are done */
	if (waitq) {
		atomic_dec(wc);
		wake_up_interruptible(waitq);
		wake_up(waitq);
	}
}

@@ -329,9 +329,7 @@ int rpmh_write_single(struct rpmh_client *rc, enum rpmh_state state,
	if (ret < 0)
		return ret;

	ret = wait_event_interruptible(waitq, atomic_read(&wait_count) == 0);
	if (ret)
		return ret;
	wait_event(waitq, atomic_read(&wait_count) == 0);

	return rpm_msg.err;
}
@@ -423,13 +421,11 @@ int rpmh_write(struct rpmh_client *rc, enum rpmh_state state,
	rpm_msg.msg.num_payload = n;

	ret = __rpmh_write(rc, state, &rpm_msg);
	if (ret < 0)
		return ret;

	ret = wait_event_interruptible(waitq, atomic_read(&wait_count) == 0);
	if (ret)
		return ret;

	wait_event(waitq, atomic_read(&wait_count) == 0);

	return rpm_msg.err;
}
EXPORT_SYMBOL(rpmh_write);
@@ -509,8 +505,7 @@ int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
			if (ret < 0)
				return ret;
		}
		return wait_event_interruptible(waitq,
					atomic_read(&wait_count) == 0);
		wait_event(waitq, atomic_read(&wait_count) == 0);
	} else {
		/* Send Sleep requests to the controller, expect no response */
		for (i = 0; i < count; i++) {
@@ -522,6 +517,8 @@ int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
		}
		return 0;
	}

	return 0;
}
EXPORT_SYMBOL(rpmh_write_passthru);

@@ -624,9 +621,7 @@ int rpmh_read(struct rpmh_client *rc, u32 addr, u32 *resp)
		return ret;

	/* Wait until the response is received from RPMH */
	ret = wait_event_interruptible(waitq, atomic_read(&wait_count) == 0);
	if (ret)
		return ret;
	wait_event(waitq, atomic_read(&wait_count) == 0);

	/* Read the data back from the tcs_mbox_msg structrure */
	*resp = rpm_msg.cmd[0].data;