diff options
| author | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
| commit | bb799d3b980eb803ca2da4a4eefbd9308f8d988a (patch) | |
| tree | 69fbe0cd6d47b23a50f5e1d87bf7489532fae149 /drivers/gpu/drm/vmwgfx | |
| parent | 919fc6e34831d1c2b58bfb5ae261dc3facc9b269 (diff) | |
| parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) | |
Merge tag 'v3.13-rc4' into core/locking
Merge Linux 3.13-rc4, to refresh this rather old tree with the latest fixes.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx')
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/Makefile | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 15 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_prime.c | 137 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 165 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 5 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 30 |
10 files changed, 291 insertions, 77 deletions
diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile index 2cc6cd91ac11..9f8b690bcf52 100644 --- a/drivers/gpu/drm/vmwgfx/Makefile +++ b/drivers/gpu/drm/vmwgfx/Makefile | |||
| @@ -6,6 +6,6 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ | |||
| 6 | vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ | 6 | vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ |
| 7 | vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ | 7 | vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ |
| 8 | vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ | 8 | vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ |
| 9 | vmwgfx_surface.o | 9 | vmwgfx_surface.o vmwgfx_prime.o |
| 10 | 10 | ||
| 11 | obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o | 11 | obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index 7776e6f0aef6..0489c6152482 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | |||
| @@ -150,6 +150,8 @@ struct vmw_ttm_tt { | |||
| 150 | bool mapped; | 150 | bool mapped; |
| 151 | }; | 151 | }; |
| 152 | 152 | ||
| 153 | const size_t vmw_tt_size = sizeof(struct vmw_ttm_tt); | ||
| 154 | |||
| 153 | /** | 155 | /** |
| 154 | * Helper functions to advance a struct vmw_piter iterator. | 156 | * Helper functions to advance a struct vmw_piter iterator. |
| 155 | * | 157 | * |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 20d5485eaf98..c7a549694e59 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |||
| @@ -677,7 +677,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
| 677 | } | 677 | } |
| 678 | 678 | ||
| 679 | dev_priv->tdev = ttm_object_device_init | 679 | dev_priv->tdev = ttm_object_device_init |
| 680 | (dev_priv->mem_global_ref.object, 12); | 680 | (dev_priv->mem_global_ref.object, 12, &vmw_prime_dmabuf_ops); |
| 681 | 681 | ||
| 682 | if (unlikely(dev_priv->tdev == NULL)) { | 682 | if (unlikely(dev_priv->tdev == NULL)) { |
| 683 | DRM_ERROR("Unable to initialize TTM object management.\n"); | 683 | DRM_ERROR("Unable to initialize TTM object management.\n"); |
| @@ -1210,7 +1210,7 @@ static const struct file_operations vmwgfx_driver_fops = { | |||
| 1210 | 1210 | ||
| 1211 | static struct drm_driver driver = { | 1211 | static struct drm_driver driver = { |
| 1212 | .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | | 1212 | .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | |
| 1213 | DRIVER_MODESET, | 1213 | DRIVER_MODESET | DRIVER_PRIME, |
| 1214 | .load = vmw_driver_load, | 1214 | .load = vmw_driver_load, |
| 1215 | .unload = vmw_driver_unload, | 1215 | .unload = vmw_driver_unload, |
| 1216 | .lastclose = vmw_lastclose, | 1216 | .lastclose = vmw_lastclose, |
| @@ -1235,6 +1235,9 @@ static struct drm_driver driver = { | |||
| 1235 | .dumb_map_offset = vmw_dumb_map_offset, | 1235 | .dumb_map_offset = vmw_dumb_map_offset, |
| 1236 | .dumb_destroy = vmw_dumb_destroy, | 1236 | .dumb_destroy = vmw_dumb_destroy, |
| 1237 | 1237 | ||
| 1238 | .prime_fd_to_handle = vmw_prime_fd_to_handle, | ||
| 1239 | .prime_handle_to_fd = vmw_prime_handle_to_fd, | ||
| 1240 | |||
| 1238 | .fops = &vmwgfx_driver_fops, | 1241 | .fops = &vmwgfx_driver_fops, |
| 1239 | .name = VMWGFX_DRIVER_NAME, | 1242 | .name = VMWGFX_DRIVER_NAME, |
| 1240 | .desc = VMWGFX_DRIVER_DESC, | 1243 | .desc = VMWGFX_DRIVER_DESC, |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index e401d5dbcb96..20890ad8408b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | |||
| @@ -615,6 +615,7 @@ extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma); | |||
| 615 | * TTM buffer object driver - vmwgfx_buffer.c | 615 | * TTM buffer object driver - vmwgfx_buffer.c |
| 616 | */ | 616 | */ |
| 617 | 617 | ||
| 618 | extern const size_t vmw_tt_size; | ||
| 618 | extern struct ttm_placement vmw_vram_placement; | 619 | extern struct ttm_placement vmw_vram_placement; |
| 619 | extern struct ttm_placement vmw_vram_ne_placement; | 620 | extern struct ttm_placement vmw_vram_ne_placement; |
| 620 | extern struct ttm_placement vmw_vram_sys_placement; | 621 | extern struct ttm_placement vmw_vram_sys_placement; |
| @@ -819,6 +820,20 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv); | |||
| 819 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; | 820 | extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; |
| 820 | 821 | ||
| 821 | /** | 822 | /** |
| 823 | * Prime - vmwgfx_prime.c | ||
| 824 | */ | ||
| 825 | |||
| 826 | extern const struct dma_buf_ops vmw_prime_dmabuf_ops; | ||
| 827 | extern int vmw_prime_fd_to_handle(struct drm_device *dev, | ||
| 828 | struct drm_file *file_priv, | ||
| 829 | int fd, u32 *handle); | ||
| 830 | extern int vmw_prime_handle_to_fd(struct drm_device *dev, | ||
| 831 | struct drm_file *file_priv, | ||
| 832 | uint32_t handle, uint32_t flags, | ||
| 833 | int *prime_fd); | ||
| 834 | |||
| 835 | |||
| 836 | /** | ||
| 822 | * Inline helper functions | 837 | * Inline helper functions |
| 823 | */ | 838 | */ |
| 824 | 839 | ||
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index ecb3d867b426..03f1c2038631 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | |||
| @@ -75,6 +75,7 @@ void vmw_display_unit_cleanup(struct vmw_display_unit *du) | |||
| 75 | vmw_surface_unreference(&du->cursor_surface); | 75 | vmw_surface_unreference(&du->cursor_surface); |
| 76 | if (du->cursor_dmabuf) | 76 | if (du->cursor_dmabuf) |
| 77 | vmw_dmabuf_unreference(&du->cursor_dmabuf); | 77 | vmw_dmabuf_unreference(&du->cursor_dmabuf); |
| 78 | drm_sysfs_connector_remove(&du->connector); | ||
| 78 | drm_crtc_cleanup(&du->crtc); | 79 | drm_crtc_cleanup(&du->crtc); |
| 79 | drm_encoder_cleanup(&du->encoder); | 80 | drm_encoder_cleanup(&du->encoder); |
| 80 | drm_connector_cleanup(&du->connector); | 81 | drm_connector_cleanup(&du->connector); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c index 79f7e8e60529..a055a26819c2 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | |||
| @@ -260,6 +260,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) | |||
| 260 | connector->encoder = NULL; | 260 | connector->encoder = NULL; |
| 261 | encoder->crtc = NULL; | 261 | encoder->crtc = NULL; |
| 262 | crtc->fb = NULL; | 262 | crtc->fb = NULL; |
| 263 | crtc->enabled = false; | ||
| 263 | 264 | ||
| 264 | vmw_ldu_del_active(dev_priv, ldu); | 265 | vmw_ldu_del_active(dev_priv, ldu); |
| 265 | 266 | ||
| @@ -285,6 +286,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) | |||
| 285 | crtc->x = set->x; | 286 | crtc->x = set->x; |
| 286 | crtc->y = set->y; | 287 | crtc->y = set->y; |
| 287 | crtc->mode = *mode; | 288 | crtc->mode = *mode; |
| 289 | crtc->enabled = true; | ||
| 288 | 290 | ||
| 289 | vmw_ldu_add_active(dev_priv, ldu, vfb); | 291 | vmw_ldu_add_active(dev_priv, ldu, vfb); |
| 290 | 292 | ||
| @@ -369,6 +371,8 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit) | |||
| 369 | encoder->possible_crtcs = (1 << unit); | 371 | encoder->possible_crtcs = (1 << unit); |
| 370 | encoder->possible_clones = 0; | 372 | encoder->possible_clones = 0; |
| 371 | 373 | ||
| 374 | (void) drm_sysfs_connector_add(connector); | ||
| 375 | |||
| 372 | drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs); | 376 | drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs); |
| 373 | 377 | ||
| 374 | drm_mode_crtc_set_gamma_size(crtc, 256); | 378 | drm_mode_crtc_set_gamma_size(crtc, 256); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c new file mode 100644 index 000000000000..31fe32d8d65a --- /dev/null +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /************************************************************************** | ||
| 2 | * | ||
| 3 | * Copyright © 2013 VMware, Inc., Palo Alto, CA., USA | ||
| 4 | * All Rights Reserved. | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the | ||
| 8 | * "Software"), to deal in the Software without restriction, including | ||
| 9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
| 10 | * distribute, sub license, and/or sell copies of the Software, and to | ||
| 11 | * permit persons to whom the Software is furnished to do so, subject to | ||
| 12 | * the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice (including the | ||
| 15 | * next paragraph) shall be included in all copies or substantial portions | ||
| 16 | * of the Software. | ||
| 17 | * | ||
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
| 21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | * | ||
| 26 | **************************************************************************/ | ||
| 27 | /* | ||
| 28 | * Authors: | ||
| 29 | * Thomas Hellstrom <thellstrom@vmware.com> | ||
| 30 | * | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include "vmwgfx_drv.h" | ||
| 34 | #include <linux/dma-buf.h> | ||
| 35 | #include <drm/ttm/ttm_object.h> | ||
| 36 | |||
| 37 | /* | ||
| 38 | * DMA-BUF attach- and mapping methods. No need to implement | ||
| 39 | * these until we have other virtual devices use them. | ||
| 40 | */ | ||
| 41 | |||
| 42 | static int vmw_prime_map_attach(struct dma_buf *dma_buf, | ||
| 43 | struct device *target_dev, | ||
| 44 | struct dma_buf_attachment *attach) | ||
| 45 | { | ||
| 46 | return -ENOSYS; | ||
| 47 | } | ||
| 48 | |||
| 49 | static void vmw_prime_map_detach(struct dma_buf *dma_buf, | ||
| 50 | struct dma_buf_attachment *attach) | ||
| 51 | { | ||
| 52 | } | ||
| 53 | |||
| 54 | static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach, | ||
| 55 | enum dma_data_direction dir) | ||
| 56 | { | ||
| 57 | return ERR_PTR(-ENOSYS); | ||
| 58 | } | ||
| 59 | |||
| 60 | static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach, | ||
| 61 | struct sg_table *sgb, | ||
| 62 | enum dma_data_direction dir) | ||
| 63 | { | ||
| 64 | } | ||
| 65 | |||
| 66 | static void *vmw_prime_dmabuf_vmap(struct dma_buf *dma_buf) | ||
| 67 | { | ||
| 68 | return NULL; | ||
| 69 | } | ||
| 70 | |||
| 71 | static void vmw_prime_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr) | ||
| 72 | { | ||
| 73 | } | ||
| 74 | |||
| 75 | static void *vmw_prime_dmabuf_kmap_atomic(struct dma_buf *dma_buf, | ||
| 76 | unsigned long page_num) | ||
| 77 | { | ||
| 78 | return NULL; | ||
| 79 | } | ||
| 80 | |||
| 81 | static void vmw_prime_dmabuf_kunmap_atomic(struct dma_buf *dma_buf, | ||
| 82 | unsigned long page_num, void *addr) | ||
| 83 | { | ||
| 84 | |||
| 85 | } | ||
| 86 | static void *vmw_prime_dmabuf_kmap(struct dma_buf *dma_buf, | ||
| 87 | unsigned long page_num) | ||
| 88 | { | ||
| 89 | return NULL; | ||
| 90 | } | ||
| 91 | |||
| 92 | static void vmw_prime_dmabuf_kunmap(struct dma_buf *dma_buf, | ||
| 93 | unsigned long page_num, void *addr) | ||
| 94 | { | ||
| 95 | |||
| 96 | } | ||
| 97 | |||
| 98 | static int vmw_prime_dmabuf_mmap(struct dma_buf *dma_buf, | ||
| 99 | struct vm_area_struct *vma) | ||
| 100 | { | ||
| 101 | WARN_ONCE(true, "Attempted use of dmabuf mmap. Bad.\n"); | ||
| 102 | return -ENOSYS; | ||
| 103 | } | ||
| 104 | |||
| 105 | const struct dma_buf_ops vmw_prime_dmabuf_ops = { | ||
| 106 | .attach = vmw_prime_map_attach, | ||
| 107 | .detach = vmw_prime_map_detach, | ||
| 108 | .map_dma_buf = vmw_prime_map_dma_buf, | ||
| 109 | .unmap_dma_buf = vmw_prime_unmap_dma_buf, | ||
| 110 | .release = NULL, | ||
| 111 | .kmap = vmw_prime_dmabuf_kmap, | ||
| 112 | .kmap_atomic = vmw_prime_dmabuf_kmap_atomic, | ||
| 113 | .kunmap = vmw_prime_dmabuf_kunmap, | ||
| 114 | .kunmap_atomic = vmw_prime_dmabuf_kunmap_atomic, | ||
| 115 | .mmap = vmw_prime_dmabuf_mmap, | ||
| 116 | .vmap = vmw_prime_dmabuf_vmap, | ||
| 117 | .vunmap = vmw_prime_dmabuf_vunmap, | ||
| 118 | }; | ||
| 119 | |||
| 120 | int vmw_prime_fd_to_handle(struct drm_device *dev, | ||
| 121 | struct drm_file *file_priv, | ||
| 122 | int fd, u32 *handle) | ||
| 123 | { | ||
| 124 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; | ||
| 125 | |||
| 126 | return ttm_prime_fd_to_handle(tfile, fd, handle); | ||
| 127 | } | ||
| 128 | |||
| 129 | int vmw_prime_handle_to_fd(struct drm_device *dev, | ||
| 130 | struct drm_file *file_priv, | ||
| 131 | uint32_t handle, uint32_t flags, | ||
| 132 | int *prime_fd) | ||
| 133 | { | ||
| 134 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; | ||
| 135 | |||
| 136 | return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd); | ||
| 137 | } | ||
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 252501a54def..9b5ea2ac7ddf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | #define VMW_RES_EVICT_ERR_COUNT 10 | 35 | #define VMW_RES_EVICT_ERR_COUNT 10 |
| 36 | 36 | ||
| 37 | struct vmw_user_dma_buffer { | 37 | struct vmw_user_dma_buffer { |
| 38 | struct ttm_base_object base; | 38 | struct ttm_prime_object prime; |
| 39 | struct vmw_dma_buffer dma; | 39 | struct vmw_dma_buffer dma; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| @@ -297,7 +297,7 @@ int vmw_user_resource_lookup_handle(struct vmw_private *dev_priv, | |||
| 297 | if (unlikely(base == NULL)) | 297 | if (unlikely(base == NULL)) |
| 298 | return -EINVAL; | 298 | return -EINVAL; |
| 299 | 299 | ||
| 300 | if (unlikely(base->object_type != converter->object_type)) | 300 | if (unlikely(ttm_base_object_type(base) != converter->object_type)) |
| 301 | goto out_bad_resource; | 301 | goto out_bad_resource; |
| 302 | 302 | ||
| 303 | res = converter->base_obj_to_res(base); | 303 | res = converter->base_obj_to_res(base); |
| @@ -352,6 +352,38 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv, | |||
| 352 | /** | 352 | /** |
| 353 | * Buffer management. | 353 | * Buffer management. |
| 354 | */ | 354 | */ |
| 355 | |||
| 356 | /** | ||
| 357 | * vmw_dmabuf_acc_size - Calculate the pinned memory usage of buffers | ||
| 358 | * | ||
| 359 | * @dev_priv: Pointer to a struct vmw_private identifying the device. | ||
| 360 | * @size: The requested buffer size. | ||
| 361 | * @user: Whether this is an ordinary dma buffer or a user dma buffer. | ||
| 362 | */ | ||
| 363 | static size_t vmw_dmabuf_acc_size(struct vmw_private *dev_priv, size_t size, | ||
| 364 | bool user) | ||
| 365 | { | ||
| 366 | static size_t struct_size, user_struct_size; | ||
| 367 | size_t num_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; | ||
| 368 | size_t page_array_size = ttm_round_pot(num_pages * sizeof(void *)); | ||
| 369 | |||
| 370 | if (unlikely(struct_size == 0)) { | ||
| 371 | size_t backend_size = ttm_round_pot(vmw_tt_size); | ||
| 372 | |||
| 373 | struct_size = backend_size + | ||
| 374 | ttm_round_pot(sizeof(struct vmw_dma_buffer)); | ||
| 375 | user_struct_size = backend_size + | ||
| 376 | ttm_round_pot(sizeof(struct vmw_user_dma_buffer)); | ||
| 377 | } | ||
| 378 | |||
| 379 | if (dev_priv->map_mode == vmw_dma_alloc_coherent) | ||
| 380 | page_array_size += | ||
| 381 | ttm_round_pot(num_pages * sizeof(dma_addr_t)); | ||
| 382 | |||
| 383 | return ((user) ? user_struct_size : struct_size) + | ||
| 384 | page_array_size; | ||
| 385 | } | ||
| 386 | |||
| 355 | void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) | 387 | void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) |
| 356 | { | 388 | { |
| 357 | struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); | 389 | struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); |
| @@ -359,6 +391,13 @@ void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) | |||
| 359 | kfree(vmw_bo); | 391 | kfree(vmw_bo); |
| 360 | } | 392 | } |
| 361 | 393 | ||
| 394 | static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo) | ||
| 395 | { | ||
| 396 | struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); | ||
| 397 | |||
| 398 | ttm_prime_object_kfree(vmw_user_bo, prime); | ||
| 399 | } | ||
| 400 | |||
| 362 | int vmw_dmabuf_init(struct vmw_private *dev_priv, | 401 | int vmw_dmabuf_init(struct vmw_private *dev_priv, |
| 363 | struct vmw_dma_buffer *vmw_bo, | 402 | struct vmw_dma_buffer *vmw_bo, |
| 364 | size_t size, struct ttm_placement *placement, | 403 | size_t size, struct ttm_placement *placement, |
| @@ -368,28 +407,23 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv, | |||
| 368 | struct ttm_bo_device *bdev = &dev_priv->bdev; | 407 | struct ttm_bo_device *bdev = &dev_priv->bdev; |
| 369 | size_t acc_size; | 408 | size_t acc_size; |
| 370 | int ret; | 409 | int ret; |
| 410 | bool user = (bo_free == &vmw_user_dmabuf_destroy); | ||
| 371 | 411 | ||
| 372 | BUG_ON(!bo_free); | 412 | BUG_ON(!bo_free && (!user && (bo_free != vmw_dmabuf_bo_free))); |
| 373 | 413 | ||
| 374 | acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct vmw_dma_buffer)); | 414 | acc_size = vmw_dmabuf_acc_size(dev_priv, size, user); |
| 375 | memset(vmw_bo, 0, sizeof(*vmw_bo)); | 415 | memset(vmw_bo, 0, sizeof(*vmw_bo)); |
| 376 | 416 | ||
| 377 | INIT_LIST_HEAD(&vmw_bo->res_list); | 417 | INIT_LIST_HEAD(&vmw_bo->res_list); |
| 378 | 418 | ||
| 379 | ret = ttm_bo_init(bdev, &vmw_bo->base, size, | 419 | ret = ttm_bo_init(bdev, &vmw_bo->base, size, |
| 380 | ttm_bo_type_device, placement, | 420 | (user) ? ttm_bo_type_device : |
| 421 | ttm_bo_type_kernel, placement, | ||
| 381 | 0, interruptible, | 422 | 0, interruptible, |
| 382 | NULL, acc_size, NULL, bo_free); | 423 | NULL, acc_size, NULL, bo_free); |
| 383 | return ret; | 424 | return ret; |
| 384 | } | 425 | } |
| 385 | 426 | ||
| 386 | static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo) | ||
| 387 | { | ||
| 388 | struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo); | ||
| 389 | |||
| 390 | ttm_base_object_kfree(vmw_user_bo, base); | ||
| 391 | } | ||
| 392 | |||
| 393 | static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) | 427 | static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) |
| 394 | { | 428 | { |
| 395 | struct vmw_user_dma_buffer *vmw_user_bo; | 429 | struct vmw_user_dma_buffer *vmw_user_bo; |
| @@ -401,7 +435,8 @@ static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) | |||
| 401 | if (unlikely(base == NULL)) | 435 | if (unlikely(base == NULL)) |
| 402 | return; | 436 | return; |
| 403 | 437 | ||
| 404 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, base); | 438 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, |
| 439 | prime.base); | ||
| 405 | bo = &vmw_user_bo->dma.base; | 440 | bo = &vmw_user_bo->dma.base; |
| 406 | ttm_bo_unref(&bo); | 441 | ttm_bo_unref(&bo); |
| 407 | } | 442 | } |
| @@ -442,18 +477,19 @@ int vmw_user_dmabuf_alloc(struct vmw_private *dev_priv, | |||
| 442 | return ret; | 477 | return ret; |
| 443 | 478 | ||
| 444 | tmp = ttm_bo_reference(&user_bo->dma.base); | 479 | tmp = ttm_bo_reference(&user_bo->dma.base); |
| 445 | ret = ttm_base_object_init(tfile, | 480 | ret = ttm_prime_object_init(tfile, |
| 446 | &user_bo->base, | 481 | size, |
| 447 | shareable, | 482 | &user_bo->prime, |
| 448 | ttm_buffer_type, | 483 | shareable, |
| 449 | &vmw_user_dmabuf_release, NULL); | 484 | ttm_buffer_type, |
| 485 | &vmw_user_dmabuf_release, NULL); | ||
| 450 | if (unlikely(ret != 0)) { | 486 | if (unlikely(ret != 0)) { |
| 451 | ttm_bo_unref(&tmp); | 487 | ttm_bo_unref(&tmp); |
| 452 | goto out_no_base_object; | 488 | goto out_no_base_object; |
| 453 | } | 489 | } |
| 454 | 490 | ||
| 455 | *p_dma_buf = &user_bo->dma; | 491 | *p_dma_buf = &user_bo->dma; |
| 456 | *handle = user_bo->base.hash.key; | 492 | *handle = user_bo->prime.base.hash.key; |
| 457 | 493 | ||
| 458 | out_no_base_object: | 494 | out_no_base_object: |
| 459 | return ret; | 495 | return ret; |
| @@ -475,8 +511,8 @@ int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, | |||
| 475 | return -EPERM; | 511 | return -EPERM; |
| 476 | 512 | ||
| 477 | vmw_user_bo = vmw_user_dma_buffer(bo); | 513 | vmw_user_bo = vmw_user_dma_buffer(bo); |
| 478 | return (vmw_user_bo->base.tfile == tfile || | 514 | return (vmw_user_bo->prime.base.tfile == tfile || |
| 479 | vmw_user_bo->base.shareable) ? 0 : -EPERM; | 515 | vmw_user_bo->prime.base.shareable) ? 0 : -EPERM; |
| 480 | } | 516 | } |
| 481 | 517 | ||
| 482 | int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | 518 | int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
| @@ -538,14 +574,15 @@ int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile, | |||
| 538 | return -ESRCH; | 574 | return -ESRCH; |
| 539 | } | 575 | } |
| 540 | 576 | ||
| 541 | if (unlikely(base->object_type != ttm_buffer_type)) { | 577 | if (unlikely(ttm_base_object_type(base) != ttm_buffer_type)) { |
| 542 | ttm_base_object_unref(&base); | 578 | ttm_base_object_unref(&base); |
| 543 | printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n", | 579 | printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n", |
| 544 | (unsigned long)handle); | 580 | (unsigned long)handle); |
| 545 | return -EINVAL; | 581 | return -EINVAL; |
| 546 | } | 582 | } |
| 547 | 583 | ||
| 548 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, base); | 584 | vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, |
| 585 | prime.base); | ||
| 549 | (void)ttm_bo_reference(&vmw_user_bo->dma.base); | 586 | (void)ttm_bo_reference(&vmw_user_bo->dma.base); |
| 550 | ttm_base_object_unref(&base); | 587 | ttm_base_object_unref(&base); |
| 551 | *out = &vmw_user_bo->dma; | 588 | *out = &vmw_user_bo->dma; |
| @@ -562,7 +599,8 @@ int vmw_user_dmabuf_reference(struct ttm_object_file *tfile, | |||
| 562 | return -EINVAL; | 599 | return -EINVAL; |
| 563 | 600 | ||
| 564 | user_bo = container_of(dma_buf, struct vmw_user_dma_buffer, dma); | 601 | user_bo = container_of(dma_buf, struct vmw_user_dma_buffer, dma); |
| 565 | return ttm_ref_object_add(tfile, &user_bo->base, TTM_REF_USAGE, NULL); | 602 | return ttm_ref_object_add(tfile, &user_bo->prime.base, |
| 603 | TTM_REF_USAGE, NULL); | ||
| 566 | } | 604 | } |
| 567 | 605 | ||
| 568 | /* | 606 | /* |
| @@ -777,53 +815,55 @@ err_ref: | |||
| 777 | } | 815 | } |
| 778 | 816 | ||
| 779 | 817 | ||
| 818 | /** | ||
| 819 | * vmw_dumb_create - Create a dumb kms buffer | ||
| 820 | * | ||
| 821 | * @file_priv: Pointer to a struct drm_file identifying the caller. | ||
| 822 | * @dev: Pointer to the drm device. | ||
| 823 | * @args: Pointer to a struct drm_mode_create_dumb structure | ||
| 824 | * | ||
| 825 | * This is a driver callback for the core drm create_dumb functionality. | ||
| 826 | * Note that this is very similar to the vmw_dmabuf_alloc ioctl, except | ||
| 827 | * that the arguments have a different format. | ||
| 828 | */ | ||
| 780 | int vmw_dumb_create(struct drm_file *file_priv, | 829 | int vmw_dumb_create(struct drm_file *file_priv, |
| 781 | struct drm_device *dev, | 830 | struct drm_device *dev, |
| 782 | struct drm_mode_create_dumb *args) | 831 | struct drm_mode_create_dumb *args) |
| 783 | { | 832 | { |
| 784 | struct vmw_private *dev_priv = vmw_priv(dev); | 833 | struct vmw_private *dev_priv = vmw_priv(dev); |
| 785 | struct vmw_master *vmaster = vmw_master(file_priv->master); | 834 | struct vmw_master *vmaster = vmw_master(file_priv->master); |
| 786 | struct vmw_user_dma_buffer *vmw_user_bo; | 835 | struct vmw_dma_buffer *dma_buf; |
| 787 | struct ttm_buffer_object *tmp; | ||
| 788 | int ret; | 836 | int ret; |
| 789 | 837 | ||
| 790 | args->pitch = args->width * ((args->bpp + 7) / 8); | 838 | args->pitch = args->width * ((args->bpp + 7) / 8); |
| 791 | args->size = args->pitch * args->height; | 839 | args->size = args->pitch * args->height; |
| 792 | 840 | ||
| 793 | vmw_user_bo = kzalloc(sizeof(*vmw_user_bo), GFP_KERNEL); | ||
| 794 | if (vmw_user_bo == NULL) | ||
| 795 | return -ENOMEM; | ||
| 796 | |||
| 797 | ret = ttm_read_lock(&vmaster->lock, true); | 841 | ret = ttm_read_lock(&vmaster->lock, true); |
| 798 | if (ret != 0) { | 842 | if (unlikely(ret != 0)) |
| 799 | kfree(vmw_user_bo); | ||
| 800 | return ret; | 843 | return ret; |
| 801 | } | ||
| 802 | 844 | ||
| 803 | ret = vmw_dmabuf_init(dev_priv, &vmw_user_bo->dma, args->size, | 845 | ret = vmw_user_dmabuf_alloc(dev_priv, vmw_fpriv(file_priv)->tfile, |
| 804 | &vmw_vram_sys_placement, true, | 846 | args->size, false, &args->handle, |
| 805 | &vmw_user_dmabuf_destroy); | 847 | &dma_buf); |
| 806 | if (ret != 0) | ||
| 807 | goto out_no_dmabuf; | ||
| 808 | |||
| 809 | tmp = ttm_bo_reference(&vmw_user_bo->dma.base); | ||
| 810 | ret = ttm_base_object_init(vmw_fpriv(file_priv)->tfile, | ||
| 811 | &vmw_user_bo->base, | ||
| 812 | false, | ||
| 813 | ttm_buffer_type, | ||
| 814 | &vmw_user_dmabuf_release, NULL); | ||
| 815 | if (unlikely(ret != 0)) | 848 | if (unlikely(ret != 0)) |
| 816 | goto out_no_base_object; | 849 | goto out_no_dmabuf; |
| 817 | |||
| 818 | args->handle = vmw_user_bo->base.hash.key; | ||
| 819 | 850 | ||
| 820 | out_no_base_object: | 851 | vmw_dmabuf_unreference(&dma_buf); |
| 821 | ttm_bo_unref(&tmp); | ||
| 822 | out_no_dmabuf: | 852 | out_no_dmabuf: |
| 823 | ttm_read_unlock(&vmaster->lock); | 853 | ttm_read_unlock(&vmaster->lock); |
| 824 | return ret; | 854 | return ret; |
| 825 | } | 855 | } |
| 826 | 856 | ||
| 857 | /** | ||
| 858 | * vmw_dumb_map_offset - Return the address space offset of a dumb buffer | ||
| 859 | * | ||
| 860 | * @file_priv: Pointer to a struct drm_file identifying the caller. | ||
| 861 | * @dev: Pointer to the drm device. | ||
| 862 | * @handle: Handle identifying the dumb buffer. | ||
| 863 | * @offset: The address space offset returned. | ||
| 864 | * | ||
| 865 | * This is a driver callback for the core drm dumb_map_offset functionality. | ||
| 866 | */ | ||
| 827 | int vmw_dumb_map_offset(struct drm_file *file_priv, | 867 | int vmw_dumb_map_offset(struct drm_file *file_priv, |
| 828 | struct drm_device *dev, uint32_t handle, | 868 | struct drm_device *dev, uint32_t handle, |
| 829 | uint64_t *offset) | 869 | uint64_t *offset) |
| @@ -841,6 +881,15 @@ int vmw_dumb_map_offset(struct drm_file *file_priv, | |||
| 841 | return 0; | 881 | return 0; |
| 842 | } | 882 | } |
| 843 | 883 | ||
| 884 | /** | ||
| 885 | * vmw_dumb_destroy - Destroy a dumb boffer | ||
| 886 | * | ||
| 887 | * @file_priv: Pointer to a struct drm_file identifying the caller. | ||
| 888 | * @dev: Pointer to the drm device. | ||
| 889 | * @handle: Handle identifying the dumb buffer. | ||
| 890 | * | ||
| 891 | * This is a driver callback for the core drm dumb_destroy functionality. | ||
| 892 | */ | ||
| 844 | int vmw_dumb_destroy(struct drm_file *file_priv, | 893 | int vmw_dumb_destroy(struct drm_file *file_priv, |
| 845 | struct drm_device *dev, | 894 | struct drm_device *dev, |
| 846 | uint32_t handle) | 895 | uint32_t handle) |
| @@ -994,7 +1043,6 @@ void vmw_resource_unreserve(struct vmw_resource *res, | |||
| 994 | */ | 1043 | */ |
| 995 | static int | 1044 | static int |
| 996 | vmw_resource_check_buffer(struct vmw_resource *res, | 1045 | vmw_resource_check_buffer(struct vmw_resource *res, |
| 997 | struct ww_acquire_ctx *ticket, | ||
| 998 | bool interruptible, | 1046 | bool interruptible, |
| 999 | struct ttm_validate_buffer *val_buf) | 1047 | struct ttm_validate_buffer *val_buf) |
| 1000 | { | 1048 | { |
| @@ -1011,7 +1059,7 @@ vmw_resource_check_buffer(struct vmw_resource *res, | |||
| 1011 | INIT_LIST_HEAD(&val_list); | 1059 | INIT_LIST_HEAD(&val_list); |
| 1012 | val_buf->bo = ttm_bo_reference(&res->backup->base); | 1060 | val_buf->bo = ttm_bo_reference(&res->backup->base); |
| 1013 | list_add_tail(&val_buf->head, &val_list); | 1061 | list_add_tail(&val_buf->head, &val_list); |
| 1014 | ret = ttm_eu_reserve_buffers(ticket, &val_list); | 1062 | ret = ttm_eu_reserve_buffers(NULL, &val_list); |
| 1015 | if (unlikely(ret != 0)) | 1063 | if (unlikely(ret != 0)) |
| 1016 | goto out_no_reserve; | 1064 | goto out_no_reserve; |
| 1017 | 1065 | ||
| @@ -1029,7 +1077,7 @@ vmw_resource_check_buffer(struct vmw_resource *res, | |||
| 1029 | return 0; | 1077 | return 0; |
| 1030 | 1078 | ||
| 1031 | out_no_validate: | 1079 | out_no_validate: |
| 1032 | ttm_eu_backoff_reservation(ticket, &val_list); | 1080 | ttm_eu_backoff_reservation(NULL, &val_list); |
| 1033 | out_no_reserve: | 1081 | out_no_reserve: |
| 1034 | ttm_bo_unref(&val_buf->bo); | 1082 | ttm_bo_unref(&val_buf->bo); |
| 1035 | if (backup_dirty) | 1083 | if (backup_dirty) |
| @@ -1074,8 +1122,7 @@ int vmw_resource_reserve(struct vmw_resource *res, bool no_backup) | |||
| 1074 | * @val_buf: Backup buffer information. | 1122 | * @val_buf: Backup buffer information. |
| 1075 | */ | 1123 | */ |
| 1076 | static void | 1124 | static void |
| 1077 | vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket, | 1125 | vmw_resource_backoff_reservation(struct ttm_validate_buffer *val_buf) |
| 1078 | struct ttm_validate_buffer *val_buf) | ||
| 1079 | { | 1126 | { |
| 1080 | struct list_head val_list; | 1127 | struct list_head val_list; |
| 1081 | 1128 | ||
| @@ -1084,7 +1131,7 @@ vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket, | |||
| 1084 | 1131 | ||
| 1085 | INIT_LIST_HEAD(&val_list); | 1132 | INIT_LIST_HEAD(&val_list); |
| 1086 | list_add_tail(&val_buf->head, &val_list); | 1133 | list_add_tail(&val_buf->head, &val_list); |
| 1087 | ttm_eu_backoff_reservation(ticket, &val_list); | 1134 | ttm_eu_backoff_reservation(NULL, &val_list); |
| 1088 | ttm_bo_unref(&val_buf->bo); | 1135 | ttm_bo_unref(&val_buf->bo); |
| 1089 | } | 1136 | } |
| 1090 | 1137 | ||
| @@ -1099,14 +1146,12 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible) | |||
| 1099 | { | 1146 | { |
| 1100 | struct ttm_validate_buffer val_buf; | 1147 | struct ttm_validate_buffer val_buf; |
| 1101 | const struct vmw_res_func *func = res->func; | 1148 | const struct vmw_res_func *func = res->func; |
| 1102 | struct ww_acquire_ctx ticket; | ||
| 1103 | int ret; | 1149 | int ret; |
| 1104 | 1150 | ||
| 1105 | BUG_ON(!func->may_evict); | 1151 | BUG_ON(!func->may_evict); |
| 1106 | 1152 | ||
| 1107 | val_buf.bo = NULL; | 1153 | val_buf.bo = NULL; |
| 1108 | ret = vmw_resource_check_buffer(res, &ticket, interruptible, | 1154 | ret = vmw_resource_check_buffer(res, interruptible, &val_buf); |
| 1109 | &val_buf); | ||
| 1110 | if (unlikely(ret != 0)) | 1155 | if (unlikely(ret != 0)) |
| 1111 | return ret; | 1156 | return ret; |
| 1112 | 1157 | ||
| @@ -1121,7 +1166,7 @@ int vmw_resource_do_evict(struct vmw_resource *res, bool interruptible) | |||
| 1121 | res->backup_dirty = true; | 1166 | res->backup_dirty = true; |
| 1122 | res->res_dirty = false; | 1167 | res->res_dirty = false; |
| 1123 | out_no_unbind: | 1168 | out_no_unbind: |
| 1124 | vmw_resource_backoff_reservation(&ticket, &val_buf); | 1169 | vmw_resource_backoff_reservation(&val_buf); |
| 1125 | 1170 | ||
| 1126 | return ret; | 1171 | return ret; |
| 1127 | } | 1172 | } |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c index 26387c3d5a21..22406c8651ea 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | |||
| @@ -310,6 +310,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) | |||
| 310 | crtc->fb = NULL; | 310 | crtc->fb = NULL; |
| 311 | crtc->x = 0; | 311 | crtc->x = 0; |
| 312 | crtc->y = 0; | 312 | crtc->y = 0; |
| 313 | crtc->enabled = false; | ||
| 313 | 314 | ||
| 314 | vmw_sou_del_active(dev_priv, sou); | 315 | vmw_sou_del_active(dev_priv, sou); |
| 315 | 316 | ||
| @@ -370,6 +371,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) | |||
| 370 | crtc->fb = NULL; | 371 | crtc->fb = NULL; |
| 371 | crtc->x = 0; | 372 | crtc->x = 0; |
| 372 | crtc->y = 0; | 373 | crtc->y = 0; |
| 374 | crtc->enabled = false; | ||
| 373 | 375 | ||
| 374 | return ret; | 376 | return ret; |
| 375 | } | 377 | } |
| @@ -382,6 +384,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) | |||
| 382 | crtc->fb = fb; | 384 | crtc->fb = fb; |
| 383 | crtc->x = set->x; | 385 | crtc->x = set->x; |
| 384 | crtc->y = set->y; | 386 | crtc->y = set->y; |
| 387 | crtc->enabled = true; | ||
| 385 | 388 | ||
| 386 | return 0; | 389 | return 0; |
| 387 | } | 390 | } |
| @@ -464,6 +467,8 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit) | |||
| 464 | encoder->possible_crtcs = (1 << unit); | 467 | encoder->possible_crtcs = (1 << unit); |
| 465 | encoder->possible_clones = 0; | 468 | encoder->possible_clones = 0; |
| 466 | 469 | ||
| 470 | (void) drm_sysfs_connector_add(connector); | ||
| 471 | |||
| 467 | drm_crtc_init(dev, crtc, &vmw_screen_object_crtc_funcs); | 472 | drm_crtc_init(dev, crtc, &vmw_screen_object_crtc_funcs); |
| 468 | 473 | ||
| 469 | drm_mode_crtc_set_gamma_size(crtc, 256); | 474 | drm_mode_crtc_set_gamma_size(crtc, 256); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 582814339748..7de2ea8bd553 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | * @size: TTM accounting size for the surface. | 38 | * @size: TTM accounting size for the surface. |
| 39 | */ | 39 | */ |
| 40 | struct vmw_user_surface { | 40 | struct vmw_user_surface { |
| 41 | struct ttm_base_object base; | 41 | struct ttm_prime_object prime; |
| 42 | struct vmw_surface srf; | 42 | struct vmw_surface srf; |
| 43 | uint32_t size; | 43 | uint32_t size; |
| 44 | uint32_t backup_handle; | 44 | uint32_t backup_handle; |
| @@ -580,7 +580,8 @@ static int vmw_surface_init(struct vmw_private *dev_priv, | |||
| 580 | static struct vmw_resource * | 580 | static struct vmw_resource * |
| 581 | vmw_user_surface_base_to_res(struct ttm_base_object *base) | 581 | vmw_user_surface_base_to_res(struct ttm_base_object *base) |
| 582 | { | 582 | { |
| 583 | return &(container_of(base, struct vmw_user_surface, base)->srf.res); | 583 | return &(container_of(base, struct vmw_user_surface, |
| 584 | prime.base)->srf.res); | ||
| 584 | } | 585 | } |
| 585 | 586 | ||
| 586 | /** | 587 | /** |
| @@ -599,7 +600,7 @@ static void vmw_user_surface_free(struct vmw_resource *res) | |||
| 599 | kfree(srf->offsets); | 600 | kfree(srf->offsets); |
| 600 | kfree(srf->sizes); | 601 | kfree(srf->sizes); |
| 601 | kfree(srf->snooper.image); | 602 | kfree(srf->snooper.image); |
| 602 | ttm_base_object_kfree(user_srf, base); | 603 | ttm_prime_object_kfree(user_srf, prime); |
| 603 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); | 604 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); |
| 604 | } | 605 | } |
| 605 | 606 | ||
| @@ -616,7 +617,7 @@ static void vmw_user_surface_base_release(struct ttm_base_object **p_base) | |||
| 616 | { | 617 | { |
| 617 | struct ttm_base_object *base = *p_base; | 618 | struct ttm_base_object *base = *p_base; |
| 618 | struct vmw_user_surface *user_srf = | 619 | struct vmw_user_surface *user_srf = |
| 619 | container_of(base, struct vmw_user_surface, base); | 620 | container_of(base, struct vmw_user_surface, prime.base); |
| 620 | struct vmw_resource *res = &user_srf->srf.res; | 621 | struct vmw_resource *res = &user_srf->srf.res; |
| 621 | 622 | ||
| 622 | *p_base = NULL; | 623 | *p_base = NULL; |
| @@ -790,8 +791,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
| 790 | } | 791 | } |
| 791 | srf->snooper.crtc = NULL; | 792 | srf->snooper.crtc = NULL; |
| 792 | 793 | ||
| 793 | user_srf->base.shareable = false; | 794 | user_srf->prime.base.shareable = false; |
| 794 | user_srf->base.tfile = NULL; | 795 | user_srf->prime.base.tfile = NULL; |
| 795 | 796 | ||
| 796 | /** | 797 | /** |
| 797 | * From this point, the generic resource management functions | 798 | * From this point, the generic resource management functions |
| @@ -803,9 +804,9 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
| 803 | goto out_unlock; | 804 | goto out_unlock; |
| 804 | 805 | ||
| 805 | tmp = vmw_resource_reference(&srf->res); | 806 | tmp = vmw_resource_reference(&srf->res); |
| 806 | ret = ttm_base_object_init(tfile, &user_srf->base, | 807 | ret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime, |
| 807 | req->shareable, VMW_RES_SURFACE, | 808 | req->shareable, VMW_RES_SURFACE, |
| 808 | &vmw_user_surface_base_release, NULL); | 809 | &vmw_user_surface_base_release, NULL); |
| 809 | 810 | ||
| 810 | if (unlikely(ret != 0)) { | 811 | if (unlikely(ret != 0)) { |
| 811 | vmw_resource_unreference(&tmp); | 812 | vmw_resource_unreference(&tmp); |
| @@ -813,7 +814,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
| 813 | goto out_unlock; | 814 | goto out_unlock; |
| 814 | } | 815 | } |
| 815 | 816 | ||
| 816 | rep->sid = user_srf->base.hash.key; | 817 | rep->sid = user_srf->prime.base.hash.key; |
| 817 | vmw_resource_unreference(&res); | 818 | vmw_resource_unreference(&res); |
| 818 | 819 | ||
| 819 | ttm_read_unlock(&vmaster->lock); | 820 | ttm_read_unlock(&vmaster->lock); |
| @@ -823,7 +824,7 @@ out_no_copy: | |||
| 823 | out_no_offsets: | 824 | out_no_offsets: |
| 824 | kfree(srf->sizes); | 825 | kfree(srf->sizes); |
| 825 | out_no_sizes: | 826 | out_no_sizes: |
| 826 | ttm_base_object_kfree(user_srf, base); | 827 | ttm_prime_object_kfree(user_srf, prime); |
| 827 | out_no_user_srf: | 828 | out_no_user_srf: |
| 828 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); | 829 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); |
| 829 | out_unlock: | 830 | out_unlock: |
| @@ -859,13 +860,14 @@ int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, | |||
| 859 | return -EINVAL; | 860 | return -EINVAL; |
| 860 | } | 861 | } |
| 861 | 862 | ||
| 862 | if (unlikely(base->object_type != VMW_RES_SURFACE)) | 863 | if (unlikely(ttm_base_object_type(base) != VMW_RES_SURFACE)) |
| 863 | goto out_bad_resource; | 864 | goto out_bad_resource; |
| 864 | 865 | ||
| 865 | user_srf = container_of(base, struct vmw_user_surface, base); | 866 | user_srf = container_of(base, struct vmw_user_surface, prime.base); |
| 866 | srf = &user_srf->srf; | 867 | srf = &user_srf->srf; |
| 867 | 868 | ||
| 868 | ret = ttm_ref_object_add(tfile, &user_srf->base, TTM_REF_USAGE, NULL); | 869 | ret = ttm_ref_object_add(tfile, &user_srf->prime.base, |
| 870 | TTM_REF_USAGE, NULL); | ||
| 869 | if (unlikely(ret != 0)) { | 871 | if (unlikely(ret != 0)) { |
| 870 | DRM_ERROR("Could not add a reference to a surface.\n"); | 872 | DRM_ERROR("Could not add a reference to a surface.\n"); |
| 871 | goto out_no_reference; | 873 | goto out_no_reference; |
