From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 03/11] drm/i915: Rework joiner and Y plane dependency handling
Date: Mon, 27 Jan 2025 19:21:48 +0200 [thread overview]
Message-ID: <20250127172156.21928-4-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20250127172156.21928-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
The current code tries to handle joiner vs. Y planes completely
independently. That does not really work since each pipe selects
its Y planes completely independently, and any plane pulled into
the state by one of the secondary pipes needs to have the plane
on the primary pipe also included in the state (for the uapi
state copy). The current code sometimes forgets to pull in planes
that we need, leading to weird things like the Y<->UV plane link
only getting torn down from one side but not the other.
Remedy the situation by pulling in the exact same set planes
on all the joined pipes. To calculate the set we simply
look through each joined crtc and any plane in the state gets
added to the set. However due to the way the Y plane selection
works we may not be able to determine the set in one go. One
plane on one pipe may pull in a Y plane, which may have to pull
in another plane because it's not acting in the same role on
another pipe, etc. The simple approach taken here is to keep
looping and adding planes to the set until it stops growing.
I suppose if we tracked more of this Y plane stuff in the
crtc state rather than the plane state we might be able to
do it in one go. But this works, and it's not going to loop
for long anyway since we only have so many pipes and Y planes
to consider.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/display/intel_display.c | 104 ++++++++++---------
1 file changed, 53 insertions(+), 51 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 2b31c8f4b7cd..68ae8770dc4f 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -4402,31 +4402,6 @@ static bool check_single_encoder_cloning(struct intel_atomic_state *state,
return true;
}
-static int icl_add_linked_planes(struct intel_atomic_state *state)
-{
- struct intel_plane *plane, *linked;
- struct intel_plane_state *plane_state, *linked_plane_state;
- int i;
-
- for_each_new_intel_plane_in_state(state, plane, plane_state, i) {
- linked = plane_state->planar_linked_plane;
-
- if (!linked)
- continue;
-
- linked_plane_state = intel_atomic_get_plane_state(state, linked);
- if (IS_ERR(linked_plane_state))
- return PTR_ERR(linked_plane_state);
-
- drm_WARN_ON(state->base.dev,
- linked_plane_state->planar_linked_plane != plane);
- drm_WARN_ON(state->base.dev,
- linked_plane_state->planar_slave == plane_state->planar_slave);
- }
-
- return 0;
-}
-
static int icl_check_nv12_planes(struct intel_atomic_state *state,
struct intel_crtc *crtc)
{
@@ -6172,44 +6147,75 @@ static bool active_planes_affects_min_cdclk(struct drm_i915_private *dev_priv)
IS_IVYBRIDGE(dev_priv);
}
-static int intel_crtc_add_joiner_planes(struct intel_atomic_state *state,
- struct intel_crtc *crtc,
- struct intel_crtc *other)
+static u8 intel_joiner_affected_planes(struct intel_atomic_state *state,
+ u8 joined_pipes)
{
- const struct intel_plane_state __maybe_unused *plane_state;
+ const struct intel_plane_state *plane_state;
struct intel_plane *plane;
- u8 plane_ids = 0;
+ u8 affected_planes = 0;
int i;
for_each_new_intel_plane_in_state(state, plane, plane_state, i) {
- if (plane->pipe == crtc->pipe)
- plane_ids |= BIT(plane->id);
+ struct intel_plane *linked = plane_state->planar_linked_plane;
+
+ if ((joined_pipes & BIT(plane->pipe)) == 0)
+ continue;
+
+ affected_planes |= BIT(plane->id);
+ if (linked)
+ affected_planes |= BIT(linked->id);
}
- return intel_crtc_add_planes_to_state(state, other, plane_ids);
+ return affected_planes;
}
-static int intel_joiner_add_affected_planes(struct intel_atomic_state *state)
+static int intel_joiner_add_affected_planes(struct intel_atomic_state *state,
+ u8 joined_pipes)
{
- struct drm_i915_private *i915 = to_i915(state->base.dev);
- const struct intel_crtc_state *crtc_state;
- struct intel_crtc *crtc;
- int i;
+ u8 prev_affected_planes, affected_planes = 0;
- for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
- struct intel_crtc *other;
+ /*
+ * We want all the joined pipes to have the same
+ * set of planes in the atomic state, to make sure
+ * state copying always works correctly, and the
+ * UV<->Y plane linkage is always up to date.
+ * Keep pulling planes in until we've determined
+ * the full set of affected plane. A bit complicated
+ * on account of each pipe being capable of selecting
+ * their own Y planes independently of the other pipes,
+ * and the selection being done from the set of
+ * inactive planes.
+ */
+ do {
+ struct intel_crtc *crtc;
- for_each_intel_crtc_in_pipe_mask(&i915->drm, other,
- crtc_state->joiner_pipes) {
+ for_each_intel_crtc_in_pipe_mask(state->base.dev, crtc, joined_pipes) {
int ret;
- if (crtc == other)
- continue;
-
- ret = intel_crtc_add_joiner_planes(state, crtc, other);
+ ret = intel_crtc_add_planes_to_state(state, crtc, affected_planes);
if (ret)
return ret;
}
+
+ prev_affected_planes = affected_planes;
+ affected_planes = intel_joiner_affected_planes(state, joined_pipes);
+ } while (affected_planes != prev_affected_planes);
+
+ return 0;
+}
+
+static int intel_add_affected_planes(struct intel_atomic_state *state)
+{
+ const struct intel_crtc_state *crtc_state;
+ struct intel_crtc *crtc;
+ int i;
+
+ for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
+ int ret;
+
+ ret = intel_joiner_add_affected_planes(state, intel_crtc_joined_pipe_mask(crtc_state));
+ if (ret)
+ return ret;
}
return 0;
@@ -6224,11 +6230,7 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state)
struct intel_crtc *crtc;
int i, ret;
- ret = icl_add_linked_planes(state);
- if (ret)
- return ret;
-
- ret = intel_joiner_add_affected_planes(state);
+ ret = intel_add_affected_planes(state);
if (ret)
return ret;
--
2.45.3
next prev parent reply other threads:[~2025-01-27 17:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-27 17:21 [PATCH 00/11] drm/i915: joiner and Y plane fixes and reorganization Ville Syrjala
2025-01-27 17:21 ` [PATCH 01/11] drm/i915: Make sure all planes in use by the joiner have their crtc included Ville Syrjala
2025-01-27 17:21 ` [PATCH 02/11] Revert "drm/i915: Fix NULL ptr deref by checking new_crtc_state" Ville Syrjala
2025-01-27 17:21 ` Ville Syrjala [this message]
2025-01-27 17:21 ` [PATCH 04/11] drm/i915: s/planar_slave/is_y_plane/ Ville Syrjala
2025-01-27 17:21 ` [PATCH 05/11] drm/i915: Extract unlink_nv12_plane() Ville Syrjala
2025-01-27 17:21 ` [PATCH 06/11] drm/i915: Remove pointless visible check in unlink_nv12_plane() Ville Syrjala
2025-01-27 17:21 ` [PATCH 07/11] drm/i915: Extract link_nv12_planes() Ville Syrjala
2025-01-27 17:21 ` [PATCH 08/11] drm/i915: Rename the variables in icl_check_nv12_planes() Ville Syrjala
2025-01-27 17:21 ` [PATCH 09/11] drm/i915: Move icl+ nv12 plane register mangling into skl_universal_plane.c Ville Syrjala
2025-01-27 17:21 ` [PATCH 10/11] drm/i915: Relocate intel_atomic_check_planes() Ville Syrjala
2025-01-27 17:21 ` [PATCH 11/11] drm/i915: Pimp the Y plane selection debugs Ville Syrjala
2025-02-12 9:39 ` Maarten Lankhorst
2025-02-12 16:46 ` Ville Syrjälä
2025-01-27 21:59 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: joiner and Y plane fixes and reorganization Patchwork
2025-01-27 21:59 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-01-27 22:14 ` ✓ i915.CI.BAT: success " Patchwork
2025-01-28 11:40 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-08 12:41 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: joiner and Y plane fixes and reorganization (rev2) Patchwork
2025-02-08 12:41 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-02-08 15:12 ` ✗ i915.CI.BAT: failure " Patchwork
2025-02-08 16:12 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: joiner and Y plane fixes and reorganization (rev3) Patchwork
2025-02-08 16:12 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-02-08 18:37 ` ✗ i915.CI.BAT: failure " Patchwork
2025-02-09 18:32 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: joiner and Y plane fixes and reorganization (rev4) Patchwork
2025-02-09 18:32 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-02-09 20:21 ` ✗ i915.CI.BAT: failure " Patchwork
2025-02-09 22:47 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: joiner and Y plane fixes and reorganization (rev5) Patchwork
2025-02-09 22:47 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-02-10 0:44 ` ✓ i915.CI.BAT: success " Patchwork
2025-02-10 2:13 ` ✗ i915.CI.Full: failure " 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=20250127172156.21928-4-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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