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

Commit d06a77ac authored by Praneeth Paladugu's avatar Praneeth Paladugu
Browse files

msm: vidc: fix a race condition in OCMEM free function



OCMEM free function is called from both power collapse and
core release function. Due to race conditions this function
can be called simultaneously. This change adds mutex to prevent
race conditions.

Change-Id: Ic0efd3ff825b3f0eb8919228602c24eff28dddd3
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
parent dbd2b72e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2323,8 +2323,9 @@ static int venus_hfi_core_release(void *device)
				"%s: Power enable failed\n", __func__);
			return -EIO;
		}

		mutex_lock(&dev->resource_lock);
		rc = __unset_free_ocmem(dev);
		mutex_unlock(&dev->resource_lock);
		if (rc)
			dprintk(VIDC_ERR,
					"Failed to unset and free OCMEM in core release, rc : %d\n",
@@ -3070,7 +3071,9 @@ static void venus_hfi_pm_hndlr(struct work_struct *work)

	dprintk(VIDC_DBG, "Prepare for power collapse\n");

	mutex_lock(&device->resource_lock);
	rc = __unset_free_ocmem(device);
	mutex_unlock(&device->resource_lock);
	if (rc) {
		dprintk(VIDC_ERR,
			"Failed to unset and free OCMEM for PC, rc : %d\n", rc);
@@ -4225,6 +4228,7 @@ static void *venus_hfi_add_device(u32 device_id,
	mutex_init(&hdevice->read_lock);
	mutex_init(&hdevice->write_lock);
	mutex_init(&hdevice->session_lock);
	mutex_init(&hdevice->resource_lock);

	if (hal_ctxt.dev_count == 0)
		INIT_LIST_HEAD(&hal_ctxt.dev_head);
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ struct venus_hfi_device {
	bool power_enabled;
	struct mutex read_lock;
	struct mutex write_lock;
	struct mutex clk_pwr_lock;
	struct mutex resource_lock;
	struct mutex session_lock;
	msm_vidc_callback callback;
	struct vidc_mem_addr iface_q_table;