Adding mutex lock to VSP driver
Bug: 22602467
Change-Id: I368bf16cb4974f4f45f50ef70a15675104a6bb25
Signed-off-by: hding3 <haitao.ding@intel.com>
diff --git a/drivers/external_drivers/intel_media/video/vsp/vsp.c b/drivers/external_drivers/intel_media/video/vsp/vsp.c
index 162cc7a..3ae40d0 100755
--- a/drivers/external_drivers/intel_media/video/vsp/vsp.c
+++ b/drivers/external_drivers/intel_media/video/vsp/vsp.c
@@ -1072,12 +1072,14 @@
return -1;
}
+ mutex_lock(&vsp_priv->vsp_mutex);
if (VAEntrypointEncSlice == ctx_type) {
vsp_priv->context_vp8_num++;
if (vsp_priv->context_vp8_num > MAX_VP8_CONTEXT_NUM) {
DRM_ERROR("VSP: Only support 3 vp8 encoding!\n");
/* store the 4th vp8 encoding fd for remove context use */
vsp_priv->vp8_filp[3] = filp;
+ mutex_unlock(&vsp_priv->vsp_mutex);
return -1;
}
@@ -1103,6 +1105,7 @@
DRM_ERROR("VSP: couldn't support the context %x\n", ctx_type);
ret = -1;
}
+ mutex_unlock(&vsp_priv->vsp_mutex);
VSP_DEBUG("context_vp8_num %d, context_vpp_num %d\n",
vsp_priv->context_vp8_num, vsp_priv->context_vpp_num);
@@ -1131,6 +1134,7 @@
return;
}
+ mutex_lock(&vsp_priv->vsp_mutex);
if (vsp_priv->ctrl == NULL) {
for (i = 0; i < MAX_VP8_CONTEXT_NUM + 1; i++) {
if (filp == vsp_priv->vp8_filp[i])
@@ -1143,13 +1147,13 @@
} else if (ctx_type == VAEntrypointVideoProc)
if (vsp_priv->context_vpp_num > 0)
vsp_priv->context_vpp_num--;
+ mutex_unlock(&vsp_priv->vsp_mutex);
return;
}
VSP_DEBUG("ctx_type=%d\n", ctx_type);
if (VAEntrypointEncSlice == ctx_type && filp != vsp_priv->vp8_filp[3]) {
- mutex_lock(&vsp_priv->vsp_mutex);
/* power on again to send VssGenDestroyContext to firmware */
if (power_island_get(OSPM_VIDEO_VPP_ISLAND) == false) {
tmp = -EBUSY;
@@ -1196,7 +1200,7 @@
PSB_UDELAY(6);
}
-
+ mutex_lock(&vsp_priv->vsp_mutex);
vsp_priv->context_vp8_num--;
if (count == 20000) {
DRM_ERROR("Failed to handle sigint event\n");
@@ -1213,17 +1217,18 @@
if (vsp_priv->context_vp8_num > 0 || vsp_priv->context_vpp_num > 0) {
VSP_DEBUG("context_vp8_num %d, context_vpp_num %d\n",
vsp_priv->context_vp8_num, vsp_priv->context_vpp_num);
+ mutex_unlock(&vsp_priv->vsp_mutex);
return;
}
vsp_priv->ctrl->entry_kind = vsp_exit;
+ mutex_unlock(&vsp_priv->vsp_mutex);
/* in case of power mode 0, HW always active,
* * in case got no response from FW, vsp_state=hang but could not be powered off,
* * force state to down */
vsp_priv->vsp_state = VSP_STATE_DOWN;
ospm_apm_power_down_vsp(dev);
-
vsp_priv->vsp_state = VSP_STATE_DOWN;
if (ret == false)