From: Lin Tzu Yang <rongh7426@gmail.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Louis Chauvet <louis.chauvet@bootlin.com>,
Melissa Wen <melissa.srw@gmail.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drm/client: limit cloned connectors per CRTC in drm_client_pick_crtcs()
Date: Tue, 1 Dec 2026 13:38:31 +0800 [thread overview]
Message-ID: <20261201053831.878886-1-rongh7426@gmail.com> (raw)
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
next reply other threads:[~2026-12-01 5:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 5:38 Lin Tzu Yang [this message]
2026-12-01 11:04 ` Lin Tzu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201053831.878886-1-rongh7426@gmail.com \
--to=rongh7426@gmail.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=melissa.srw@gmail.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®