Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v4 0/2] lib/igt_kms: Reset leftover color state
@ 2026-12-04 23:36 Gil Dekel
  2026-12-04 23:36 ` [PATCH i-g-t v4 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE Gil Dekel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gil Dekel @ 2026-12-04 23:36 UTC (permalink / raw)
  To: igt-dev
  Cc: Gil Dekel, Melissa Wen, Chaitanya Kumar Borah, Swati Sharma,
	Kamil Konieczny, Mark Yacoub

A KMS client that exits without cleaning up can leave plane color
pipelines and connector colorimetry set, and IGT inherits that state
without always being able to see it. Patch 1 resets COLOR_PIPELINE to
Bypass even for tests that never enable the color pipeline client cap.
Patch 2 resets the connector Colorspace property to Default.

v4:
- Patch 2/2: match surrounding indentation in
  enum igt_atomic_connector_properties (Melissa Wen).
- Rebased on master and collected Melissa's Reviewed-by tags on both
  patches.
v3:
- Patch 1/2: 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 on hiding vs. rejecting legacy properties (Melissa Wen).
- Rebased on master and sent as a fresh thread so Patchwork keeps both
  patches together in one series; added Kamil to Cc.
v2:
- Patch 1/2: reuse plane_resources from igt_display_require() without
  helper functions or temporary id arrays.

Cc: Melissa Wen <mwen@igalia.com>
Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Mark Yacoub <markyacoub@google.com>

Gil Dekel (2):
  lib/igt_kms: Reset leftover COLOR_PIPELINE
  lib/igt_kms: Reset connector Colorspace

 lib/igt_kms.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 79 insertions(+)

-- 
Gil Dekel, Senior SWE, Google | Android Laptops & Tablets Display


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH i-g-t v4 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE
  2026-12-04 23:36 [PATCH i-g-t v4 0/2] lib/igt_kms: Reset leftover color state Gil Dekel
@ 2026-12-04 23:36 ` Gil Dekel
  2026-12-04 23:36 ` [PATCH i-g-t v4 2/2] lib/igt_kms: Reset connector Colorspace Gil Dekel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gil Dekel @ 2026-12-04 23:36 UTC (permalink / raw)
  To: igt-dev
  Cc: Gil Dekel, Melissa Wen, Chaitanya Kumar Borah, Swati Sharma,
	Kamil Konieczny, Mark Yacoub

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 <mwen@igalia.com>
Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Mark Yacoub <markyacoub@google.com>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Gil Dekel <gildekel@google.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
---

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH i-g-t v4 2/2] lib/igt_kms: Reset connector Colorspace
  2026-12-04 23:36 [PATCH i-g-t v4 0/2] lib/igt_kms: Reset leftover color state Gil Dekel
  2026-12-04 23:36 ` [PATCH i-g-t v4 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE Gil Dekel
@ 2026-12-04 23:36 ` Gil Dekel
  2026-12-05  5:41 ` ✓ Xe.CI.BAT: success for lib/igt_kms: Reset leftover color state (rev2) Patchwork
  2026-12-05  5:58 ` ✓ i915.CI.BAT: " Patchwork
  3 siblings, 0 replies; 5+ messages in thread
From: Gil Dekel @ 2026-12-04 23:36 UTC (permalink / raw)
  To: igt-dev
  Cc: Gil Dekel, Melissa Wen, Chaitanya Kumar Borah, Swati Sharma,
	Kamil Konieczny, Mark Yacoub

igt_display_reset() leaves the connector Colorspace property alone, so
tests inherit whatever the previous KMS client set. After a compositor
that drove an HDR eDP panel exits, the connector can stay at
BT2020_RGB. The next test then sends BT.2020 colorimetry to the sink
while it renders plain sRGB content.

Track Colorspace as IGT_CONNECTOR_COLORSPACE and set it back to
"Default" in igt_output_reset(), next to HDR_OUTPUT_METADATA. Use
igt_output_try_prop_enum() so a driver whose enum lacks "Default" can't
abort the reset.

Cc: Melissa Wen <mwen@igalia.com>
Cc: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Mark Yacoub <markyacoub@google.com>
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Gil Dekel <gildekel@google.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
---

Notes:
    v4: Match enum indentation in lib/igt_kms.h and add Melissa's R-b.
    v3: No code changes; rebased on master and added Kamil to Cc.
    v2: No changes.

 lib/igt_kms.c | 6 ++++++
 lib/igt_kms.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b88c33d99..d554d42e9 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -759,6 +759,7 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	[IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID",
 	[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = "WRITEBACK_OUT_FENCE_PTR",
 	[IGT_CONNECTOR_DITHERING_MODE] = "dithering mode",
+	[IGT_CONNECTOR_COLORSPACE] = "Colorspace",
 };
 
 const char * const igt_rotation_names[] = {
@@ -2779,6 +2780,10 @@ static void igt_output_reset(igt_output_t *output)
 	if (igt_output_has_prop(output, IGT_CONNECTOR_DITHERING_MODE))
 		igt_output_set_prop_enum(output, IGT_CONNECTOR_DITHERING_MODE,
 					 "off");
+
+	if (igt_output_has_prop(output, IGT_CONNECTOR_COLORSPACE))
+		igt_output_try_prop_enum(output, IGT_CONNECTOR_COLORSPACE,
+					 "Default");
 }
 
 /**
@@ -2794,6 +2799,7 @@ static void igt_output_reset(igt_output_t *output)
  *   %IGT_CONNECTOR_CONTENT_PROTECTION (if applicable)
  *   %IGT_CONNECTOR_HDR_OUTPUT_METADATA (if applicable)
  * - %IGT_CONNECTOR_DITHERING_MODE (if applicable)
+ * - %IGT_CONNECTOR_COLORSPACE (if applicable)
  * - igt_output_override_mode() to default.
  *
  * For pipes:
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 29a4e96fc..4e4005665 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -203,6 +203,7 @@ enum igt_atomic_connector_properties {
        IGT_CONNECTOR_WRITEBACK_FB_ID,
        IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR,
        IGT_CONNECTOR_DITHERING_MODE,
+       IGT_CONNECTOR_COLORSPACE,
        IGT_NUM_CONNECTOR_PROPS
 };
 
-- 
Gil Dekel, Senior SWE, Google | Android Laptops & Tablets Display


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* ✓ Xe.CI.BAT: success for lib/igt_kms: Reset leftover color state (rev2)
  2026-12-04 23:36 [PATCH i-g-t v4 0/2] lib/igt_kms: Reset leftover color state Gil Dekel
  2026-12-04 23:36 ` [PATCH i-g-t v4 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE Gil Dekel
  2026-12-04 23:36 ` [PATCH i-g-t v4 2/2] lib/igt_kms: Reset connector Colorspace Gil Dekel
@ 2026-12-05  5:41 ` Patchwork
  2026-12-05  5:58 ` ✓ i915.CI.BAT: " Patchwork
  3 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2026-12-05  5:41 UTC (permalink / raw)
  To: Gil Dekel; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 981 bytes --]

== Series Details ==

Series: lib/igt_kms: Reset leftover color state (rev2)
URL   : https://patchwork.freedesktop.org/series/180214/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_9228_BAT -> XEIGTPW_16272_BAT
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Participating hosts (13 -> 13)
------------------------------

  No changes in participating hosts


Changes
-------

  No changes found


Build changes
-------------

  * IGT: IGT_9228 -> IGTPW_16272
  * Linux: xe-6300-abdce4d362f3afbd89257034cb82d284112bab2d -> xe-6302-5a3f33f625394c8c075d93226cc6d71c25985615

  IGTPW_16272: 16272
  IGT_9228: 9228
  xe-6300-abdce4d362f3afbd89257034cb82d284112bab2d: abdce4d362f3afbd89257034cb82d284112bab2d
  xe-6302-5a3f33f625394c8c075d93226cc6d71c25985615: 5a3f33f625394c8c075d93226cc6d71c25985615

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_16272/index.html

[-- Attachment #2: Type: text/html, Size: 1540 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* ✓ i915.CI.BAT: success for lib/igt_kms: Reset leftover color state (rev2)
  2026-12-04 23:36 [PATCH i-g-t v4 0/2] lib/igt_kms: Reset leftover color state Gil Dekel
                   ` (2 preceding siblings ...)
  2026-12-05  5:41 ` ✓ Xe.CI.BAT: success for lib/igt_kms: Reset leftover color state (rev2) Patchwork
@ 2026-12-05  5:58 ` Patchwork
  3 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2026-12-05  5:58 UTC (permalink / raw)
  To: Gil Dekel; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 2884 bytes --]

== Series Details ==

Series: lib/igt_kms: Reset leftover color state (rev2)
URL   : https://patchwork.freedesktop.org/series/180214/
State : success

== Summary ==

CI Bug Log - changes from IGT_9228 -> IGTPW_16272
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_16272/index.html

Participating hosts (39 -> 38)
------------------------------

  Missing    (1): bat-dg2-13 

Known issues
------------

  Here are the changes found in IGTPW_16272 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live@objects:
    - bat-mtlp-9:         [PASS][1] -> [INCOMPLETE][2] ([i915#16229]) +1 other test incomplete
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9228/bat-mtlp-9/igt@i915_selftest@live@objects.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_16272/bat-mtlp-9/igt@i915_selftest@live@objects.html

  
#### Possible fixes ####

  * igt@i915_selftest@live@sanitycheck:
    - fi-kbl-7567u:       [DMESG-WARN][3] ([i915#13735]) -> [PASS][4] +79 other tests pass
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9228/fi-kbl-7567u/igt@i915_selftest@live@sanitycheck.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_16272/fi-kbl-7567u/igt@i915_selftest@live@sanitycheck.html

  * igt@kms_busy@basic@flip:
    - fi-kbl-7567u:       [DMESG-WARN][5] ([i915#13735] / [i915#180]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9228/fi-kbl-7567u/igt@kms_busy@basic@flip.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_16272/fi-kbl-7567u/igt@kms_busy@basic@flip.html

  * igt@kms_pm_rpm@basic-pci-d3-state:
    - fi-kbl-7567u:       [DMESG-WARN][7] ([i915#13735] / [i915#15673] / [i915#180]) -> [PASS][8] +52 other tests pass
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_9228/fi-kbl-7567u/igt@kms_pm_rpm@basic-pci-d3-state.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_16272/fi-kbl-7567u/igt@kms_pm_rpm@basic-pci-d3-state.html

  
  [i915#13735]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13735
  [i915#15673]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15673
  [i915#16229]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/16229
  [i915#180]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/180


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_9228 -> IGTPW_16272
  * Linux: CI_DRM_19674 -> CI_DRM_19675

  CI-20190529: 20190529
  CI_DRM_19674: a7d5d527e32a2e5e2340a39958360b5fb80c7205 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_19675: 5a3f33f625394c8c075d93226cc6d71c25985615 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_16272: 16272
  IGT_9228: 9228

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_16272/index.html

[-- Attachment #2: Type: text/html, Size: 3796 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-05  5:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 23:36 [PATCH i-g-t v4 0/2] lib/igt_kms: Reset leftover color state Gil Dekel
2026-12-04 23:36 ` [PATCH i-g-t v4 1/2] lib/igt_kms: Reset leftover COLOR_PIPELINE Gil Dekel
2026-12-04 23:36 ` [PATCH i-g-t v4 2/2] lib/igt_kms: Reset connector Colorspace Gil Dekel
2026-12-05  5:41 ` ✓ Xe.CI.BAT: success for lib/igt_kms: Reset leftover color state (rev2) Patchwork
2026-12-05  5:58 ` ✓ i915.CI.BAT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox