From 886db84e9461fb37b7a92153dcc5c8619722b826 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 24 Aug 2022 13:38:18 +0200 Subject: [PATCH] nouveau/ws: add API to query if the context was killed Signed-off-by: Karol Herbst Part-of: --- src/nouveau/winsys/nouveau_context.c | 16 ++++++++++++++++ src/nouveau/winsys/nouveau_context.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/nouveau/winsys/nouveau_context.c b/src/nouveau/winsys/nouveau_context.c index c085e9b..11f3c40 100644 --- a/src/nouveau/winsys/nouveau_context.c +++ b/src/nouveau/winsys/nouveau_context.c @@ -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; +} diff --git a/src/nouveau/winsys/nouveau_context.h b/src/nouveau/winsys/nouveau_context.h index 1fe10ee..e03b461 100644 --- a/src/nouveau/winsys/nouveau_context.h +++ b/src/nouveau/winsys/nouveau_context.h @@ -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 -- 2.7.4