novueau/bo: refcount it
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user