summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-04-29 11:52:24 +1000
committerDave Airlie <airlied@redhat.com>2020-06-09 15:13:23 +1000
commit8e804e1dbd1fd3dabe52d9ebd405e7eb7467b67a (patch)
tree40ff8d80fb2d7da99a0715179d3d969e75feb17b
parent763084f67c0d08dcad7720a0ae335e5315fc9697 (diff)
add a fence lock to protect fence->handle
-rw-r--r--src/gallium/frontends/vallium/val_device.c25
-rw-r--r--src/gallium/frontends/vallium/val_execute.c9
-rw-r--r--src/gallium/frontends/vallium/val_private.h1
3 files changed, 27 insertions, 8 deletions
diff --git a/src/gallium/frontends/vallium/val_device.c b/src/gallium/frontends/vallium/val_device.c
index e59e0dd7a18..f8b14db567c 100644
--- a/src/gallium/frontends/vallium/val_device.c
+++ b/src/gallium/frontends/vallium/val_device.c
@@ -733,6 +733,7 @@ VkResult val_CreateDevice(
device->enabled_extensions.extensions[index] = true;
}
+ mtx_init(&device->fence_lock, mtx_plain);
device->pscreen = physical_device->pscreen;
val_queue_init(device, &device->queue);
@@ -1285,9 +1286,10 @@ VkResult val_ResetFences(
fence->signaled = false;
- if (!fence->handle)
- continue;
- device->pscreen->fence_reference(device->pscreen, &fence->handle, NULL);
+ mtx_lock(&device->fence_lock);
+ if (fence->handle)
+ device->pscreen->fence_reference(device->pscreen, &fence->handle, NULL);
+ mtx_unlock(&device->fence_lock);
}
return VK_SUCCESS;
}
@@ -1302,13 +1304,18 @@ VkResult val_GetFenceStatus(
if (fence->signaled)
return VK_SUCCESS;
- if (!fence->handle)
+ mtx_lock(&device->fence_lock);
+
+ if (!fence->handle) {
+ mtx_unlock(&device->fence_lock);
return VK_NOT_READY;
+ }
bool signalled = device->pscreen->fence_finish(device->pscreen,
NULL,
fence->handle,
0);
+ mtx_unlock(&device->fence_lock);
if (signalled)
return VK_SUCCESS;
else
@@ -1372,6 +1379,8 @@ VkResult val_WaitForFences(
bool timeout_status = false;
if (qret == VK_TIMEOUT)
return VK_TIMEOUT;
+
+ mtx_lock(&device->fence_lock);
for (unsigned i = 0; i < fenceCount; i++) {
struct val_fence *fence = val_fence_from_handle(pFences[i]);
@@ -1385,11 +1394,15 @@ VkResult val_WaitForFences(
NULL,
fence->handle,
timeout);
- if (ret && !waitAll)
- return VK_SUCCESS;
+ if (ret && !waitAll) {
+ timeout_status = false;
+ break;
+ }
+
if (!ret)
timeout_status |= true;
}
+ mtx_unlock(&device->fence_lock);
return timeout_status ? VK_TIMEOUT : VK_SUCCESS;
}
diff --git a/src/gallium/frontends/vallium/val_execute.c b/src/gallium/frontends/vallium/val_execute.c
index dd4cc3acfc9..50fb28b2d99 100644
--- a/src/gallium/frontends/vallium/val_execute.c
+++ b/src/gallium/frontends/vallium/val_execute.c
@@ -2509,7 +2509,7 @@ VkResult val_execute_cmds(struct val_device *device,
struct val_cmd_buffer *cmd_buffer)
{
struct rendering_state state;
-
+ struct pipe_fence_handle *handle = NULL;
memset(&state, 0, sizeof(state));
state.pctx = queue->ctx;
state.blend_dirty = true;
@@ -2518,7 +2518,12 @@ VkResult val_execute_cmds(struct val_device *device,
/* create a gallium context */
val_execute_cmd_buffer(cmd_buffer, &state);
- state.pctx->flush(state.pctx, fence ? &fence->handle : NULL, 0);
+ state.pctx->flush(state.pctx, fence ? &handle : NULL, 0);
+ if (fence) {
+ mtx_lock(&device->fence_lock);
+ fence->handle = handle;
+ mtx_unlock(&device->fence_lock);
+ }
state.start_vb = -1;
state.num_vb = 0;
state.pctx->set_vertex_buffers(state.pctx, 0, PIPE_MAX_ATTRIBS, NULL);
diff --git a/src/gallium/frontends/vallium/val_private.h b/src/gallium/frontends/vallium/val_private.h
index 15b1f42ed3c..db123feca72 100644
--- a/src/gallium/frontends/vallium/val_private.h
+++ b/src/gallium/frontends/vallium/val_private.h
@@ -275,6 +275,7 @@ struct val_device {
struct val_physical_device *physical_device;
struct pipe_screen *pscreen;
+ mtx_t fence_lock;
struct val_device_extension_table enabled_extensions;
};