7cae8068934e7f57b077271eeb47f52fc68cf811
[oweals/openwrt.git] /
1 From 5d8eefe0b0b10b346c76cda1c99bceca33d66aac Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Thu, 10 May 2018 12:42:09 -0700
4 Subject: [PATCH 369/454] staging: bcm2835-camera: Remove bulk_mutex as it is
5  not required
6
7 commit 71fcbc4740ab24c5208a24cf48a8190dc8f5d9ae upstream.
8
9 There is no requirement to serialise bulk transfers as that is all
10 done in VCHI, and if a second MMAL_MSG_TYPE_BUFFER_TO_HOST happened
11 before the VCHI_CALLBACK_BULK_RECEIVED, then the service_callback
12 thread is deadlocked.
13
14 Remove the bulk_mutex so that multiple receives can be scheduled at a
15 time.
16
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
18 Signed-off-by: Eric Anholt <eric@anholt.net>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 ---
21  .../vc04_services/bcm2835-camera/mmal-vchiq.c | 48 +------------------
22  1 file changed, 1 insertion(+), 47 deletions(-)
23
24 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
25 +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
26 @@ -165,9 +165,6 @@ struct vchiq_mmal_instance {
27         /* ensure serialised access to service */
28         struct mutex vchiq_mutex;
29  
30 -       /* ensure serialised access to bulk operations */
31 -       struct mutex bulk_mutex;
32 -
33         /* vmalloc page to receive scratch bulk xfers into */
34         void *bulk_scratch;
35  
36 @@ -335,13 +332,6 @@ static int bulk_receive(struct vchiq_mma
37         unsigned long flags = 0;
38         int ret;
39  
40 -       /* bulk mutex stops other bulk operations while we have a
41 -        * receive in progress - released in callback
42 -        */
43 -       ret = mutex_lock_interruptible(&instance->bulk_mutex);
44 -       if (ret != 0)
45 -               return ret;
46 -
47         rd_len = msg->u.buffer_from_host.buffer_header.length;
48  
49         /* take buffer from queue */
50 @@ -360,8 +350,6 @@ static int bulk_receive(struct vchiq_mma
51                  * waiting bulk receive?
52                  */
53  
54 -               mutex_unlock(&instance->bulk_mutex);
55 -
56                 return -EINVAL;
57         }
58  
59 @@ -402,11 +390,6 @@ static int bulk_receive(struct vchiq_mma
60  
61         vchi_service_release(instance->handle);
62  
63 -       if (ret != 0) {
64 -               /* callback will not be clearing the mutex */
65 -               mutex_unlock(&instance->bulk_mutex);
66 -       }
67 -
68         return ret;
69  }
70  
71 @@ -416,13 +399,6 @@ static int dummy_bulk_receive(struct vch
72  {
73         int ret;
74  
75 -       /* bulk mutex stops other bulk operations while we have a
76 -        * receive in progress - released in callback
77 -        */
78 -       ret = mutex_lock_interruptible(&instance->bulk_mutex);
79 -       if (ret != 0)
80 -               return ret;
81 -
82         /* zero length indicates this was a dummy transfer */
83         msg_context->u.bulk.buffer_used = 0;
84  
85 @@ -438,11 +414,6 @@ static int dummy_bulk_receive(struct vch
86  
87         vchi_service_release(instance->handle);
88  
89 -       if (ret != 0) {
90 -               /* callback will not be clearing the mutex */
91 -               mutex_unlock(&instance->bulk_mutex);
92 -       }
93 -
94         return ret;
95  }
96  
97 @@ -497,18 +468,11 @@ buffer_from_host(struct vchiq_mmal_insta
98  
99         pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
100  
101 -       /* bulk mutex stops other bulk operations while we
102 -        * have a receive in progress
103 -        */
104 -       if (mutex_lock_interruptible(&instance->bulk_mutex))
105 -               return -EINTR;
106 -
107         /* get context */
108         if (!buf->msg_context) {
109                 pr_err("%s: msg_context not allocated, buf %p\n", __func__,
110                        buf);
111 -               ret = -EINVAL;
112 -               goto unlock;
113 +               return -EINVAL;
114         }
115         msg_context = buf->msg_context;
116  
117 @@ -562,9 +526,6 @@ buffer_from_host(struct vchiq_mmal_insta
118  
119         vchi_service_release(instance->handle);
120  
121 -unlock:
122 -       mutex_unlock(&instance->bulk_mutex);
123 -
124         return ret;
125  }
126  
127 @@ -688,9 +649,6 @@ static void buffer_to_host_cb(struct vch
128  static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
129                             struct mmal_msg_context *msg_context)
130  {
131 -       /* bulk receive operation complete */
132 -       mutex_unlock(&msg_context->u.bulk.instance->bulk_mutex);
133 -
134         /* replace the buffer header */
135         port_buffer_from_host(msg_context->u.bulk.instance,
136                               msg_context->u.bulk.port);
137 @@ -706,9 +664,6 @@ static void bulk_abort_cb(struct vchiq_m
138  {
139         pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
140  
141 -       /* bulk receive operation complete */
142 -       mutex_unlock(&msg_context->u.bulk.instance->bulk_mutex);
143 -
144         /* replace the buffer header */
145         port_buffer_from_host(msg_context->u.bulk.instance,
146                               msg_context->u.bulk.port);
147 @@ -2047,7 +2002,6 @@ int vchiq_mmal_init(struct vchiq_mmal_in
148                 return -ENOMEM;
149  
150         mutex_init(&instance->vchiq_mutex);
151 -       mutex_init(&instance->bulk_mutex);
152  
153         instance->bulk_scratch = vmalloc(PAGE_SIZE);
154