From dc2f9f7fed1a8ea5290f9f60c6310d497e85e666 Mon Sep 17 00:00:00 2001 From: Vincenzo Frascino Date: Mon, 3 Aug 2026 15:21:22 +0100 Subject: [PATCH] drm/komeda: Set display/writeback clone masks Since commit 41b4b11da0215 ("drm: Add valid clones check"), all encoders attached to the same CRTC must advertise each other through possible_clones. Komeda creates one writeback connector per CRTC. Allow the writeback encoder to be cloned only with encoders that can drive the same CRTC, and update those encoders reciprocally. Signed-off-by: Asad Malik Signed-off-by: Vincenzo Frascino Co-developed-by: Raveendra Talabattula Signed-off-by: Raveendra Talabattula Reviewed-by: Liviu Dudau Signed-off-by: Liviu Dudau Link: https://patch.msgid.link/20260803142122.4127851-3-raveendra.talabattula@arm.com --- .../arm/display/komeda/komeda_wb_connector.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c index 41cc3e080dc9..4872253a2449 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c @@ -143,12 +143,17 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms, struct komeda_wb_connector *kwb_conn; struct drm_writeback_connector *wb_conn; struct drm_display_info *info; + struct drm_encoder *encoder; + struct drm_encoder *wb_encoder; u32 *formats, n_formats = 0; + u32 crtc_mask; int err; if (!kcrtc->master->wb_layer) return 0; + crtc_mask = drm_crtc_mask(&kcrtc->base); + kwb_conn = kzalloc_obj(*kwb_conn); if (!kwb_conn) return -ENOMEM; @@ -176,6 +181,34 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms, return err; } + wb_encoder = &wb_conn->encoder; + + /* + * The writeback connector is associated with a single CRTC. Make its + * encoder clone-compatible only with encoders that can drive that CRTC. + * + * possible_clones must contain the encoder's own bit whenever it is + * non-zero. Add both the encoder itself and the writeback encoder when + * updating the reciprocal clone relationship. + */ + wb_encoder->possible_clones = drm_encoder_mask(wb_encoder); + + drm_for_each_encoder(encoder, &kms->base) { + u32 encoder_mask; + + if (encoder == wb_encoder) + continue; + + if (!(encoder->possible_crtcs & crtc_mask)) + continue; + + encoder_mask = drm_encoder_mask(encoder); + + wb_encoder->possible_clones |= encoder_mask; + encoder->possible_clones |= encoder_mask | + drm_encoder_mask(wb_encoder); + } + drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs); info = &kwb_conn->base.base.display_info;