* [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation
@ 2014-05-30 13:16 Chris Wilson
2014-05-30 17:44 ` Ben Widawsky
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Chris Wilson @ 2014-05-30 13:16 UTC (permalink / raw)
To: intel-gfx; +Cc: Mika Kuoppala, Ben Widawsky
Fallout from
commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e
Author: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Date: Wed May 21 19:01:06 2014 +0300
drm/i915: Add null state batch to active list
undid the earlier fix of only marking the ctx as initialised after it is
saved by the hardware during a SET_CONTEXT operation.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Damien Lespiau <damien.lespiau@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Ben Widawsky <ben@bwidawsk.net>
---
drivers/gpu/drm/i915/i915_gem_context.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 5a71ef1975b3..34a0b49e6add 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -641,6 +641,7 @@ static int do_switch(struct intel_engine_cs *ring,
struct intel_context *from = ring->last_context;
struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to);
u32 hw_flags = 0;
+ bool uninitialized = false;
int ret, i;
if (from != NULL && ring == &dev_priv->ring[RCS]) {
@@ -739,18 +740,19 @@ static int do_switch(struct intel_engine_cs *ring,
i915_gem_context_unreference(from);
}
+ uninitialized = !to->is_initialized && from == NULL;
+ to->is_initialized = true;
+
done:
i915_gem_context_reference(to);
ring->last_context = to;
- if (ring->id == RCS && !to->is_initialized && from == NULL) {
+ if (uninitialized) {
ret = i915_gem_render_state_init(ring);
if (ret)
DRM_ERROR("init render state: %d\n", ret);
}
- to->is_initialized = true;
-
return 0;
unpin_out:
--
2.0.0.rc4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-05-30 13:16 [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation Chris Wilson @ 2014-05-30 17:44 ` Ben Widawsky 2014-05-30 17:49 ` Chris Wilson 2014-06-10 10:34 ` Chris Wilson 2014-06-23 9:55 ` Jani Nikula 2 siblings, 1 reply; 8+ messages in thread From: Ben Widawsky @ 2014-05-30 17:44 UTC (permalink / raw) To: Chris Wilson; +Cc: intel-gfx, Mika Kuoppala On Fri, May 30, 2014 at 02:16:30PM +0100, Chris Wilson wrote: > Fallout from > > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> > Date: Wed May 21 19:01:06 2014 +0300 > > drm/i915: Add null state batch to active list > > undid the earlier fix of only marking the ctx as initialised after it is > saved by the hardware during a SET_CONTEXT operation. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> > Cc: Damien Lespiau <damien.lespiau@intel.com> > Cc: Mika Kuoppala <mika.kuoppala@intel.com> > Cc: Ben Widawsky <ben@bwidawsk.net> > --- > drivers/gpu/drm/i915/i915_gem_context.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c > index 5a71ef1975b3..34a0b49e6add 100644 > --- a/drivers/gpu/drm/i915/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/i915_gem_context.c > @@ -641,6 +641,7 @@ static int do_switch(struct intel_engine_cs *ring, > struct intel_context *from = ring->last_context; > struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to); > u32 hw_flags = 0; > + bool uninitialized = false; > int ret, i; > > if (from != NULL && ring == &dev_priv->ring[RCS]) { > @@ -739,18 +740,19 @@ static int do_switch(struct intel_engine_cs *ring, > i915_gem_context_unreference(from); > } > > + uninitialized = !to->is_initialized && from == NULL; > + to->is_initialized = true; Aren't you missing some error paths if you do this? I think we need to set the state after we've successfully emitted the MI_SET_CONTEXT command (though really, until we move the ringbuffer tail, it's all lies, on that note, I'm scared to look at if reset dtrt). > + > done: > i915_gem_context_reference(to); > ring->last_context = to; > > - if (ring->id == RCS && !to->is_initialized && from == NULL) { > + if (uninitialized) { > ret = i915_gem_render_state_init(ring); > if (ret) > DRM_ERROR("init render state: %d\n", ret); > } > > - to->is_initialized = true; > - > return 0; > > unpin_out: I just realized the from == NULL check is something which seems fragile to me given how much churn we might see with init/reset paths. It'd probably be good to eventually switch to some global state in dev_priv which we can track across init/reset/fini Otherwise it looks correct to me. -- Ben Widawsky, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-05-30 17:44 ` Ben Widawsky @ 2014-05-30 17:49 ` Chris Wilson 0 siblings, 0 replies; 8+ messages in thread From: Chris Wilson @ 2014-05-30 17:49 UTC (permalink / raw) To: Ben Widawsky; +Cc: intel-gfx, Mika Kuoppala On Fri, May 30, 2014 at 10:44:53AM -0700, Ben Widawsky wrote: > On Fri, May 30, 2014 at 02:16:30PM +0100, Chris Wilson wrote: > > Fallout from > > > > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e > > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> > > Date: Wed May 21 19:01:06 2014 +0300 > > > > drm/i915: Add null state batch to active list > > > > undid the earlier fix of only marking the ctx as initialised after it is > > saved by the hardware during a SET_CONTEXT operation. > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Cc: Damien Lespiau <damien.lespiau@intel.com> > > Cc: Mika Kuoppala <mika.kuoppala@intel.com> > > Cc: Ben Widawsky <ben@bwidawsk.net> > > --- > > drivers/gpu/drm/i915/i915_gem_context.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c > > index 5a71ef1975b3..34a0b49e6add 100644 > > --- a/drivers/gpu/drm/i915/i915_gem_context.c > > +++ b/drivers/gpu/drm/i915/i915_gem_context.c > > @@ -641,6 +641,7 @@ static int do_switch(struct intel_engine_cs *ring, > > struct intel_context *from = ring->last_context; > > struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to); > > u32 hw_flags = 0; > > + bool uninitialized = false; > > int ret, i; > > > > if (from != NULL && ring == &dev_priv->ring[RCS]) { > > @@ -739,18 +740,19 @@ static int do_switch(struct intel_engine_cs *ring, > > i915_gem_context_unreference(from); > > } > > > > + uninitialized = !to->is_initialized && from == NULL; > > + to->is_initialized = true; > > Aren't you missing some error paths if you do this? I think we need to > set the state after we've successfully emitted the MI_SET_CONTEXT > command (though really, until we move the ringbuffer tail, it's all > lies, on that note, I'm scared to look at if reset dtrt). I also think that until we successfully emit the MI_SET_CONTEXT and allow the execbuffer to proceed, we can continue to treat the context as garbage and force-inhibit on the next attempt to run the execbuffer. > > + > > done: > > i915_gem_context_reference(to); > > ring->last_context = to; > > > > - if (ring->id == RCS && !to->is_initialized && from == NULL) { > > + if (uninitialized) { > > ret = i915_gem_render_state_init(ring); > > if (ret) > > DRM_ERROR("init render state: %d\n", ret); > > } > > > > - to->is_initialized = true; > > - > > return 0; > > > > unpin_out: > > I just realized the from == NULL check is something which seems fragile > to me given how much churn we might see with init/reset paths. It'd > probably be good to eventually switch to some global state in dev_priv > which we can track across init/reset/fini It's as fragile as the bug we are papering over. Presumably we do need to apply fresh paper after a GPU reset, but it is hard to tell without knowing the bug. -Chris -- Chris Wilson, Intel Open Source Technology Centre ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-05-30 13:16 [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation Chris Wilson 2014-05-30 17:44 ` Ben Widawsky @ 2014-06-10 10:34 ` Chris Wilson 2014-06-10 13:17 ` Daniel Vetter 2014-06-23 9:55 ` Jani Nikula 2 siblings, 1 reply; 8+ messages in thread From: Chris Wilson @ 2014-06-10 10:34 UTC (permalink / raw) To: intel-gfx; +Cc: Ben Widawsky, Mika Kuoppala On Fri, May 30, 2014 at 02:16:30PM +0100, Chris Wilson wrote: > Fallout from > > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> > Date: Wed May 21 19:01:06 2014 +0300 > > drm/i915: Add null state batch to active list > > undid the earlier fix of only marking the ctx as initialised after it is > saved by the hardware during a SET_CONTEXT operation. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> > Cc: Damien Lespiau <damien.lespiau@intel.com> > Cc: Mika Kuoppala <mika.kuoppala@intel.com> > Cc: Ben Widawsky <ben@bwidawsk.net> Ping. Ben's comments do not impact upon the urgent need for this fix. -Chris -- Chris Wilson, Intel Open Source Technology Centre ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-06-10 10:34 ` Chris Wilson @ 2014-06-10 13:17 ` Daniel Vetter 0 siblings, 0 replies; 8+ messages in thread From: Daniel Vetter @ 2014-06-10 13:17 UTC (permalink / raw) To: Chris Wilson, intel-gfx, Ville Syrjälä, Damien Lespiau, Mika Kuoppala, Ben Widawsky On Tue, Jun 10, 2014 at 11:34:34AM +0100, Chris Wilson wrote: > On Fri, May 30, 2014 at 02:16:30PM +0100, Chris Wilson wrote: > > Fallout from > > > > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e > > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> > > Date: Wed May 21 19:01:06 2014 +0300 > > > > drm/i915: Add null state batch to active list > > > > undid the earlier fix of only marking the ctx as initialised after it is > > saved by the hardware during a SET_CONTEXT operation. > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Cc: Damien Lespiau <damien.lespiau@intel.com> > > Cc: Mika Kuoppala <mika.kuoppala@intel.com> > > Cc: Ben Widawsky <ben@bwidawsk.net> > > Ping. Ben's comments do not impact upon the urgent need for this fix. Ok, this code is extremely convoluted. ctx->last_ring is terrible, and we should make a clear disdinction of which ctx->foo fields are for the logical context and which for the per-engine stuff. Will be much more important for execlists so that we properly fan out the state. I'm ranting here a bit since it took me a while to realize that ->is_initialized is _only_ for the RCS stuff. I guess we should have ctx->obj[ring] and ctx->is_initialized[ring] or even better, a substruct i915_hw_context with an array. </rant> With that out of the way, this is Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Thanks, Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-05-30 13:16 [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation Chris Wilson 2014-05-30 17:44 ` Ben Widawsky 2014-06-10 10:34 ` Chris Wilson @ 2014-06-23 9:55 ` Jani Nikula 2014-06-23 15:51 ` Ben Widawsky 2 siblings, 1 reply; 8+ messages in thread From: Jani Nikula @ 2014-06-23 9:55 UTC (permalink / raw) To: Chris Wilson, intel-gfx; +Cc: Ben Widawsky, Mika Kuoppala On Fri, 30 May 2014, Chris Wilson <chris@chris-wilson.co.uk> wrote: > Fallout from > > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> > Date: Wed May 21 19:01:06 2014 +0300 > > drm/i915: Add null state batch to active list > > undid the earlier fix of only marking the ctx as initialised after it is > saved by the hardware during a SET_CONTEXT operation. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> > Cc: Damien Lespiau <damien.lespiau@intel.com> > Cc: Mika Kuoppala <mika.kuoppala@intel.com> > Cc: Ben Widawsky <ben@bwidawsk.net> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79108 > --- > drivers/gpu/drm/i915/i915_gem_context.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c > index 5a71ef1975b3..34a0b49e6add 100644 > --- a/drivers/gpu/drm/i915/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/i915_gem_context.c > @@ -641,6 +641,7 @@ static int do_switch(struct intel_engine_cs *ring, > struct intel_context *from = ring->last_context; > struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to); > u32 hw_flags = 0; > + bool uninitialized = false; > int ret, i; > > if (from != NULL && ring == &dev_priv->ring[RCS]) { > @@ -739,18 +740,19 @@ static int do_switch(struct intel_engine_cs *ring, > i915_gem_context_unreference(from); > } > > + uninitialized = !to->is_initialized && from == NULL; > + to->is_initialized = true; > + > done: > i915_gem_context_reference(to); > ring->last_context = to; > > - if (ring->id == RCS && !to->is_initialized && from == NULL) { > + if (uninitialized) { > ret = i915_gem_render_state_init(ring); > if (ret) > DRM_ERROR("init render state: %d\n", ret); > } > > - to->is_initialized = true; > - > return 0; > > unpin_out: > -- > 2.0.0.rc4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-06-23 9:55 ` Jani Nikula @ 2014-06-23 15:51 ` Ben Widawsky 2014-06-24 13:20 ` Jani Nikula 0 siblings, 1 reply; 8+ messages in thread From: Ben Widawsky @ 2014-06-23 15:51 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx, Mika Kuoppala On Mon, Jun 23, 2014 at 12:55:47PM +0300, Jani Nikula wrote: > On Fri, 30 May 2014, Chris Wilson <chris@chris-wilson.co.uk> wrote: > > Fallout from > > > > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e > > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> > > Date: Wed May 21 19:01:06 2014 +0300 > > > > drm/i915: Add null state batch to active list > > > > undid the earlier fix of only marking the ctx as initialised after it is > > saved by the hardware during a SET_CONTEXT operation. > > > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> > > Cc: Damien Lespiau <damien.lespiau@intel.com> > > Cc: Mika Kuoppala <mika.kuoppala@intel.com> > > Cc: Ben Widawsky <ben@bwidawsk.net> > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79108 > Daniel put his IRC r-b on this on IIRC. [snip] -- Ben Widawsky, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation 2014-06-23 15:51 ` Ben Widawsky @ 2014-06-24 13:20 ` Jani Nikula 0 siblings, 0 replies; 8+ messages in thread From: Jani Nikula @ 2014-06-24 13:20 UTC (permalink / raw) To: Ben Widawsky; +Cc: intel-gfx, Mika Kuoppala On Mon, 23 Jun 2014, Ben Widawsky <ben@bwidawsk.net> wrote: > On Mon, Jun 23, 2014 at 12:55:47PM +0300, Jani Nikula wrote: >> On Fri, 30 May 2014, Chris Wilson <chris@chris-wilson.co.uk> wrote: >> > Fallout from >> > >> > commit 46470fc932ac8a0e8317a220b3f4ea4ed903338e >> > Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> >> > Date: Wed May 21 19:01:06 2014 +0300 >> > >> > drm/i915: Add null state batch to active list >> > >> > undid the earlier fix of only marking the ctx as initialised after it is >> > saved by the hardware during a SET_CONTEXT operation. >> > >> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> >> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> >> > Cc: Damien Lespiau <damien.lespiau@intel.com> >> > Cc: Mika Kuoppala <mika.kuoppala@intel.com> >> > Cc: Ben Widawsky <ben@bwidawsk.net> >> >> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79108 >> > > Daniel put his IRC r-b on this on IIRC. Pushed to -fixes, thanks for the patch and review. BR, Jani. > > [snip] > > -- > Ben Widawsky, Intel Open Source Technology Center -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-06-24 13:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-05-30 13:16 [PATCH] drm/i915: Only mark the ctx as initialised after a SET_CONTEXT operation Chris Wilson 2014-05-30 17:44 ` Ben Widawsky 2014-05-30 17:49 ` Chris Wilson 2014-06-10 10:34 ` Chris Wilson 2014-06-10 13:17 ` Daniel Vetter 2014-06-23 9:55 ` Jani Nikula 2014-06-23 15:51 ` Ben Widawsky 2014-06-24 13:20 ` Jani Nikula
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox