Browse Source

video: driver: Avoid device crash after fence usecase execution

Since spin lock for fence is per session based and stored in instance
memory, by the time fence consumer released the fence, driver close
might be called and instance memory might be cleared. So, when fence
consumer released the fence, at the time of fence release callback,
this spin lock might nt be available. This race condition is resulting
into device crash after fence playback session ends. Avoid this by
using per fence based spin lock, which decouples it from instance
memory.

Change-Id: I12d6976c0bac3f0211bb16e24009603b37471ef3
Signed-off-by: Akshata Sahukar <[email protected]>
Akshata Sahukar 3 năm trước cách đây
mục cha
commit
50a00f8265
2 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 1 1
      driver/vidc/inc/msm_vidc_internal.h
  2. 2 2
      driver/vidc/src/msm_vidc_fence.c

+ 1 - 1
driver/vidc/inc/msm_vidc_internal.h

@@ -843,13 +843,13 @@ struct msm_vidc_fence_context {
 	char                      name[MAX_NAME_LENGTH];
 	u64                       ctx_num;
 	u64                       seq_num;
-	spinlock_t                lock;
 };
 
 struct msm_vidc_fence {
 	struct list_head            list;
 	struct dma_fence            dma_fence;
 	char                        name[MAX_NAME_LENGTH];
+	spinlock_t                  lock;
 	struct sync_file            *sync_file;
 	int                         fd;
 };

+ 2 - 2
driver/vidc/src/msm_vidc_fence.c

@@ -65,8 +65,9 @@ struct msm_vidc_fence *msm_vidc_fence_create(struct msm_vidc_inst *inst)
 		return NULL;
 
 	fence->fd = INVALID_FD;
+	spin_lock_init(&fence->lock);
 	dma_fence_init(&fence->dma_fence, &msm_vidc_dma_fence_ops,
-		&inst->fence_context.lock, inst->fence_context.ctx_num,
+		&fence->lock, inst->fence_context.ctx_num,
 		++inst->fence_context.seq_num);
 	snprintf(fence->name, sizeof(fence->name), "%s: %llu",
 		inst->fence_context.name, inst->fence_context.seq_num);
@@ -201,7 +202,6 @@ int msm_vidc_fence_init(struct msm_vidc_inst *inst)
 	}
 
 	inst->fence_context.ctx_num = dma_fence_context_alloc(1);
-	spin_lock_init(&inst->fence_context.lock);
 	snprintf(inst->fence_context.name, sizeof(inst->fence_context.name),
 		"msm_vidc_fence: %s: %llu", inst->debug_str,
 		inst->fence_context.ctx_num);