summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarendra Muppalla <quic_nmuppall@quicinc.com>2022-03-30 12:14:59 -0700
committerNarendra Muppalla <quic_nmuppall@quicinc.com>2022-04-07 14:28:17 -0700
commit03173f7cc81b11d359203f7ece6f3e41e7b91dc7 (patch)
tree8f3a75af9e20f73153678c2e9f5145750ccb9cc7
parent40f846646bdf59667eb577a84fde8cd8e3cb9181 (diff)
downloadmm-03173f7cc81b11d359203f7ece6f3e41e7b91dc7.tar.gz
mm-drivers: sync-fence: add changes to serialize fence operations
This change acquires fence_lock to serialize the enable_sw signalling operation on dma_fence_array. It bails out safely if the bind operation is called twice on the spec fence. The error level for bind failure with invalid user fd is changed to warning as this case can be treated non fatal. Change-Id: I688cbc84ba3cfb49c54de9b5e1bf8a9ec9d8da3a Signed-off-by: Narendra Muppalla <quic_nmuppall@quicinc.com>
-rw-r--r--sync_fence/src/qcom_sync_file.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sync_fence/src/qcom_sync_file.c b/sync_fence/src/qcom_sync_file.c
index 3cb2178..3c006cc 100644
--- a/sync_fence/src/qcom_sync_file.c
+++ b/sync_fence/src/qcom_sync_file.c
@@ -276,6 +276,13 @@ static int spec_sync_bind_array(struct fence_bind_data *sync_bind_info)
ret = -EINVAL;
goto end;
}
+
+ if (fence_array->fences) {
+ pr_err("fence array already populated, spec fd:%d status:%d flags:0x%x\n",
+ sync_bind_info->out_bind_fd, dma_fence_get_status(fence), fence->flags);
+ goto end;
+ }
+
num_fences = fence_array->num_fences;
counter = num_fences;
@@ -298,11 +305,12 @@ static int spec_sync_bind_array(struct fence_bind_data *sync_bind_info)
goto out;
}
+ spin_lock(fence->lock);
fence_array->fences = fence_list;
for (i = 0; i < num_fences; i++) {
user_fence = sync_file_get_fence(user_fds[i]);
if (!user_fence) {
- pr_err("bind fences are invalid !! user_fd:%d out_bind_fd:%d\n",
+ pr_warn("bind fences are invalid !! user_fd:%d out_bind_fd:%d\n",
user_fds[i], sync_bind_info->out_bind_fd);
counter = i;
ret = -EINVAL;
@@ -314,6 +322,7 @@ static int spec_sync_bind_array(struct fence_bind_data *sync_bind_info)
}
clear_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags);
+ spin_unlock(fence->lock);
dma_fence_enable_sw_signaling(&fence_array->base);
clear_fence_array_tracker(false);
@@ -327,6 +336,7 @@ bind_invalid:
fence_array->fences = NULL;
fence_array->num_fences = 0;
dma_fence_set_error(fence, -EINVAL);
+ spin_unlock(fence->lock);
dma_fence_signal(fence);
clear_fence_array_tracker(false);
}