OSDN Git Service

i965/batch: Ensure we use a consistent offset in relocs
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Apr 2017 07:13:47 +0000 (09:13 +0200)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 10 Apr 2017 21:33:18 +0000 (14:33 -0700)
commita99a4979fdb84a41cc3626b27695f02b32ebb98a
treeef0d8b913ed2ebc771a8ec66b0b9b185bedfeaa3
parent7f3c85c21e0e18bbedb2f59ba13838d963f0a106
i965/batch: Ensure we use a consistent offset in relocs

In theory gcc is free to re-load them, and if a concurrent
execbuf races and updates bo->offset64 then we have a problem:
execbuffer api requires that the ->presumed_offset and the one
we used for the reloc matches. It does not require that the value
is sensible, which means no locks needed, just a consistent load.

Ken said his next series will nuke this, so just hand-roll the
kernel's READ_ONCE idea inline.

FIXME: Most callers of brw_emit_reloc recompute the relocation
themselves, which means this doesn't really fix the race. But the long
term plan is to move to per-context relocation handling, which will
fix this all properly. So leave this for now as just a reminder.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/intel_batchbuffer.c