summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiwei Zhang <zzyiwei@chromium.org>2023-09-05 22:34:21 +0000
committerMarge Bot <emma+marge@anholt.net>2023-09-06 19:23:11 +0000
commite34b5669b7d7a87e339cd09eaf5292bef2b78b1a (patch)
tree37a11151e5b3db707f322f69b602796841cae65c
parentb3798b07cc7aef01f7847ba12aed5e71d23a4164 (diff)
vkr: tighten up threading for transport dispatch
The below must be dispatched from context: - vkCreateRingMESA - vkDestroyRingMESA - vkNotifyRingMESA - vkWriteRingExtraMESA - vkSubmitVirtqueueSeqnoMESA - vkWaitRingSeqnoMESA The below must be dispatched from ring: - vkWaitVirtqueueSeqnoMESA Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1220>
-rw-r--r--src/venus/vkr_transport.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/venus/vkr_transport.c b/src/venus/vkr_transport.c
index bf28040..996c89e 100644
--- a/src/venus/vkr_transport.c
+++ b/src/venus/vkr_transport.c
@@ -199,6 +199,12 @@ vkr_dispatch_vkCreateRingMESA(struct vn_dispatch_context *dispatch,
struct vkr_context *ctx = dispatch->data;
const VkRingCreateInfoMESA *info = args->pCreateInfo;
+ if (unlikely(!is_dispatched_from_vkr_context(dispatch))) {
+ vkr_log("%s must be called on context dispatch", __func__);
+ vkr_context_set_fatal(ctx);
+ return;
+ }
+
const struct vkr_resource *res = vkr_context_get_resource(ctx, info->resourceId);
if (!res) {
vkr_context_set_fatal(ctx);
@@ -263,6 +269,13 @@ vkr_dispatch_vkDestroyRingMESA(struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyRingMESA *args)
{
struct vkr_context *ctx = dispatch->data;
+
+ if (unlikely(!is_dispatched_from_vkr_context(dispatch))) {
+ vkr_log("%s must be called on context dispatch", __func__);
+ vkr_context_set_fatal(ctx);
+ return;
+ }
+
struct vkr_ring *ring = lookup_ring(ctx, args->ring);
if (!ring || !vkr_ring_stop(ring)) {
vkr_context_set_fatal(ctx);
@@ -279,6 +292,13 @@ vkr_dispatch_vkNotifyRingMESA(struct vn_dispatch_context *dispatch,
struct vn_command_vkNotifyRingMESA *args)
{
struct vkr_context *ctx = dispatch->data;
+
+ if (unlikely(!is_dispatched_from_vkr_context(dispatch))) {
+ vkr_log("%s must be called on context dispatch", __func__);
+ vkr_context_set_fatal(ctx);
+ return;
+ }
+
struct vkr_ring *ring = lookup_ring(ctx, args->ring);
if (!ring) {
vkr_context_set_fatal(ctx);
@@ -293,6 +313,13 @@ vkr_dispatch_vkWriteRingExtraMESA(struct vn_dispatch_context *dispatch,
struct vn_command_vkWriteRingExtraMESA *args)
{
struct vkr_context *ctx = dispatch->data;
+
+ if (unlikely(!is_dispatched_from_vkr_context(dispatch))) {
+ vkr_log("%s must be called on context dispatch", __func__);
+ vkr_context_set_fatal(ctx);
+ return;
+ }
+
struct vkr_ring *ring = lookup_ring(ctx, args->ring);
if (!ring) {
vkr_context_set_fatal(ctx);
@@ -308,6 +335,13 @@ vkr_dispatch_vkSubmitVirtqueueSeqnoMESA(struct vn_dispatch_context *dispatch,
struct vn_command_vkSubmitVirtqueueSeqnoMESA *args)
{
struct vkr_context *ctx = dispatch->data;
+
+ if (unlikely(!is_dispatched_from_vkr_context(dispatch))) {
+ vkr_log("%s must be called on context dispatch", __func__);
+ vkr_context_set_fatal(ctx);
+ return;
+ }
+
struct vkr_ring *ring = lookup_ring(ctx, args->ring);
if (!ring) {
vkr_context_set_fatal(ctx);
@@ -342,6 +376,13 @@ vkr_dispatch_vkWaitRingSeqnoMESA(struct vn_dispatch_context *dispatch,
struct vn_command_vkWaitRingSeqnoMESA *args)
{
struct vkr_context *ctx = dispatch->data;
+
+ if (unlikely(!is_dispatched_from_vkr_context(dispatch))) {
+ vkr_log("%s must be called on context dispatch", __func__);
+ vkr_context_set_fatal(ctx);
+ return;
+ }
+
struct vkr_ring *ring = lookup_ring(ctx, args->ring);
if (!ring) {
vkr_context_set_fatal(ctx);