dma-buf: allow reserving more than one shared fence slot

Let's support simultaneous submissions to multiple engines.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Link: https://patchwork.kernel.org/patch/10626149/
This commit is contained in:
Christian König
2018-09-19 16:12:25 +02:00
parent 27836b641c
commit ca05359f1e
16 changed files with 28 additions and 23 deletions

View File

@@ -56,9 +56,10 @@ const char reservation_seqcount_string[] = "reservation_seqcount";
EXPORT_SYMBOL(reservation_seqcount_string);
/**
* reservation_object_reserve_shared - Reserve space to add a shared
* fence to a reservation_object.
* reservation_object_reserve_shared - Reserve space to add shared fences to
* a reservation_object.
* @obj: reservation object
* @num_fences: number of fences we want to add
*
* Should be called before reservation_object_add_shared_fence(). Must
* be called with obj->lock held.
@@ -66,7 +67,8 @@ EXPORT_SYMBOL(reservation_seqcount_string);
* RETURNS
* Zero for success, or -errno
*/
int reservation_object_reserve_shared(struct reservation_object *obj)
int reservation_object_reserve_shared(struct reservation_object *obj,
unsigned int num_fences)
{
struct reservation_object_list *old, *new;
unsigned int i, j, k, max;
@@ -74,10 +76,11 @@ int reservation_object_reserve_shared(struct reservation_object *obj)
old = reservation_object_get_list(obj);
if (old && old->shared_max) {
if (old->shared_count < old->shared_max)
if ((old->shared_count + num_fences) <= old->shared_max)
return 0;
else
max = old->shared_max * 2;
max = max(old->shared_count + num_fences,
old->shared_max * 2);
} else {
max = 4;
}