From nobody Mon Feb 9 02:12:48 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96C7A34F498 for ; Tue, 13 Jan 2026 18:47:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768330051; cv=none; b=eI4vwrzmbPwxC55seHcfhhdwoAPgehqBWPq9nJj7OpyP4VYbQUiRoSX9tXZvr7T5U8SkqUfaZCiYmO0SjyU/0OpJguxlHJyzYXx9L5AJUH1hXHV9bHTAeb19fkwEYAbgWhd8TJvvYu3gpnEUuRytgYtuH7gV9aCNmLOsHLufpJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768330051; c=relaxed/simple; bh=Ik1Ta8asSSx5KKFD5HidAoDfhg86wbj6pxNUwca2YpY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T83Kor2yraiTw0w7LmZ/7OR+QBdXtUCbp9tHXHR0ptizPWZbrpnjj23tOuAOCDiYHXvT1T8dovhbEwVoQjfEnih2pfFKMfjwOrMTATa+ii2NemCSYv5P4xna5vbVEyEGw3s005v3PcrBbs3zX7lmLxzSxafCaX1xMsrgIbDO2js= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jEYYIe6W; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jEYYIe6W" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 094051A283D; Tue, 13 Jan 2026 18:47:27 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D42F460751; Tue, 13 Jan 2026 18:47:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4CE8F103C8707; Tue, 13 Jan 2026 19:47:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1768330045; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=DHAxbpmXFQ1iq3WpgZRrDbJUoPE1BIRMc7j1mDaZ/Xo=; b=jEYYIe6WSmwNsjP9/Dg27QouOnhnca9alwgHt9c2BpWU82Id3xDRi9r9rSdZi+kd9JmVGL 88Q5KT0n08kRx8bouqBqJf+7pnu1aoYlQmx9e7zF3ykJnZveDi6bw22ZzmD2E9bWBJ6Mct vAy1hpUirXKIkqQN+X2D6VuTzpkWtUprKbAX3YT0jcQo+F7D9YYh8fdECrhMPN4hHR4erv BaqM82/+sQFXZaPffwkTRtYRgA29zns8yf0Y67OV6OVmYqFkMmc4eD2qowHmtBi6zr8C1i Zm9D8u5XX5A3elIc4guJeKPmKVRiWZAk0J4m8F0E6kJEDWBXIOZywFC/3AAlzA== From: Luca Ceresoli Date: Tue, 13 Jan 2026 19:47:12 +0100 Subject: [PATCH RESEND v4 1/7] drm/encoder: add mutex to protect the bridge chain Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260113-drm-bridge-alloc-encoder-chain-mutex-v4-1-60f3135adc45@bootlin.com> References: <20260113-drm-bridge-alloc-encoder-chain-mutex-v4-0-60f3135adc45@bootlin.com> In-Reply-To: <20260113-drm-bridge-alloc-encoder-chain-mutex-v4-0-60f3135adc45@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec Cc: Hui Pu , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Ian Ray X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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 Signed-off-by: Luca Ceresoli --- Changes in v3: - Removed the drm_encoder_chain_[un]lock() wrappers Changes in v2: - Added documentation to new APIs --- drivers/gpu/drm/drm_encoder.c | 2 ++ include/drm/drm_encoder.h | 4 ++++ 2 files changed, 6 insertions(+) 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, } =20 INIT_LIST_HEAD(&encoder->bridge_chain); + mutex_init(&encoder->bridge_chain_mutex); list_add_tail(&encoder->head, &dev->mode_config.encoder_list); encoder->index =3D dev->mode_config.num_encoder++; =20 @@ -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); =20 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 @@ =20 #include #include +#include #include #include #include @@ -189,6 +190,9 @@ struct drm_encoder { */ struct list_head bridge_chain; =20 + /** @bridge_chain_mutex: protect bridge_chain from changes while iteratin= g */ + struct mutex bridge_chain_mutex; + const struct drm_encoder_funcs *funcs; const struct drm_encoder_helper_funcs *helper_private; =20 --=20 2.52.0