From 99fe21a76f0f2d36e5f9afc95ce6ed5cc354ebad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com> Date: Thu, 4 Oct 2018 14:45:17 +0200 Subject: [PATCH] dma-buf: test shared slot allocation when mutex debugging is active MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/reservation.h b/include/linux/reservation.h index 5ddb0e143721f..2f0ffca357807 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -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); } -- GitLab