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 01/11] lib/kms: Extract igt_crtc_init()
Date: Wed, 17 Dec 2025 21:04:59 +0200 [thread overview]
Message-ID: <2076fb1f4d58efa1bc80fb619b0dae6ebfba9af7@intel.com> (raw)
In-Reply-To: <20251217153758.9369-2-ville.syrjala@linux.intel.com>
On Wed, 17 Dec 2025, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Coccinelle tends to hit some kind of pathological performance
> problem with igt_display_require(). Carving it up seems to help
> a bit, so extract the crtc init loop into a separate function.
It's too big for humans too, good cleanup.
'git show --color-moved-ws=allow-indentation-change --color-moved' FTW.
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> lib/igt_kms.c | 199 ++++++++++++++++++++++++++------------------------
> 1 file changed, 102 insertions(+), 97 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e3e9bf9bce07..4993d4db8a8a 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3052,6 +3052,106 @@ void igt_display_reset_outputs(igt_display_t *display)
> drmModeFreeResources(resources);
> }
>
> +static void igt_crtc_init(igt_display_t *display,
> + drmModeRes *resources, int i)
> +{
> + igt_crtc_t *pipe = igt_crtc_for_pipe(display, i);
> + igt_plane_t *plane;
> + int p = 1, crtc_mask = 0;
> + int j, type;
> + uint8_t last_plane = 0, n_planes = 0;
> +
> + pipe->display = display;
> + pipe->plane_cursor = -1;
> + pipe->plane_primary = -1;
> + pipe->planes = NULL;
> + pipe->num_primary_planes = 0;
> +
> + igt_fill_pipe_props(display, pipe, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names);
> +
> + /* Get valid crtc index from crtcs for a pipe */
> + crtc_mask = __get_crtc_mask_for_pipe(resources, pipe);
> +
> + /* count number of valid planes */
> + for (j = 0; j < display->n_planes; j++) {
> + drmModePlane *drm_plane = display->planes[j].drm_plane;
> + igt_assert(drm_plane);
> +
> + if (drm_plane->possible_crtcs & crtc_mask)
> + n_planes++;
> + }
> +
> + igt_assert_lt(0, n_planes);
> + pipe->planes = calloc(n_planes, sizeof(igt_plane_t));
> + igt_assert_f(pipe->planes, "Failed to allocate memory for %d planes\n", n_planes);
> + last_plane = n_planes - 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;
> +
> + if (!(drm_plane->possible_crtcs & crtc_mask))
> + continue;
> +
> + 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;
> + pipe->num_primary_planes++;
> + } else if (type == DRM_PLANE_TYPE_CURSOR && pipe->plane_cursor == -1) {
> + plane = &pipe->planes[last_plane];
> + plane->index = last_plane;
> + pipe->plane_cursor = last_plane;
> + display->has_cursor_plane = true;
> + } else {
> + /*
> + * 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 < n_planes, "n_planes < plane->index failed\n");
> + plane->type = type;
> + plane->pipe = pipe;
> + plane->drm_plane = drm_plane;
> + plane->values[IGT_PLANE_IN_FENCE_FD] = ~0ULL;
> + plane->ref = global_plane;
> +
> + /*
> + * HACK: point the global plane to the first pipe that
> + * it can go on.
> + */
> + if (!global_plane->ref)
> + igt_plane_set_pipe(plane, pipe);
> +
> + igt_fill_plane_props(display, plane, IGT_NUM_PLANE_PROPS, igt_plane_prop_names);
> +
> + igt_fill_plane_format_mod(display, plane);
> + }
> +
> + /*
> + * At the bare minimum, we should expect to have a primary
> + * plane, and it must be in slot 0.
> + */
> + igt_assert_eq(pipe->plane_primary, 0);
> +
> + /* Check that we filled every slot exactly once */
> + if (display->has_cursor_plane)
> + igt_assert_eq(p, last_plane);
> + else
> + igt_assert_eq(p, n_planes);
> +
> + pipe->n_planes = n_planes;
> +}
> +
> /**
> * igt_display_require:
> * @display: a pointer to an #igt_display_t structure
> @@ -3155,103 +3255,8 @@ void igt_display_require(igt_display_t *display, int drm_fd)
> display->colorops = calloc(MAX_NUM_COLOROPS, sizeof(igt_colorop_t));
> display->n_colorops = 0;
>
> - for_each_pipe(display, i) {
> - igt_crtc_t *pipe = igt_crtc_for_pipe(display, i);
> - igt_plane_t *plane;
> - int p = 1, crtc_mask = 0;
> - int j, type;
> - uint8_t last_plane = 0, n_planes = 0;
> -
> - pipe->display = display;
> - pipe->plane_cursor = -1;
> - pipe->plane_primary = -1;
> - pipe->planes = NULL;
> - pipe->num_primary_planes = 0;
> -
> - igt_fill_pipe_props(display, pipe, IGT_NUM_CRTC_PROPS, igt_crtc_prop_names);
> -
> - /* Get valid crtc index from crtcs for a pipe */
> - crtc_mask = __get_crtc_mask_for_pipe(resources, pipe);
> -
> - /* count number of valid planes */
> - for (j = 0; j < display->n_planes; j++) {
> - drmModePlane *drm_plane = display->planes[j].drm_plane;
> - igt_assert(drm_plane);
> -
> - if (drm_plane->possible_crtcs & crtc_mask)
> - n_planes++;
> - }
> -
> - igt_assert_lt(0, n_planes);
> - pipe->planes = calloc(n_planes, sizeof(igt_plane_t));
> - igt_assert_f(pipe->planes, "Failed to allocate memory for %d planes\n", n_planes);
> - last_plane = n_planes - 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;
> -
> - if (!(drm_plane->possible_crtcs & crtc_mask))
> - continue;
> -
> - 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;
> - pipe->num_primary_planes++;
> - } else if (type == DRM_PLANE_TYPE_CURSOR && pipe->plane_cursor == -1) {
> - plane = &pipe->planes[last_plane];
> - plane->index = last_plane;
> - pipe->plane_cursor = last_plane;
> - display->has_cursor_plane = true;
> - } else {
> - /*
> - * 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 < n_planes, "n_planes < plane->index failed\n");
> - plane->type = type;
> - plane->pipe = pipe;
> - plane->drm_plane = drm_plane;
> - plane->values[IGT_PLANE_IN_FENCE_FD] = ~0ULL;
> - plane->ref = global_plane;
> -
> - /*
> - * HACK: point the global plane to the first pipe that
> - * it can go on.
> - */
> - if (!global_plane->ref)
> - igt_plane_set_pipe(plane, pipe);
> -
> - igt_fill_plane_props(display, plane, IGT_NUM_PLANE_PROPS, igt_plane_prop_names);
> -
> - igt_fill_plane_format_mod(display, plane);
> - }
> -
> - /*
> - * At the bare minimum, we should expect to have a primary
> - * plane, and it must be in slot 0.
> - */
> - igt_assert_eq(pipe->plane_primary, 0);
> -
> - /* Check that we filled every slot exactly once */
> - if (display->has_cursor_plane)
> - igt_assert_eq(p, last_plane);
> - else
> - igt_assert_eq(p, n_planes);
> -
> - pipe->n_planes = n_planes;
> - }
> + for_each_pipe(display, i)
> + igt_crtc_init(display, resources, i);
>
> drmModeFreeResources(resources);
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-12-17 19:05 UTC|newest]
Thread overview: 30+ 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 [this message]
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
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
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=2076fb1f4d58efa1bc80fb619b0dae6ebfba9af7@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.