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

Commit fe328cb4 authored by Skylar Chang's avatar Skylar Chang Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa3: add mhi state check after calling mhi-API



Add mhi state check after getting errors from
mhi-API to return IPA_QMI_ERR_INCOMPATIBLE_STATE_V01
when mhi is not in active state.

Change-Id: I6907a533e912172f4098b3f9c00f102d4f2ea1f1
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 2f0b9d5e
Loading
Loading
Loading
Loading
+33 −8
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ struct imp_qmi_cache {
	struct ipa_mhi_ready_indication_msg_v01 ready_ind;
	struct ipa_mhi_alloc_channel_req_msg_v01 alloc_ch_req;
	struct ipa_mhi_alloc_channel_resp_msg_v01 alloc_ch_resp;
	struct ipa_mhi_clk_vote_resp_msg_v01 clk_vote_resp;
};

struct imp_mhi_driver {
@@ -380,7 +381,12 @@ static int __imp_configure_mhi_device(
			ridx++;
			resp->alloc_resp_arr_len = ridx;
			resp->resp.result = IPA_QMI_RESULT_FAILURE_V01;
			/* return INCOMPATIBLE_STATE if mhi not active */
			if (mhi_is_active(imp_ctx->md.mhi_dev))
				resp->resp.error = IPA_QMI_ERR_INVALID_ID_V01;
			else
				resp->resp.error =
					IPA_QMI_ERR_INCOMPATIBLE_STATE_V01;
			return -EINVAL;
		}

@@ -436,6 +442,7 @@ static int __imp_configure_mhi_device(
		IMP_DBG("Configuring MHI device for ch %d\n", ch->props.id);
		ret = mhi_device_configure(imp_ctx->md.mhi_dev, ch->props.dir,
			ch_config, 2);
		/* configure mhi-host, no need check mhi state */
		if (ret) {
			IMP_ERR("mhi_device_configure failed for ch %d\n",
				req->tr_info_arr[i].ch_id);
@@ -478,7 +485,7 @@ struct ipa_mhi_alloc_channel_resp_msg_v01 *imp_handle_allocate_channel_req(
	if (imp_ctx->state != IMP_READY) {
		IMP_ERR("invalid state %d\n", imp_ctx->state);
		resp->resp.result = IPA_QMI_RESULT_FAILURE_V01;
		resp->resp.error = IPA_QMI_ERR_INCOMPATIBLE_STATE_V01;
		resp->resp.error = IPA_QMI_ERR_INTERNAL_V01;
		mutex_unlock(&imp_ctx->mutex);
		return resp;
	}
@@ -542,7 +549,11 @@ struct ipa_mhi_alloc_channel_resp_msg_v01 *imp_handle_allocate_channel_req(
			.is_success = 0;
		resp->alloc_resp_arr_len++;
		resp->resp.result = IPA_QMI_RESULT_FAILURE_V01;
		/* return INCOMPATIBLE_STATE if mhi not active */
		if (mhi_is_active(imp_ctx->md.mhi_dev))
			resp->resp.error = IPA_QMI_ERR_INTERNAL_V01;
		else
			resp->resp.error = IPA_QMI_ERR_INCOMPATIBLE_STATE_V01;
		goto fail_smmu;
	}

@@ -592,23 +603,29 @@ struct ipa_mhi_alloc_channel_resp_msg_v01 *imp_handle_allocate_channel_req(
 *
 * Return: 0 on success, negative otherwise
 */
int imp_handle_vote_req(bool vote)
struct ipa_mhi_clk_vote_resp_msg_v01
	*imp_handle_vote_req(bool vote)
{
	int ret;
	struct ipa_mhi_clk_vote_resp_msg_v01 *resp =
	&imp_ctx->qmi.clk_vote_resp;

	IMP_DBG_LOW("vote %d\n", vote);
	memset(resp, 0, sizeof(struct ipa_mhi_clk_vote_resp_msg_v01));
	resp->resp.result = IPA_QMI_RESULT_FAILURE_V01;
	resp->resp.error = IPA_QMI_ERR_INTERNAL_V01;

	mutex_lock(&imp_ctx->mutex);
	if (imp_ctx->state != IMP_STARTED) {
		IMP_ERR("unexpected vote when in state %d\n", imp_ctx->state);
		mutex_unlock(&imp_ctx->mutex);
		return -EPERM;
		return resp;
	}

	if (vote == imp_ctx->lpm_disabled) {
		IMP_ERR("already voted/devoted %d\n", vote);
		mutex_unlock(&imp_ctx->mutex);
		return -EPERM;
		return resp;
	}
	mutex_unlock(&imp_ctx->mutex);

@@ -622,7 +639,14 @@ int imp_handle_vote_req(bool vote)
		ret = mhi_device_get_sync(imp_ctx->md.mhi_dev);
		if (ret) {
			IMP_ERR("mhi_sync_get failed %d\n", ret);
			return ret;
			resp->resp.result = IPA_QMI_RESULT_FAILURE_V01;
			/* return INCOMPATIBLE_STATE if mhi not active */
			if (mhi_is_active(imp_ctx->md.mhi_dev))
				resp->resp.error = IPA_QMI_ERR_INVALID_ID_V01;
			else
				resp->resp.error =
					IPA_QMI_ERR_INCOMPATIBLE_STATE_V01;
			return resp;
		}
	} else {
		mhi_device_put(imp_ctx->md.mhi_dev);
@@ -635,7 +659,8 @@ int imp_handle_vote_req(bool vote)
		imp_ctx->lpm_disabled = false;
	mutex_unlock(&imp_ctx->mutex);

	return 0;
	resp->resp.result = IPA_QMI_RESULT_SUCCESS_V01;
	return resp;
}

static int imp_read_iova_from_dtsi(const char *node, struct imp_iova_addr *out)
+4 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ void imp_handle_modem_ready(void);
struct ipa_mhi_alloc_channel_resp_msg_v01 *imp_handle_allocate_channel_req(
	struct ipa_mhi_alloc_channel_req_msg_v01 *req);

int imp_handle_vote_req(bool vote);
struct ipa_mhi_clk_vote_resp_msg_v01 *imp_handle_vote_req(bool vote);

void imp_handle_modem_shutdown(void);

@@ -33,9 +33,10 @@ static inline struct ipa_mhi_alloc_channel_resp_msg_v01
		return NULL;
}

static inline int imp_handle_vote_req(bool vote)
static inline struct ipa_mhi_clk_vote_resp_msg_v01
	*imp_handle_vote_req(bool vote)
{
	return -EPERM;
	return NULL;
}

static inline  void imp_handle_modem_shutdown(void)
+3 −9
Original line number Diff line number Diff line
@@ -285,25 +285,19 @@ static void ipa3_handle_mhi_vote_req(struct qmi_handle *qmi_handle,
	const void *decoded_msg)
{
	struct ipa_mhi_clk_vote_req_msg_v01 *vote_req;
	struct ipa_mhi_clk_vote_resp_msg_v01 resp;
	struct ipa_mhi_clk_vote_resp_msg_v01 *resp;
	int rc;

	vote_req = (struct ipa_mhi_clk_vote_req_msg_v01 *)decoded_msg;
	IPAWANDBG("Received QMI_IPA_MHI_CLK_VOTE_REQ_V01(%d)\n",
		vote_req->mhi_vote);
	rc = imp_handle_vote_req(vote_req->mhi_vote);
	if (rc) {
		resp.resp.result = IPA_QMI_RESULT_FAILURE_V01;
		resp.resp.error = IPA_QMI_ERR_INTERNAL_V01;
	} else {
		resp.resp.result = IPA_QMI_RESULT_SUCCESS_V01;
	}
	resp = imp_handle_vote_req(vote_req->mhi_vote);
	IPAWANDBG("start sending QMI_IPA_MHI_CLK_VOTE_RESP_V01\n");
	rc = qmi_send_response(qmi_handle, sq, txn,
		QMI_IPA_MHI_CLK_VOTE_RESP_V01,
		IPA_MHI_CLK_VOTE_RESP_MSG_V01_MAX_MSG_LEN,
		ipa_mhi_clk_vote_resp_msg_v01_ei,
		&resp);
		resp);

	if (rc < 0)
		IPAWANERR("QMI_IPA_MHI_CLK_VOTE_RESP_V01 failed\n");