aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Bornecrantz2010-01-15 14:13:20 -0600
committerJakob Bornecrantz2010-01-15 14:13:20 -0600
commit2959266188dd564975503d74e24b55013f58f861 (patch)
tree62589f2cf5d276b994910944dfa81de93a127081 /libkms/vmwgfx.c
parent320811b282d7f57b364f8414e2e7b714f89b0503 (diff)
downloadexternal-libdrm-2959266188dd564975503d74e24b55013f58f861.tar.gz
external-libdrm-2959266188dd564975503d74e24b55013f58f861.tar.xz
external-libdrm-2959266188dd564975503d74e24b55013f58f861.zip
libkms: Fix multiple map unmap in vmwgfx and add comment in intel
Diffstat (limited to 'libkms/vmwgfx.c')
-rw-r--r--libkms/vmwgfx.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/libkms/vmwgfx.c b/libkms/vmwgfx.c
index 5030b7e3..bcbc240a 100644
--- a/libkms/vmwgfx.c
+++ b/libkms/vmwgfx.c
@@ -160,16 +160,17 @@ vmwgfx_bo_map(struct kms_bo *_bo, void **out)
160 struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo; 160 struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
161 void *map; 161 void *map;
162 162
163 if (!bo->map_count) { 163 if (bo->base.ptr) {
164 map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, 164 bo->map_count++;
165 MAP_SHARED, bo->base.kms->fd, bo->map_handle); 165 *out = bo->base.ptr;
166 166 return 0;
167 if (!map)
168 return -ENOMEM;
169
170 bo->base.ptr = map;
171 } 167 }
172 168
169 map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle);
170 if (map == MAP_FAILED)
171 return -errno;
172
173 bo->base.ptr = map;
173 bo->map_count++; 174 bo->map_count++;
174 *out = bo->base.ptr; 175 *out = bo->base.ptr;
175 176
@@ -190,7 +191,8 @@ vmwgfx_bo_destroy(struct kms_bo *_bo)
190 struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo; 191 struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
191 struct drm_vmw_unref_dmabuf_arg arg; 192 struct drm_vmw_unref_dmabuf_arg arg;
192 193
193 if (bo->map_count) { 194 if (bo->base.ptr) {
195 /* XXX Sanity check map_count */
194 munmap(bo->base.ptr, bo->base.size); 196 munmap(bo->base.ptr, bo->base.size);
195 bo->base.ptr = NULL; 197 bo->base.ptr = NULL;
196 } 198 }