All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: Bhanuprakash Modem <bhanuprakash.modem@intel.com>,
	igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: Re: [igt-dev] [v4 i-g-t 01/14] lib/igt_kms: helper to override the mode on all connectors
Date: Wed, 5 May 2021 16:34:15 +0530	[thread overview]
Message-ID: <b18f786c-b81c-ee6e-e497-c9b9ad319a96@intel.com> (raw)
In-Reply-To: <20210504004313.28804-2-bhanuprakash.modem@intel.com>

LGTM.

Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>

On 5/4/2021 6:13 AM, Bhanuprakash Modem wrote:
> This helper will iterate through all connectors those have a
> pending_pipe != PIPE_NONE set by the test upto the point of
> calling this helper. And find the combination by using
> ATOMIC_TEST_ONLY then return to the test.
>
> This helper would override the mode on all connectors that will
> be modeset by the next igt_display_commit() call in the test.
>
> V2:
> * Remove MST specific logic (Daniel)
> V3:
> * Sort connector modes in descending order
> V4:
> * Fine tune the logic to reduce #of interations (Ankit)
> * Update the documentation (Ankit)
>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> ---
>   lib/igt_kms.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++
>   lib/igt_kms.h |  1 +
>   2 files changed, 73 insertions(+)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 47b829b0c..d604c1b38 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -4048,6 +4048,78 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
>   	}
>   }
>   
> +#define for_each_connector_mode(output)		\
> +	for (int i__ = 0;  i__ < output->config.connector->count_modes; i__++)
> +
> +static int sort_drm_modes(const void *a, const void *b)
> +{
> +	const drmModeModeInfo *mode1 = a, *mode2 = b;
> +
> +	return (mode1->clock < mode2->clock) - (mode2->clock < mode1->clock);
> +}
> +
> +static
> +bool __override_all_active_output_modes_to_fit_link_bw(igt_display_t *display,
> +							igt_output_t *outputs[IGT_MAX_PIPES],
> +							const int n_outputs,
> +							int base)
> +{
> +	igt_output_t *output = NULL;
> +
> +	if (base >= n_outputs)
> +		return false;
> +
> +	output = outputs[base];
> +
> +	for_each_connector_mode(output) {
> +		igt_output_override_mode(output, &output->config.connector->modes[i__]);
> +
> +		if (__override_all_active_output_modes_to_fit_link_bw(display, outputs, n_outputs, base + 1))
> +			return true;
> +
> +		if (igt_display_try_commit_atomic(display,
> +				DRM_MODE_ATOMIC_TEST_ONLY |
> +				DRM_MODE_ATOMIC_ALLOW_MODESET,
> +				NULL) == 0)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
> +/**
> + * igt_override_all_active_output_modes_to_fit_link_bw:
> + * @display: a pointer to an #igt_display_t structure
> + *
> + * Override the mode on all active outputs (i.e. pending_pipe != PIPE_NONE)
> + * on basis of bandwidth.
> + *
> + * Returns: true if a valid connector mode combo found, else false
> + */
> +bool igt_override_all_active_output_modes_to_fit_link_bw(igt_display_t *display)
> +{
> +	int i, n_outputs = 0;
> +	igt_output_t *outputs[IGT_MAX_PIPES];
> +
> +	for (i = 0 ; i < display->n_outputs; i++) {
> +		igt_output_t *output = &display->outputs[i];
> +
> +		if (output->pending_pipe == PIPE_NONE)
> +			continue;
> +
> +		/* Sort the modes in descending order by clock freq. */
> +		qsort(output->config.connector->modes,
> +		      output->config.connector->count_modes,
> +		      sizeof(drmModeModeInfo),
> +		      sort_drm_modes);
> +
> +		outputs[n_outputs++] = output;
> +	}
> +	igt_require_f(n_outputs, "No active outputs found.\n");
> +
> +	return __override_all_active_output_modes_to_fit_link_bw(display, outputs, n_outputs, 0);
> +}
> +
>   /*
>    * igt_pipe_refresh:
>    * @display: a pointer to an #igt_display_t structure
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 85f0769c9..95463b1c5 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -915,5 +915,6 @@ void igt_require_pipe(igt_display_t *display,
>   
>   void igt_dump_connectors_fd(int drmfd);
>   void igt_dump_crtcs_fd(int drmfd);
> +bool igt_override_all_active_output_modes_to_fit_link_bw(igt_display_t *display);
>   
>   #endif /* __IGT_KMS_H__ */
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2021-05-05 11:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04  0:42 [igt-dev] [v4 i-g-t 00/14] Fix mode selection for 2x tests Bhanuprakash Modem
2021-05-03 17:41 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix mode selection for 2x tests (rev4) Patchwork
2021-05-03 21:57 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 01/14] lib/igt_kms: helper to override the mode on all connectors Bhanuprakash Modem
2021-05-05 11:04   ` Nautiyal, Ankit K [this message]
2021-05-07 12:37     ` Nautiyal, Ankit K
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 02/14] tests/kms_frontbuffer_tracking: Fix mode selection for 2x tests Bhanuprakash Modem
2021-05-07 12:46   ` Nautiyal, Ankit K
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 03/14] tests/kms_cursor_legacy: " Bhanuprakash Modem
2021-05-07 13:09   ` Nautiyal, Ankit K
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 04/14] tests/debugfs_test: Fix mode selection for MST Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 05/14] tests/kms_content_protection: Fix mode selection for 2x tests Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 06/14] tests/kms_plane_scaling: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 07/14] tests/kms_atomic_transition: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 08/14] tests/kms_plane: Reset the state before exiting the test Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 09/14] tests/kms_plane_alpha_blend: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 10/14] tests/kms_cursor_edge_walk: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 11/14] tests/kms_plane_lowres: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 12/14] tests/kms_plane_cursor: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 13/14] tests/kms_flip_scaled_crc: " Bhanuprakash Modem
2021-05-04  0:43 ` [igt-dev] [v4 i-g-t 14/14] tests/kms_vblank: " Bhanuprakash Modem

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=b18f786c-b81c-ee6e-e497-c9b9ad319a96@intel.com \
    --to=ankit.k.nautiyal@intel.com \
    --cc=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@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.