summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorJerome Glisse <glisse@freedesktop.org>2008-11-15 10:38:44 +0100
committerJerome Glisse <glisse@freedesktop.org>2008-11-15 10:39:37 +0100
commit5ae79e7edd819b84d9e447a2ab9b995a862ac3a7 (patch)
tree76201d055fb1f078f526dd8d10bf1afcace60a4c /libdrm
parent1f6602185455957bde0fac09dcab5215326d49a0 (diff)
libdrm-radeon: unref return current BO ptr to reflect BO destruction
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/radeon/radeon_bo.h12
-rw-r--r--libdrm/radeon/radeon_bo_gem.c11
-rw-r--r--libdrm/radeon/radeon_bo_gem.h4
-rw-r--r--libdrm/radeon/radeon_cs_gem.c9
-rw-r--r--libdrm/radeon/radeon_cs_gem.h4
5 files changed, 21 insertions, 19 deletions
diff --git a/libdrm/radeon/radeon_bo.h b/libdrm/radeon/radeon_bo.h
index ed785034..523cf38e 100644
--- a/libdrm/radeon/radeon_bo.h
+++ b/libdrm/radeon/radeon_bo.h
@@ -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,
diff --git a/libdrm/radeon/radeon_bo_gem.c b/libdrm/radeon/radeon_bo_gem.c
index 8ce82919..b6d5b294 100644
--- a/libdrm/radeon/radeon_bo_gem.c
+++ b/libdrm/radeon/radeon_bo_gem.c
@@ -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;
diff --git a/libdrm/radeon/radeon_bo_gem.h b/libdrm/radeon/radeon_bo_gem.h
index aaefd8c3..c0f68e6d 100644
--- a/libdrm/radeon/radeon_bo_gem.h
+++ b/libdrm/radeon/radeon_bo_gem.h
@@ -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
diff --git a/libdrm/radeon/radeon_cs_gem.c b/libdrm/radeon/radeon_cs_gem.c
index 9488f81c..91489dff 100644
--- a/libdrm/radeon/radeon_cs_gem.c
+++ b/libdrm/radeon/radeon_cs_gem.c
@@ -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);
}
diff --git a/libdrm/radeon/radeon_cs_gem.h b/libdrm/radeon/radeon_cs_gem.h
index f50c5e84..5efd146f 100644
--- a/libdrm/radeon/radeon_cs_gem.h
+++ b/libdrm/radeon/radeon_cs_gem.h
@@ -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