summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-04-06 13:02:21 +1000
committerDave Airlie <airlied@redhat.com>2009-04-06 13:02:21 +1000
commit2f0720455da3e62a60221f876f95b5952e74111d (patch)
tree896d90c0b54f2bc639397e737a1c305fcedf9061
parent96982ffc091a8c1603272ec5fd4776e3679e77d4 (diff)
radeon: fixup mmap interface
-rw-r--r--libdrm/radeon/radeon_bo_gem.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libdrm/radeon/radeon_bo_gem.c b/libdrm/radeon/radeon_bo_gem.c
index 7ed752a4..70f4b6b4 100644
--- a/libdrm/radeon/radeon_bo_gem.c
+++ b/libdrm/radeon/radeon_bo_gem.c
@@ -29,6 +29,9 @@
* Dave Airlie
* Jérôme Glisse <glisse@freedesktop.org>
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -144,6 +147,7 @@ static int bo_map(struct radeon_bo *bo, int write)
struct radeon_bo_gem *bo_gem = (struct radeon_bo_gem*)bo;
struct drm_radeon_gem_mmap args;
int r;
+ void *ptr;
if (bo_gem->map_count++ != 0) {
return 0;
@@ -156,12 +160,16 @@ static int bo_map(struct radeon_bo *bo, int write)
DRM_RADEON_GEM_MMAP,
&args,
sizeof(args));
- if (!r) {
- bo->ptr = (void *)(unsigned long)args.addr_ptr;
- } else {
+ if (r) {
fprintf(stderr, "error mapping %p 0x%08X (error = %d)\n",
bo, bo->handle, r);
+ return r;
}
+ 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;
+
return r;
}