[Mesa-dev] [PATCH v4] i965: Avoid problems from referencing orphaned BOs after growing.
kenneth at whitecape.org
Tue Feb 6 17:49:27 UTC 2018
On Thursday, January 25, 2018 3:29:01 AM PST Emil Velikov wrote:
> On 18 January 2018 at 07:36, Kenneth Graunke <kenneth at whitecape.org> wrote:
> > Growing the batch/state buffer is a lot more dangerous than I thought.
> > A number of places emit multiple state buffer sections, and then write
> > data to the returned pointer, or save a pointer to brw->batch.state.bo
> > and then use it in relocations. If each call can grow, this can result
> > in stale map references or stale BO pointers. Furthermore, fences refer
> > to the old batch BO, and that reference needs to continue working.
> > To avoid these woes, we avoid ever swapping the brw->batch.*.bo pointer,
> > instead exchanging the brw_bo structures in place. That way, stale BO
> > references are fine - the GEM handle changes, but the brw_bo pointer
> > doesn't. We also defer the memcpy until a quiescent point, so callers
> > can write to the returned pointer - which may be in either BO - and
> > we'll sort it out and combine the two properly in the end.
> > v2/v3:
> > - Handle stale pointers in the shadow copy case, where realloc may or
> > may not move our shadow copy to a new address.
> > - Track the partial map explicitly, to avoid problems with buffer reuse
> > where multiple map modes exist (caught by Chris Wilson).
> > v4:
> > - Don't use realloc in the CPU shadow case, it isn't safe.
> > Fixes: 2dfc119f22f257082ab0 "i965: Grow the batch/state buffers if we need space and can't flush."
> > Reviewed-by: Iago Toral Quiroga <itoral at igalia.com> [v3]
> > ---
> Hi Ken,
> Picking this patch leads to a few picky conflicts. Can you please
> provide a backport for 17.3?
> Using --subject-prefix="BACKPORT 17.3". would be amazing.
Sorry, looks like I poorly labeled things...this was the only patch that
"fixes" an issue in an earlier patch, but it needs prior commits.
$ git cherry-pick -x 02c1c25b1a620a336f2e18d39bba188635363f24
# i965: Replace cpu_map pointers with a "use_shadow_copy" boolean.
$ git cherry-pick -x 81ca8e69e327f07f57d597fa6ce23ff67b932de8
# i965: Make a helper for recreating growing buffers.
$ git cherry-pick -x d139b5e4ccf0da19f37428434bf0ef7c76c85049
# i965: Pass brw_growing_bo to grow_buffer().
$ git cherry-pick -x c7dcee58b5fe183e1653c13bff6a212f0d157b29
# i965: Avoid problems from referencing orphaned BOs after growing.
will make it apply cleanly.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: This is a digitally signed message part.
More information about the mesa-dev