[PATCH 01/13] drm/atomic: Handle max bpc properties before connector state allocation

From: Xilin Wu

Date: Wed Sep 30 2026 - 08:50:58 EST


Bridge connectors can attach the max bpc property before their atomic
state is allocated by drm_mode_config_reset(). Unconditionally updating
connector->state in drm_connector_attach_max_bpc_property() dereferences
a NULL pointer in this case. Adding max bpc support to MSM DP and eDP
exposes this during display initialization, before a framebuffer console
is available.

Only update an existing state when attaching the property. Initialize
max_requested_bpc and max_bpc from the property range when creating a
connector state so that deferred allocation and subsequent resets both
restore the default. Avoid leaving the bit depth at zero after reset,
which would otherwise cause valid display configurations to be rejected.

With MSM DP max bpc support applied, this also restores boot on the Lenovo
Yoga Slim 7x.

Assisted-by: LLM
Signed-off-by: Xilin Wu <sophon@xxxxxxxxx>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 5 +++++
drivers/gpu/drm/drm_connector.c | 6 ++++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index a2ef272e9f27..91d60bc7a2b2 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -34,6 +34,7 @@
#include <drm/drm_framebuffer.h>
#include <drm/drm_plane.h>
#include <drm/drm_print.h>
+#include <drm/drm_property.h>
#include <drm/drm_vblank.h>
#include <drm/drm_writeback.h>

@@ -495,6 +496,10 @@ __drm_atomic_helper_connector_state_init(struct drm_connector_state *conn_state,
struct drm_connector *connector)
{
conn_state->connector = connector;
+ if (connector->max_bpc_property) {
+ conn_state->max_requested_bpc = connector->max_bpc_property->values[1];
+ conn_state->max_bpc = conn_state->max_requested_bpc;
+ }
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_state_init);

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 8b4baed060f3..34c30469f405 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2886,8 +2886,10 @@ int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
}

drm_object_attach_property(&connector->base, prop, max);
- connector->state->max_requested_bpc = max;
- connector->state->max_bpc = max;
+ if (connector->state) {
+ connector->state->max_requested_bpc = max;
+ connector->state->max_bpc = max;
+ }

return 0;
}

--
2.55.0