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

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

msm: ipa: gsb: Protect mutual exclusive memory



Resumed iface counter a global variable, common
between different iface handle is not protected.
Protect it with mutex lock.

Change-Id: I17a0970c0d8cdfce0f80792063b27c349f0b4cbb
Signed-off-by: default avatarMohammed <mjavid@codeaurora.org>
parent 51683be8
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -866,16 +866,19 @@ int ipa_bridge_connect(u32 hdl)
		return 0;
	}

	mutex_lock(&ipa_gsb_ctx->lock);
	if (ipa_gsb_ctx->num_connected_iface == 0) {
		ret = ipa_pm_activate_sync(ipa_gsb_ctx->pm_hdl);
		if (ret) {
			IPA_GSB_ERR("failed to activate ipa pm\n");
			mutex_unlock(&ipa_gsb_ctx->lock);
			mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
			return ret;
		}
		ret = ipa_gsb_connect_sys_pipe();
		if (ret) {
			IPA_GSB_ERR("fail to connect pipe\n");
			mutex_unlock(&ipa_gsb_ctx->lock);
			mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
			return ret;
		}
@@ -891,7 +894,7 @@ int ipa_bridge_connect(u32 hdl)
	ipa_gsb_ctx->num_resumed_iface++;
	IPA_GSB_DBG("num resumed iface: %d\n",
		ipa_gsb_ctx->num_resumed_iface);

	mutex_unlock(&ipa_gsb_ctx->lock);
	mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
	return 0;
}
@@ -952,6 +955,7 @@ int ipa_bridge_disconnect(u32 hdl)
		goto fail;
	}

	mutex_lock(&ipa_gsb_ctx->lock);
	if (ipa_gsb_ctx->num_connected_iface == 1) {
		ret = ipa_gsb_disconnect_sys_pipe();
		if (ret) {
@@ -982,6 +986,7 @@ int ipa_bridge_disconnect(u32 hdl)
	}

fail:
	mutex_unlock(&ipa_gsb_ctx->lock);
	atomic_set(&ipa_gsb_ctx->disconnect_in_progress, 0);
	mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
	return ret;
@@ -1023,10 +1028,12 @@ int ipa_bridge_resume(u32 hdl)
		return 0;
	}

	mutex_lock(&ipa_gsb_ctx->lock);
	if (ipa_gsb_ctx->num_resumed_iface == 0) {
		ret = ipa_pm_activate_sync(ipa_gsb_ctx->pm_hdl);
		if (ret) {
			IPA_GSB_ERR("fail to activate ipa pm\n");
			mutex_unlock(&ipa_gsb_ctx->lock);
			mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
			return ret;
		}
@@ -1037,6 +1044,7 @@ int ipa_bridge_resume(u32 hdl)
			IPA_GSB_ERR(
				"fail to start con ep %d\n",
				ret);
			mutex_unlock(&ipa_gsb_ctx->lock);
			mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
			return ret;
		}
@@ -1047,6 +1055,7 @@ int ipa_bridge_resume(u32 hdl)
	IPA_GSB_DBG_LOW("num resumed iface: %d\n",
		ipa_gsb_ctx->num_resumed_iface);

	mutex_unlock(&ipa_gsb_ctx->lock);
	mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
	return 0;
}
@@ -1087,6 +1096,7 @@ int ipa_bridge_suspend(u32 hdl)
		return 0;
	}

	mutex_lock(&ipa_gsb_ctx->lock);
	if (ipa_gsb_ctx->num_resumed_iface == 1) {
		ret = ipa_stop_gsi_channel(
			ipa_gsb_ctx->cons_hdl);
@@ -1094,6 +1104,7 @@ int ipa_bridge_suspend(u32 hdl)
			IPA_GSB_ERR(
				"fail to stop cons ep %d\n",
				ret);
			mutex_unlock(&ipa_gsb_ctx->lock);
			mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
			return ret;
		}
@@ -1102,6 +1113,7 @@ int ipa_bridge_suspend(u32 hdl)
		if (ret) {
			IPA_GSB_ERR("fail to deactivate ipa pm\n");
			ipa_start_gsi_channel(ipa_gsb_ctx->cons_hdl);
			mutex_unlock(&ipa_gsb_ctx->lock);
			mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
			return ret;
		}
@@ -1112,6 +1124,7 @@ int ipa_bridge_suspend(u32 hdl)
	IPA_GSB_DBG_LOW("num resumed iface: %d\n",
		ipa_gsb_ctx->num_resumed_iface);

	mutex_unlock(&ipa_gsb_ctx->lock);
	mutex_unlock(&ipa_gsb_ctx->iface_lock[hdl]);
	return 0;
}