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

Commit 43779b0f authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: qcom: rpmh: Do not send active votes in solver mode



When the controller is in solver mode, the RSC sequencer takes over the
control and s/w cannot send requests and receive interrupt response.
However, it is okay to write the sleep and wake votes.

Check for the state for the controller and the request in hand to see if
its okay to pass the request to the controller. Also, make the check for
all variants of the API, not just write_passthru.

Change-Id: I803ea0fe1c85df17763cc9700cc87816572470f3
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 2440b784
Loading
Loading
Loading
Loading
+36 −10
Original line number Diff line number Diff line
@@ -227,6 +227,21 @@ static struct rpmh_req *cache_rpm_request(struct rpmh_client *rc,
	return req;
}

static int check_ctrlr_state(struct rpmh_client *rc, enum rpmh_state state)
{
	struct rpmh_mbox *rpm = rc->rpmh;
	unsigned long flags;
	int ret = 0;

	/* Do not allow setting active votes when in solver mode */
	spin_lock_irqsave(&rpm->lock, flags);
	if (rpm->in_solver_mode && state == RPMH_AWAKE_STATE)
		ret = -EBUSY;
	spin_unlock_irqrestore(&rpm->lock, flags);

	return ret;
}

/**
 * __rpmh_write: Cache and send the RPMH request
 *
@@ -282,6 +297,7 @@ int rpmh_write_single_async(struct rpmh_client *rc, enum rpmh_state state,
			u32 addr, u32 data)
{
	struct rpmh_msg *rpm_msg;
	int ret;

	if (IS_ERR_OR_NULL(rc))
		return -EINVAL;
@@ -289,6 +305,10 @@ int rpmh_write_single_async(struct rpmh_client *rc, enum rpmh_state state,
	if (rpmh_standalone)
		return 0;

	ret = check_ctrlr_state(rc, state);
	if (ret)
		return ret;

	rpm_msg = get_msg_from_pool(rc);
	if (!rpm_msg)
		return -ENOMEM;
@@ -333,6 +353,10 @@ int rpmh_write_single(struct rpmh_client *rc, enum rpmh_state state,
	if (rpmh_standalone)
		return 0;

	ret = check_ctrlr_state(rc, state);
	if (ret)
		return ret;

	rpm_msg.cmd[0].addr = addr;
	rpm_msg.cmd[0].data = data;
	rpm_msg.msg.num_payload = 1;
@@ -385,10 +409,15 @@ int rpmh_write_async(struct rpmh_client *rc, enum rpmh_state state,
			struct tcs_cmd *cmd, int n)
{
	struct rpmh_msg *rpm_msg;
	int ret;

	if (rpmh_standalone)
		return 0;

	ret = check_ctrlr_state(rc, state);
	if (ret)
		return ret;

	rpm_msg = __get_rpmh_msg_async(rc, state, cmd, n);
	if (IS_ERR(rpm_msg))
		return PTR_ERR(rpm_msg);
@@ -429,6 +458,10 @@ int rpmh_write(struct rpmh_client *rc, enum rpmh_state state,
	if (rpmh_standalone)
		return 0;

	ret = check_ctrlr_state(rc, state);
	if (ret)
		return ret;

	memcpy(rpm_msg.cmd, cmd, n * sizeof(*cmd));
	rpm_msg.msg.num_payload = n;

@@ -467,8 +500,6 @@ int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
	int count = 0;
	int ret, i, j, k;
	bool complete_set;
	unsigned long flags;
	struct rpmh_mbox *rpm;

	if (IS_ERR_OR_NULL(rc) || !cmd || !n)
		return -EINVAL;
@@ -476,14 +507,9 @@ int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
	if (rpmh_standalone)
		return 0;

	/* Do not allow setting wake votes when in solver mode */
	rpm = rc->rpmh;
	spin_lock_irqsave(&rpm->lock, flags);
	if (rpm->in_solver_mode && state == RPMH_WAKE_ONLY_STATE) {
		spin_unlock_irqrestore(&rpm->lock, flags);
		return -EIO;
	}
	spin_unlock_irqrestore(&rpm->lock, flags);
	ret = check_ctrlr_state(rc, state);
	if (ret)
		return ret;

	while (n[count++])
		;