struct vmw_region *region;
void *map;
unsigned map_flags;
+ unsigned map_count;
};
{
struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
- vmw_ioctl_region_unmap(buf->region);
-
+ assert(buf->map_count == 0);
+ if (buf->map) {
+ assert(buf->mgr->vws->cache_maps);
+ vmw_ioctl_region_unmap(buf->region);
+ }
+
vmw_ioctl_region_destroy(buf->region);
FREE(buf);
if (!buf->map)
return NULL;
-
if ((_buf->usage & VMW_BUFFER_USAGE_SYNC) &&
!(flags & PB_USAGE_UNSYNCHRONIZED)) {
ret = vmw_ioctl_syncforcpu(buf->region,
return NULL;
}
+ buf->map_count++;
return buf->map;
}
!(flags & PB_USAGE_CPU_WRITE),
FALSE);
}
+
+ assert(buf->map_count > 0);
+ if (!--buf->map_count && !buf->mgr->vws->cache_maps) {
+ vmw_ioctl_region_unmap(buf->region);
+ buf->map = NULL;
+ }
}
{
struct vmw_winsys_screen *vws;
struct stat stat_buf;
+ const char *getenv_val;
if (dev_hash == NULL) {
dev_hash = _mesa_hash_table_create(NULL, vmw_dev_hash, vmw_dev_compare);
vws->base.have_gb_dma = !vws->force_coherent;
vws->base.need_to_rebind_resources = FALSE;
vws->base.have_transfer_from_buffer_cmd = vws->base.have_vgpu10;
+ getenv_val = getenv("SVGA_FORCE_KERNEL_UNMAPS");
+ vws->cache_maps = !getenv_val || strcmp(getenv_val, "0") == 0;
vws->fence_ops = vmw_fence_ops_create(vws);
if (!vws->fence_ops)
goto out_no_fence_ops;
mtx_t cs_mutex;
boolean force_coherent;
+ boolean cache_maps;
};
uint32_t handle;
uint64_t map_handle;
void *data;
- uint32_t map_count;
int drm_fd;
uint32_t size;
};
region->data = NULL;
region->handle = rep->handle;
region->map_handle = rep->map_handle;
- region->map_count = 0;
region->size = size;
region->drm_fd = vws->ioctl.drm_fd;
vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
region->ptr.gmrId, region->ptr.offset);
- if (region->data) {
- os_munmap(region->data, region->size);
- region->data = NULL;
- }
+ assert(region->data == NULL);
memset(&arg, 0, sizeof(arg));
arg.handle = region->handle;
region->data = map;
}
- ++region->map_count;
-
return region->data;
}
{
vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
region->ptr.gmrId, region->ptr.offset);
- --region->map_count;
+
+ os_munmap(region->data, region->size);
+ region->data = NULL;
}
/**