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

Commit eefd721b authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

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

parents 84822319 43779b0f
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++])
		;