u32 *pmr_flags)
{
struct dma_resv *resv;
- struct dma_resv_list *resv_list;
+ struct dma_resv_iter cursor;
struct dma_fence *fence;
u32 fence_count = 0;
bool exclusive;
if (WARN_ON_ONCE(!resv))
continue;
- resv_list = dma_resv_shared_list(resv);
- fence = dma_resv_excl_fence(resv);
-
- if (fence &&
- (!exclusive || !resv_list || !resv_list->shared_count))
+ dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_BOOKKEEP, fence) {
fence_count++;
-
- if (exclusive && resv_list)
- fence_count += resv_list->shared_count;
+ }
}
return fence_count;
{
struct pvr_buffer_sync_check_data *data;
struct dma_resv *resv;
- struct dma_resv_list *resv_list;
+ struct dma_resv_iter cursor;
struct dma_fence *fence;
u32 fence_count;
bool exclusive;
- int i, j;
+ int i;
int err;
data = kzalloc(sizeof(*data), GFP_KERNEL);
continue;
exclusive = !!(pmr_flags[i] & PVR_BUFFER_FLAG_WRITE);
- if (!exclusive) {
- err = dma_resv_reserve_shared(resv
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
- , 1
-#endif
- );
+
+ if (!fence_count) {
+ err = dma_resv_reserve_fences(resv, 1);
if (err)
goto err_destroy_fences;
}
- resv_list = dma_resv_shared_list(resv);
- fence = dma_resv_excl_fence(resv);
-
- if (fence &&
- (!exclusive || !resv_list || !resv_list->shared_count)) {
+ dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_BOOKKEEP, fence) {
data->fences[data->nr_fences++] =
pvr_fence_create_from_fence(fence_ctx,
sync_checkpoint_ctx,
WARN_ON(dma_fence_wait(fence, true) <= 0);
}
}
-
- if (exclusive && resv_list) {
- for (j = 0; j < resv_list->shared_count; j++) {
- fence = rcu_dereference_protected(resv_list->shared[j],
- dma_resv_held(resv));
- data->fences[data->nr_fences++] =
- pvr_fence_create_from_fence(fence_ctx,
- sync_checkpoint_ctx,
- fence,
- PVRSRV_NO_FENCE,
- "check fence");
- if (!data->fences[data->nr_fences - 1]) {
- data->nr_fences--;
- PVR_FENCE_TRACE(fence,
- "waiting on non-exclusive fence\n");
- WARN_ON(dma_fence_wait(fence, true) <= 0);
- }
- }
- }
}
WARN_ON((i != nr_pmrs) || (data->nr_fences != fence_count));
PVR_FENCE_TRACE(&data->update_fence->base,
"added exclusive fence (%s) to resv %p\n",
data->update_fence->name, resv);
- dma_resv_add_excl_fence(resv,
- &data->update_fence->base);
+ dma_resv_add_fence(resv,
+ &data->update_fence->base, DMA_RESV_USAGE_WRITE);
} else if (data->pmr_flags[i] & PVR_BUFFER_FLAG_READ) {
PVR_FENCE_TRACE(&data->update_fence->base,
"added non-exclusive fence (%s) to resv %p\n",
data->update_fence->name, resv);
- dma_resv_add_shared_fence(resv,
- &data->update_fence->base);
+ dma_resv_add_fence(resv,
+ &data->update_fence->base, DMA_RESV_USAGE_READ);
}
}