From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 06/20] drm/i915: Allow fuzzy matching in pipe_config_compare.
Date: Wed, 08 Jul 2015 10:38:33 +0200 [thread overview]
Message-ID: <559CE189.4030106@linux.intel.com> (raw)
In-Reply-To: <20150707101146.GE7568@phenom.ffwll.local>
Op 07-07-15 om 12:11 schreef Daniel Vetter:
> On Tue, Jul 07, 2015 at 09:08:17AM +0200, Maarten Lankhorst wrote:
>> Instead of doing ad-hoc checks we already have a way of checking
>> if the state is compatible or not. Use this to force a modeset.
>>
>> Only during modesets, or with PIPE_CONFIG_QUIRK_INHERITED_MODE
>> we should check if a full modeset is really needed.
>>
>> Fastboot will allow the adjust parameter to ignore some stuff
>> too, and it will fix up differences in state that are ignored
>> by the compare function.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>> drivers/gpu/drm/i915/intel_display.c | 198 ++++++++++++++++++++++++-----------
>> 1 file changed, 139 insertions(+), 59 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 8cd3a7eb1e30..eb7c2e2819b7 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -12277,19 +12277,6 @@ encoder_retry:
>> DRM_DEBUG_KMS("plane bpp: %i, pipe bpp: %i, dithering: %i\n",
>> base_bpp, pipe_config->pipe_bpp, pipe_config->dither);
>>
>> - /* Check if we need to force a modeset */
>> - if (pipe_config->has_audio !=
>> - to_intel_crtc_state(crtc->state)->has_audio) {
>> - pipe_config->base.mode_changed = true;
>> - ret = drm_atomic_add_affected_planes(state, crtc);
>> - }
>> -
>> - /*
>> - * Note we have an issue here with infoframes: current code
>> - * only updates them on the full mode set path per hw
>> - * requirements. So here we should be checking for any
>> - * required changes and forcing a mode set.
>> - */
>> fail:
>> return ret;
>> }
>> @@ -12392,27 +12379,124 @@ static bool intel_fuzzy_clock_check(int clock1, int clock2)
>> base.head) \
>> if (mask & (1 <<(intel_crtc)->pipe))
>>
>> +
>> +static bool
>> +intel_compare_m_n(unsigned int m, unsigned int n,
>> + unsigned int m2, unsigned int n2)
>> +{
>> + if (m == m2 && n == n2)
>> + return true;
>> +
>> + if (!m || !n || !m2 || !n2)
>> + return false;
>> +
>> + if (m > m2) {
>> + while (m > m2) {
> I think we need to make sure we don't reduce precision by eating low bits,
> i.e.
> while (m > m2 && !(m & 1) && !(n & 1)) {
Could be useful, lets hope everyone rounds in the same way. :)
>> + m >>= 1;
>> + n >>= 1;
>> + }
>> + } else if (m < m2) {
>> + while (m < m2) {
>> + m2 >>= 1;
>> + n2 >>= 1;
>> + }
>> + }
>> +
>> + return m == m2 && n == n2;
>> +}
>> +
>> +static bool
>> +intel_compare_link_m_n(const struct intel_link_m_n *m_n,
>> + const struct intel_link_m_n *m2_n2)
> I think these need to take adjust as an agurment and check for exact match
> (not just matching ratio), like before.
I just implemented it, then remembered why I didn't.
It will cause a failure in intel_modeset_check_state.
>> +{
>> + if (m_n->tu == m2_n2->tu &&
>> + intel_compare_m_n(m_n->gmch_m, m_n->gmch_n,
>> + m2_n2->gmch_m, m2_n2->gmch_n) &&
>> + intel_compare_m_n(m_n->link_m, m_n->link_n,
>> + m2_n2->link_m, m2_n2->link_n))
>> + return true;
>> +
>> + return false;
>> +}
>> +
>> static bool
>> intel_pipe_config_compare(struct drm_device *dev,
>> struct intel_crtc_state *current_config,
>> - struct intel_crtc_state *pipe_config)
>> + struct intel_crtc_state *pipe_config,
>> + bool adjust)
>> {
>> + bool ret = true;
>> +
>> +#define INTEL_ERR_OR_DBG_KMS(fmt, ...) \
>> + do { \
>> + if (!adjust) \
>> + DRM_ERROR(fmt, ##__VA_ARGS__); \
>> + else \
>> + DRM_DEBUG_KMS(fmt, ##__VA_ARGS__); \
>> + } while (0)
>> +
>> #define PIPE_CONF_CHECK_X(name) \
>> if (current_config->name != pipe_config->name) { \
>> - DRM_ERROR("mismatch in " #name " " \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
>> "(expected 0x%08x, found 0x%08x)\n", \
>> current_config->name, \
>> pipe_config->name); \
>> - return false; \
>> + ret = false; \
>> }
>>
>> #define PIPE_CONF_CHECK_I(name) \
>> if (current_config->name != pipe_config->name) { \
>> - DRM_ERROR("mismatch in " #name " " \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
>> "(expected %i, found %i)\n", \
>> current_config->name, \
>> pipe_config->name); \
>> - return false; \
>> + ret = false; \
>> + }
>> +
>> +#define PIPE_CONF_CHECK_M_N(name) \
>> + if (!intel_compare_link_m_n(¤t_config->name, \
>> + &pipe_config->name)) { \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
>> + "(expected tu %i gmch %i/%i link %i/%i, " \
>> + "found tu %i, gmch %i/%i link %i/%i)\n", \
>> + current_config->name.tu, \
>> + current_config->name.gmch_m, \
>> + current_config->name.gmch_n, \
>> + current_config->name.link_m, \
>> + current_config->name.link_n, \
>> + pipe_config->name.tu, \
>> + pipe_config->name.gmch_m, \
>> + pipe_config->name.gmch_n, \
>> + pipe_config->name.link_m, \
>> + pipe_config->name.link_n); \
>> + ret = false; \
>> + }
>> +
>> +#define PIPE_CONF_CHECK_M_N_ALT(name, alt_name) \
>> + if (!intel_compare_link_m_n(¤t_config->name, \
>> + &pipe_config->name) && \
>> + !intel_compare_link_m_n(¤t_config->alt_name, \
>> + &pipe_config->name)) { \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
>> + "(expected tu %i gmch %i/%i link %i/%i, " \
>> + "or tu %i gmch %i/%i link %i/%i, " \
>> + "found tu %i, gmch %i/%i link %i/%i)\n", \
>> + current_config->name.tu, \
>> + current_config->name.gmch_m, \
>> + current_config->name.gmch_n, \
>> + current_config->name.link_m, \
>> + current_config->name.link_n, \
>> + current_config->alt_name.tu, \
>> + current_config->alt_name.gmch_m, \
>> + current_config->alt_name.gmch_n, \
>> + current_config->alt_name.link_m, \
>> + current_config->alt_name.link_n, \
>> + pipe_config->name.tu, \
>> + pipe_config->name.gmch_m, \
>> + pipe_config->name.gmch_n, \
>> + pipe_config->name.link_m, \
>> + pipe_config->name.link_n); \
>> + ret = false; \
>> }
>>
>> /* This is required for BDW+ where there is only one set of registers for
>> @@ -12423,30 +12507,30 @@ intel_pipe_config_compare(struct drm_device *dev,
>> #define PIPE_CONF_CHECK_I_ALT(name, alt_name) \
>> if ((current_config->name != pipe_config->name) && \
>> (current_config->alt_name != pipe_config->name)) { \
>> - DRM_ERROR("mismatch in " #name " " \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
>> "(expected %i or %i, found %i)\n", \
>> current_config->name, \
>> current_config->alt_name, \
>> pipe_config->name); \
>> - return false; \
>> + ret = false; \
>> }
>>
>> #define PIPE_CONF_CHECK_FLAGS(name, mask) \
>> if ((current_config->name ^ pipe_config->name) & (mask)) { \
>> - DRM_ERROR("mismatch in " #name "(" #mask ") " \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name "(" #mask ") " \
>> "(expected %i, found %i)\n", \
>> current_config->name & (mask), \
>> pipe_config->name & (mask)); \
>> - return false; \
>> + ret = false; \
>> }
>>
>> #define PIPE_CONF_CHECK_CLOCK_FUZZY(name) \
>> if (!intel_fuzzy_clock_check(current_config->name, pipe_config->name)) { \
>> - DRM_ERROR("mismatch in " #name " " \
>> + INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
>> "(expected %i, found %i)\n", \
>> current_config->name, \
>> pipe_config->name); \
>> - return false; \
>> + ret = false; \
>> }
>>
>> #define PIPE_CONF_QUIRK(quirk) \
>> @@ -12456,35 +12540,18 @@ intel_pipe_config_compare(struct drm_device *dev,
>>
>> PIPE_CONF_CHECK_I(has_pch_encoder);
>> PIPE_CONF_CHECK_I(fdi_lanes);
>> - PIPE_CONF_CHECK_I(fdi_m_n.gmch_m);
>> - PIPE_CONF_CHECK_I(fdi_m_n.gmch_n);
>> - PIPE_CONF_CHECK_I(fdi_m_n.link_m);
>> - PIPE_CONF_CHECK_I(fdi_m_n.link_n);
>> - PIPE_CONF_CHECK_I(fdi_m_n.tu);
>> + PIPE_CONF_CHECK_M_N(fdi_m_n);
>>
>> PIPE_CONF_CHECK_I(has_dp_encoder);
>>
>> if (INTEL_INFO(dev)->gen < 8) {
>> - PIPE_CONF_CHECK_I(dp_m_n.gmch_m);
>> - PIPE_CONF_CHECK_I(dp_m_n.gmch_n);
>> - PIPE_CONF_CHECK_I(dp_m_n.link_m);
>> - PIPE_CONF_CHECK_I(dp_m_n.link_n);
>> - PIPE_CONF_CHECK_I(dp_m_n.tu);
>> -
>> - if (current_config->has_drrs) {
>> - PIPE_CONF_CHECK_I(dp_m2_n2.gmch_m);
>> - PIPE_CONF_CHECK_I(dp_m2_n2.gmch_n);
>> - PIPE_CONF_CHECK_I(dp_m2_n2.link_m);
>> - PIPE_CONF_CHECK_I(dp_m2_n2.link_n);
>> - PIPE_CONF_CHECK_I(dp_m2_n2.tu);
>> - }
>> - } else {
>> - PIPE_CONF_CHECK_I_ALT(dp_m_n.gmch_m, dp_m2_n2.gmch_m);
>> - PIPE_CONF_CHECK_I_ALT(dp_m_n.gmch_n, dp_m2_n2.gmch_n);
>> - PIPE_CONF_CHECK_I_ALT(dp_m_n.link_m, dp_m2_n2.link_m);
>> - PIPE_CONF_CHECK_I_ALT(dp_m_n.link_n, dp_m2_n2.link_n);
>> - PIPE_CONF_CHECK_I_ALT(dp_m_n.tu, dp_m2_n2.tu);
>> - }
>> + PIPE_CONF_CHECK_M_N(dp_m_n);
>> +
>> + PIPE_CONF_CHECK_I(has_drrs);
>> + if (current_config->has_drrs)
>> + PIPE_CONF_CHECK_M_N(dp_m2_n2);
>> + } else
>> + PIPE_CONF_CHECK_M_N_ALT(dp_m_n, dp_m2_n2);
>>
>> PIPE_CONF_CHECK_I(base.adjusted_mode.crtc_hdisplay);
>> PIPE_CONF_CHECK_I(base.adjusted_mode.crtc_htotal);
>> @@ -12580,8 +12647,9 @@ intel_pipe_config_compare(struct drm_device *dev,
>> #undef PIPE_CONF_CHECK_FLAGS
>> #undef PIPE_CONF_CHECK_CLOCK_FUZZY
>> #undef PIPE_CONF_QUIRK
>> +#undef INTEL_ERR_OR_DBG_KMS
>>
>> - return true;
>> + return ret;
>> }
>>
>> static void check_wm_state(struct drm_device *dev)
>> @@ -12773,8 +12841,11 @@ check_crtc_state(struct drm_device *dev)
>> "transitional active state does not match atomic hw state "
>> "(expected %i, found %i)\n", crtc->base.state->active, crtc->active);
>>
>> - if (active &&
>> - !intel_pipe_config_compare(dev, crtc->config, &pipe_config)) {
>> + if (!active)
>> + continue;
>> +
>> + if (!intel_pipe_config_compare(dev, crtc->config,
>> + &pipe_config, false)) {
>> I915_STATE_WARN(1, "pipe state doesn't match!\n");
>> intel_dump_pipe_config(crtc, &pipe_config,
>> "[hw state]");
>> @@ -13075,14 +13146,16 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
>> return ret;
>>
>> for_each_crtc_in_state(state, crtc, crtc_state, i) {
>> + struct intel_crtc_state *pipe_config =
>> + to_intel_crtc_state(crtc_state);
>> +
>> if (!crtc_state->enable) {
>> if (needs_modeset(crtc_state))
>> any_ms = true;
>> continue;
>> }
>>
>> - if (to_intel_crtc_state(crtc_state)->quirks &
>> - PIPE_CONFIG_QUIRK_INITIAL_PLANES) {
>> + if (pipe_config->quirks & PIPE_CONFIG_QUIRK_INITIAL_PLANES) {
>> ret = drm_atomic_add_affected_planes(state, crtc);
>> if (ret)
>> return ret;
>> @@ -13096,21 +13169,28 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
>> }
>>
>> if (!needs_modeset(crtc_state)) {
>> + if (!(pipe_config->quirks & PIPE_CONFIG_QUIRK_INHERITED_MODE))
>> + continue;
> double negative is harder to read ... what about:
>
> if (!needs_modeset && !INHERITED_MODE)
> continue;
>
> And then just unconditionally doing the
> add_affected_connectors? It'll be redundant almost always,
> but it also won't really matter since it'll be fast.
Ok.
>> +
>> ret = drm_atomic_add_affected_connectors(state, crtc);
>> if (ret)
>> return ret;
>> }
>>
>> - ret = intel_modeset_pipe_config(crtc,
>> - to_intel_crtc_state(crtc_state));
>> + ret = intel_modeset_pipe_config(crtc, pipe_config);
>> if (ret)
>> return ret;
>>
>> - if (needs_modeset(crtc_state))
>> - any_ms = true;
>> + if (!intel_pipe_config_compare(state->dev,
>> + to_intel_crtc_state(crtc->state),
>> + pipe_config, true))
>> + crtc_state->mode_changed = true;
>> + else if (!needs_modeset(crtc_state))
>> + continue;
> Hm for bebugging I'd always dump the pipe config, even if we notice that
> fastboot is posible. Perhaps changes the "[modeset]" below to a
>
> needs_modset() ? "[modeset: full]" : "[modeset: fast]"
Ok.
~Maarten
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-07-08 8:38 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 7:08 [PATCH v2 00/20] Convert to atomic, part 4 Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 01/20] drm/atomic: add connectors_changed to separate it from mode_changed Maarten Lankhorst
2015-07-07 8:59 ` Daniel Vetter
2015-07-07 10:05 ` Maarten Lankhorst
2015-07-07 12:03 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 02/20] drm: Don't update plane properties for atomic planes if it stays the same Maarten Lankhorst
2015-07-07 9:18 ` [Intel-gfx] " Daniel Vetter
2015-07-07 10:20 ` Maarten Lankhorst
2015-07-07 12:10 ` [Intel-gfx] " Daniel Vetter
2015-07-07 14:32 ` Maarten Lankhorst
2015-07-07 16:40 ` Daniel Vetter
2015-07-07 15:08 ` Maarten Lankhorst
2015-07-07 16:43 ` Daniel Vetter
2015-07-08 8:00 ` [Intel-gfx] " Maarten Lankhorst
2015-07-08 8:55 ` Daniel Vetter
2015-07-08 16:35 ` Maarten Lankhorst
2015-07-08 17:52 ` [Intel-gfx] " Daniel Vetter
2015-07-08 18:25 ` Maarten Lankhorst
2015-07-08 20:12 ` Daniel Vetter
2015-07-13 8:59 ` Maarten Lankhorst
2015-07-13 9:13 ` [Intel-gfx] " Daniel Vetter
2015-07-13 9:23 ` Maarten Lankhorst
2015-07-13 9:45 ` Daniel Vetter
2015-07-13 9:49 ` Maarten Lankhorst
2015-07-13 10:06 ` [Intel-gfx] " Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 03/20] drm/i915: Fix noatomic crtc disabling Maarten Lankhorst
2015-07-07 9:18 ` Daniel Vetter
2015-07-07 10:22 ` Maarten Lankhorst
2015-07-07 12:39 ` Patrik Jakobsson
2015-07-07 14:14 ` Maarten Lankhorst
2015-07-08 8:12 ` Patrik Jakobsson
2015-07-08 8:50 ` Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 04/20] drm/i915: Do not update pfit state when toggling crtc enabled Maarten Lankhorst
2015-07-07 9:26 ` Daniel Vetter
2015-07-07 10:46 ` Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 05/20] drm/i915: Do not use plane_config in intel_fbdev.c Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 06/20] drm/i915: Allow fuzzy matching in pipe_config_compare Maarten Lankhorst
2015-07-07 10:11 ` Daniel Vetter
2015-07-08 8:38 ` Maarten Lankhorst [this message]
2015-07-08 9:09 ` Daniel Vetter
2015-07-08 9:18 ` Maarten Lankhorst
2015-07-08 9:33 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 07/20] drm/i915: Rework primary plane stuff slightly Maarten Lankhorst
2015-07-07 11:16 ` Daniel Vetter
2015-07-07 14:02 ` Maarten Lankhorst
2015-07-08 9:27 ` Daniel Vetter
2015-07-08 12:36 ` Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 08/20] drm/i915: fill in more mode members Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 09/20] drm/i915: Fill in more crtc state, v2 Maarten Lankhorst
2015-07-07 10:28 ` Daniel Vetter
2015-07-13 9:32 ` Maarten Lankhorst
2015-07-13 9:48 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 10/20] drm/i915: Convert suspend/resume to atomic Maarten Lankhorst
2015-07-07 9:57 ` Daniel Vetter
2015-07-07 10:33 ` Maarten Lankhorst
2015-07-07 13:14 ` Daniel Vetter
2015-07-07 13:20 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 11/20] drm/i915: Update power domains on readout Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 12/20] drm/i915: skip modeset if compatible, and enable fastboot for everyone, v2 Maarten Lankhorst
2015-07-07 10:14 ` Daniel Vetter
2015-07-07 10:34 ` Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 13/20] drm/i915: Always reset in intel_crtc_restore_mode Maarten Lankhorst
2015-07-07 10:17 ` Daniel Vetter
2015-07-07 10:48 ` Maarten Lankhorst
2015-07-07 13:16 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 14/20] drm/i915: Make intel_display_suspend atomic, try 2 Maarten Lankhorst
2015-07-07 9:48 ` Daniel Vetter
2015-07-07 10:50 ` Maarten Lankhorst
2015-07-07 13:21 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 15/20] drm/i915: Use full atomic modeset Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 16/20] drm/i915: Call plane update functions directly from intel_atomic_commit Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 17/20] drm/i915: always disable irqs in intel_pipe_update_start Maarten Lankhorst
2015-07-07 7:08 ` [PATCH v2 18/20] drm/i915: Only commit planes on crtc's that have changed planes Maarten Lankhorst
2015-07-07 9:33 ` Daniel Vetter
2015-07-07 10:51 ` Maarten Lankhorst
2015-07-07 13:22 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 19/20] drm/i915: Remove use of runtime pm in atomic commit functions Maarten Lankhorst
2015-07-07 10:19 ` Daniel Vetter
2015-07-07 7:08 ` [PATCH v2 20/20] drm/i915: Skip modeset checks when modeset is prevented Maarten Lankhorst
2015-07-07 13:42 ` [PATCH v2 00/20] Convert to atomic, part 4 Daniel Vetter
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=559CE189.4030106@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=daniel@ffwll.ch \
--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 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.