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 A776A606A322 for ; Fri, 4 Dec 2026 23:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=bB+D/JNX Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5468110ECEC; Fri, 4 Dec 2026 23:38:34 +0000 (UTC) Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61E0F10ECFD for ; Fri, 4 Dec 2026 23:36:28 +0000 (UTC) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-921286add9fso31398646d6.3 for ; Fri, 04 Dec 2026 15:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796427387; x=1797032187; darn=lists.freedesktop.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=97QU4oyIrJGSSO9SnGtXTQTRAUYgL15uT0/qy8q3cJs=; b=bB+D/JNXhTHjJCjuilsfPlMi6aqOWjeGMgSCcfhTjc0rp/cGpbovPmM9Sj4nTNzH4C t2TYyZYMwq2uRF8v2tGObhDRMjn08e4oAitXTNlkcoLJeb2TaILgI1XvRKD9FVvJ5JVB TCSxkFa4mfDTmmIZ/bAb0SQIraB9ydvMHxTTqHAqUX+8T2CX3c6PPeow6ir5lnp0TlfK 0PSTAvVzAkAXi1Jfvxo1qlLmnQXUFEcJRTlfimpLd7mm4QRmrbtoVJEtvXzfpiKTqtxh UIlxKuFf9n7HE4IVyOEsZClEPmjYQ8TYl63UVFuuqzmX06fQ/UPJNm335PTgeCV/fsYO aIuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796427387; x=1797032187; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=97QU4oyIrJGSSO9SnGtXTQTRAUYgL15uT0/qy8q3cJs=; b=tRPYnQKds+c9GA1FTFPR+lAqQ8qZsNLeGkUNhj2dm31RijSYS1sAZBADlEWb5MxhxQ vQjApmYfHe0WxOm9copRwogbu1AybbLL2PTRNP5bKoKZ0RKPhIO6ASdf3vj1rTdph6d2 fM1v/GYxGm2fQOA8K/tvAjesuw6E+Sv+tx14n9vgtT8nXsC4qkcLhSuxTl6Ar8Go6mqS 26miYz6eK15fd4Y/99axMuY+Yazqo+/nLbQdKaXoMZ0b5tpLUTj6PkNE7PiM0xvIfdxr GqGXEcwkB7AW4atsIkJvEgvPQ4GAz4v9u/eau3upz3RMbN0H/wGjd+gdumGKHGnWt4cY LTbw== X-Gm-Message-State: APuU4Z/0D1L1KtP06yODy2b3ONvEDKxhEaNYGvrnTaXetOnhEGFLyRzC 2GT5/oZjdDUcIXp4I8nDuP6MW1KjhHf/8Om6ksN6rUA1Y5xRkG+xlMWZo95iuWaR2MIcn/p/s73 cNAecCWcsnCG3vmhlzbXaBPW4hsRJ0CzoftiJg393SgaMiDTkIaWYmmECucszVM0vpu1RY8T5kB o2CYsgpDeC9eXlBFqPrlhf0pz4juIoACnw0vbYcJy5Rr07J+EesWj34xeH X-Received: from qkg24.prod.google.com ([2002:a05:620a:9518:b0:949:729a:fc5e]) (user=gildekel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:2714:b0:949:8d02:38aa with SMTP id af79cd13be357-94a82f11757mr572207985a.51.1796427386930; Fri, 04 Dec 2026 15:36:26 -0800 (PST) Date: Fri, 4 Dec 2026 18:36:23 -0500 In-Reply-To: <20261204233624.2091892-1-gildekel@google.com> X-Archived-By: Mime-Version: 1.0 References: <20261204233624.2091892-1-gildekel@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204233624.2091892-2-gildekel@google.com> Subject: [PATCH i-g-t v4 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE From: Gil Dekel To: igt-dev@lists.freedesktop.org Cc: Gil Dekel , Melissa Wen , Chaitanya Kumar Borah , Swati Sharma , Kamil Konieczny , Mark Yacoub Content-Type: text/plain; charset="UTF-8" X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "igt-dev" X-Spam-Status: No, score=-26.5 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 The plane COLOR_PIPELINE property is only visible to clients that set DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE. Most tests don't, so a pipeline left active by the previous KMS client stays applied to every plane they scan out, and IGT has no way to see it. igt_plane_reset() already resets COLOR_PIPELINE, but only when the test enabled the cap before igt_display_require(). The kernel keeps plane state when a client closes its fd, so a color pipeline a compositor selected stays active after it exits unless it puts the planes back to Bypass first. Anything a test then scans out on those planes goes through that color transform. On an xe laptop, two planes were still on non-Bypass pipelines after the compositor was stopped. In igt_display_require(), before the planes are initialized, turn the cap on for a moment and commit COLOR_PIPELINE = 0 plane by plane for every plane where it isn't 0, stopping at the first -EACCES if the caller is not DRM master. Warn on other commit failures without aborting so one bad plane can't block resetting the rest. Then turn the cap off again unless a plane already exposed COLOR_PIPELINE, which means the caller had enabled it: with the cap on the kernel hides COLOR_ENCODING and COLOR_RANGE from property enumeration, which tests that don't use color pipelines still rely on. Cc: Melissa Wen Cc: Chaitanya Kumar Borah Cc: Swati Sharma Cc: Kamil Konieczny Cc: Mark Yacoub Assisted-by: Claude:claude-opus-5.5 Signed-off-by: Gil Dekel Reviewed-by: Melissa Wen --- Notes: v4: No code changes; rebased on master and added Melissa's R-b. v3 (Melissa): - Reset leaked planes plane-by-plane directly and stop on -EACCES. - Log leaked resets with igt_info(), non-EACCES failures with igt_warn(), and -EACCES with igt_debug(). - Correct commit message and comment: cap hides (not rejects) legacy COLOR_ENCODING and COLOR_RANGE from property enumeration. v2: - Reuse plane_resources from igt_display_require() without helper functions or temporary id arrays. lib/igt_kms.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 9c4c9b8ff..b88c33d99 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -3126,6 +3126,74 @@ static int crtc_pipe_compare(const void *_a, const void *_b) return a->hardware_pipe - b->hardware_pipe; } +/* + * Put every plane COLOR_PIPELINE back to Bypass (0). + * + * COLOR_PIPELINE is only visible with DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE, + * so a pipeline left active by a previous client (e.g. a compositor that + * was killed) is invisible to IGT and alters every plane it scans out. + * Enable the cap just for this reset, then drop it again unless the + * caller had already enabled it: with the cap set the kernel hides + * COLOR_ENCODING and COLOR_RANGE from property enumeration, which legacy + * tests rely on. + */ +static void igt_reset_plane_color_pipelines(int drm_fd, + const drmModePlaneRes *plane_res) +{ + bool cap_was_set = false; + + for (int i = 0; i < plane_res->count_planes; i++) { + if (kmstest_get_property(drm_fd, plane_res->planes[i], + DRM_MODE_OBJECT_PLANE, + "COLOR_PIPELINE", NULL, NULL, NULL)) { + cap_was_set = true; + break; + } + } + + if (!cap_was_set && + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE, 1)) + return; + + for (int i = 0; i < plane_res->count_planes; i++) { + drmModeAtomicReq *req; + uint32_t prop_id; + uint64_t value; + int ret; + + if (!kmstest_get_property(drm_fd, plane_res->planes[i], + DRM_MODE_OBJECT_PLANE, + "COLOR_PIPELINE", + &prop_id, &value, NULL) || !value) + continue; + + req = drmModeAtomicAlloc(); + igt_assert(req); + igt_assert_lte(0, drmModeAtomicAddProperty(req, + plane_res->planes[i], + prop_id, 0)); + ret = drmModeAtomicCommit(drm_fd, req, + DRM_MODE_ATOMIC_ALLOW_MODESET, NULL); + drmModeAtomicFree(req); + if (ret == -EACCES) { + igt_debug("Skipping COLOR_PIPELINE reset: %s\n", + strerror(-ret)); + break; + } + if (ret) + igt_warn("Plane %u: failed to reset COLOR_PIPELINE %" PRIu64 + " to Bypass: %s\n", + plane_res->planes[i], value, strerror(-ret)); + else + igt_info("Plane %u: reset leaked COLOR_PIPELINE %" PRIu64 + " to Bypass\n", + plane_res->planes[i], value); + } + + if (!cap_was_set) + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE, 0); +} + /** * igt_display_require: * @display: a pointer to an #igt_display_t structure @@ -3214,6 +3282,10 @@ void igt_display_require(igt_display_t *display, int drm_fd) plane_resources = drmModeGetPlaneResources(display->drm_fd); igt_assert(plane_resources); + /* Before igt_crtc_init(), so plane props are read with the caller's caps. */ + if (display->is_atomic) + igt_reset_plane_color_pipelines(drm_fd, plane_resources); + display->n_planes = plane_resources->count_planes; display->planes = calloc(display->n_planes, sizeof(igt_plane_t)); igt_assert_f(display->planes, "Failed to allocate memory for %d planes\n", display->n_planes); -- Gil Dekel, Senior SWE, Google | Android Laptops & Tablets Display