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 3759E606A6AC for ; Fri, 4 Dec 2026 18:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=HLwBB7Gj Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB12E10E328; Fri, 4 Dec 2026 18:25:15 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A08410E328 for ; Fri, 4 Dec 2026 18:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:Message-ID:Subject:Cc:To :From:Date:MIME-Version:From:Reply-To; bh=qeE3rnMPbzm+HWtf4MBc4yGrr6EunscSR1rOSVJCg9I=; t=1796408650; x=2111768650; b=HLwBB7GjbYeWzzKRvaECKnwxoKyAd2K832gPQxFLibMxNjMHHbfYKbu0qe/eqHOn8xNe4Qxa8/7 MAyr42hdekGaiK9H1nRVsflYb5arVXmUYARO2JlHcRnXV6VmTja5+lXMyUogEY99JUBv6ez0daBTc fvRXhgJA8hT3+TKJi/Pk90ilz46sKy5nnt/wyk1ldrzeGwPTkFKsYEek1cc0KKRakvnPWVEXENKa2 R5E3rizt0hcdR98WgJYPCKzDYuJQVH1MBATLfFDY914WVtLaPbSnBIacF1U9ZP/nX/aTGOLolE7ll KDk1kAL9UR2Rz7t0gb4iDEYleYG+r+IFBqOQ==; Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine2.igalia.com with esmtps (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) (envelope-from ) id 1xZXx1-00000002CGn-44gA; Fri, 04 Dec 2026 19:24:07 +0100 Received: from webmail.service.igalia.com ([192.168.21.45]) by mail.igalia.com with esmtp (Exim) id 1xZXx1-000000095Cp-1w5Q; Fri, 04 Dec 2026 19:24:07 +0100 Received: from [127.0.0.1] (helo=webmail.igalia.com) by webmail.service.igalia.com with esmtp (Exim 4.98.2) (envelope-from ) id 1xZXx0-00000001Co3-43uN; Fri, 04 Dec 2026 19:24:07 +0100 X-Archived-By: MIME-Version: 1.0 Date: Fri, 04 Dec 2026 17:24:06 -0100 From: Melissa Wen To: Gil Dekel Cc: igt-dev@lists.freedesktop.org, Chaitanya Kumar Borah , Swati Sharma , Kamil Konieczny , Mark Yacoub Subject: Re: [PATCH i-g-t v3 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE In-Reply-To: <20261201215037.3329830-2-gildekel@google.com> References: <20261201215037.3329830-1-gildekel@google.com> <20261201215037.3329830-2-gildekel@google.com> Message-ID: X-Sender: mwen@igalia.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: -48 X-Spam-Bar: ---- X-Rspamd-Score: -3.0 X-Rspamd-Action: no action X-Rspamd-Bar: --- 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=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 On 01-12-2026 20:50, Gil Dekel wrote: > 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. > LGTM. Reviewed-by: Melissa Wen > 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 > --- > > Notes: > 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);