dma-buf: test shared slot allocation when mutex debugging is active
authorChristian König <christian.koenig@amd.com>
Thu, 4 Oct 2018 12:45:17 +0000 (14:45 +0200)
committerChristian König <christian.koenig@amd.com>
Thu, 25 Oct 2018 11:45:23 +0000 (13:45 +0200)
Set shared_max to the number of shared fences right before we release
the lock.

This way every attempt to add a shared fence without previously
reserving a slot will cause an error.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Acked-by: Junwei Zhang <Jerry.Zhang@amd.com>
Link: https://patchwork.kernel.org/patch/10626147/
include/linux/reservation.h

index 5ddb0e143721f46b14ff72343d2806079ef07b3d..2f0ffca357807858c8446ad2d4051dec853481e8 100644 (file)
@@ -214,6 +214,11 @@ reservation_object_trylock(struct reservation_object *obj)
 static inline void
 reservation_object_unlock(struct reservation_object *obj)
 {
+#ifdef CONFIG_DEBUG_MUTEXES
+       /* Test shared fence slot reservation */
+       if (obj->fence)
+               obj->fence->shared_max = obj->fence->shared_count;
+#endif
        ww_mutex_unlock(&obj->lock);
 }