brcm2708: add linux 4.19 support
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.19 / 950-0489-staging-mmal-vchiq-Replace-spinlock-protecting-conte.patch
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
5 context_map with mutex
6
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
9 and a spinlock.
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
12 spinlock.
13
14 There is no need for this to be a spinlock as a standard mutex is
15 sufficient.
16
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
18 ---
19 .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 13 +++++++------
20 1 file changed, 7 insertions(+), 6 deletions(-)
21
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 {
25 void *bulk_scratch;
26
27 struct idr context_map;
28 - spinlock_t context_map_lock;
29 + /* protect accesses to context_map */
30 + struct mutex context_map_lock;
31
32 struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
33
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.
37 */
38 - spin_lock(&instance->context_map_lock);
39 + mutex_lock(&instance->context_map_lock);
40 handle = idr_alloc(&instance->context_map, msg_context,
41 0, 0, GFP_KERNEL);
42 - spin_unlock(&instance->context_map_lock);
43 + mutex_unlock(&instance->context_map_lock);
44
45 if (handle < 0) {
46 kfree(msg_context);
47 @@ -236,9 +237,9 @@ release_msg_context(struct mmal_msg_cont
48 {
49 struct vchiq_mmal_instance *instance = msg_context->instance;
50
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);
56 kfree(msg_context);
57 }
58
59 @@ -2143,7 +2144,7 @@ int vchiq_mmal_init(struct vchiq_mmal_in
60
61 instance->bulk_scratch = vmalloc(PAGE_SIZE);
62
63 - spin_lock_init(&instance->context_map_lock);
64 + mutex_init(&instance->context_map_lock);
65 idr_init_base(&instance->context_map, 1);
66
67 params.callback_param = instance;