All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Brian Geffon <bgeffon@google.com>
Cc: intel-gfx@lists.freedesktop.org,
	Vidya Srinivas <vidya.srinivas@intel.com>
Subject: Re: [PATCH 3/4] drm/i915/dpt: Evict all DPT VMAs on suspend
Date: Tue, 3 Dec 2024 10:20:23 +0200	[thread overview]
Message-ID: <Z06_R3Rj78B81ULM@intel.com> (raw)
In-Reply-To: <CADyq12zaBCxJ_dZVadew+JMp1=uNVAJWYX-k45m76-G925UuTg@mail.gmail.com>

On Mon, Dec 02, 2024 at 10:40:36AM -0500, Brian Geffon wrote:
> On Wed, Nov 27, 2024 at 1:11 AM Ville Syrjala
> <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Currently intel_dpt_resume() tries to blindly rewrite all the
> > PTEs for currently bound DPT VMAs. That is problematic because
> > the CPU mapping for the DPT is only really guaranteed to exist
> > while the DPT object has been pinned. In the past we worked
> > around this issue by making DPT objects unshrinkable, but that
> > is undesirable as it'll waste physical RAM.
> >
> > Let's instead forcefully evict all the DPT VMAs on suspend,
> > thus guaranteeing that intel_dpt_resume() has nothing to do.
> > To guarantee that all the DPT VMAs are evictable by
> > intel_dpt_suspend() we need to flush the cleanup workqueue
> > after the display output has been shut down.
> >
> > And for good measure throw in a few extra WARNs to catch
> > any mistakes.
> >
> > Cc: Brian Geffon <bgeffon@google.com>
> > Cc: Vidya Srinivas <vidya.srinivas@intel.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  .../drm/i915/display/intel_display_driver.c   |  3 +++
> >  drivers/gpu/drm/i915/display/intel_dpt.c      |  4 ++--
> >  drivers/gpu/drm/i915/gt/intel_ggtt.c          | 19 ++++++++++++++-----
> >  drivers/gpu/drm/i915/gt/intel_gtt.h           |  4 ++--
> >  4 files changed, 21 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c
> > index 286d6f893afa..973bee43b554 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display_driver.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
> > @@ -680,6 +680,9 @@ int intel_display_driver_suspend(struct drm_i915_private *i915)
> >         else
> >                 i915->display.restore.modeset_state = state;
> >
> > +       /* ensure all DPT VMAs have been unpinned for intel_dpt_suspend() */
> > +       flush_workqueue(i915->display.wq.cleanup);
> > +
> >         intel_dp_mst_suspend(i915);
> >
> >         return ret;
> > diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c b/drivers/gpu/drm/i915/display/intel_dpt.c
> > index ce8c76e44e6a..8b1f0e92a11c 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dpt.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dpt.c
> > @@ -205,7 +205,7 @@ void intel_dpt_resume(struct drm_i915_private *i915)
> >                 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
> >
> >                 if (fb->dpt_vm)
> > -                       i915_ggtt_resume_vm(fb->dpt_vm);
> > +                       i915_ggtt_resume_vm(fb->dpt_vm, true);
> >         }
> >         mutex_unlock(&i915->drm.mode_config.fb_lock);
> >  }
> > @@ -233,7 +233,7 @@ void intel_dpt_suspend(struct drm_i915_private *i915)
> >                 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
> >
> >                 if (fb->dpt_vm)
> > -                       i915_ggtt_suspend_vm(fb->dpt_vm);
> > +                       i915_ggtt_suspend_vm(fb->dpt_vm, true);
> >         }
> >
> >         mutex_unlock(&i915->drm.mode_config.fb_lock);
> > diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > index d60a6ca0cae5..f6c59f20832f 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > @@ -107,11 +107,12 @@ int i915_ggtt_init_hw(struct drm_i915_private *i915)
> >  /**
> >   * i915_ggtt_suspend_vm - Suspend the memory mappings for a GGTT or DPT VM
> >   * @vm: The VM to suspend the mappings for
> > + * @evict_all: Evict all VMAs
> >   *
> >   * Suspend the memory mappings for all objects mapped to HW via the GGTT or a
> >   * DPT page table.
> >   */
> > -void i915_ggtt_suspend_vm(struct i915_address_space *vm)
> > +void i915_ggtt_suspend_vm(struct i915_address_space *vm, bool evict_all)
> >  {
> >         struct i915_vma *vma, *vn;
> >         int save_skip_rewrite;
> > @@ -157,7 +158,7 @@ void i915_ggtt_suspend_vm(struct i915_address_space *vm)
> >                         goto retry;
> >                 }
> >
> > -               if (!i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND)) {
> > +               if (evict_all || !i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND)) {
> 
> I don't fully understand this part. Why can we safely assume we can do
> __i915_vma_evict(), shouldn't we want to __i915_vma_unbind() in the
> case where it was bound? Because of the unconditional evict_all we
> might be unbinding a bound vma, no? Is that safe? Please forgive my
> ignorance if this question doesn't make sense.

It looked to me like __i915_vma_unbind() pretty much just calls
__i915_vma_evict() anyway, and the sync stuff shouldn't matter
here.

Hmm, I suppose there is that vma->node handling that might screw
us over somehow. I'll need to check what that actually does.

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2024-12-03  8:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27  6:11 [PATCH 0/4] drm/i915/dpt: Try to make DPT shrinkable again Ville Syrjala
2024-11-27  6:11 ` [PATCH 1/4] drm/i915: Don't reuse commit_work for the cleanup Ville Syrjala
2024-11-28  7:43   ` Srinivas, Vidya
2024-11-27  6:11 ` [PATCH 2/4] drm/i915: Intruduce display.wq.cleanup Ville Syrjala
2024-11-28  7:43   ` Srinivas, Vidya
2024-11-27  6:11 ` [PATCH 3/4] drm/i915/dpt: Evict all DPT VMAs on suspend Ville Syrjala
2024-11-27  8:32   ` Srinivas, Vidya
2024-11-28  7:44   ` Srinivas, Vidya
2024-12-02 15:40   ` Brian Geffon
2024-12-03  8:20     ` Ville Syrjälä [this message]
2024-12-03  8:25       ` Ville Syrjälä
2024-12-03 15:13         ` Brian Geffon
2024-11-27  6:11 ` [PATCH 4/4] Revert "drm/i915/dpt: Make DPT object unshrinkable" Ville Syrjala
2024-11-27  9:00   ` Brian Geffon
2024-11-28  7:44   ` Srinivas, Vidya
2024-11-27  6:38 ` ✗ Fi.CI.SPARSE: warning for drm/i915/dpt: Try to make DPT shrinkable again Patchwork
2024-11-27  6:55 ` ✓ i915.CI.BAT: success " Patchwork
2024-11-27  8:26 ` ✗ i915.CI.Full: failure " Patchwork
2024-11-27  8:54 ` [PATCH 0/4] " Srinivas, Vidya
2024-11-28 15:40 ` Ville Syrjälä

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=Z06_R3Rj78B81ULM@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=bgeffon@google.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=vidya.srinivas@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.