diff options
Diffstat (limited to 'lib/mesa/src/gallium/winsys/svga')
-rw-r--r-- | lib/mesa/src/gallium/winsys/svga/drm/SConscript | 23 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/svga/drm/vmw_context.c | 35 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c | 19 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h | 1 | ||||
-rw-r--r-- | lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | 16 |
5 files changed, 68 insertions, 26 deletions
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/SConscript b/lib/mesa/src/gallium/winsys/svga/drm/SConscript new file mode 100644 index 000000000..739896859 --- /dev/null +++ b/lib/mesa/src/gallium/winsys/svga/drm/SConscript @@ -0,0 +1,23 @@ +Import('*') + +env = env.Clone() + +env.PkgUseModules('DRM') + +env.Append(CPPDEFINES = [ + '-D_FILE_OFFSET_BITS=64', +]) + +env.Prepend(CPPPATH = [ + '#/src/gallium/drivers/svga', + '#/src/gallium/drivers/svga/include', +]) + +sources = env.ParseSourceList('Makefile.sources', 'C_SOURCES') + +svgadrm = env.ConvenienceLibrary( + target = 'svgadrm', + source = sources, +) + +Export('svgadrm') diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_context.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_context.c index 432f9afcd..6ab43cb99 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_context.c +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_context.c @@ -95,7 +95,7 @@ struct vmw_svga_winsys_context struct svga_winsys_context base; struct vmw_winsys_screen *vws; - struct hash_table *hash; + struct util_hash_table *hash; #ifdef DEBUG boolean must_flush; @@ -260,7 +260,7 @@ vmw_swc_flush(struct svga_winsys_context *swc, vmw_svga_winsys_surface_reference(&isurf->vsurf, NULL); } - _mesa_hash_table_clear(vswc->hash, NULL); + util_hash_table_clear(vswc->hash); vswc->surface.used = 0; vswc->surface.reserved = 0; @@ -504,8 +504,12 @@ vmw_swc_surface_only_relocation(struct svga_winsys_context *swc, isrf = &vswc->surface.items[vswc->surface.used + vswc->surface.staged]; vmw_svga_winsys_surface_reference(&isrf->vsurf, vsurf); isrf->referenced = FALSE; - - _mesa_hash_table_insert(vswc->hash, vsurf, isrf); + /* + * Note that a failure here may just fall back to unhashed behavior + * and potentially cause unnecessary flushing, so ignore the + * return code. + */ + (void) util_hash_table_set(vswc->hash, vsurf, isrf); ++vswc->surface.staged; vswc->seen_surfaces += vsurf->size; @@ -596,8 +600,12 @@ vmw_swc_shader_relocation(struct svga_winsys_context *swc, ishader = &vswc->shader.items[vswc->shader.used + vswc->shader.staged]; vmw_svga_winsys_shader_reference(&ishader->vshader, vshader); ishader->referenced = FALSE; - - _mesa_hash_table_insert(vswc->hash, vshader, ishader); + /* + * Note that a failure here may just fall back to unhashed behavior + * and potentially cause unnecessary flushing, so ignore the + * return code. + */ + (void) util_hash_table_set(vswc->hash, vshader, ishader); ++vswc->shader.staged; } @@ -674,7 +682,7 @@ vmw_swc_destroy(struct svga_winsys_context *swc) vmw_svga_winsys_shader_reference(&ishader->vshader, NULL); } - _mesa_hash_table_destroy(vswc->hash, NULL); + util_hash_table_destroy(vswc->hash); pb_validate_destroy(vswc->validate); vmw_ioctl_context_destroy(vswc->vws, swc->cid); #ifdef DEBUG @@ -683,6 +691,17 @@ vmw_swc_destroy(struct svga_winsys_context *swc) FREE(vswc); } +static unsigned vmw_hash_ptr(void *p) +{ + return (unsigned)(unsigned long)p; +} + +static int vmw_ptr_compare(void *key1, void *key2) +{ + return (key1 == key2) ? 0 : 1; +} + + /** * vmw_svga_winsys_vgpu10_shader_screate - The winsys shader_crate callback * @@ -825,7 +844,7 @@ vmw_svga_winsys_context_create(struct svga_winsys_screen *sws) if(!vswc->validate) goto out_no_validate; - vswc->hash = util_hash_table_create_ptr_keys(); + vswc->hash = util_hash_table_create(vmw_hash_ptr, vmw_ptr_compare); if (!vswc->hash) goto out_no_hash; diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c index 2f70212de..e3440bfd9 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c @@ -41,15 +41,15 @@ #include <unistd.h> #include <fcntl.h> -static struct hash_table *dev_hash = NULL; +static struct util_hash_table *dev_hash = NULL; -static bool vmw_dev_compare(const void *key1, const void *key2) +static int vmw_dev_compare(void *key1, void *key2) { return (major(*(dev_t *)key1) == major(*(dev_t *)key2) && - minor(*(dev_t *)key1) == minor(*(dev_t *)key2)); + minor(*(dev_t *)key1) == minor(*(dev_t *)key2)) ? 0 : 1; } -static uint32_t vmw_dev_hash(const void *key) +static unsigned vmw_dev_hash(void *key) { return (major(*(dev_t *) key) << 16) | minor(*(dev_t *) key); } @@ -67,10 +67,9 @@ vmw_winsys_create( int fd ) { 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); + dev_hash = util_hash_table_create(vmw_dev_hash, vmw_dev_compare); if (dev_hash == NULL) return NULL; } @@ -98,8 +97,6 @@ vmw_winsys_create( int fd ) 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; @@ -110,12 +107,14 @@ vmw_winsys_create( int fd ) if (!vmw_winsys_screen_init_svga(vws)) goto out_no_svga; - _mesa_hash_table_insert(dev_hash, &vws->device, vws); + if (util_hash_table_set(dev_hash, &vws->device, vws) != PIPE_OK) + goto out_no_hash_insert; cnd_init(&vws->cs_cond); mtx_init(&vws->cs_mutex, mtx_plain); return vws; +out_no_hash_insert: out_no_svga: vmw_pools_cleanup(vws); out_no_pools: @@ -133,7 +132,7 @@ void vmw_winsys_destroy(struct vmw_winsys_screen *vws) { if (--vws->open_count == 0) { - _mesa_hash_table_remove_key(dev_hash, &vws->device); + util_hash_table_remove(dev_hash, &vws->device); vmw_pools_cleanup(vws); vws->fence_ops->destroy(vws->fence_ops); vmw_ioctl_cleanup(vws); diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h index 4cf6b3fd8..c55de4a2b 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h @@ -108,7 +108,6 @@ struct vmw_winsys_screen mtx_t cs_mutex; boolean force_coherent; - boolean cache_maps; }; diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c index bb3a1aded..6f987ba05 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c @@ -64,6 +64,7 @@ struct vmw_region uint32_t handle; uint64_t map_handle; void *data; + uint32_t map_count; int drm_fd; uint32_t size; }; @@ -636,6 +637,7 @@ vmw_ioctl_region_create(struct vmw_winsys_screen *vws, 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; @@ -657,7 +659,10 @@ vmw_ioctl_region_destroy(struct vmw_region *region) vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__, region->ptr.gmrId, region->ptr.offset); - assert(region->data == NULL); + if (region->data) { + os_munmap(region->data, region->size); + region->data = NULL; + } memset(&arg, 0, sizeof(arg)); arg.handle = region->handle; @@ -689,13 +694,12 @@ vmw_ioctl_region_map(struct vmw_region *region) return NULL; } -// MADV_HUGEPAGE only exists on Linux -#ifdef MADV_HUGEPAGE (void) madvise(map, region->size, MADV_HUGEPAGE); -#endif region->data = map; } + ++region->map_count; + return region->data; } @@ -704,9 +708,7 @@ vmw_ioctl_region_unmap(struct vmw_region *region) { vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__, region->ptr.gmrId, region->ptr.offset); - - os_munmap(region->data, region->size); - region->data = NULL; + --region->map_count; } /** |