venus: workaround cacheline overflush issue on Intel JSL

We observed that Venus on ANV on JSL platform has some cacheline flush
issue. The overflush shows up as:
1. There're 2 threads venus bliting the feedback buffers suballocated
   from the same backing device memory, back to back.
2. On thread A, flushing the feedback buffer for cpu read is placed
   behind flushing a shader storage buffer for cpu read.
3. On thread B, flushing a different feedback buffer with the same
   backing device memory (different offset bound to) can kick the
   feedback buffer flush in (2) earlier than it should be flushed.
4. As a result, CPU polling thread for thread B results would see venus
   feedback buffer update earlier than shader storage buffer results
   being updated, breaking Venus sync primitives optimization.

During investigation, a solid workaround for JSL platform is to force
Venus to align up to 128 bytes for feedback buffer suballocation while
the default is at 64 bytes.

Cc: mesa-stable
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30879>
This commit is contained in:
Yiwei Zhang 2024-08-27 11:57:11 -07:00 committed by Marge Bot
parent c0762e88f3
commit 7941d705c3
3 changed files with 12 additions and 3 deletions

View file

@ -134,10 +134,12 @@ vn_feedback_buffer_destroy(struct vn_device *dev,
}
static inline uint32_t
vn_get_feedback_buffer_alignment(struct vn_feedback_buffer *fb_buf)
vn_get_feedback_buffer_alignment(struct vn_device *dev,
struct vn_feedback_buffer *fb_buf)
{
struct vn_buffer *buf = vn_buffer_from_handle(fb_buf->buf_handle);
return buf->requirements.memory.memoryRequirements.alignment;
return align(buf->requirements.memory.memoryRequirements.alignment,
dev->physical_device->wa_min_fb_align);
}
static VkResult
@ -153,7 +155,7 @@ vn_feedback_pool_grow_locked(struct vn_feedback_pool *pool)
return result;
pool->used = 0;
pool->alignment = vn_get_feedback_buffer_alignment(fb_buf);
pool->alignment = vn_get_feedback_buffer_alignment(pool->dev, fb_buf);
list_add(&fb_buf->head, &pool->fb_bufs);

View file

@ -417,6 +417,8 @@ vn_physical_device_sanitize_properties(struct vn_physical_device *physical_dev)
if (!forward_driver_version)
props->driverVersion = vk_get_driver_version();
physical_dev->wa_min_fb_align = strstr(props->deviceName, "JSL") ? 128 : 1;
char device_name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
int device_name_len = snprintf(device_name, sizeof(device_name),
"Virtio-GPU Venus (%s)", props->deviceName);

View file

@ -73,6 +73,11 @@ struct vn_physical_device {
struct vk_device_extension_table renderer_extensions;
uint32_t *extension_spec_versions;
/* Venus feedback encounters cacheline overflush issue on Intel JSL, and
* has to workaround by further aligning up the feedback buffer alignment.
*/
uint32_t wa_min_fb_align;
enum VkDriverId renderer_driver_id;
VkQueueFamilyProperties2 *queue_family_properties;