From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 063F8606A320 for ; Tue, 1 Dec 2026 08:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=LjB0qDiJ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C750810F5EF; Tue, 1 Dec 2026 08:00:23 +0000 (UTC) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 148D210E1FA for ; Tue, 1 Dec 2026 05:38:37 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-3b3fb193c03so4884620a91.2 for ; Mon, 30 Nov 2026 21:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796103516; x=1796708316; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=skwZe5Jq6bAbO7e+QR0jxi1JA5cUNUz6yyOU6HsICms=; b=LjB0qDiJS0PCJ89gpnqX71/C8IrYRDaKQI7s8v5S7+nX1SeRGIPn/hDXa2nxmgNQz5 O8xFGxqqYeuPkEARbF2yYSSXV5W8tWIJKMhFumJcbliKUKxqBHo6yClWJBmJuOfmWuc3 8htFKht+g/HzG8E7XlycBPZ4T2OHnKj0unGjGqfzVZF/JtR0T0LjJPyBF9sOrTdoZN9M O80YiOu8JMKgDy9cXqaMOspKyOvNPpyJHs5b2eg0DqQUn9DYpl1U4qjjmlPlbUJRQNzO hk0fYz+YSNVxf39JN2lVx1wMHAQiwGlNb3DxrpIm/bJfmg0juoURHJNPN4QfMRpu+DYT w7iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796103516; x=1796708316; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=skwZe5Jq6bAbO7e+QR0jxi1JA5cUNUz6yyOU6HsICms=; b=Ji5VbvMwnPvE7cCJQzQsw8+QNdatg+DJ4chEHCkGdcdYZeNp+kLgqc15e4Lf156jXe ohHpWEEcWoftoZfnTGBPqZwZdonAf3Sl9wlUEk+Z3rkT5M6TEyiUtSzFtJnRBJmwr90W JaG4aaecwuPCD4ZCqmgpUWsWq43+xcRCxrAciUaLK6UnKDVibuI9kbm4inp6ASG8oMBp cvAumUayZe7P6gwCNRffIkv+enOaV8G3DAZnSGJzUnW4ZPWkFDRJlSe9ix8CCt/i6mPh 1RYcpulNCGIIdzJEBOzOe4ZkB10VxYDXpqLu4i0xY4q+VSsQUzfkePqNbisXvtirgg9P gpsg== X-Forwarded-Encrypted: i=1; AL+hErGqHqY0kVCdyF7LDo/cCM6jVVt0jCcg463pH5pbC/C092yAJRFdvvRjrIueFoaWU9zmG+tX456E3qs=@lists.freedesktop.org X-Gm-Message-State: APuU4Z+4z1D6MWEW47bX9EeslAJIoIvD6kZI3P3qz9NlP5l97uiMYuke Y+SgFErHOvJQgvaYZIv/IWEkDi86EFeZnkOrAdwFu3gqatlrj+P+Bc9U X-Gm-Gg: AZFdTZfF+uBr/9fyg+DwW4tcqUu49jb7mBRD+le8Nsqf7WK0Qf0VeMHQ31mQGIpH1p4 kgEzGzmAsLuHhrhHzBgsNoVyyUYK7Pb5TKra+/x1v3Nc6+/wxho6Ad5dRLPEaxbPuBFVYgfhjUm HJhzk9qfLN1lJ5Q6FeaPCT7E81XT+mgJ3rIaoLvSVcmJ3sSwDPfnCgXU1AhN2AuhCWMlp+sbuMt m/a9U0H2JAbNJ/Jv7e7qR5gv5hj/Ou4Ovao75CgHfNmp4ueOvXeHCJb89HknE8alY3n7jTi/Qy7 38sWCRjiEo84D4bZpwwlklSfwxf9q3aztyFHnRNV2XoM3KXU8U1Vsnd4ub5l1Uy/DqxUO2PagaK viSfGCxOhFDXpWiUJcU/MaKzHch+1gv8zSHBl2VErv7NU/LnsznS6WinYa0dYCw9I3pHaRhmLHl P4v1hWw2m5FGU1muCQfGa/2lGBAJpMMow98V/hAYxEwfKhPDywvSD0w8zY7X0VPIrHI4USfUkLJ sVEVc7B7zaQr6igRBiK4qVG/Zn4Pyxa2ofTdSp+kKK5m256u+5lwM+Kc8ooXasOojwSg998Elmm dHC5ybwH/7ynRu2KXfFb72x0fn2RCGNlNBs7r83Nrbis1ss3OumrD54Qs/Yps4Bm2YeSflNEvR4 Op7juUK0= X-Received: by 2002:a17:90b:1d03:b0:3ab:7031:d962 with SMTP id 98e67ed59e1d1-3b41caecd21mr34911111a91.41.1796103516217; Mon, 30 Nov 2026 21:38:36 -0800 (PST) Received: from DESKTOP-TPPBPA1 (36-226-254-86.dynamic-ip.hinet.net. [36.226.254.86]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5639e13f7sm13440089a91.12.2026.11.30.21.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 21:38:35 -0800 (PST) From: Lin Tzu Yang To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: David Airlie , Simona Vetter , Louis Chauvet , Melissa Wen , 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 Message-ID: <20261201053831.878886-1-rongh7426@gmail.com> X-Mailer: git-send-email 2.51.1.windows.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 01 Dec 2026 07:59:46 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 --- 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