From: Jani Nikula <jani.nikula@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
igt-dev@lists.freedesktop.org
Subject: Re: [PATCH i-g-t v2 04/11] lib/kms: Get rid of the 'p' plane index variable
Date: Fri, 19 Dec 2025 12:55:09 +0200 [thread overview]
Message-ID: <10394ac34bb9dd0112a2da94d8382b17fb8e95be@intel.com> (raw)
In-Reply-To: <20251218154723.14896-1-ville.syrjala@linux.intel.com>
On Thu, 18 Dec 2025, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> The 'p' thing used to track the next free plane slot is annoying.
> Get rid of it by just initializing the plane indexes to -1 to
> indicate a free slot at the start, and then do a straightforward
> search for the next free slot. And for good measure make sure all
> the -1's have disappeared at the end.
>
> v2: Remove spurious whitespace (Jani)
> Fix the post init plane->index assert (Jani/CI)
>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> lib/igt_kms.c | 42 +++++++++++++++++++++++++-----------------
> 1 file changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 72c91fb5da76..803a1e926b10 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3057,7 +3057,7 @@ static void igt_crtc_init(igt_display_t *display,
> {
> igt_crtc_t *pipe = igt_crtc_for_pipe(display, i);
> igt_plane_t *plane;
> - int p = 1, crtc_mask = 0;
> + int crtc_mask = 0;
> int j, type;
>
> pipe->display = display;
> @@ -3085,10 +3085,14 @@ static void igt_crtc_init(igt_display_t *display,
> igt_assert_f(pipe->planes, "Failed to allocate memory for %d planes\n",
> pipe->n_planes);
>
> + for (j = 0; j < pipe->n_planes; j++)
> + pipe->planes[j].index = -1;
> +
> /* add the planes that can be used with that pipe */
> for (j = 0; j < display->n_planes; j++) {
> igt_plane_t *global_plane = &display->planes[j];
> drmModePlane *drm_plane = global_plane->drm_plane;
> + int index;
>
> if (!(drm_plane->possible_crtcs & crtc_mask))
> continue;
> @@ -3096,29 +3100,36 @@ static void igt_crtc_init(igt_display_t *display,
> type = global_plane->type;
>
> if (type == DRM_PLANE_TYPE_PRIMARY && pipe->plane_primary == -1) {
> - plane = &pipe->planes[0];
> - plane->index = 0;
> - pipe->plane_primary = 0;
> + index = 0;
> +
> + pipe->plane_primary = index;
> pipe->num_primary_planes++;
> } else if (type == DRM_PLANE_TYPE_CURSOR && pipe->plane_cursor == -1) {
> - plane = &pipe->planes[pipe->n_planes - 1];
> - plane->index = pipe->n_planes - 1;
> - pipe->plane_cursor = pipe->n_planes - 1;
> + index = pipe->n_planes - 1;
> +
> + pipe->plane_cursor = index;
> display->has_cursor_plane = true;
> } else {
> + for (index = 1; index < pipe->n_planes; index++) {
> + if (pipe->planes[index].index < 0)
> + break;
> + }
> +
> /*
> * Increment num_primary_planes for any extra
> * primary plane found.
> */
> if (type == DRM_PLANE_TYPE_PRIMARY)
> pipe->num_primary_planes++;
> -
> - plane = &pipe->planes[p];
> - plane->index = p++;
> }
>
> - igt_assert_f(plane->index < pipe->n_planes,
> - "n_planes < plane->index failed\n");
> + igt_assert_lt(index, pipe->n_planes);
> +
> + plane = &pipe->planes[index];
> +
> + igt_assert_lt(plane->index, 0);
> +
> + plane->index = index;
> plane->type = type;
> plane->pipe = pipe;
> plane->drm_plane = drm_plane;
> @@ -3143,11 +3154,8 @@ static void igt_crtc_init(igt_display_t *display,
> */
> igt_assert_eq(pipe->plane_primary, 0);
>
> - /* Check that we filled every slot exactly once */
> - if (display->has_cursor_plane)
> - igt_assert_eq(p, pipe->n_planes - 1);
> - else
> - igt_assert_eq(p, pipe->n_planes);
> + for (j = 0; j < pipe->n_planes; j++)
> + igt_assert_lte(0, pipe->planes[j].index);
> }
>
> /**
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-12-19 10:55 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 15:37 [PATCH i-g-t 00/11] lib/kms: Carve up igt_display_require() Ville Syrjala
2025-12-17 15:37 ` [PATCH i-g-t 01/11] lib/kms: Extract igt_crtc_init() Ville Syrjala
2025-12-17 19:04 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 02/11] lib/kms: Nuke 'n_planes' from igt_crtc_init() Ville Syrjala
2025-12-17 19:11 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 03/11] lib/kms: Nuke 'last_plane' " Ville Syrjala
2025-12-17 19:12 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 04/11] lib/kms: Get rid of the 'p' plane index variable Ville Syrjala
2025-12-17 19:17 ` Jani Nikula
2025-12-18 11:33 ` Jani Nikula
2025-12-18 15:47 ` [PATCH i-g-t v2 " Ville Syrjala
2025-12-19 10:55 ` Jani Nikula [this message]
2025-12-17 15:37 ` [PATCH i-g-t 05/11] lib/kms: Extract igt_crtc_plane_init() Ville Syrjala
2025-12-17 19:18 ` Jani Nikula
2025-12-18 15:48 ` [PATCH i-g-t v2 " Ville Syrjala
2025-12-17 15:37 ` [PATCH i-g-t 06/11] lib/kms: Nuke pipe->plane_primary Ville Syrjala
2025-12-18 11:37 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 07/11] lib/kms: Nuke pipe->plane_cursor Ville Syrjala
2025-12-18 11:39 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 08/11] lib/kms: Use '{old, new}_primary' variable names in plane swapping Ville Syrjala
2025-12-17 19:20 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 09/11] lib/kms: Pimp the priamry " Ville Syrjala
2025-12-19 12:00 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 10/11] lib/kms: Extract plane_type_index() Ville Syrjala
2025-12-19 12:08 ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 11/11] lib/kms: Streamline plane index handling further Ville Syrjala
2025-12-19 12:10 ` Jani Nikula
2025-12-17 20:36 ` ✗ Xe.CI.BAT: failure for lib/kms: Carve up igt_display_require() Patchwork
2025-12-17 21:00 ` ✗ i915.CI.BAT: " Patchwork
2025-12-18 20:21 ` ✗ Xe.CI.Full: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-12-19 20:33 [PATCH i-g-t v2 00/11] " Ville Syrjala
2025-12-19 20:33 ` [PATCH i-g-t v2 04/11] lib/kms: Get rid of the 'p' plane index variable Ville Syrjala
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=10394ac34bb9dd0112a2da94d8382b17fb8e95be@intel.com \
--to=jani.nikula@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=ville.syrjala@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.