Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sowmiya S <sowmiya.s@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: kunal1.joshi@intel.com, swati2.sharma@intel.com,
	ramanaidu.naladala@intel.com, Sowmiya S <sowmiya.s@intel.com>
Subject: [PATCH i-g-t v4 1/3] lib/igt_kms: Add MST bandwidth-fitting support and helpers
Date: Mon, 29 Jun 2026 14:56:09 +0530	[thread overview]
Message-ID: <20260629092611.298235-2-sowmiya.s@intel.com> (raw)
In-Reply-To: <20260629092611.298235-1-sowmiya.s@intel.com>

Add helpers to handle shared-link DP bandwidth fitting for
MST/daisy-chain configurations.

On MST hubs/daisy-chains multiple streams share one DP link
and a joint atomic commit can be rejected unless modes are
chosen to fit the link BW. This will centralizes MST detection
and fitting so tests can request fitting only when required.

v2: Remove the flag used for caching values and update the
function name to better describe its functionality (Jani)
v3: Apply mst bw fit for shared link (Kunal)
    Remove unused variable (Kunal)

Signed-off-by: Sowmiya S <sowmiya.s@intel.com>
---
 lib/igt_kms.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 75 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e82d32130..fceca2a1b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -5472,6 +5472,80 @@ bool igt_fit_modes_in_bw(igt_display_t *display)
 	return true;
 }
 
+/**
+ * igt_outputs_share_mst_link:
+ * @output_a: first output
+ * @output_b: second output
+ *
+ * Returns: true if both outputs are active DP-MST streams that share the
+ * same upstream link, i.e. their root connector IDs (as encoded in the
+ * MST PATH property) are equal.  Returns false if either output is not an
+ * active MST stream or if they are rooted at different connectors.
+ */
+static bool igt_outputs_share_mst_link(igt_output_t *output_a,
+				       igt_output_t *output_b)
+{
+	if (!output_a->pending_crtc || !igt_check_output_is_dp_mst(output_a))
+		return false;
+
+	if (!output_b->pending_crtc || !igt_check_output_is_dp_mst(output_b))
+		return false;
+
+	return igt_get_dp_mst_connector_id(output_a) ==
+	       igt_get_dp_mst_connector_id(output_b);
+}
+
+/**
+ * igt_require_mst_link_bw:
+ * @display: a pointer to an #igt_display_t structure
+ *
+ * When two or more DP-MST streams share the same upstream link (i.e. they
+ * are both rooted at the same MST hub), a joint atomic commit may be
+ * rejected by the driver if the combined stream bandwidth exceeds the link
+ * capacity.  This function detects that situation by comparing the root
+ * connector ID embedded in each output's MST PATH property and, when two
+ * or more active outputs share the same root, calls igt_fit_modes_in_bw()
+ * to select mode overrides that satisfy the shared-link BW budget.  The
+ * test is skipped if no valid combination can be found.
+ *
+ * TODO: Extend this function to proactively detect outputs that share a
+ * DP tunnel (USB4/Thunderbolt) and trigger igt_fit_modes_in_bw() for
+ * those too.
+ */
+void igt_require_mst_link_bw(igt_display_t *display)
+{
+	igt_output_t *mst_outputs[IGT_MAX_PIPES];
+	int n_mst = 0;
+	igt_output_t *output;
+	bool shared_link = false;
+	int i, j;
+
+	/* Collect all active MST outputs in one pass. */
+	for_each_output(display, output) {
+		if (output->pending_crtc && igt_check_output_is_dp_mst(output))
+			mst_outputs[n_mst++] = output;
+	}
+
+	/* Need at least two MST outputs before a shared-link is possible. */
+	if (n_mst < 2)
+		return;
+
+	/* Check every pair for a shared upstream root connector. */
+	for (i = 0; i < n_mst && !shared_link; i++)
+		for (j = i + 1; j < n_mst; j++)
+			if (igt_outputs_share_mst_link(mst_outputs[i],
+						       mst_outputs[j])) {
+				shared_link = true;
+				break;
+			}
+
+	if (!shared_link)
+		return;
+
+	igt_require_f(igt_fit_modes_in_bw(display),
+		      "No valid mode combination fits available MST link BW\n");
+}
+
 /**
  * igt_crtc_refresh:
  * @crtc: CRTC to refresh
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3df3ba866..f5aff5008 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1370,6 +1370,7 @@ drmModePropertyBlobRes *igt_get_writeback_formats_blob(igt_output_t *output);
 uint64_t igt_get_writeback_fb_id(igt_output_t *output);
 void igt_detach_crtc(igt_display_t *display, igt_output_t *output);
 void igt_get_and_wait_out_fence(igt_output_t *output);
+void igt_require_mst_link_bw(igt_display_t *display);
 
 igt_colorop_t *igt_find_colorop(igt_display_t *display, uint32_t id);
 
-- 
2.51.0


  reply	other threads:[~2026-06-29  9:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  9:26 [PATCH i-g-t v4 0/3] Fix 2-display test for MST shared-link BW Sowmiya S
2026-06-29  9:26 ` Sowmiya S [this message]
2026-06-29 10:02   ` [PATCH i-g-t v4 1/3] lib/igt_kms: Add MST bandwidth-fitting support and helpers Jani Nikula
2026-06-29  9:26 ` [PATCH i-g-t v4 2/3] tests/kms_plane_multiple: Fix 2-display test for MST shared-link BW Sowmiya S
2026-06-29  9:26 ` [PATCH i-g-t v4 3/3] tests/intel/kms_pipe_stress: Fit display modes to MST link budget Sowmiya S
2026-06-29 10:05   ` Jani Nikula
2026-06-29 20:37 ` ✓ i915.CI.BAT: success for Fix 2-display test for MST shared-link BW (rev4) Patchwork
2026-06-29 20:48 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-30  4:28 ` ✓ Xe.CI.FULL: " Patchwork
2026-06-30  7:37 ` ✓ 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=20260629092611.298235-2-sowmiya.s@intel.com \
    --to=sowmiya.s@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kunal1.joshi@intel.com \
    --cc=ramanaidu.naladala@intel.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