mesa/src/intel
Paulo Zanoni 2d11fda237 anv: don't leave undefined values in exec->syncobj_values
In anv_execbuf_add_syncobj(), we try to not create or use
exec->syncobj_values if we don't need to. But when we figure we're
going to need it (i.e., when timeline_value is not zero), then we
create exec->syncobj_values with vk_zalloc, which means every previous
value is set to zero, as it should be. This is all correct.

The problem starts when we add a 16th element. In this case we double
exec->syncobj_array_length and realloc the buffer by using vk_alloc
and copying the old array to the new one. After that, we write the
timeline_value to the array only if it's not zero, and that's the
problem: since we just used vkalloc and memcpy, we don't have any
guarantees that the new array will be zero after the 16th element, and
if timeline_value is zero we write nothing to that position.

Once we start using exec->syncobj_values we have to commit to using
it, so the "if (timeline_value)" check near the end of the function
has to be changed to "if (exec->syncobj_values)", so we actually set
elements after the 16th to zero when they need to be zero.  Another
approach to fix this would be to memset the new elements once we
double syncobj_array_length.

In practice, I couldn't find any application or deqp test that used
more than 3 elements in exec->syncobj_array_length, and we need more
than 16 elements in order to be able to reproduce the bug, so I'm not
aware of any real-world bug that goes away with this patch. This issue
was found while reading code.

If we craft a little Vulkan program that submits a ton of timeline and
binary semaphores on vkQueueSubmit, then waits for them, we get the
following error without this patch:

MESA: error: ../../src/intel/vulkan/anv_batch_chain.c:1910: execbuf2 failed: Invalid argument (VK_ERROR_DEVICE_LOST)

v2: Rebase.

Cc: mesa-stable
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20703>
(cherry picked from commit ad6a036a68)

Conflicts:
	src/intel/vulkan/i915/anv_batch_chain.c

Stable:
    reapplied to src/intel/vulkan/anv_batch_chain.c, as this hasn't been
    moved in the staging branch.
2023-01-24 15:27:04 -08:00
..
blorp intel/blorp: Lower base_workgroup_id to zero 2023-01-18 11:43:56 -08:00
ci ci/iris: Add some recent flakes. 2023-01-04 21:18:08 +00:00
common intel/common: Move i915 gem specific code to its own file 2022-12-23 18:22:29 +00:00
compiler intel/compiler: Drop redundant 32-bit expansion for shared float atomics 2023-01-24 15:27:04 -08:00
dev Revert "intel/compiler: fine-grained control of dispatch widths" 2023-01-12 00:33:25 +00:00
ds intel/ds: add missing generate draws perfetto glue 2022-12-26 14:11:44 +02:00
genxml intel/genxml: Drop CACHE_MODE_SS definition. 2023-01-12 21:48:40 +00:00
isl intel/isl: Disable CCS on MTL until B0 (Wa_14017353530) 2022-12-15 11:43:00 -08:00
nullhw-layer utils: Merge util/debug.* into util/u_debug.* and remove util/debug.* 2022-11-02 07:25:39 +00:00
perf intel: add MTL performance metrics 2022-12-09 09:13:02 +00:00
tools anv,hasvk: migrate align32 to the right functions from util 2023-01-06 17:22:16 +00:00
vulkan anv: don't leave undefined values in exec->syncobj_values 2023-01-24 15:27:04 -08:00
vulkan_hasvk anv,hasvk: move the null check into the function call and drop null check copies 2023-01-06 17:22:16 +00:00
meson.build intel: Disable SSE2 instruction set if building for non x86 architectures 2022-11-23 16:57:23 +00:00