nouveau/ws: add API to query if the context was killed

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Karol Herbst
2022-08-24 13:38:18 +02:00
committed by Marge Bot
parent e1af0f983f
commit 886db84e94
2 changed files with 17 additions and 0 deletions
+16
View File
@@ -192,3 +192,19 @@ nouveau_ws_context_destroy(struct nouveau_ws_context *context)
nouveau_ws_channel_dealloc(context->dev->fd, context->channel);
FREE(context);
}
bool
nouveau_ws_context_killed(struct nouveau_ws_context *context)
{
/* we are using the normal pushbuf submission ioctl as this is how nouveau implemented this on
* the kernel side.
* And as long as we submit nothing (e.g. nr_push is 0) it's more or less a noop on the kernel
* side.
*/
struct drm_nouveau_gem_pushbuf req = {
.channel = context->channel,
};
int ret = drmCommandWriteRead(context->dev->fd, DRM_NOUVEAU_GEM_PUSHBUF, &req, sizeof(req));
/* nouveau returns ENODEV once the channel was killed */
return ret == -ENODEV;
}
+1
View File
@@ -22,6 +22,7 @@ struct nouveau_ws_context {
};
int nouveau_ws_context_create(struct nouveau_ws_device *, struct nouveau_ws_context **out);
bool nouveau_ws_context_killed(struct nouveau_ws_context *);
void nouveau_ws_context_destroy(struct nouveau_ws_context *);
#endif