drm/i915: set ctx->initialized only after RCS
Subsystems (2)
PATCH 1/1 drm/i915: set ctx->initialized only after RCS
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2
It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Thanks to Chris for helping me track this down.
--- drivers/gpu/drm/i915/i915_gem_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +2 -1
@@ -686,10 +686,11 @@ static int do_switch(struct intel_ring_buffer *ring,i915_gem_context_unreference (from); } + to->is_initialized = true; + done:i915_gem_context_reference (to); ring->last_context = to; - to->is_initialized = true; to->last_ring = ring;return 0 ;
Signature · 1 line
1.8.5.2
Quoted 9 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
+context marked as initialised
Quoted 2 lines
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2
Note that step 2 is not required since the tracking is per-ring.
Quoted 5 lines
It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Though we did postulate that mesa could hit this in a pathological scenario with a freshly created context.
Quoted 4 lines
Thanks to Chris for helping me track this down.
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
Quoted 8 lines
Quoted 1 line
1. context 1 blit // context initialized
+context marked as initialised
Quoted 2 lines
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2Note that step 2 is not required since the tracking is per-ring.
This is missing an extremely important caveat which I was incorrectly correlating earlier in our discussion. Yes, step 2 is not required. The step which is required is the page allocated must be non-zero when allocated, and the contents of the page must be capable of hanging the GPU when used as a context object.
Otherwise, the uninitialized context would always be all 0, which if I understand the HW correctly, is "safe"
As long as you don't disagree, I'll fix the commit message with that info.
Quoted 18 lines
Quoted 5 lines
It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Though we did postulate that mesa could hit this in a pathological scenario with a freshly created context.
Quoted 4 lines
Thanks to Chris for helping me track this down.
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>Reviewed-by Chris Wilson <[email protected]>-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 16 lines · Ben Widawsky
Quoted 15 lines · Chris Wilson
Quoted 9 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
+context marked as initialised
Quoted 2 lines
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2
Quoted 8 lines
Quoted 2 lines
Note that step 2 is not required since the tracking is per-ring.
This is missing an extremely important caveat which I was incorrectly correlating earlier in our discussion. Yes, step 2 is not required. The step which is required is the page allocated must be non-zero when allocated, and the contents of the page must be capable of hanging the GPU when used as a context object.
Really? I'm pretty sure the last error state we looked at, the context was all zeroes.
Quoted 5 lines
Otherwise, the uninitialized context would always be all 0, which if I understand the HW correctly, is "safe"
As long as you don't disagree, I'll fix the commit message with that info.
Whatever you feel matches our best understanding of the problem. Just double check that last error state first ;-)
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 20 lines · Chris Wilson
Quoted 19 lines · Ben Widawsky
Quoted 17 lines · Chris Wilson
Quoted 9 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
+context marked as initialised
Quoted 2 lines
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2Note that step 2 is not required since the tracking is per-ring.
Quoted 9 lines
Quoted 5 lines
This is missing an extremely important caveat which I was incorrectly correlating earlier in our discussion. Yes, step 2 is not required. The step which is required is the page allocated must be non-zero when allocated, and the contents of the page must be capable of hanging the GPU when used as a context object.
Really? I'm pretty sure the last error state we looked at, the context was all zeroes.
Well... the first page of the context is all 0.
Quoted 10 lines
Quoted 5 lines
Otherwise, the uninitialized context would always be all 0, which if I understand the HW correctly, is "safe"
As long as you don't disagree, I'll fix the commit message with that info.
Whatever you feel matches our best understanding of the problem. Just double check that last error state first ;-)
-Chris
The real problem is that I've gone and convinced myself that no other means exists to actually make the GPU hang. This incidentally also gives some merit to my assumption that IPEHR is accurate through context loads
- in other words, we try to do MI_SET_CONTEXT during a MI_SET_CONTEXT.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 15 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
Quoted 7 lines
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Thanks to Chris for helping me track this down.
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Do we have a testcase for this or a bug report?
-Daniel
Quoted 28 lines
--- drivers/gpu/drm/i915/i915_gem_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem_context.c +2
-1@@ -686,10 +686,11 @@ static int do_switch(struct intel_ring_buffer *ring,i915_gem_context_unreference (from); } + to->is_initialized = true; + done:i915_gem_context_reference (to); ring->last_context = to; - to->is_initialized = true; to->last_ring = ring;return 0 ;Signature · 6 lines
1.8.5.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Quoted 6 lines
Quoted 4 lines
Thanks to Chris for helping me track this down.
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>Do we have a testcase for this or a bug report?
Odd, since QA should have hit this...
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 22 lines · Chris Wilson
Quoted 21 lines · Daniel Vetter
Quoted 20 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Thanks to Chris for helping me track this down.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>Do we have a testcase for this or a bug report?
Odd, since QA should have hit this...
-Chris
I was only able to hit it on one machine. The test case was 'startx.' I think getting it to fail is somewhat dependent upon how the backing pages for the context are initialized (at least, that is my theory).
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 26 lines · Ben Widawsky
Quoted 25 lines · Chris Wilson
Quoted 24 lines · Daniel Vetter
Quoted 22 lines · Ben Widawsky
The initialized flag is used to specify a context has been initialized and it's context is safe to load, ie. the 3d state is setup properly. With full PPGTT, we emit the address space loads during context switch and this currently marks a context as initialized. With full PPGTT patches, if a client first emits a batch to !RCS, then later, RCS, the code will mistake the context as initialized and try to reload an uninitialized context.
1. context 1 blit // context initialized
2. context 2 <X operation> // saves context 1 random state
3. context 1 render // loads random state from step 2It is really easy to hit this with a planned upcoming patch which makes default context reuse possible.
NOTE: This should only effect full PPGTT branches, ie. current drm-intel-nightly.
Thanks to Chris for helping me track this down.
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Do we have a testcase for this or a bug report?
Odd, since QA should have hit this...
-ChrisI was only able to hit it on one machine. The test case was 'startx.' I think getting it to fail is somewhat dependent upon how the backing pages for the context are initialized (at least, that is my theory).
Well I've hoped we'd understand the fallout a bit better, but meh. Patch merged with the failure scenario in the commit message simplified as noted by Chris.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch