From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 2/4] drm/i915: Add belts and suspenders locking for seamless M/N changes
Date: Tue, 07 Mar 2023 14:24:08 +0200 [thread overview]
Message-ID: <87a60osqaf.fsf@intel.com> (raw)
In-Reply-To: <20230306152841.6563-2-ville.syrjala@linux.intel.com>
On Mon, 06 Mar 2023, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Add some (probably overkill) locking to protect the vblank
> timestamping constants updates during seamless M/N fastsets.
>
> As everything should be naturally aligned I think the individual
> pieces should probably end up updating atomically enough. So this
> is only really meant to guarantee everyone sees a consistent whole.
>
> All the drm_vblank.c usage is covered by vblank_time_lock,
> and uncore.lock will take care of __intel_get_crtc_scanline()
> that can also be called from outside the core vblank functionality.
The patch seems to do what it says on the box, but I increasingly
dislike the use of uncore.lock for anything other than the nuts and
bolts of uncore.
BR,
Jani.
>
> Currently only crtc_clock and framedur_ns can change, but in
> the future might fastset also across eg. vtotal/vblank_end
> changes, so let's just grab the locks across the whole thing.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_display.c | 24 +++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index a1fbdf32bd21..020320468967 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -5908,6 +5908,8 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
> struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> struct drm_display_mode adjusted_mode;
> + int vmax_vblank_start = 0;
> + unsigned long irqflags;
>
> drm_mode_init(&adjusted_mode, &crtc_state->hw.adjusted_mode);
>
> @@ -5915,11 +5917,28 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
> adjusted_mode.crtc_vtotal = crtc_state->vrr.vmax;
> adjusted_mode.crtc_vblank_end = crtc_state->vrr.vmax;
> adjusted_mode.crtc_vblank_start = intel_vrr_vmin_vblank_start(crtc_state);
> - crtc->vmax_vblank_start = intel_vrr_vmax_vblank_start(crtc_state);
> + vmax_vblank_start = intel_vrr_vmax_vblank_start(crtc_state);
> }
>
> + /*
> + * Belts and suspenders locking to guarantee everyone sees 100%
> + * consistent state during fastset seamless refresh rate changes.
> + *
> + * vblank_time_lock takes care of all drm_vblank.c stuff, and
> + * uncore.lock takes care of __intel_get_crtc_scanline() which
> + * may get called elsewhere as well.
> + *
> + * TODO maybe just protect everything (including
> + * __intel_get_crtc_scanline()) with vblank_time_lock?
> + * Need to audit everything to make sure it's safe.
> + */
> + spin_lock_irqsave(&dev_priv->drm.vblank_time_lock, irqflags);
> + spin_lock(&dev_priv->uncore.lock);
> +
> drm_calc_timestamping_constants(&crtc->base, &adjusted_mode);
>
> + crtc->vmax_vblank_start = vmax_vblank_start;
> +
> crtc->mode_flags = crtc_state->mode_flags;
>
> /*
> @@ -5963,6 +5982,9 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
> } else {
> crtc->scanline_offset = 1;
> }
> +
> + spin_unlock(&dev_priv->uncore.lock);
> + spin_unlock_irqrestore(&dev_priv->drm.vblank_time_lock, irqflags);
> }
>
> /*
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2023-03-07 12:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 15:28 [Intel-gfx] [PATCH 1/4] drm/i915: Update vblank timestamping stuff on seamless M/N change Ville Syrjala
2023-03-06 15:28 ` [Intel-gfx] [PATCH 2/4] drm/i915: Add belts and suspenders locking for seamless M/N changes Ville Syrjala
2023-03-07 12:24 ` Jani Nikula [this message]
2023-03-07 14:13 ` Ville Syrjälä
2023-03-07 14:23 ` Jani Nikula
2023-03-06 15:28 ` [Intel-gfx] [PATCH 3/4] drm/i915: Relocate intel_crtc_update_active_timings() Ville Syrjala
2023-03-07 12:28 ` Jani Nikula
2023-03-10 19:41 ` Golani, Mitulkumar Ajitkumar
2023-03-06 15:28 ` [Intel-gfx] [PATCH 4/4] drm/i915: Extract intel_crtc_scanline_offset() Ville Syrjala
2023-03-07 12:29 ` Jani Nikula
2023-03-10 19:42 ` Golani, Mitulkumar Ajitkumar
2023-03-07 12:16 ` [Intel-gfx] [PATCH 1/4] drm/i915: Update vblank timestamping stuff on seamless M/N change Jani Nikula
2023-03-07 14:13 ` Ville Syrjälä
2023-03-10 19:01 ` Golani, Mitulkumar Ajitkumar
2023-03-10 20:46 ` Ville Syrjälä
2023-03-10 23:45 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [1/4] drm/i915: Update vblank timestamping stuff on seamless M/N change (rev4) 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=87a60osqaf.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox