mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-01-04 21:30:20 +01:00
libkms: Fix multiple map unmap in vmwgfx and add comment in intel
This commit is contained in:
parent
320811b282
commit
2959266188
2 changed files with 15 additions and 10 deletions
|
|
@ -220,8 +220,11 @@ intel_bo_destroy(struct kms_bo *_bo)
|
|||
struct drm_gem_close arg;
|
||||
int ret;
|
||||
|
||||
if (bo->base.ptr)
|
||||
if (bo->base.ptr) {
|
||||
/* XXX Sanity check map_count */
|
||||
munmap(bo->base.ptr, bo->base.size);
|
||||
bo->base.ptr = NULL;
|
||||
}
|
||||
|
||||
memset(&arg, 0, sizeof(arg));
|
||||
arg.handle = bo->base.handle;
|
||||
|
|
|
|||
|
|
@ -160,16 +160,17 @@ vmwgfx_bo_map(struct kms_bo *_bo, void **out)
|
|||
struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
|
||||
void *map;
|
||||
|
||||
if (!bo->map_count) {
|
||||
map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, bo->base.kms->fd, bo->map_handle);
|
||||
|
||||
if (!map)
|
||||
return -ENOMEM;
|
||||
|
||||
bo->base.ptr = map;
|
||||
if (bo->base.ptr) {
|
||||
bo->map_count++;
|
||||
*out = bo->base.ptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle);
|
||||
if (map == MAP_FAILED)
|
||||
return -errno;
|
||||
|
||||
bo->base.ptr = map;
|
||||
bo->map_count++;
|
||||
*out = bo->base.ptr;
|
||||
|
||||
|
|
@ -190,7 +191,8 @@ vmwgfx_bo_destroy(struct kms_bo *_bo)
|
|||
struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
|
||||
struct drm_vmw_unref_dmabuf_arg arg;
|
||||
|
||||
if (bo->map_count) {
|
||||
if (bo->base.ptr) {
|
||||
/* XXX Sanity check map_count */
|
||||
munmap(bo->base.ptr, bo->base.size);
|
||||
bo->base.ptr = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue