nouveau: Add class information to nouveau_ws_device
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:54 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:57 +0000 (21:31 +0000)
Annoyingly, with the current uAPI, this requires creating a dummy
context and throwing it away.  Fortunately, we should only do this once
on driver load so it's really not that big a problem.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/winsys/nouveau_device.c
src/nouveau/winsys/nouveau_device.h

index 2fa36a5..0b83579 100644 (file)
@@ -6,6 +6,8 @@
 #include <nvif/cl0080.h>
 #include <nvif/class.h>
 
+#include "nouveau_context.h"
+
 #include "util/u_debug.h"
 #include "util/os_file.h"
 #include "util/os_misc.h"
@@ -229,6 +231,18 @@ nouveau_ws_device_new(int fd)
 
    nouveau_ws_device_set_dbg_flags(device);
 
+   struct nouveau_ws_context *tmp_ctx;
+   if (nouveau_ws_context_create(device, &tmp_ctx))
+      goto out_dev;
+
+   device->cls_copy     = tmp_ctx->copy.cls;
+   device->cls_eng2d    = tmp_ctx->eng2d.cls;
+   device->cls_eng3d    = tmp_ctx->eng3d.cls;
+   device->cls_m2mf     = tmp_ctx->m2mf.cls;
+   device->cls_compute  = tmp_ctx->compute.cls;
+
+   nouveau_ws_context_destroy(tmp_ctx);
+
    return device;
 
 out_dev:
index 856bfa2..7a9b1d2 100644 (file)
@@ -35,6 +35,12 @@ struct nouveau_ws_device {
    enum nouveau_ws_device_type device_type;
    uint32_t chipset;
 
+   uint16_t cls_copy;
+   uint16_t cls_eng2d;
+   uint16_t cls_eng3d;
+   uint16_t cls_m2mf;
+   uint16_t cls_compute;
+
    char *chipset_name;
    char *device_name;