anv/allocator: Avoid race condition in anv_block_pool_map.
authorRafael Antognolli <rafael.antognolli@intel.com>
Wed, 23 Jan 2019 20:36:39 +0000 (12:36 -0800)
committerRafael Antognolli <rafael.antognolli@intel.com>
Fri, 25 Jan 2019 01:39:40 +0000 (17:39 -0800)
commitf2ece26601adda221ce5ae69c984f8b79a9cb0d0
tree308c1b280a96f4cf64ff2cd85eb687e03e7b5d00
parentc1efa240c91e78385e8e433af134289b006016d0
anv/allocator: Avoid race condition in anv_block_pool_map.

Accessing bo->map and then pool->center_bo_offset without a lock is
racy. One way of avoiding such race condition is to store the bo->map +
center_bo_offset into pool->map at the time the block pool is growing,
which happens within a lock.

v2: Only set pool->map if not using softpin (Jason).
v3: Move things around and only update center_bo_offset if not using
softpin too (Jason).

Cc: Jason Ekstrand <jason@jlekstrand.net>
Reported-by: Ian Romanick <idr@freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109442
Fixes: fc3f58832015cbb177179e7f3420d3611479b4a9
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_allocator.c
src/intel/vulkan/anv_private.h