From: Gil Dekel <gildekel@google.com>
To: igt-dev@lists.freedesktop.org
Cc: Gil Dekel <gildekel@google.com>, Melissa Wen <mwen@igalia.com>,
Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>,
Swati Sharma <swati2.sharma@intel.com>,
Mark Yacoub <markyacoub@google.com>
Subject: [PATCH i-g-t v2 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE
Date: Sat, 14 Nov 2026 19:18:54 -0500 [thread overview]
Message-ID: <20261115001855.2931860-2-gildekel@google.com> (raw)
In-Reply-To: <20261115001855.2931860-1-gildekel@google.com>
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 on every plane
where it isn't 0. Log any commit failure without aborting, so a driver
that rejects the reset can't break unrelated tests. 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 and
rejects COLOR_ENCODING and COLOR_RANGE, which tests that don't use
color pipelines still set.
Cc: Melissa Wen <mwen@igalia.com>
Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Mark Yacoub <markyacoub@google.com>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Gil Dekel <gildekel@google.com>
---
Notes:
v2: Apologies for the over-engineered v1 bloat from agent-assisted
drafting; reuse plane_resources from igt_display_require() and
build one drmModeAtomicReq inline without temporary id arrays.
lib/igt_kms.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 915c6a8a2..33060eaac 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3110,6 +3110,70 @@ 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 rejects
+ * COLOR_ENCODING and COLOR_RANGE, which legacy tests rely on.
+ */
+static void igt_reset_plane_color_pipelines(int drm_fd,
+ const drmModePlaneRes *plane_res)
+{
+ drmModeAtomicReq *req = NULL;
+ 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++) {
+ uint32_t prop_id;
+ uint64_t value;
+
+ if (!kmstest_get_property(drm_fd, plane_res->planes[i],
+ DRM_MODE_OBJECT_PLANE,
+ "COLOR_PIPELINE",
+ &prop_id, &value, NULL) || !value)
+ continue;
+
+ igt_debug("Plane %u: resetting leaked COLOR_PIPELINE %" PRIu64
+ " to Bypass\n", plane_res->planes[i], value);
+ if (!req) {
+ req = drmModeAtomicAlloc();
+ igt_assert(req);
+ }
+ igt_assert_lte(0, drmModeAtomicAddProperty(req,
+ plane_res->planes[i],
+ prop_id, 0));
+ }
+
+ if (req) {
+ int ret = drmModeAtomicCommit(drm_fd, req,
+ DRM_MODE_ATOMIC_ALLOW_MODESET,
+ NULL);
+ if (ret)
+ igt_debug("Resetting COLOR_PIPELINE failed: %s\n",
+ strerror(-ret));
+ drmModeAtomicFree(req);
+ }
+
+ 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
@@ -3198,6 +3262,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, Software Engineer, Google / ChromeOS Display and Graphics
next prev parent reply other threads:[~2026-11-16 5:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 22:29 [PATCH i-g-t 0/2] lib/igt_kms: Reset leftover KMS color state Gil Dekel
2026-11-14 22:29 ` [PATCH i-g-t 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE Gil Dekel
2026-11-14 22:29 ` [PATCH i-g-t 2/2] lib/igt_kms: Reset connector Colorspace Gil Dekel
2026-11-15 0:18 ` [PATCH i-g-t v2 0/2] lib/igt_kms: Reset leftover color state Gil Dekel
2026-11-15 0:18 ` Gil Dekel [this message]
2026-11-15 0:18 ` [PATCH i-g-t v2 2/2] lib/igt_kms: Reset connector Colorspace Gil Dekel
2026-11-16 8:36 ` ✓ Xe.CI.BAT: success for lib/igt_kms: Reset leftover KMS color state Patchwork
2026-11-16 8:43 ` ✓ i915.CI.BAT: " Patchwork
2026-11-16 10:56 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-16 12:23 ` ✗ i915.CI.Full: " Patchwork
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=20261115001855.2931860-2-gildekel@google.com \
--to=gildekel@google.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=markyacoub@google.com \
--cc=mwen@igalia.com \
--cc=swati2.sharma@intel.com \
/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