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

Commit b364b5e5 authored by Mohammed Javid's avatar Mohammed Javid Committed by Gerrit - the friendly Code Review server
Browse files

ipa3: fix suspend sequence for MHI ADPL pipe



Make changes to suspend both the DL pipes (data pipe and ADPL pipe)
whenever MHI pipes are suspended to avoid stale access from IPA HW.

Change-Id: I0592bd92bab1fda4b7a51c7bcd2712f95cec9e6b
Signed-off-by: default avatarChaitanya Pratapa <cpratapa@codeaurora.org>
Signed-off-by: default avatarMohammed Javid <mjavid@codeaurora.org>
parent 7cac96b4
Loading
Loading
Loading
Loading
+32 −19
Original line number Diff line number Diff line
@@ -1727,13 +1727,14 @@ static int ipa_mhi_wait_for_cons_release(void)
	return 0;
}

static int ipa_mhi_suspend_channels(struct ipa_mhi_channel_ctx *channels)
static int ipa_mhi_suspend_channels(struct ipa_mhi_channel_ctx *channels,
	int max_channels)
{
	int i;
	int res;

	IPA_MHI_FUNC_ENTRY();
	for (i = 0; i < IPA_MHI_MAX_UL_CHANNELS; i++) {
	for (i = 0; i < max_channels; i++) {
		if (!channels[i].valid)
			continue;
		if (channels[i].state !=
@@ -1763,7 +1764,7 @@ static int ipa_mhi_suspend_channels(struct ipa_mhi_channel_ctx *channels)
}

static int ipa_mhi_stop_event_update_channels(
		struct ipa_mhi_channel_ctx *channels)
		struct ipa_mhi_channel_ctx *channels, int max_channels)
{
	int i;
	int res;
@@ -1772,7 +1773,7 @@ static int ipa_mhi_stop_event_update_channels(
		return 0;

	IPA_MHI_FUNC_ENTRY();
	for (i = 0; i < IPA_MHI_MAX_UL_CHANNELS; i++) {
	for (i = 0; i < max_channels; i++) {
		if (!channels[i].valid)
			continue;
		if (channels[i].state !=
@@ -1831,14 +1832,14 @@ static bool ipa_mhi_check_pending_packets_from_host(void)
}

static int ipa_mhi_resume_channels(bool LPTransitionRejected,
		struct ipa_mhi_channel_ctx *channels)
		struct ipa_mhi_channel_ctx *channels, int max_channels)
{
	int i;
	int res;
	struct ipa_mhi_channel_ctx *channel;

	IPA_MHI_FUNC_ENTRY();
	for (i = 0; i < IPA_MHI_MAX_UL_CHANNELS; i++) {
	for (i = 0; i < max_channels; i++) {
		if (!channels[i].valid)
			continue;
		if (channels[i].state !=
@@ -1887,7 +1888,8 @@ static int ipa_mhi_suspend_ul(bool force, bool *empty, bool *force_clear)

	*force_clear = false;

	res = ipa_mhi_suspend_channels(ipa_mhi_client_ctx->ul_channels);
	res = ipa_mhi_suspend_channels(ipa_mhi_client_ctx->ul_channels,
		IPA_MHI_MAX_UL_CHANNELS);
	if (res) {
		IPA_MHI_ERR("ipa_mhi_suspend_ul_channels failed %d\n", res);
		goto fail_suspend_ul_channel;
@@ -1948,7 +1950,7 @@ static int ipa_mhi_suspend_ul(bool force, bool *empty, bool *force_clear)
	}

	res = ipa_mhi_stop_event_update_channels(
		ipa_mhi_client_ctx->ul_channels);
		ipa_mhi_client_ctx->ul_channels, IPA_MHI_MAX_UL_CHANNELS);
	if (res) {
		IPA_MHI_ERR(
			"ipa_mhi_stop_event_update_ul_channels failed %d\n",
@@ -2069,7 +2071,8 @@ static int ipa_mhi_suspend_dl(bool force)
{
	int res;

	res = ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels);
	res = ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels,
		IPA_MHI_MAX_DL_CHANNELS);
	if (res) {
		IPA_MHI_ERR(
			"ipa_mhi_suspend_channels for dl failed %d\n", res);
@@ -2077,7 +2080,8 @@ static int ipa_mhi_suspend_dl(bool force)
	}

	res = ipa_mhi_stop_event_update_channels
			(ipa_mhi_client_ctx->dl_channels);
			(ipa_mhi_client_ctx->dl_channels,
			IPA_MHI_MAX_DL_CHANNELS);
	if (res) {
		IPA_MHI_ERR("failed to stop event update on DL %d\n", res);
		goto fail_stop_event_update_dl_channel;
@@ -2099,7 +2103,8 @@ static int ipa_mhi_suspend_dl(bool force)

fail_stop_event_update_dl_channel:
		ipa_mhi_resume_channels(true,
				ipa_mhi_client_ctx->dl_channels);
				ipa_mhi_client_ctx->dl_channels,
				IPA_MHI_MAX_DL_CHANNELS);
fail_suspend_dl_channel:
		return res;
}
@@ -2209,7 +2214,8 @@ int ipa_mhi_suspend(bool force)
fail_deactivate_pm:
	IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
fail_suspend_ul_channel:
	ipa_mhi_resume_channels(true, ipa_mhi_client_ctx->ul_channels);
	ipa_mhi_resume_channels(true, ipa_mhi_client_ctx->ul_channels,
		IPA_MHI_MAX_UL_CHANNELS);
	if (force_clear) {
		if (
		ipa_mhi_disable_force_clear(ipa_mhi_client_ctx->qmi_req_id)) {
@@ -2220,7 +2226,8 @@ int ipa_mhi_suspend(bool force)
		ipa_mhi_client_ctx->qmi_req_id++;
	}
fail_suspend_dl_channel:
	ipa_mhi_resume_channels(true, ipa_mhi_client_ctx->dl_channels);
	ipa_mhi_resume_channels(true, ipa_mhi_client_ctx->dl_channels,
		IPA_MHI_MAX_DL_CHANNELS);
	ipa_mhi_set_state(IPA_MHI_STATE_STARTED);
	return res;
}
@@ -2255,7 +2262,8 @@ int ipa_mhi_resume(void)
	if (ipa_mhi_client_ctx->rm_cons_state == IPA_MHI_RM_STATE_REQUESTED) {
		/* resume all DL channels */
		res = ipa_mhi_resume_channels(false,
				ipa_mhi_client_ctx->dl_channels);
				ipa_mhi_client_ctx->dl_channels,
				IPA_MHI_MAX_DL_CHANNELS);
		if (res) {
			IPA_MHI_ERR("ipa_mhi_resume_dl_channels failed %d\n",
				res);
@@ -2289,7 +2297,8 @@ int ipa_mhi_resume(void)

	/* resume all UL channels */
	res = ipa_mhi_resume_channels(false,
					ipa_mhi_client_ctx->ul_channels);
					ipa_mhi_client_ctx->ul_channels,
					IPA_MHI_MAX_UL_CHANNELS);
	if (res) {
		IPA_MHI_ERR("ipa_mhi_resume_ul_channels failed %d\n", res);
		goto fail_resume_ul_channels;
@@ -2297,7 +2306,8 @@ int ipa_mhi_resume(void)

	if (!dl_channel_resumed) {
		res = ipa_mhi_resume_channels(false,
					ipa_mhi_client_ctx->dl_channels);
					ipa_mhi_client_ctx->dl_channels,
					IPA_MHI_MAX_DL_CHANNELS);
		if (res) {
			IPA_MHI_ERR("ipa_mhi_resume_dl_channels failed %d\n",
				res);
@@ -2318,9 +2328,11 @@ int ipa_mhi_resume(void)
	return 0;

fail_set_state:
	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels);
	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels,
		IPA_MHI_MAX_DL_CHANNELS);
fail_resume_dl_channels2:
	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->ul_channels);
	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->ul_channels,
		IPA_MHI_MAX_UL_CHANNELS);
fail_resume_ul_channels:
	if (!ipa_pm_is_used())
		ipa_mhi_release_prod();
@@ -2331,7 +2343,8 @@ int ipa_mhi_resume(void)
	if (ipa_pm_is_used())
		ipa_pm_deactivate_sync(ipa_mhi_client_ctx->pm_hdl);
fail_pm_activate:
	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels);
	ipa_mhi_suspend_channels(ipa_mhi_client_ctx->dl_channels,
		IPA_MHI_MAX_DL_CHANNELS);
fail_resume_dl_channels:
	ipa_mhi_set_state(IPA_MHI_STATE_SUSPENDED);
	return res;