1 From 39464cbb618af3ddf6427d77b0c0be0042bcaaf9 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 1 May 2019 15:17:00 +0100
4 Subject: [PATCH 489/703] staging: mmal-vchiq: Replace spinlock protecting
7 950fd86 staging: bcm2835-camera: Replace open-coded idr with a struct idr.
8 replaced an internal implementation of an idr with the standard functions
10 idr_alloc(GFP_KERNEL) can sleep whilst calling kmem_cache_alloc to allocate
11 the new node, but this is not valid whilst in an atomic context due to the
14 There is no need for this to be a spinlock as a standard mutex is
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
19 .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 13 +++++++------
20 1 file changed, 7 insertions(+), 6 deletions(-)
22 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
23 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
24 @@ -185,7 +185,8 @@ struct vchiq_mmal_instance {
27 struct idr context_map;
28 - spinlock_t context_map_lock;
29 + /* protect accesses to context_map */
30 + struct mutex context_map_lock;
32 struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
34 @@ -209,10 +210,10 @@ get_msg_context(struct vchiq_mmal_instan
35 * that when we service the VCHI reply, we can look up what
36 * message is being replied to.
38 - spin_lock(&instance->context_map_lock);
39 + mutex_lock(&instance->context_map_lock);
40 handle = idr_alloc(&instance->context_map, msg_context,
42 - spin_unlock(&instance->context_map_lock);
43 + mutex_unlock(&instance->context_map_lock);
47 @@ -236,9 +237,9 @@ release_msg_context(struct mmal_msg_cont
49 struct vchiq_mmal_instance *instance = msg_context->instance;
51 - spin_lock(&instance->context_map_lock);
52 + mutex_lock(&instance->context_map_lock);
53 idr_remove(&instance->context_map, msg_context->handle);
54 - spin_unlock(&instance->context_map_lock);
55 + mutex_unlock(&instance->context_map_lock);
59 @@ -2143,7 +2144,7 @@ int vchiq_mmal_init(struct vchiq_mmal_in
61 instance->bulk_scratch = vmalloc(PAGE_SIZE);
63 - spin_lock_init(&instance->context_map_lock);
64 + mutex_init(&instance->context_map_lock);
65 idr_init_base(&instance->context_map, 1);
67 params.callback_param = instance;