diff mbox series

[01/27] drm/i915: Flush context free work on cleanup

Message ID 20191112092854.869-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [01/27] drm/i915: Flush context free work on cleanup | expand

Commit Message

Chris Wilson Nov. 12, 2019, 9:28 a.m. UTC
Throw in a flush_work() and rcu_barrier() to specifically flush the
context cleanup work.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=112248
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 +
 drivers/gpu/drm/i915/gt/intel_engine_cs.c   | 1 +
 2 files changed, 2 insertions(+)

Comments

Mika Kuoppala Nov. 12, 2019, 2:23 p.m. UTC | #1
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Throw in a flush_work() and rcu_barrier() to specifically flush the
> context cleanup work.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=112248
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 +
>  drivers/gpu/drm/i915/gt/intel_engine_cs.c   | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 72d389afa28a..17f395672e5e 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -776,6 +776,7 @@ int i915_gem_init_contexts(struct drm_i915_private *i915)
>  void i915_gem_driver_release__contexts(struct drm_i915_private *i915)
>  {
>  	destroy_kernel_context(&i915->kernel_context);
> +	flush_work(&i915->gem.contexts.free_work);
>  }
>  
>  static int context_idr_cleanup(int id, void *p, void *data)
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index b9613d044393..1f68700a2311 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -402,6 +402,7 @@ void intel_engines_cleanup(struct intel_gt *gt)
>  		gt->engine[id] = NULL;
>  		gt->i915->engine[id] = NULL;
>  	}
> +	rcu_barrier();

I guess we need this for releasing kernel_ctx but I don't see why
exactly.
-Mika


>  }
>  
>  /**
> -- 
> 2.24.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Nov. 12, 2019, 2:39 p.m. UTC | #2
Quoting Mika Kuoppala (2019-11-12 14:23:14)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> 
> > Throw in a flush_work() and rcu_barrier() to specifically flush the
> > context cleanup work.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=112248
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 +
> >  drivers/gpu/drm/i915/gt/intel_engine_cs.c   | 1 +
> >  2 files changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> > index 72d389afa28a..17f395672e5e 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> > @@ -776,6 +776,7 @@ int i915_gem_init_contexts(struct drm_i915_private *i915)
> >  void i915_gem_driver_release__contexts(struct drm_i915_private *i915)
> >  {
> >       destroy_kernel_context(&i915->kernel_context);
> > +     flush_work(&i915->gem.contexts.free_work);
> >  }
> >  
> >  static int context_idr_cleanup(int id, void *p, void *data)
> > diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > index b9613d044393..1f68700a2311 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > @@ -402,6 +402,7 @@ void intel_engines_cleanup(struct intel_gt *gt)
> >               gt->engine[id] = NULL;
> >               gt->i915->engine[id] = NULL;
> >       }
> > +     rcu_barrier();
> 
> I guess we need this for releasing kernel_ctx but I don't see why
> exactly.

It's the rcu'ed ppgtt I worry about.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 72d389afa28a..17f395672e5e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -776,6 +776,7 @@  int i915_gem_init_contexts(struct drm_i915_private *i915)
 void i915_gem_driver_release__contexts(struct drm_i915_private *i915)
 {
 	destroy_kernel_context(&i915->kernel_context);
+	flush_work(&i915->gem.contexts.free_work);
 }
 
 static int context_idr_cleanup(int id, void *p, void *data)
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index b9613d044393..1f68700a2311 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -402,6 +402,7 @@  void intel_engines_cleanup(struct intel_gt *gt)
 		gt->engine[id] = NULL;
 		gt->i915->engine[id] = NULL;
 	}
+	rcu_barrier();
 }
 
 /**