summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ceresoli <luca.ceresoli@bootlin.com>2026-03-24 09:58:08 +0100
committerLuca Ceresoli <luca.ceresoli@bootlin.com>2026-04-16 09:08:42 +0200
commit01b92f0d18214660d9978f0c4dd9507ee8d27d06 (patch)
tree863a072a492f391ddba8e70f3372155a27e82c01
parent8065890f5cda3f8a503f3b9d326aab0e9cca39e7 (diff)
downloadlinux-01b92f0d18214660d9978f0c4dd9507ee8d27d06.tar.gz
linux-01b92f0d18214660d9978f0c4dd9507ee8d27d06.zip
drm/encoder: add mutex to protect the bridge chain
The per-encoder bridge chain is currently assumed to be static once it is fully initialized. Work is in progress to add hot-pluggable bridges, breaking that assumption. With bridge removal, the encoder chain can change without notice, removing tail bridges. This can be problematic while iterating over the chain. Add a mutex to be taken whenever looping or changing the encoder chain. Reviewed-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> Link: https://patch.msgid.link/20260324-drm-bridge-alloc-encoder-chain-mutex-v5-1-8bf786c5c7e6@bootlin.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
-rw-r--r--drivers/gpu/drm/drm_encoder.c2
-rw-r--r--include/drm/drm_encoder.h4
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 8f2bc6a28482..3261f142baea 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -129,6 +129,7 @@ static int __drm_encoder_init(struct drm_device *dev,
}
INIT_LIST_HEAD(&encoder->bridge_chain);
+ mutex_init(&encoder->bridge_chain_mutex);
list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
encoder->index = dev->mode_config.num_encoder++;
@@ -202,6 +203,7 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
kfree(encoder->name);
list_del(&encoder->head);
dev->mode_config.num_encoder--;
+ mutex_destroy(&encoder->bridge_chain_mutex);
memset(encoder, 0, sizeof(*encoder));
}
diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
index 977a9381c8ba..eded7c34481a 100644
--- a/include/drm/drm_encoder.h
+++ b/include/drm/drm_encoder.h
@@ -25,6 +25,7 @@
#include <linux/list.h>
#include <linux/ctype.h>
+#include <linux/mutex.h>
#include <drm/drm_crtc.h>
#include <drm/drm_mode.h>
#include <drm/drm_mode_object.h>
@@ -189,6 +190,9 @@ struct drm_encoder {
*/
struct list_head bridge_chain;
+ /** @bridge_chain_mutex: protect bridge_chain from changes while iterating */
+ struct mutex bridge_chain_mutex;
+
const struct drm_encoder_funcs *funcs;
const struct drm_encoder_helper_funcs *helper_private;