From: Michael Zoran Date: Fri, 10 Mar 2017 05:08:56 +0000 (-0800) Subject: staging: bcm2835-camera: Convert spinlock to mutex in handle mapping code X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=74369b5f22b72a4b4fd38a12f36251d38c022831;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git staging: bcm2835-camera: Convert spinlock to mutex in handle mapping code The handle mapping code that converts context pointers to handles uses a spinlock. Since the btree implementation can sleep while allocating memory, turning on several kernel debugging options will result in errors in the log. Since this code path is never called in atomic context, perhaps it's better to just use a mutex. Signed-off-by: Michael Zoran Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index f7d7f2ab45f1..41de8956e421 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -155,7 +154,7 @@ struct mmal_msg_context { struct vchiq_mmal_context_map { /* ensure serialized access to the btree(contention should be low) */ - spinlock_t spinlock; + struct mutex lock; struct btree_head32 btree_head; u32 last_handle; }; @@ -183,16 +182,16 @@ struct vchiq_mmal_instance { static int __must_check mmal_context_map_init(struct vchiq_mmal_context_map *context_map) { - spin_lock_init(&context_map->spinlock); + mutex_init(&context_map->lock); context_map->last_handle = 0; return btree_init32(&context_map->btree_head); } static void mmal_context_map_destroy(struct vchiq_mmal_context_map *context_map) { - spin_lock(&context_map->spinlock); + mutex_lock(&context_map->lock); btree_destroy32(&context_map->btree_head); - spin_unlock(&context_map->spinlock); + mutex_unlock(&context_map->lock); } static u32 @@ -202,7 +201,7 @@ mmal_context_map_create_handle(struct vchiq_mmal_context_map *context_map, { u32 handle; - spin_lock(&context_map->spinlock); + mutex_lock(&context_map->lock); while (1) { /* just use a simple count for handles, but do not use 0 */ @@ -220,11 +219,11 @@ mmal_context_map_create_handle(struct vchiq_mmal_context_map *context_map, if (btree_insert32(&context_map->btree_head, handle, msg_context, gfp)) { /* probably out of memory */ - spin_unlock(&context_map->spinlock); + mutex_unlock(&context_map->lock); return 0; } - spin_unlock(&context_map->spinlock); + mutex_unlock(&context_map->lock); return handle; } @@ -237,11 +236,11 @@ mmal_context_map_lookup_handle(struct vchiq_mmal_context_map *context_map, if (!handle) return NULL; - spin_lock(&context_map->spinlock); + mutex_lock(&context_map->lock); msg_context = btree_lookup32(&context_map->btree_head, handle); - spin_unlock(&context_map->spinlock); + mutex_unlock(&context_map->lock); return msg_context; } @@ -249,9 +248,9 @@ static void mmal_context_map_destroy_handle(struct vchiq_mmal_context_map *context_map, u32 handle) { - spin_lock(&context_map->spinlock); + mutex_lock(&context_map->lock); btree_remove32(&context_map->btree_head, handle); - spin_unlock(&context_map->spinlock); + mutex_unlock(&context_map->lock); } static struct mmal_msg_context *