summaryrefslogtreecommitdiff
path: root/libdrm/radeon
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-08-01 16:47:24 +1000
committerDave Airlie <airlied@redhat.com>2009-08-01 17:20:35 +1000
commit322cf6cf736b22b62656ac0431936b3cdb784038 (patch)
treef3dfbe16e3c0774c22988309d8e741cc02f1103a /libdrm/radeon
parent5a73f066ba149816cc0fc2de4b97ec4714cf8ebc (diff)
radeon: don't map/unmap explicitly.
This caches the mapping and just use mapping as a sync point
Diffstat (limited to 'libdrm/radeon')
-rw-r--r--libdrm/radeon/radeon_bo_gem.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libdrm/radeon/radeon_bo_gem.c b/libdrm/radeon/radeon_bo_gem.c
index 558b93ae..9b0d867b 100644
--- a/libdrm/radeon/radeon_bo_gem.c
+++ b/libdrm/radeon/radeon_bo_gem.c
@@ -49,6 +49,7 @@ struct radeon_bo_gem {
struct radeon_bo base;
uint32_t name;
int map_count;
+ void *priv_ptr;
};
struct bo_manager_gem {
@@ -130,8 +131,8 @@ static struct radeon_bo *bo_unref(struct radeon_bo *bo)
if (bo->cref) {
return bo;
}
- if (bo_gem->map_count) {
- munmap(bo->ptr, bo->size);
+ if (bo_gem->priv_ptr) {
+ munmap(bo_gem->priv_ptr, bo->size);
}
/* close object */
@@ -152,6 +153,14 @@ static int bo_map(struct radeon_bo *bo, int write)
if (bo_gem->map_count++ != 0) {
return 0;
}
+ if (bo_gem->priv_ptr) {
+ r = bo_wait(bo);
+ bo->ptr = bo_gem->priv_ptr;
+ if (r)
+ return r;
+ return 0;
+ }
+
bo->ptr = NULL;
args.handle = bo->handle;
args.offset = 0;
@@ -168,8 +177,8 @@ static int bo_map(struct radeon_bo *bo, int write)
ptr = mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED, bo->bom->fd, args.addr_ptr);
if (ptr == MAP_FAILED)
return -errno;
- bo->ptr = ptr;
-
+ bo_gem->priv_ptr = ptr;
+ bo->ptr = bo_gem->priv_ptr;
return r;
}
@@ -180,7 +189,7 @@ static int bo_unmap(struct radeon_bo *bo)
if (--bo_gem->map_count > 0) {
return 0;
}
- munmap(bo->ptr, bo->size);
+ //munmap(bo->ptr, bo->size);
bo->ptr = NULL;
return 0;
}