aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libkms/intel.c5
-rw-r--r--libkms/vmwgfx.c20
2 files changed, 15 insertions, 10 deletions
diff --git a/libkms/intel.c b/libkms/intel.c
index 784ee7b6..670494e7 100644
--- a/libkms/intel.c
+++ b/libkms/intel.c
@@ -220,8 +220,11 @@ intel_bo_destroy(struct kms_bo *_bo)
220 struct drm_gem_close arg; 220 struct drm_gem_close arg;
221 int ret; 221 int ret;
222 222
223 if (bo->base.ptr) 223 if (bo->base.ptr) {
224 /* XXX Sanity check map_count */
224 munmap(bo->base.ptr, bo->base.size); 225 munmap(bo->base.ptr, bo->base.size);
226 bo->base.ptr = NULL;
227 }
225 228
226 memset(&arg, 0, sizeof(arg)); 229 memset(&arg, 0, sizeof(arg));
227 arg.handle = bo->base.handle; 230 arg.handle = bo->base.handle;
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 }