Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-07-14 11:33:41 +0200
committerJiri Slaby <jslaby@suse.cz>2019-07-14 11:33:56 +0200
commit1f37d00ead857b175dd965bc6e00b4a2a53db3ef (patch)
treed5f1514c19c2ed6ec19d5d4ec089ca0bd89fa454
parent66931a310b466ed1063308d2e9a4ec732b752f5d (diff)
staging: bcm2835-camera: Replace spinlock protecting context_map
with mutex (bnc#1012628).
-rw-r--r--patches.kernel.org/5.2.1-056-staging-bcm2835-camera-Replace-spinlock-protect.patch81
-rw-r--r--series.conf1
2 files changed, 82 insertions, 0 deletions
diff --git a/patches.kernel.org/5.2.1-056-staging-bcm2835-camera-Replace-spinlock-protect.patch b/patches.kernel.org/5.2.1-056-staging-bcm2835-camera-Replace-spinlock-protect.patch
new file mode 100644
index 0000000000..e8e7ed09da
--- /dev/null
+++ b/patches.kernel.org/5.2.1-056-staging-bcm2835-camera-Replace-spinlock-protect.patch
@@ -0,0 +1,81 @@
+From: Dave Stevenson <dave.stevenson@raspberrypi.org>
+Date: Sat, 29 Jun 2019 14:13:17 +0200
+Subject: [PATCH] staging: bcm2835-camera: Replace spinlock protecting
+ context_map with mutex
+References: bnc#1012628
+Patch-mainline: 5.2.1
+Git-commit: 8dedab2903f152aa3cee9ae3d57c828dea0d356e
+
+commit 8dedab2903f152aa3cee9ae3d57c828dea0d356e upstream.
+
+The commit "staging: bcm2835-camera: Replace open-coded idr with a struct idr."
+replaced an internal implementation of an idr with the standard functions
+and a spinlock. idr_alloc(GFP_KERNEL) can sleep whilst calling kmem_cache_alloc
+to allocate the new node, but this is not valid whilst in an atomic context
+due to the spinlock.
+
+There is no need for this to be a spinlock as a standard mutex is
+sufficient.
+
+Fixes: 950fd867c635 ("staging: bcm2835-camera: Replace open-coded idr with a struct idr.")
+Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
+Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
+Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ .../vc04_services/bcm2835-camera/mmal-vchiq.c | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+index 16af735af5c3..f1bb900c4aa6 100644
+--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
++++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+@@ -161,7 +161,8 @@ struct vchiq_mmal_instance {
+ void *bulk_scratch;
+
+ struct idr context_map;
+- spinlock_t context_map_lock;
++ /* protect accesses to context_map */
++ struct mutex context_map_lock;
+
+ /* component to use next */
+ int component_idx;
+@@ -184,10 +185,10 @@ get_msg_context(struct vchiq_mmal_instance *instance)
+ * that when we service the VCHI reply, we can look up what
+ * message is being replied to.
+ */
+- spin_lock(&instance->context_map_lock);
++ mutex_lock(&instance->context_map_lock);
+ handle = idr_alloc(&instance->context_map, msg_context,
+ 0, 0, GFP_KERNEL);
+- spin_unlock(&instance->context_map_lock);
++ mutex_unlock(&instance->context_map_lock);
+
+ if (handle < 0) {
+ kfree(msg_context);
+@@ -211,9 +212,9 @@ release_msg_context(struct mmal_msg_context *msg_context)
+ {
+ struct vchiq_mmal_instance *instance = msg_context->instance;
+
+- spin_lock(&instance->context_map_lock);
++ mutex_lock(&instance->context_map_lock);
+ idr_remove(&instance->context_map, msg_context->handle);
+- spin_unlock(&instance->context_map_lock);
++ mutex_unlock(&instance->context_map_lock);
+ kfree(msg_context);
+ }
+
+@@ -1849,7 +1850,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
+
+ instance->bulk_scratch = vmalloc(PAGE_SIZE);
+
+- spin_lock_init(&instance->context_map_lock);
++ mutex_init(&instance->context_map_lock);
+ idr_init_base(&instance->context_map, 1);
+
+ params.callback_param = instance;
+--
+2.22.0
+
diff --git a/series.conf b/series.conf
index 74e300349e..313ce51037 100644
--- a/series.conf
+++ b/series.conf
@@ -82,6 +82,7 @@
patches.kernel.org/5.2.1-053-staging-vchiq-make-wait-events-interruptible.patch
patches.kernel.org/5.2.1-054-staging-vchiq-revert-switch-to-wait_for_complet.patch
patches.kernel.org/5.2.1-055-staging-fsl-dpaa2-ethsw-fix-memory-leak-of-swit.patch
+ patches.kernel.org/5.2.1-056-staging-bcm2835-camera-Replace-spinlock-protect.patch
########################################################
# Build fixes that apply to the vanilla kernel too.