mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/client: limit cloned connectors per CRTC in drm_client_pick_crtcs()
@ 2026-12-01  5:38 Lin Tzu Yang
  2026-12-01 11:04 ` Lin Tzu Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Tzu Yang @ 2026-12-01  5:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Louis Chauvet, Melissa Wen,
	dri-devel, linux-kernel

When a device has a single CRTC, drm_client_pick_crtcs() lets any
number of connectors with the same mode share it. A modeset can only
hold DRM_CLIENT_MAX_CLONED_CONNECTORS (8) connectors, so with nine or
more such connectors drm_client_modeset_probe() hits

	drm_WARN_ON_ONCE(dev, modeset->num_connectors ==
				DRM_CLIENT_MAX_CLONED_CONNECTORS || ...)

and gives up on the configuration.

This is easy to reach with vkms, which allows up to 31 connectors per
device through configfs: one plane, one CRTC, one encoder and nine
connectors linked to that encoder trigger the warning when the device
is enabled and fbdev is set up.

Stop offering a CRTC as a clone target once it already has
DRM_CLIENT_MAX_CLONED_CONNECTORS connectors, so the remaining
connectors are left without a CRTC instead of producing a
configuration that the probe code then rejects.

Tested in an arm64 QEMU/KVM guest with vkms configured through
configfs (1 CRTC, 1, 8, 9, 12, 16 and 18 connectors): before this
change, enabling the device with 9 connectors printed the warning;
with it, there is no warning for any of the counts and fbdev is still
created for each device.

Signed-off-by: Lin Tzu Yang <rongh7426@gmail.com>
---
The bug was found while fuzzing vkms through configfs and the fix was
written with AI assistance (Claude); I reviewed and tested it. The
patch is against drm-misc-next; it was tested on a tree where
drm_client_modeset.c differs only in a debug message.

A related question: drm_client_pick_crtcs() tries every assignment
recursively, so its cost doubles with each connector on a single CRTC.
With vkms the enable time was 0.4s for 16 connectors, 1.4s for 18,
5.5s for 20 and 23s for 22 (KASAN kernel), all under
mode_config.mutex; 31 connectors would take hours. This patch does not
change that. Should vkms cap the connector count lower, or is a
non-exhaustive search in drm_client_pick_crtcs() preferred?

 drivers/gpu/drm/drm_client_modeset.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
index 67f90e5d15..847ac02a9d 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -583,7 +583,7 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client,
 	 */
 	drm_client_for_each_modeset(modeset, client) {
 		struct drm_crtc *crtc = modeset->crtc;
-		int o;
+		int o, clones;
 
 		if (!connector_has_possible_crtc(connector, crtc))
 			continue;
@@ -599,6 +599,13 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client,
 
 			if (!drm_mode_equal(modes[o], modes[n]))
 				continue;
+
+			/* a modeset can hold only so many cloned connectors */
+			for (clones = 0; o < n; o++)
+				if (best_crtcs[o] == crtc)
+					clones++;
+			if (clones >= DRM_CLIENT_MAX_CLONED_CONNECTORS)
+				continue;
 		}
 
 		crtcs[n] = crtc;
-- 
2.47.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/client: limit cloned connectors per CRTC in drm_client_pick_crtcs()
  2026-12-01  5:38 [PATCH] drm/client: limit cloned connectors per CRTC in drm_client_pick_crtcs() Lin Tzu Yang
@ 2026-12-01 11:04 ` Lin Tzu Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Lin Tzu Yang @ 2026-12-01 11:04 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Louis Chauvet, Melissa Wen,
	dri-devel, linux-kernel

As Sashiko noted, the fixed limit of eight cloned connectors and the
warning came in with d81294afeecd; before that each CRTC's connector
array was sized by the max_conn_count the driver passed in. So this
should carry:

Fixes: d81294afeecd ("drm/fb-helper: Remove drm_fb_helper_crtc")

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  5:38 [PATCH] drm/client: limit cloned connectors per CRTC in drm_client_pick_crtcs() Lin Tzu Yang
2026-12-01 11:04 ` Lin Tzu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®