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 6B88F606A31A for ; Tue, 1 Dec 2026 21:52:48 +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=XW0eFxoB Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CD0810E440; Tue, 1 Dec 2026 21:52:43 +0000 (UTC) Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 84D3310EA98 for ; Tue, 1 Dec 2026 21:50:41 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93f33438950so2028126485a.1 for ; Tue, 01 Dec 2026 13:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796161840; x=1796766640; 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=oV/dUGSt1sbUHv8S7n6FdHbEEmYyI/IYTmRb8uobLWE=; b=XW0eFxoBUl2cHpuYtf/LGDsDp50Xwa2R9QzGgcwDi4NlgApPLi/2ZCBgOgbbNsHWcy INRKFavLRu2rYZ9onNzCz0VVFK+wOYqERUnDZWi2aGPlPN7OufWnSbiuOXia9hR/SDaJ dLxvGbyXRF7CGQ0UbFI6uGf5Z+ib3bDBhqV5r8Eh8yn0Q+whVxVFq+/MWiBlXKgjSGyA sKgKn9C+1gZq6IVBSzRqVVCUchLJuIvANgB0ORDuPLrg6raWhN77CyeR1lmdQIwzZtGs d22LKg9egKdrir1Pt/WpUAIp7npey3C7j3SajF5CUu4ceYIQy7dQWZkV7pudSURP+spH IWAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796161840; x=1796766640; 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=oV/dUGSt1sbUHv8S7n6FdHbEEmYyI/IYTmRb8uobLWE=; b=jdgTME2/bmSVEVgP/HfeUUcfoJmysCweewzpcfLhV+oyxZvwkVL63w6wC0h6QN5ERj eFwDwoeBGMopdt+fZPUytewEOGBnCyQjj48t84aANn2nCFZ/3n0B9NxHX/+Yz96WFwfj hOfawoBhv49TgVEnQ27xkYDg2g6EULk25r8BIDxF0biZEb11ZR/fU+1vED17jR8wwVTm ImU65LTTH0OpdG0SEwLayt9VdRPNq9dAmLMNYQOudZS+E4CQAhBv1WLLAY3fwQNdUKds xX2T+i8UNJwoFMFPLDdjFJoosNhKzG/hCz4SWOW2ierd4OWY2HDJ2UxhREU+BbZGgyaA UUUw== X-Gm-Message-State: APuU4Z+MLc/XquCs3m+7Q/8l7+0JXve5ngnFd4rqSoIVSCRenMarOeaJ b02whhwWwzrYUEKBFHbZFHq2/XwOgVBwNYHg1Cm23hWCswV0ZvwIWvpZmUI0JpmNIVevpFNY8tC 3tVgpJsI2X0ykLA/jYd4AURZE1hLYlkGzc3BqHig/q6iNwaJKvp70oyoUmNtOBV2xdZGKaV+j7c R5yLx8BFUHhFZuzyU0jw3vTNWW7UJo8aOf6iwE2FtLz7VGprRBS0EsgRdr X-Received: from qknsu12.prod.google.com ([2002:a05:620a:4b4c:b0:93e:a14:eff7]) (user=gildekel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:45a2:b0:947:7f5e:2b62 with SMTP id af79cd13be357-949ba9a0713mr6845502885a.37.1796161839946; Tue, 01 Dec 2026 13:50:39 -0800 (PST) Date: Tue, 1 Dec 2026 16:50:36 -0500 In-Reply-To: <20261201215037.3329830-1-gildekel@google.com> X-Archived-By: Mime-Version: 1.0 References: <20261201215037.3329830-1-gildekel@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261201215037.3329830-2-gildekel@google.com> Subject: [PATCH i-g-t v3 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.3 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 --- 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); -- Gil Dekel, Senior SWE, Google | Android Laptops & Tablets Display