novueau/bo: refcount it

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Karol Herbst
2022-06-01 01:03:57 +02:00
committed by Marge Bot
parent f9cd1d6941
commit d71a4d73b8
2 changed files with 11 additions and 0 deletions
+4
View File
@@ -42,6 +42,7 @@ nouveau_ws_bo_new(struct nouveau_ws_device *dev, uint64_t size, uint64_t align,
bo->map_handle = req.info.map_handle;
bo->fd = pdev->fd;
bo->flags = flags;
bo->refcnt = 1;
return bo;
}
@@ -49,6 +50,9 @@ nouveau_ws_bo_new(struct nouveau_ws_device *dev, uint64_t size, uint64_t align,
void
nouveau_ws_bo_destroy(struct nouveau_ws_bo *bo)
{
if (--bo->refcnt)
return;
drmCloseBufferHandle(bo->fd, bo->handle);
FREE(bo);
}
+7
View File
@@ -25,10 +25,17 @@ struct nouveau_ws_bo {
int fd;
uint32_t handle;
enum nouveau_ws_bo_flags flags;
_Atomic uint32_t refcnt;
};
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);
static inline void
nouveau_ws_bo_ref(struct nouveau_ws_bo *bo)
{
bo->refcnt++;
}
#endif