libdrm-radeon: unref return current BO ptr to reflect BO destruction

main
Jerome Glisse 2008-11-15 10:38:44 +01:00
parent 1f66021854
commit 5ae79e7edd
5 changed files with 21 additions and 19 deletions

View File

@ -63,7 +63,7 @@ struct radeon_bo_funcs {
uint32_t domains,
uint32_t flags);
void (*bo_ref)(struct radeon_bo *bo);
void (*bo_unref)(struct radeon_bo *bo);
struct radeon_bo *(*bo_unref)(struct radeon_bo *bo);
int (*bo_map)(struct radeon_bo *bo, int write);
int (*bo_unmap)(struct radeon_bo *bo);
};
@ -118,10 +118,10 @@ static inline void _radeon_bo_ref(struct radeon_bo *bo,
bo->bom->funcs->bo_ref(bo);
}
static inline void _radeon_bo_unref(struct radeon_bo *bo,
const char *file,
const char *func,
int line)
static inline struct radeon_bo *_radeon_bo_unref(struct radeon_bo *bo,
const char *file,
const char *func,
int line)
{
bo->cref--;
#ifdef RADEON_BO_TRACK
@ -131,7 +131,7 @@ static inline void _radeon_bo_unref(struct radeon_bo *bo,
bo->track = NULL;
}
#endif
bo->bom->funcs->bo_unref(bo);
return bo->bom->funcs->bo_unref(bo);
}
static inline int _radeon_bo_map(struct radeon_bo *bo,

View File

@ -115,16 +115,16 @@ static void bo_ref(struct radeon_bo *bo)
{
}
static void bo_unref(struct radeon_bo *bo)
static struct radeon_bo *bo_unref(struct radeon_bo *bo)
{
struct radeon_bo_gem *bo_gem = (struct radeon_bo_gem*)bo;
struct drm_gem_close args;
if (bo == NULL) {
return;
return NULL;
}
if (bo->cref) {
return;
return bo;
}
if (bo_gem->map_count) {
munmap(bo->ptr, bo->size);
@ -134,6 +134,7 @@ static void bo_unref(struct radeon_bo *bo)
args.handle = bo->handle;
ioctl(bo->bom->fd, DRM_IOCTL_GEM_CLOSE, &args);
free(bo_gem);
return NULL;
}
static int bo_map(struct radeon_bo *bo, int write)
@ -182,7 +183,7 @@ static struct radeon_bo_funcs bo_gem_funcs = {
bo_unmap
};
struct radeon_bo_manager *radeon_bo_manager_gem(int fd)
struct radeon_bo_manager *radeon_bo_manager_gem_ctor(int fd)
{
struct bo_manager_gem *bomg;
@ -195,7 +196,7 @@ struct radeon_bo_manager *radeon_bo_manager_gem(int fd)
return (struct radeon_bo_manager*)bomg;
}
void radeon_bo_manager_gem_shutdown(struct radeon_bo_manager *bom)
void radeon_bo_manager_gem_dtor(struct radeon_bo_manager *bom)
{
struct bo_manager_gem *bomg = (struct bo_manager_gem*)bom;

View File

@ -34,7 +34,7 @@
#include "radeon_bo.h"
struct radeon_bo_manager *radeon_bo_manager_gem(int fd);
void radeon_bo_manager_gem_shutdown(struct radeon_bo_manager *bom);
struct radeon_bo_manager *radeon_bo_manager_gem_ctor(int fd);
void radeon_bo_manager_gem_dtor(struct radeon_bo_manager *bom);
#endif

View File

@ -251,7 +251,8 @@ static int cs_gem_emit(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
uint64_t chunk_array[2];
int r, i;
unsigned i;
int r;
chunk_array[0] = (uint64_t)(intptr_t)&csg->chunks[0];
chunk_array[1] = (uint64_t)(intptr_t)&csg->chunks[1];
@ -282,7 +283,7 @@ static int cs_gem_destroy(struct radeon_cs *cs)
static int cs_gem_erase(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
int i;
unsigned i;
if (csg->relocs_bo) {
for (i = 0; i < csg->base.crelocs; i++) {
@ -318,7 +319,7 @@ static struct radeon_cs_funcs radeon_cs_gem_funcs = {
cs_gem_need_flush
};
struct radeon_cs_manager *radeon_cs_manager_gem(int fd)
struct radeon_cs_manager *radeon_cs_manager_gem_ctor(int fd)
{
struct radeon_cs_manager *csm;
@ -332,7 +333,7 @@ struct radeon_cs_manager *radeon_cs_manager_gem(int fd)
return csm;
}
void radeon_cs_manager_gem_shutdown(struct radeon_cs_manager *csm)
void radeon_cs_manager_gem_dtor(struct radeon_cs_manager *csm)
{
free(csm);
}

View File

@ -35,7 +35,7 @@
#include "radeon_cs.h"
struct radeon_cs_manager *radeon_cs_manager_gem(int fd);
void radeon_cs_manager_gem_shutdown(struct radeon_cs_manager *csm);
struct radeon_cs_manager *radeon_cs_manager_gem_ctor(int fd);
void radeon_cs_manager_gem_dtor(struct radeon_cs_manager *csm);
#endif