novueau/bo: add nouveau_ws_bo_wait
authorKarol Herbst <kherbst@redhat.com>
Tue, 31 May 2022 23:04:08 +0000 (01:04 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:53 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/winsys/nouveau_bo.c
src/nouveau/winsys/nouveau_bo.h

index d9b4044..6a3c46b 100644 (file)
@@ -73,3 +73,15 @@ nouveau_ws_bo_map(struct nouveau_ws_bo *bo, enum nouveau_ws_bo_map_flags flags)
 
    return res;
 }
+
+bool
+nouveau_ws_bo_wait(struct nouveau_ws_bo *bo, enum nouveau_ws_bo_map_flags flags)
+{
+   struct drm_nouveau_gem_cpu_prep req = {};
+
+   req.handle = bo->handle;
+   if (flags & NOUVEAU_WS_BO_WR)
+      req.flags |= NOUVEAU_GEM_CPU_PREP_WRITE;
+
+   return !drmCommandWrite(bo->fd, DRM_NOUVEAU_GEM_CPU_PREP, &req, sizeof(req));
+}
index 55cca39..93925ac 100644 (file)
@@ -31,6 +31,7 @@ struct nouveau_ws_bo {
 struct nouveau_ws_bo *nouveau_ws_bo_new(struct nouveau_ws_device *, uint64_t size, uint64_t align, enum nouveau_ws_bo_flags);
 void nouveau_ws_bo_destroy(struct nouveau_ws_bo *);
 void *nouveau_ws_bo_map(struct nouveau_ws_bo *, enum nouveau_ws_bo_map_flags);
+bool nouveau_ws_bo_wait(struct nouveau_ws_bo *, enum nouveau_ws_bo_map_flags flags);
 
 static inline void
 nouveau_ws_bo_ref(struct nouveau_ws_bo *bo)