Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: Rename vmw_buffer_object to vmw_bo

The rest of the drivers which are using ttm have mostly standardized on
driver_prefix_bo as the name for subclasses of the TTM buffer object.
Make vmwgfx match the rest of the drivers and follow the same naming
semantics.

This is especially clear given that the name of the file in which the
object was defined is vmw_bo.c.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Reviewed-by: Maaz Mombasawala <mombasawalam@vmware.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230131033542.953249-4-zack@kde.org

+421 -387
+42 -56
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright © 2011-2018 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright © 2011-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * All Rights Reserved. 6 6 * 7 7 * Permission is hereby granted, free of charge, to any person obtaining a ··· 26 26 * 27 27 **************************************************************************/ 28 28 29 + #include "vmwgfx_bo.h" 30 + #include "vmwgfx_drv.h" 31 + 32 + 29 33 #include <drm/ttm/ttm_placement.h> 30 34 31 - #include "vmwgfx_drv.h" 32 - #include "ttm_object.h" 33 - 34 - 35 35 /** 36 - * vmw_buffer_object - Convert a struct ttm_buffer_object to a struct 37 - * vmw_buffer_object. 38 - * 39 - * @bo: Pointer to the TTM buffer object. 40 - * Return: Pointer to the struct vmw_buffer_object embedding the 41 - * TTM buffer object. 42 - */ 43 - static struct vmw_buffer_object * 44 - vmw_buffer_object(struct ttm_buffer_object *bo) 45 - { 46 - return container_of(bo, struct vmw_buffer_object, base); 47 - } 48 - 49 - /** 50 - * vmw_bo_bo_free - vmw buffer object destructor 36 + * vmw_bo_free - vmw_bo destructor 51 37 * 52 38 * @bo: Pointer to the embedded struct ttm_buffer_object 53 39 */ 54 - static void vmw_bo_bo_free(struct ttm_buffer_object *bo) 40 + static void vmw_bo_free(struct ttm_buffer_object *bo) 55 41 { 56 - struct vmw_buffer_object *vmw_bo = vmw_buffer_object(bo); 42 + struct vmw_bo *vbo = to_vmw_bo(&bo->base); 57 43 58 - WARN_ON(vmw_bo->dirty); 59 - WARN_ON(!RB_EMPTY_ROOT(&vmw_bo->res_tree)); 60 - vmw_bo_unmap(vmw_bo); 44 + WARN_ON(vbo->dirty); 45 + WARN_ON(!RB_EMPTY_ROOT(&vbo->res_tree)); 46 + vmw_bo_unmap(vbo); 61 47 drm_gem_object_release(&bo->base); 62 - kfree(vmw_bo); 48 + kfree(vbo); 63 49 } 64 50 65 51 /** 66 - * bo_is_vmw - check if the buffer object is a &vmw_buffer_object 52 + * bo_is_vmw - check if the buffer object is a &vmw_bo 67 53 * @bo: ttm buffer object to be checked 68 54 * 69 55 * Uses destroy function associated with the object to determine if this is 70 - * a &vmw_buffer_object. 56 + * a &vmw_bo. 71 57 * 72 58 * Returns: 73 - * true if the object is of &vmw_buffer_object type, false if not. 59 + * true if the object is of &vmw_bo type, false if not. 74 60 */ 75 61 static bool bo_is_vmw(struct ttm_buffer_object *bo) 76 62 { 77 - return bo->destroy == &vmw_bo_bo_free; 63 + return bo->destroy == &vmw_bo_free; 78 64 } 79 65 80 66 /** ··· 74 88 * -ERESTARTSYS if interrupted by a signal 75 89 */ 76 90 int vmw_bo_pin_in_placement(struct vmw_private *dev_priv, 77 - struct vmw_buffer_object *buf, 91 + struct vmw_bo *buf, 78 92 struct ttm_placement *placement, 79 93 bool interruptible) 80 94 { ··· 111 125 * -ERESTARTSYS if interrupted by a signal 112 126 */ 113 127 int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, 114 - struct vmw_buffer_object *buf, 128 + struct vmw_bo *buf, 115 129 bool interruptible) 116 130 { 117 131 struct ttm_operation_ctx ctx = {interruptible, false }; ··· 153 167 * -ERESTARTSYS if interrupted by a signal 154 168 */ 155 169 int vmw_bo_pin_in_vram(struct vmw_private *dev_priv, 156 - struct vmw_buffer_object *buf, 170 + struct vmw_bo *buf, 157 171 bool interruptible) 158 172 { 159 173 return vmw_bo_pin_in_placement(dev_priv, buf, &vmw_vram_placement, ··· 174 188 * -ERESTARTSYS if interrupted by a signal 175 189 */ 176 190 int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, 177 - struct vmw_buffer_object *buf, 191 + struct vmw_bo *buf, 178 192 bool interruptible) 179 193 { 180 194 struct ttm_operation_ctx ctx = {interruptible, false }; ··· 234 248 * -ERESTARTSYS if interrupted by a signal 235 249 */ 236 250 int vmw_bo_unpin(struct vmw_private *dev_priv, 237 - struct vmw_buffer_object *buf, 251 + struct vmw_bo *buf, 238 252 bool interruptible) 239 253 { 240 254 struct ttm_buffer_object *bo = &buf->base; ··· 279 293 * @pin: Whether to pin or unpin. 280 294 * 281 295 */ 282 - void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin) 296 + void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin) 283 297 { 284 298 struct ttm_operation_ctx ctx = { false, true }; 285 299 struct ttm_place pl; ··· 327 341 * 3) Buffer object destruction 328 342 * 329 343 */ 330 - void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo) 344 + void *vmw_bo_map_and_cache(struct vmw_bo *vbo) 331 345 { 332 346 struct ttm_buffer_object *bo = &vbo->base; 333 347 bool not_used; ··· 352 366 * @vbo: The buffer object whose map we are tearing down. 353 367 * 354 368 * This function tears down a cached map set up using 355 - * vmw_buffer_object_map_and_cache(). 369 + * vmw_bo_map_and_cache(). 356 370 */ 357 - void vmw_bo_unmap(struct vmw_buffer_object *vbo) 371 + void vmw_bo_unmap(struct vmw_bo *vbo) 358 372 { 359 373 if (vbo->map.bo == NULL) 360 374 return; ··· 418 432 int vmw_bo_create(struct vmw_private *vmw, 419 433 size_t size, struct ttm_placement *placement, 420 434 bool interruptible, bool pin, 421 - struct vmw_buffer_object **p_bo) 435 + struct vmw_bo **p_bo) 422 436 { 423 437 int ret; 424 438 ··· 444 458 * vmw_bo_init - Initialize a vmw buffer object 445 459 * 446 460 * @dev_priv: Pointer to the device private struct 447 - * @vmw_bo: Pointer to the struct vmw_buffer_object to initialize. 461 + * @vmw_bo: Pointer to the struct vmw_bo to initialize. 448 462 * @size: Buffer object size in bytes. 449 463 * @placement: Initial placement. 450 464 * @interruptible: Whether waits should be performed interruptible. ··· 454 468 * Note that on error, the code will free the buffer object. 455 469 */ 456 470 int vmw_bo_init(struct vmw_private *dev_priv, 457 - struct vmw_buffer_object *vmw_bo, 471 + struct vmw_bo *vmw_bo, 458 472 size_t size, struct ttm_placement *placement, 459 473 bool interruptible, bool pin) 460 474 { ··· 475 489 drm_gem_private_object_init(vdev, &vmw_bo->base.base, size); 476 490 477 491 ret = ttm_bo_init_reserved(bdev, &vmw_bo->base, ttm_bo_type_device, 478 - placement, 0, &ctx, NULL, NULL, vmw_bo_bo_free); 492 + placement, 0, &ctx, NULL, NULL, vmw_bo_free); 479 493 if (unlikely(ret)) { 480 494 return ret; 481 495 } ··· 488 502 } 489 503 490 504 /** 491 - * vmw_user_bo_synccpu_grab - Grab a struct vmw_buffer_object for cpu 505 + * vmw_user_bo_synccpu_grab - Grab a struct vmw_bo for cpu 492 506 * access, idling previous GPU operations on the buffer and optionally 493 507 * blocking it for further command submissions. 494 508 * ··· 501 515 * 502 516 * A blocking grab will be automatically released when @tfile is closed. 503 517 */ 504 - static int vmw_user_bo_synccpu_grab(struct vmw_buffer_object *vmw_bo, 518 + static int vmw_user_bo_synccpu_grab(struct vmw_bo *vmw_bo, 505 519 uint32_t flags) 506 520 { 507 521 bool nonblock = !!(flags & drm_vmw_synccpu_dontblock); ··· 548 562 uint32_t handle, 549 563 uint32_t flags) 550 564 { 551 - struct vmw_buffer_object *vmw_bo; 565 + struct vmw_bo *vmw_bo; 552 566 int ret = vmw_user_bo_lookup(filp, handle, &vmw_bo); 553 567 554 568 if (!ret) { ··· 579 593 { 580 594 struct drm_vmw_synccpu_arg *arg = 581 595 (struct drm_vmw_synccpu_arg *) data; 582 - struct vmw_buffer_object *vbo; 596 + struct vmw_bo *vbo; 583 597 int ret; 584 598 585 599 if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0 ··· 652 666 * @filp: The file the handle is registered with. 653 667 * @handle: The user buffer object handle 654 668 * @out: Pointer to a where a pointer to the embedded 655 - * struct vmw_buffer_object should be placed. 669 + * struct vmw_bo should be placed. 656 670 * Return: Zero on success, Negative error code on error. 657 671 * 658 672 * The vmw buffer object pointer will be refcounted. 659 673 */ 660 674 int vmw_user_bo_lookup(struct drm_file *filp, 661 675 uint32_t handle, 662 - struct vmw_buffer_object **out) 676 + struct vmw_bo **out) 663 677 { 664 678 struct drm_gem_object *gobj; 665 679 ··· 670 684 return -ESRCH; 671 685 } 672 686 673 - *out = gem_to_vmw_bo(gobj); 687 + *out = to_vmw_bo(gobj); 674 688 ttm_bo_get(&(*out)->base); 675 689 drm_gem_object_put(gobj); 676 690 ··· 730 744 struct drm_mode_create_dumb *args) 731 745 { 732 746 struct vmw_private *dev_priv = vmw_priv(dev); 733 - struct vmw_buffer_object *vbo; 747 + struct vmw_bo *vbo; 734 748 int cpp = DIV_ROUND_UP(args->bpp, 8); 735 749 int ret; 736 750 ··· 764 778 */ 765 779 void vmw_bo_swap_notify(struct ttm_buffer_object *bo) 766 780 { 767 - /* Is @bo embedded in a struct vmw_buffer_object? */ 781 + /* Is @bo embedded in a struct vmw_bo? */ 768 782 if (!bo_is_vmw(bo)) 769 783 return; 770 784 771 785 /* Kill any cached kernel maps before swapout */ 772 - vmw_bo_unmap(vmw_buffer_object(bo)); 786 + vmw_bo_unmap(to_vmw_bo(&bo->base)); 773 787 } 774 788 775 789 ··· 786 800 void vmw_bo_move_notify(struct ttm_buffer_object *bo, 787 801 struct ttm_resource *mem) 788 802 { 789 - struct vmw_buffer_object *vbo; 803 + struct vmw_bo *vbo; 790 804 791 - /* Make sure @bo is embedded in a struct vmw_buffer_object? */ 805 + /* Make sure @bo is embedded in a struct vmw_bo? */ 792 806 if (!bo_is_vmw(bo)) 793 807 return; 794 808 795 - vbo = container_of(bo, struct vmw_buffer_object, base); 809 + vbo = container_of(bo, struct vmw_bo, base); 796 810 797 811 /* 798 812 * Kill any cached kernel maps before move to or from VRAM.
+189
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 + /************************************************************************** 3 + * 4 + * Copyright 2023 VMware, Inc., Palo Alto, CA., USA 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 + #ifndef VMWGFX_BO_H 29 + #define VMWGFX_BO_H 30 + 31 + #include "device_include/svga_reg.h" 32 + 33 + #include <drm/ttm/ttm_bo.h> 34 + 35 + #include <linux/rbtree_types.h> 36 + #include <linux/types.h> 37 + 38 + struct vmw_bo_dirty; 39 + struct vmw_fence_obj; 40 + struct vmw_private; 41 + struct vmw_resource; 42 + 43 + /** 44 + * struct vmw_bo - TTM buffer object with vmwgfx additions 45 + * @base: The TTM buffer object 46 + * @res_tree: RB tree of resources using this buffer object as a backing MOB 47 + * @base_mapped_count: ttm BO mapping count; used by KMS atomic helpers. 48 + * @cpu_writers: Number of synccpu write grabs. Protected by reservation when 49 + * increased. May be decreased without reservation. 50 + * @dx_query_ctx: DX context if this buffer object is used as a DX query MOB 51 + * @map: Kmap object for semi-persistent mappings 52 + * @res_prios: Eviction priority counts for attached resources 53 + * @dirty: structure for user-space dirty-tracking 54 + */ 55 + struct vmw_bo { 56 + struct ttm_buffer_object base; 57 + struct rb_root res_tree; 58 + /* For KMS atomic helpers: ttm bo mapping count */ 59 + atomic_t base_mapped_count; 60 + 61 + atomic_t cpu_writers; 62 + /* Not ref-counted. Protected by binding_mutex */ 63 + struct vmw_resource *dx_query_ctx; 64 + /* Protected by reservation */ 65 + struct ttm_bo_kmap_obj map; 66 + u32 res_prios[TTM_MAX_BO_PRIORITY]; 67 + struct vmw_bo_dirty *dirty; 68 + }; 69 + 70 + int vmw_bo_create_kernel(struct vmw_private *dev_priv, 71 + unsigned long size, 72 + struct ttm_placement *placement, 73 + struct ttm_buffer_object **p_bo); 74 + int vmw_bo_create(struct vmw_private *dev_priv, 75 + size_t size, struct ttm_placement *placement, 76 + bool interruptible, bool pin, 77 + struct vmw_bo **p_bo); 78 + int vmw_bo_init(struct vmw_private *dev_priv, 79 + struct vmw_bo *vmw_bo, 80 + size_t size, struct ttm_placement *placement, 81 + bool interruptible, bool pin); 82 + int vmw_bo_unref_ioctl(struct drm_device *dev, void *data, 83 + struct drm_file *file_priv); 84 + 85 + int vmw_bo_pin_in_placement(struct vmw_private *vmw_priv, 86 + struct vmw_bo *bo, 87 + struct ttm_placement *placement, 88 + bool interruptible); 89 + int vmw_bo_pin_in_vram(struct vmw_private *dev_priv, 90 + struct vmw_bo *buf, 91 + bool interruptible); 92 + int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, 93 + struct vmw_bo *buf, 94 + bool interruptible); 95 + int vmw_bo_pin_in_start_of_vram(struct vmw_private *vmw_priv, 96 + struct vmw_bo *bo, 97 + bool interruptible); 98 + void vmw_bo_pin_reserved(struct vmw_bo *bo, bool pin); 99 + int vmw_bo_unpin(struct vmw_private *vmw_priv, 100 + struct vmw_bo *bo, 101 + bool interruptible); 102 + 103 + void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf, 104 + SVGAGuestPtr *ptr); 105 + int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data, 106 + struct drm_file *file_priv); 107 + int vmw_user_bo_lookup(struct drm_file *filp, 108 + uint32_t handle, 109 + struct vmw_bo **out); 110 + void vmw_bo_fence_single(struct ttm_buffer_object *bo, 111 + struct vmw_fence_obj *fence); 112 + 113 + void *vmw_bo_map_and_cache(struct vmw_bo *vbo); 114 + void vmw_bo_unmap(struct vmw_bo *vbo); 115 + 116 + void vmw_bo_move_notify(struct ttm_buffer_object *bo, 117 + struct ttm_resource *mem); 118 + void vmw_bo_swap_notify(struct ttm_buffer_object *bo); 119 + 120 + /** 121 + * vmw_bo_adjust_prio - Adjust the buffer object eviction priority 122 + * according to attached resources 123 + * @vbo: The struct vmw_bo 124 + */ 125 + static inline void vmw_bo_prio_adjust(struct vmw_bo *vbo) 126 + { 127 + int i = ARRAY_SIZE(vbo->res_prios); 128 + 129 + while (i--) { 130 + if (vbo->res_prios[i]) { 131 + vbo->base.priority = i; 132 + return; 133 + } 134 + } 135 + 136 + vbo->base.priority = 3; 137 + } 138 + 139 + /** 140 + * vmw_bo_prio_add - Notify a buffer object of a newly attached resource 141 + * eviction priority 142 + * @vbo: The struct vmw_bo 143 + * @prio: The resource priority 144 + * 145 + * After being notified, the code assigns the highest resource eviction priority 146 + * to the backing buffer object (mob). 147 + */ 148 + static inline void vmw_bo_prio_add(struct vmw_bo *vbo, int prio) 149 + { 150 + if (vbo->res_prios[prio]++ == 0) 151 + vmw_bo_prio_adjust(vbo); 152 + } 153 + 154 + /** 155 + * vmw_bo_prio_del - Notify a buffer object of a resource with a certain 156 + * priority being removed 157 + * @vbo: The struct vmw_bo 158 + * @prio: The resource priority 159 + * 160 + * After being notified, the code assigns the highest resource eviction priority 161 + * to the backing buffer object (mob). 162 + */ 163 + static inline void vmw_bo_prio_del(struct vmw_bo *vbo, int prio) 164 + { 165 + if (--vbo->res_prios[prio] == 0) 166 + vmw_bo_prio_adjust(vbo); 167 + } 168 + 169 + static inline void vmw_bo_unreference(struct vmw_bo **buf) 170 + { 171 + struct vmw_bo *tmp_buf = *buf; 172 + 173 + *buf = NULL; 174 + if (tmp_buf) 175 + ttm_bo_put(&tmp_buf->base); 176 + } 177 + 178 + static inline struct vmw_bo *vmw_bo_reference(struct vmw_bo *buf) 179 + { 180 + ttm_bo_get(&buf->base); 181 + return buf; 182 + } 183 + 184 + static inline struct vmw_bo *to_vmw_bo(struct drm_gem_object *gobj) 185 + { 186 + return container_of((gobj), struct vmw_bo, base.base); 187 + } 188 + 189 + #endif // VMWGFX_BO_H
+5 -5
drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2020 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 24 24 * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 25 * 26 26 **************************************************************************/ 27 - 28 - #include <linux/sched/signal.h> 27 + #include "vmwgfx_bo.h" 28 + #include "vmwgfx_drv.h" 29 + #include "vmwgfx_devcaps.h" 29 30 30 31 #include <drm/ttm/ttm_placement.h> 31 32 32 - #include "vmwgfx_drv.h" 33 - #include "vmwgfx_devcaps.h" 33 + #include <linux/sched/signal.h> 34 34 35 35 bool vmw_supports_3d(struct vmw_private *dev_priv) 36 36 {
+5 -4
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2015-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 25 25 * 26 26 **************************************************************************/ 27 27 28 - #include <linux/dmapool.h> 29 - #include <linux/pci.h> 28 + #include "vmwgfx_bo.h" 29 + #include "vmwgfx_drv.h" 30 30 31 31 #include <drm/ttm/ttm_bo.h> 32 32 33 - #include "vmwgfx_drv.h" 33 + #include <linux/dmapool.h> 34 + #include <linux/pci.h> 34 35 35 36 /* 36 37 * Size of inline command buffers. Try to make sure that a page size is a
+6 -5
drivers/gpu/drm/vmwgfx/vmwgfx_context.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 27 27 28 28 #include <drm/ttm/ttm_placement.h> 29 29 30 + #include "vmwgfx_binding.h" 31 + #include "vmwgfx_bo.h" 30 32 #include "vmwgfx_drv.h" 31 33 #include "vmwgfx_resource_priv.h" 32 - #include "vmwgfx_binding.h" 33 34 34 35 struct vmw_user_context { 35 36 struct ttm_base_object base; ··· 39 38 struct vmw_cmdbuf_res_manager *man; 40 39 struct vmw_resource *cotables[SVGA_COTABLE_MAX]; 41 40 spinlock_t cotable_lock; 42 - struct vmw_buffer_object *dx_query_mob; 41 + struct vmw_bo *dx_query_mob; 43 42 }; 44 43 45 44 static void vmw_user_context_free(struct vmw_resource *res); ··· 854 853 * specified in the parameter. 0 otherwise. 855 854 */ 856 855 int vmw_context_bind_dx_query(struct vmw_resource *ctx_res, 857 - struct vmw_buffer_object *mob) 856 + struct vmw_bo *mob) 858 857 { 859 858 struct vmw_user_context *uctx = 860 859 container_of(ctx_res, struct vmw_user_context, res); ··· 886 885 * 887 886 * @ctx_res: The context resource 888 887 */ 889 - struct vmw_buffer_object * 888 + struct vmw_bo * 890 889 vmw_context_get_dx_query_mob(struct vmw_resource *ctx_res) 891 890 { 892 891 struct vmw_user_context *uctx =
+5 -4
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2014-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2014-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 30 30 * whenever the backing MOB is evicted. 31 31 */ 32 32 33 - #include <drm/ttm/ttm_placement.h> 34 - 33 + #include "vmwgfx_bo.h" 35 34 #include "vmwgfx_drv.h" 36 35 #include "vmwgfx_mksstat.h" 37 36 #include "vmwgfx_resource_priv.h" 38 37 #include "vmwgfx_so.h" 38 + 39 + #include <drm/ttm/ttm_placement.h> 39 40 40 41 /** 41 42 * struct vmw_cotable - Context Object Table resource ··· 400 399 struct ttm_operation_ctx ctx = { false, false }; 401 400 struct vmw_private *dev_priv = res->dev_priv; 402 401 struct vmw_cotable *vcotbl = vmw_cotable(res); 403 - struct vmw_buffer_object *buf, *old_buf = res->backup; 402 + struct vmw_bo *buf, *old_buf = res->backup; 404 403 struct ttm_buffer_object *bo, *old_bo = &res->backup->base; 405 404 size_t old_size = res->backup_size; 406 405 size_t old_size_read_back = vcotbl->size_read_back;
+4 -3
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 28 28 29 29 #include "vmwgfx_drv.h" 30 30 31 + #include "vmwgfx_bo.h" 32 + #include "vmwgfx_binding.h" 31 33 #include "vmwgfx_devcaps.h" 32 34 #include "vmwgfx_mksstat.h" 33 - #include "vmwgfx_binding.h" 34 35 #include "ttm_object.h" 35 36 36 37 #include <drm/drm_aperture.h> ··· 387 386 static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv) 388 387 { 389 388 int ret; 390 - struct vmw_buffer_object *vbo; 389 + struct vmw_bo *vbo; 391 390 struct ttm_bo_kmap_obj map; 392 391 volatile SVGA3dQueryResult *result; 393 392 bool dummy;
+20 -164
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 117 117 unsigned long key; 118 118 }; 119 119 120 - /** 121 - * struct vmw_buffer_object - TTM buffer object with vmwgfx additions 122 - * @base: The TTM buffer object 123 - * @res_tree: RB tree of resources using this buffer object as a backing MOB 124 - * @base_mapped_count: ttm BO mapping count; used by KMS atomic helpers. 125 - * @cpu_writers: Number of synccpu write grabs. Protected by reservation when 126 - * increased. May be decreased without reservation. 127 - * @dx_query_ctx: DX context if this buffer object is used as a DX query MOB 128 - * @map: Kmap object for semi-persistent mappings 129 - * @res_prios: Eviction priority counts for attached resources 130 - * @dirty: structure for user-space dirty-tracking 131 - */ 132 - struct vmw_buffer_object { 133 - struct ttm_buffer_object base; 134 - struct rb_root res_tree; 135 - /* For KMS atomic helpers: ttm bo mapping count */ 136 - atomic_t base_mapped_count; 137 - 138 - atomic_t cpu_writers; 139 - /* Not ref-counted. Protected by binding_mutex */ 140 - struct vmw_resource *dx_query_ctx; 141 - /* Protected by reservation */ 142 - struct ttm_bo_kmap_obj map; 143 - u32 res_prios[TTM_MAX_BO_PRIORITY]; 144 - struct vmw_bo_dirty *dirty; 145 - }; 146 120 147 121 /** 148 122 * struct vmw_validate_buffer - Carries validation info about buffers. ··· 164 190 * @hw_destroy: Callback to destroy the resource on the device, as part of 165 191 * resource destruction. 166 192 */ 193 + struct vmw_bo; 167 194 struct vmw_resource_dirty; 168 195 struct vmw_resource { 169 196 struct kref kref; ··· 175 200 u32 res_dirty : 1; 176 201 u32 backup_dirty : 1; 177 202 u32 coherent : 1; 178 - struct vmw_buffer_object *backup; 203 + struct vmw_bo *backup; 179 204 unsigned long backup_offset; 180 205 unsigned long pin_count; 181 206 const struct vmw_res_func *func; ··· 421 446 struct drm_file *filp; 422 447 uint32_t *cmd_bounce; 423 448 uint32_t cmd_bounce_size; 424 - struct vmw_buffer_object *cur_query_bo; 449 + struct vmw_bo *cur_query_bo; 425 450 struct list_head bo_relocations; 426 451 struct list_head res_relocations; 427 452 uint32_t *buf_start; ··· 433 458 struct list_head staged_cmd_res; 434 459 struct list_head ctx_list; 435 460 struct vmw_ctx_validation_info *dx_ctx_node; 436 - struct vmw_buffer_object *dx_query_mob; 461 + struct vmw_bo *dx_query_mob; 437 462 struct vmw_resource *dx_query_ctx; 438 463 struct vmw_cmdbuf_res_manager *man; 439 464 struct vmw_validation_context *ctx; ··· 607 632 * are protected by the cmdbuf mutex. 608 633 */ 609 634 610 - struct vmw_buffer_object *dummy_query_bo; 611 - struct vmw_buffer_object *pinned_bo; 635 + struct vmw_bo *dummy_query_bo; 636 + struct vmw_bo *pinned_bo; 612 637 uint32_t query_cid; 613 638 uint32_t query_cid_valid; 614 639 bool dummy_query_bo_pinned; ··· 651 676 atomic_t mksstat_kern_pids[MKSSTAT_CAPACITY]; 652 677 #endif 653 678 }; 654 - 655 - static inline struct vmw_buffer_object *gem_to_vmw_bo(struct drm_gem_object *gobj) 656 - { 657 - return container_of((gobj), struct vmw_buffer_object, base.base); 658 - } 659 679 660 680 static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res) 661 681 { ··· 795 825 struct drm_file *filp, 796 826 uint32_t handle, 797 827 struct vmw_surface **out_surf, 798 - struct vmw_buffer_object **out_buf); 828 + struct vmw_bo **out_buf); 799 829 extern int vmw_user_resource_lookup_handle( 800 830 struct vmw_private *dev_priv, 801 831 struct ttm_object_file *tfile, ··· 815 845 bool dirty_set, 816 846 bool dirty, 817 847 bool switch_backup, 818 - struct vmw_buffer_object *new_backup, 848 + struct vmw_bo *new_backup, 819 849 unsigned long new_backup_offset); 820 850 extern void vmw_query_move_notify(struct ttm_buffer_object *bo, 821 851 struct ttm_resource *old_mem, 822 852 struct ttm_resource *new_mem); 823 - extern int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob); 824 - extern void vmw_resource_evict_all(struct vmw_private *dev_priv); 825 - extern void vmw_resource_unbind_list(struct vmw_buffer_object *vbo); 853 + int vmw_query_readback_all(struct vmw_bo *dx_query_mob); 854 + void vmw_resource_evict_all(struct vmw_private *dev_priv); 855 + void vmw_resource_unbind_list(struct vmw_bo *vbo); 826 856 void vmw_resource_mob_attach(struct vmw_resource *res); 827 857 void vmw_resource_mob_detach(struct vmw_resource *res); 828 858 void vmw_resource_dirty_update(struct vmw_resource *res, pgoff_t start, 829 859 pgoff_t end); 830 - int vmw_resources_clean(struct vmw_buffer_object *vbo, pgoff_t start, 860 + int vmw_resources_clean(struct vmw_bo *vbo, pgoff_t start, 831 861 pgoff_t end, pgoff_t *num_prefault); 832 862 833 863 /** ··· 842 872 } 843 873 844 874 /** 845 - * Buffer object helper functions - vmwgfx_bo.c 846 - */ 847 - extern int vmw_bo_pin_in_placement(struct vmw_private *vmw_priv, 848 - struct vmw_buffer_object *bo, 849 - struct ttm_placement *placement, 850 - bool interruptible); 851 - extern int vmw_bo_pin_in_vram(struct vmw_private *dev_priv, 852 - struct vmw_buffer_object *buf, 853 - bool interruptible); 854 - extern int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, 855 - struct vmw_buffer_object *buf, 856 - bool interruptible); 857 - extern int vmw_bo_pin_in_start_of_vram(struct vmw_private *vmw_priv, 858 - struct vmw_buffer_object *bo, 859 - bool interruptible); 860 - extern int vmw_bo_unpin(struct vmw_private *vmw_priv, 861 - struct vmw_buffer_object *bo, 862 - bool interruptible); 863 - extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf, 864 - SVGAGuestPtr *ptr); 865 - extern void vmw_bo_pin_reserved(struct vmw_buffer_object *bo, bool pin); 866 - extern int vmw_bo_create_kernel(struct vmw_private *dev_priv, 867 - unsigned long size, 868 - struct ttm_placement *placement, 869 - struct ttm_buffer_object **p_bo); 870 - extern int vmw_bo_create(struct vmw_private *dev_priv, 871 - size_t size, struct ttm_placement *placement, 872 - bool interruptible, bool pin, 873 - struct vmw_buffer_object **p_bo); 874 - extern int vmw_bo_init(struct vmw_private *dev_priv, 875 - struct vmw_buffer_object *vmw_bo, 876 - size_t size, struct ttm_placement *placement, 877 - bool interruptible, bool pin); 878 - extern int vmw_bo_unref_ioctl(struct drm_device *dev, void *data, 879 - struct drm_file *file_priv); 880 - extern int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data, 881 - struct drm_file *file_priv); 882 - extern int vmw_user_bo_lookup(struct drm_file *filp, 883 - uint32_t handle, 884 - struct vmw_buffer_object **out); 885 - extern void vmw_bo_fence_single(struct ttm_buffer_object *bo, 886 - struct vmw_fence_obj *fence); 887 - extern void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo); 888 - extern void vmw_bo_unmap(struct vmw_buffer_object *vbo); 889 - extern void vmw_bo_move_notify(struct ttm_buffer_object *bo, 890 - struct ttm_resource *mem); 891 - extern void vmw_bo_swap_notify(struct ttm_buffer_object *bo); 892 - 893 - /** 894 - * vmw_bo_adjust_prio - Adjust the buffer object eviction priority 895 - * according to attached resources 896 - * @vbo: The struct vmw_buffer_object 897 - */ 898 - static inline void vmw_bo_prio_adjust(struct vmw_buffer_object *vbo) 899 - { 900 - int i = ARRAY_SIZE(vbo->res_prios); 901 - 902 - while (i--) { 903 - if (vbo->res_prios[i]) { 904 - vbo->base.priority = i; 905 - return; 906 - } 907 - } 908 - 909 - vbo->base.priority = 3; 910 - } 911 - 912 - /** 913 - * vmw_bo_prio_add - Notify a buffer object of a newly attached resource 914 - * eviction priority 915 - * @vbo: The struct vmw_buffer_object 916 - * @prio: The resource priority 917 - * 918 - * After being notified, the code assigns the highest resource eviction priority 919 - * to the backing buffer object (mob). 920 - */ 921 - static inline void vmw_bo_prio_add(struct vmw_buffer_object *vbo, int prio) 922 - { 923 - if (vbo->res_prios[prio]++ == 0) 924 - vmw_bo_prio_adjust(vbo); 925 - } 926 - 927 - /** 928 - * vmw_bo_prio_del - Notify a buffer object of a resource with a certain 929 - * priority being removed 930 - * @vbo: The struct vmw_buffer_object 931 - * @prio: The resource priority 932 - * 933 - * After being notified, the code assigns the highest resource eviction priority 934 - * to the backing buffer object (mob). 935 - */ 936 - static inline void vmw_bo_prio_del(struct vmw_buffer_object *vbo, int prio) 937 - { 938 - if (--vbo->res_prios[prio] == 0) 939 - vmw_bo_prio_adjust(vbo); 940 - } 941 - 942 - /** 943 875 * GEM related functionality - vmwgfx_gem.c 944 876 */ 945 877 extern int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, 946 878 struct drm_file *filp, 947 879 uint32_t size, 948 880 uint32_t *handle, 949 - struct vmw_buffer_object **p_vbo); 881 + struct vmw_bo **p_vbo); 950 882 extern int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, 951 883 struct drm_file *filp); 952 884 extern void vmw_debugfs_gem_init(struct vmw_private *vdev); ··· 1159 1287 extern void vmw_dx_context_scrub_cotables(struct vmw_resource *ctx, 1160 1288 bool readback); 1161 1289 extern int vmw_context_bind_dx_query(struct vmw_resource *ctx_res, 1162 - struct vmw_buffer_object *mob); 1163 - extern struct vmw_buffer_object * 1290 + struct vmw_bo *mob); 1291 + extern struct vmw_bo * 1164 1292 vmw_context_get_dx_query_mob(struct vmw_resource *ctx_res); 1165 1293 1166 1294 ··· 1385 1513 DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__) 1386 1514 1387 1515 /* Resource dirtying - vmwgfx_page_dirty.c */ 1388 - void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo); 1389 - int vmw_bo_dirty_add(struct vmw_buffer_object *vbo); 1516 + void vmw_bo_dirty_scan(struct vmw_bo *vbo); 1517 + int vmw_bo_dirty_add(struct vmw_bo *vbo); 1390 1518 void vmw_bo_dirty_transfer_to_res(struct vmw_resource *res); 1391 1519 void vmw_bo_dirty_clear_res(struct vmw_resource *res); 1392 - void vmw_bo_dirty_release(struct vmw_buffer_object *vbo); 1393 - void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, 1520 + void vmw_bo_dirty_release(struct vmw_bo *vbo); 1521 + void vmw_bo_dirty_unmap(struct vmw_bo *vbo, 1394 1522 pgoff_t start, pgoff_t end); 1395 1523 vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf); 1396 1524 vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf); ··· 1421 1549 { 1422 1550 (void) vmw_resource_reference(&srf->res); 1423 1551 return srf; 1424 - } 1425 - 1426 - static inline void vmw_bo_unreference(struct vmw_buffer_object **buf) 1427 - { 1428 - struct vmw_buffer_object *tmp_buf = *buf; 1429 - 1430 - *buf = NULL; 1431 - if (tmp_buf != NULL) 1432 - ttm_bo_put(&tmp_buf->base); 1433 - } 1434 - 1435 - static inline struct vmw_buffer_object * 1436 - vmw_bo_reference(struct vmw_buffer_object *buf) 1437 - { 1438 - ttm_bo_get(&buf->base); 1439 - return buf; 1440 1552 } 1441 1553 1442 1554 static inline void vmw_fifo_resource_inc(struct vmw_private *dev_priv)
+26 -26
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009 - 2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009 - 2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 24 24 * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 25 * 26 26 **************************************************************************/ 27 - #include <linux/sync_file.h> 28 - #include <linux/hashtable.h> 29 - 27 + #include "vmwgfx_binding.h" 28 + #include "vmwgfx_bo.h" 30 29 #include "vmwgfx_drv.h" 31 - #include "vmwgfx_reg.h" 30 + #include "vmwgfx_mksstat.h" 31 + #include "vmwgfx_so.h" 32 + 32 33 #include <drm/ttm/ttm_bo.h> 33 34 #include <drm/ttm/ttm_placement.h> 34 - #include "vmwgfx_so.h" 35 - #include "vmwgfx_binding.h" 36 - #include "vmwgfx_mksstat.h" 37 35 36 + #include <linux/sync_file.h> 37 + #include <linux/hashtable.h> 38 38 39 39 /* 40 40 * Helper macro to get dx_ctx_node if available otherwise print an error ··· 65 65 */ 66 66 struct vmw_relocation { 67 67 struct list_head head; 68 - struct vmw_buffer_object *vbo; 68 + struct vmw_bo *vbo; 69 69 union { 70 70 SVGAMobId *mob_loc; 71 71 SVGAGuestPtr *location; ··· 149 149 static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, 150 150 struct vmw_sw_context *sw_context, 151 151 SVGAMobId *id, 152 - struct vmw_buffer_object **vmw_bo_p); 152 + struct vmw_bo **vmw_bo_p); 153 153 /** 154 154 * vmw_ptr_diff - Compute the offset from a to b in bytes 155 155 * ··· 475 475 476 476 if (has_sm4_context(dev_priv) && 477 477 vmw_res_type(ctx) == vmw_res_dx_context) { 478 - struct vmw_buffer_object *dx_query_mob; 478 + struct vmw_bo *dx_query_mob; 479 479 480 480 dx_query_mob = vmw_context_get_dx_query_mob(ctx); 481 481 if (dx_query_mob) ··· 596 596 return ret; 597 597 598 598 if (sw_context->dx_query_mob) { 599 - struct vmw_buffer_object *expected_dx_query_mob; 599 + struct vmw_bo *expected_dx_query_mob; 600 600 601 601 expected_dx_query_mob = 602 602 vmw_context_get_dx_query_mob(sw_context->dx_query_ctx); ··· 703 703 static int vmw_rebind_all_dx_query(struct vmw_resource *ctx_res) 704 704 { 705 705 struct vmw_private *dev_priv = ctx_res->dev_priv; 706 - struct vmw_buffer_object *dx_query_mob; 706 + struct vmw_bo *dx_query_mob; 707 707 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindAllQuery); 708 708 709 709 dx_query_mob = vmw_context_get_dx_query_mob(ctx_res); ··· 1017 1017 * after successful submission of the current command batch. 1018 1018 */ 1019 1019 static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv, 1020 - struct vmw_buffer_object *new_query_bo, 1020 + struct vmw_bo *new_query_bo, 1021 1021 struct vmw_sw_context *sw_context) 1022 1022 { 1023 1023 struct vmw_res_cache_entry *ctx_entry = ··· 1145 1145 static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, 1146 1146 struct vmw_sw_context *sw_context, 1147 1147 SVGAMobId *id, 1148 - struct vmw_buffer_object **vmw_bo_p) 1148 + struct vmw_bo **vmw_bo_p) 1149 1149 { 1150 - struct vmw_buffer_object *vmw_bo; 1150 + struct vmw_bo *vmw_bo; 1151 1151 uint32_t handle = *id; 1152 1152 struct vmw_relocation *reloc; 1153 1153 int ret; ··· 1199 1199 static int vmw_translate_guest_ptr(struct vmw_private *dev_priv, 1200 1200 struct vmw_sw_context *sw_context, 1201 1201 SVGAGuestPtr *ptr, 1202 - struct vmw_buffer_object **vmw_bo_p) 1202 + struct vmw_bo **vmw_bo_p) 1203 1203 { 1204 - struct vmw_buffer_object *vmw_bo; 1204 + struct vmw_bo *vmw_bo; 1205 1205 uint32_t handle = ptr->gmrId; 1206 1206 struct vmw_relocation *reloc; 1207 1207 int ret; ··· 1278 1278 SVGA3dCmdHeader *header) 1279 1279 { 1280 1280 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindQuery); 1281 - struct vmw_buffer_object *vmw_bo; 1281 + struct vmw_bo *vmw_bo; 1282 1282 int ret; 1283 1283 1284 1284 cmd = container_of(header, typeof(*cmd), header); ··· 1361 1361 struct vmw_sw_context *sw_context, 1362 1362 SVGA3dCmdHeader *header) 1363 1363 { 1364 - struct vmw_buffer_object *vmw_bo; 1364 + struct vmw_bo *vmw_bo; 1365 1365 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndGBQuery); 1366 1366 int ret; 1367 1367 ··· 1391 1391 struct vmw_sw_context *sw_context, 1392 1392 SVGA3dCmdHeader *header) 1393 1393 { 1394 - struct vmw_buffer_object *vmw_bo; 1394 + struct vmw_bo *vmw_bo; 1395 1395 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndQuery); 1396 1396 int ret; 1397 1397 ··· 1437 1437 struct vmw_sw_context *sw_context, 1438 1438 SVGA3dCmdHeader *header) 1439 1439 { 1440 - struct vmw_buffer_object *vmw_bo; 1440 + struct vmw_bo *vmw_bo; 1441 1441 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForGBQuery); 1442 1442 int ret; 1443 1443 ··· 1465 1465 struct vmw_sw_context *sw_context, 1466 1466 SVGA3dCmdHeader *header) 1467 1467 { 1468 - struct vmw_buffer_object *vmw_bo; 1468 + struct vmw_bo *vmw_bo; 1469 1469 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForQuery); 1470 1470 int ret; 1471 1471 ··· 1502 1502 struct vmw_sw_context *sw_context, 1503 1503 SVGA3dCmdHeader *header) 1504 1504 { 1505 - struct vmw_buffer_object *vmw_bo = NULL; 1505 + struct vmw_bo *vmw_bo = NULL; 1506 1506 struct vmw_surface *srf = NULL; 1507 1507 VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSurfaceDMA); 1508 1508 int ret; ··· 1668 1668 struct vmw_sw_context *sw_context, 1669 1669 void *buf) 1670 1670 { 1671 - struct vmw_buffer_object *vmw_bo; 1671 + struct vmw_bo *vmw_bo; 1672 1672 1673 1673 struct { 1674 1674 uint32_t header; ··· 1699 1699 struct vmw_resource *res, uint32_t *buf_id, 1700 1700 unsigned long backup_offset) 1701 1701 { 1702 - struct vmw_buffer_object *vbo; 1702 + struct vmw_bo *vbo; 1703 1703 void *info; 1704 1704 int ret; 1705 1705
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2011-2014 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2011-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the
+7 -20
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /* 3 - * Copyright 2021 VMware, Inc. 3 + * Copyright 2021-2023 VMware, Inc. 4 4 * 5 5 * Permission is hereby granted, free of charge, to any person 6 6 * obtaining a copy of this software and associated documentation ··· 24 24 * 25 25 */ 26 26 27 + #include "vmwgfx_bo.h" 27 28 #include "vmwgfx_drv.h" 28 29 29 30 #include "drm/drm_prime.h" 30 31 #include "drm/drm_gem_ttm_helper.h" 31 - 32 - /** 33 - * vmw_buffer_object - Convert a struct ttm_buffer_object to a struct 34 - * vmw_buffer_object. 35 - * 36 - * @bo: Pointer to the TTM buffer object. 37 - * Return: Pointer to the struct vmw_buffer_object embedding the 38 - * TTM buffer object. 39 - */ 40 - static struct vmw_buffer_object * 41 - vmw_buffer_object(struct ttm_buffer_object *bo) 42 - { 43 - return container_of(bo, struct vmw_buffer_object, base); 44 - } 45 32 46 33 static void vmw_gem_object_free(struct drm_gem_object *gobj) 47 34 { ··· 52 65 static int vmw_gem_pin_private(struct drm_gem_object *obj, bool do_pin) 53 66 { 54 67 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(obj); 55 - struct vmw_buffer_object *vbo = vmw_buffer_object(bo); 68 + struct vmw_bo *vbo = to_vmw_bo(obj); 56 69 int ret; 57 70 58 71 ret = ttm_bo_reserve(bo, false, false, NULL); ··· 116 129 struct drm_file *filp, 117 130 uint32_t size, 118 131 uint32_t *handle, 119 - struct vmw_buffer_object **p_vbo) 132 + struct vmw_bo **p_vbo) 120 133 { 121 134 int ret; 122 135 ··· 146 159 (union drm_vmw_alloc_dmabuf_arg *)data; 147 160 struct drm_vmw_alloc_dmabuf_req *req = &arg->req; 148 161 struct drm_vmw_dmabuf_rep *rep = &arg->rep; 149 - struct vmw_buffer_object *vbo; 162 + struct vmw_bo *vbo; 150 163 uint32_t handle; 151 164 int ret; 152 165 ··· 165 178 166 179 #if defined(CONFIG_DEBUG_FS) 167 180 168 - static void vmw_bo_print_info(int id, struct vmw_buffer_object *bo, struct seq_file *m) 181 + static void vmw_bo_print_info(int id, struct vmw_bo *bo, struct seq_file *m) 169 182 { 170 183 const char *placement; 171 184 const char *type; ··· 246 259 247 260 spin_lock(&file->table_lock); 248 261 idr_for_each_entry(&file->object_idr, gobj, id) { 249 - struct vmw_buffer_object *bo = gem_to_vmw_bo(gobj); 262 + struct vmw_bo *bo = to_vmw_bo(gobj); 250 263 251 264 vmw_bo_print_info(id, bo, m); 252 265 }
+9 -8
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 24 24 * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 25 * 26 26 **************************************************************************/ 27 - 28 27 #include "vmwgfx_kms.h" 28 + 29 + #include "vmwgfx_bo.h" 29 30 #include "vmw_surface_cache.h" 30 31 31 32 #include <drm/drm_atomic.h> ··· 1494 1493 static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb) 1495 1494 { 1496 1495 struct vmw_private *dev_priv = vmw_priv(vfb->base.dev); 1497 - struct vmw_buffer_object *buf; 1496 + struct vmw_bo *buf; 1498 1497 struct ttm_placement *placement; 1499 1498 int ret; 1500 1499 ··· 1539 1538 static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb) 1540 1539 { 1541 1540 struct vmw_private *dev_priv = vmw_priv(vfb->base.dev); 1542 - struct vmw_buffer_object *buf; 1541 + struct vmw_bo *buf; 1543 1542 1544 1543 buf = vfb->bo ? vmw_framebuffer_to_vfbd(&vfb->base)->buffer : 1545 1544 vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.backup; ··· 1567 1566 */ 1568 1567 static int vmw_create_bo_proxy(struct drm_device *dev, 1569 1568 const struct drm_mode_fb_cmd2 *mode_cmd, 1570 - struct vmw_buffer_object *bo_mob, 1569 + struct vmw_bo *bo_mob, 1571 1570 struct vmw_surface **srf_out) 1572 1571 { 1573 1572 struct vmw_surface_metadata metadata = {0}; ··· 1631 1630 1632 1631 1633 1632 static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv, 1634 - struct vmw_buffer_object *bo, 1633 + struct vmw_bo *bo, 1635 1634 struct vmw_framebuffer **out, 1636 1635 const struct drm_mode_fb_cmd2 1637 1636 *mode_cmd) ··· 1719 1718 */ 1720 1719 struct vmw_framebuffer * 1721 1720 vmw_kms_new_framebuffer(struct vmw_private *dev_priv, 1722 - struct vmw_buffer_object *bo, 1721 + struct vmw_bo *bo, 1723 1722 struct vmw_surface *surface, 1724 1723 bool only_2d, 1725 1724 const struct drm_mode_fb_cmd2 *mode_cmd) ··· 1783 1782 struct vmw_private *dev_priv = vmw_priv(dev); 1784 1783 struct vmw_framebuffer *vfb = NULL; 1785 1784 struct vmw_surface *surface = NULL; 1786 - struct vmw_buffer_object *bo = NULL; 1785 + struct vmw_bo *bo = NULL; 1787 1786 int ret; 1788 1787 1789 1788 /* returns either a bo or surface */
+6 -6
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
··· 233 233 struct vmw_framebuffer_surface { 234 234 struct vmw_framebuffer base; 235 235 struct vmw_surface *surface; 236 - struct vmw_buffer_object *buffer; 236 + struct vmw_bo *buffer; 237 237 struct list_head head; 238 238 bool is_bo_proxy; /* true if this is proxy surface for DMA buf */ 239 239 }; ··· 241 241 242 242 struct vmw_framebuffer_bo { 243 243 struct vmw_framebuffer base; 244 - struct vmw_buffer_object *buffer; 244 + struct vmw_bo *buffer; 245 245 }; 246 246 247 247 ··· 293 293 struct vmw_plane_state { 294 294 struct drm_plane_state base; 295 295 struct vmw_surface *surf; 296 - struct vmw_buffer_object *bo; 296 + struct vmw_bo *bo; 297 297 298 298 int content_fb_type; 299 299 unsigned long bo_size; ··· 364 364 struct vmw_cursor_plane cursor; 365 365 366 366 struct vmw_surface *cursor_surface; 367 - struct vmw_buffer_object *cursor_bo; 367 + struct vmw_bo *cursor_bo; 368 368 size_t cursor_age; 369 369 370 370 int cursor_x; ··· 397 397 398 398 struct vmw_validation_ctx { 399 399 struct vmw_resource *res; 400 - struct vmw_buffer_object *buf; 400 + struct vmw_bo *buf; 401 401 }; 402 402 403 403 #define vmw_crtc_to_du(x) \ ··· 458 458 uint32_t num_clips); 459 459 struct vmw_framebuffer * 460 460 vmw_kms_new_framebuffer(struct vmw_private *dev_priv, 461 - struct vmw_buffer_object *bo, 461 + struct vmw_bo *bo, 462 462 struct vmw_surface *surface, 463 463 bool only_2d, 464 464 const struct drm_mode_fb_cmd2 *mode_cmd);
+4 -3
drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2012-2021 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2012-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 25 25 * 26 26 **************************************************************************/ 27 27 28 - #include <linux/highmem.h> 29 - 28 + #include "vmwgfx_bo.h" 30 29 #include "vmwgfx_drv.h" 30 + 31 + #include <linux/highmem.h> 31 32 32 33 #ifdef CONFIG_64BIT 33 34 #define VMW_PPN_SIZE 8
+9 -9
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2014 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 24 24 * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 25 * 26 26 **************************************************************************/ 27 - 28 - #include <drm/ttm/ttm_placement.h> 27 + #include "vmwgfx_bo.h" 28 + #include "vmwgfx_drv.h" 29 29 30 30 #include "device_include/svga_overlay.h" 31 31 #include "device_include/svga_escape.h" 32 32 33 - #include "vmwgfx_drv.h" 33 + #include <drm/ttm/ttm_placement.h> 34 34 35 35 #define VMW_MAX_NUM_STREAMS 1 36 36 #define VMW_OVERLAY_CAP_MASK (SVGA_FIFO_CAP_VIDEO | SVGA_FIFO_CAP_ESCAPE) 37 37 38 38 struct vmw_stream { 39 - struct vmw_buffer_object *buf; 39 + struct vmw_bo *buf; 40 40 bool claimed; 41 41 bool paused; 42 42 struct drm_vmw_control_stream_arg saved; ··· 92 92 * -ERESTARTSYS if interrupted by a signal. 93 93 */ 94 94 static int vmw_overlay_send_put(struct vmw_private *dev_priv, 95 - struct vmw_buffer_object *buf, 95 + struct vmw_bo *buf, 96 96 struct drm_vmw_control_stream_arg *arg, 97 97 bool interruptible) 98 98 { ··· 223 223 * used with GMRs instead of being locked to vram. 224 224 */ 225 225 static int vmw_overlay_move_buffer(struct vmw_private *dev_priv, 226 - struct vmw_buffer_object *buf, 226 + struct vmw_bo *buf, 227 227 bool pin, bool inter) 228 228 { 229 229 if (!pin) ··· 295 295 * -ERESTARTSYS if interrupted. 296 296 */ 297 297 static int vmw_overlay_update_stream(struct vmw_private *dev_priv, 298 - struct vmw_buffer_object *buf, 298 + struct vmw_bo *buf, 299 299 struct drm_vmw_control_stream_arg *arg, 300 300 bool interruptible) 301 301 { ··· 433 433 struct vmw_overlay *overlay = dev_priv->overlay_priv; 434 434 struct drm_vmw_control_stream_arg *arg = 435 435 (struct drm_vmw_control_stream_arg *)data; 436 - struct vmw_buffer_object *buf; 436 + struct vmw_bo *buf; 437 437 struct vmw_resource *res; 438 438 int ret; 439 439
+14 -13
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2019 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2019-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 24 24 * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 25 * 26 26 **************************************************************************/ 27 + #include "vmwgfx_bo.h" 27 28 #include "vmwgfx_drv.h" 28 29 29 30 /* ··· 79 78 * dirty structure with the results. This function may change the 80 79 * dirty-tracking method. 81 80 */ 82 - static void vmw_bo_dirty_scan_pagetable(struct vmw_buffer_object *vbo) 81 + static void vmw_bo_dirty_scan_pagetable(struct vmw_bo *vbo) 83 82 { 84 83 struct vmw_bo_dirty *dirty = vbo->dirty; 85 84 pgoff_t offset = drm_vma_node_start(&vbo->base.base.vma_node); ··· 117 116 * 118 117 * This function may change the dirty-tracking method. 119 118 */ 120 - static void vmw_bo_dirty_scan_mkwrite(struct vmw_buffer_object *vbo) 119 + static void vmw_bo_dirty_scan_mkwrite(struct vmw_bo *vbo) 121 120 { 122 121 struct vmw_bo_dirty *dirty = vbo->dirty; 123 122 unsigned long offset = drm_vma_node_start(&vbo->base.base.vma_node); ··· 161 160 * 162 161 * This function may change the dirty tracking method. 163 162 */ 164 - void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo) 163 + void vmw_bo_dirty_scan(struct vmw_bo *vbo) 165 164 { 166 165 struct vmw_bo_dirty *dirty = vbo->dirty; 167 166 ··· 182 181 * when calling unmap_mapping_range(). This function makes sure we pick 183 182 * up all dirty pages. 184 183 */ 185 - static void vmw_bo_dirty_pre_unmap(struct vmw_buffer_object *vbo, 184 + static void vmw_bo_dirty_pre_unmap(struct vmw_bo *vbo, 186 185 pgoff_t start, pgoff_t end) 187 186 { 188 187 struct vmw_bo_dirty *dirty = vbo->dirty; ··· 207 206 * 208 207 * This is similar to ttm_bo_unmap_virtual() except it takes a subrange. 209 208 */ 210 - void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, 209 + void vmw_bo_dirty_unmap(struct vmw_bo *vbo, 211 210 pgoff_t start, pgoff_t end) 212 211 { 213 212 unsigned long offset = drm_vma_node_start(&vbo->base.base.vma_node); ··· 228 227 * 229 228 * Return: Zero on success, -ENOMEM on memory allocation failure. 230 229 */ 231 - int vmw_bo_dirty_add(struct vmw_buffer_object *vbo) 230 + int vmw_bo_dirty_add(struct vmw_bo *vbo) 232 231 { 233 232 struct vmw_bo_dirty *dirty = vbo->dirty; 234 233 pgoff_t num_pages = PFN_UP(vbo->base.resource->size); ··· 285 284 * 286 285 * Return: Zero on success, -ENOMEM on memory allocation failure. 287 286 */ 288 - void vmw_bo_dirty_release(struct vmw_buffer_object *vbo) 287 + void vmw_bo_dirty_release(struct vmw_bo *vbo) 289 288 { 290 289 struct vmw_bo_dirty *dirty = vbo->dirty; 291 290 ··· 307 306 */ 308 307 void vmw_bo_dirty_transfer_to_res(struct vmw_resource *res) 309 308 { 310 - struct vmw_buffer_object *vbo = res->backup; 309 + struct vmw_bo *vbo = res->backup; 311 310 struct vmw_bo_dirty *dirty = vbo->dirty; 312 311 pgoff_t start, cur, end; 313 312 unsigned long res_start = res->backup_offset; ··· 354 353 { 355 354 unsigned long res_start = res->backup_offset; 356 355 unsigned long res_end = res->backup_offset + res->backup_size; 357 - struct vmw_buffer_object *vbo = res->backup; 356 + struct vmw_bo *vbo = res->backup; 358 357 struct vmw_bo_dirty *dirty = vbo->dirty; 359 358 360 359 res_start >>= PAGE_SHIFT; ··· 381 380 vm_fault_t ret; 382 381 unsigned long page_offset; 383 382 unsigned int save_flags; 384 - struct vmw_buffer_object *vbo = 383 + struct vmw_bo *vbo = 385 384 container_of(bo, typeof(*vbo), base); 386 385 387 386 /* ··· 420 419 struct vm_area_struct *vma = vmf->vma; 421 420 struct ttm_buffer_object *bo = (struct ttm_buffer_object *) 422 421 vma->vm_private_data; 423 - struct vmw_buffer_object *vbo = 424 - container_of(bo, struct vmw_buffer_object, base); 422 + struct vmw_bo *vbo = 423 + container_of(bo, struct vmw_bo, base); 425 424 pgoff_t num_prefault; 426 425 pgprot_t prot; 427 426 vm_fault_t ret;
+15 -14
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 27 27 28 28 #include <drm/ttm/ttm_placement.h> 29 29 30 - #include "vmwgfx_resource_priv.h" 31 30 #include "vmwgfx_binding.h" 31 + #include "vmwgfx_bo.h" 32 32 #include "vmwgfx_drv.h" 33 + #include "vmwgfx_resource_priv.h" 33 34 34 35 #define VMW_RES_EVICT_ERR_COUNT 10 35 36 ··· 40 39 */ 41 40 void vmw_resource_mob_attach(struct vmw_resource *res) 42 41 { 43 - struct vmw_buffer_object *backup = res->backup; 42 + struct vmw_bo *backup = res->backup; 44 43 struct rb_node **new = &backup->res_tree.rb_node, *parent = NULL; 45 44 46 45 dma_resv_assert_held(res->backup->base.base.resv); ··· 68 67 */ 69 68 void vmw_resource_mob_detach(struct vmw_resource *res) 70 69 { 71 - struct vmw_buffer_object *backup = res->backup; 70 + struct vmw_bo *backup = res->backup; 72 71 73 72 dma_resv_assert_held(backup->base.base.resv); 74 73 if (vmw_resource_mob_attached(res)) { ··· 291 290 struct drm_file *filp, 292 291 uint32_t handle, 293 292 struct vmw_surface **out_surf, 294 - struct vmw_buffer_object **out_buf) 293 + struct vmw_bo **out_buf) 295 294 { 296 295 struct ttm_object_file *tfile = vmw_fpriv(filp)->tfile; 297 296 struct vmw_resource *res; ··· 323 322 bool interruptible) 324 323 { 325 324 unsigned long size = PFN_ALIGN(res->backup_size); 326 - struct vmw_buffer_object *backup; 325 + struct vmw_bo *backup; 327 326 int ret; 328 327 329 328 if (likely(res->backup)) { ··· 439 438 bool dirty_set, 440 439 bool dirty, 441 440 bool switch_backup, 442 - struct vmw_buffer_object *new_backup, 441 + struct vmw_bo *new_backup, 443 442 unsigned long new_backup_offset) 444 443 { 445 444 struct vmw_private *dev_priv = res->dev_priv; ··· 740 739 * validation code, since resource validation and eviction 741 740 * both require the backup buffer to be reserved. 742 741 */ 743 - void vmw_resource_unbind_list(struct vmw_buffer_object *vbo) 742 + void vmw_resource_unbind_list(struct vmw_bo *vbo) 744 743 { 745 744 struct ttm_validate_buffer val_buf = { 746 745 .bo = &vbo->base, ··· 773 772 * Read back cached states from the device if they exist. This function 774 773 * assumes binding_mutex is held. 775 774 */ 776 - int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob) 775 + int vmw_query_readback_all(struct vmw_bo *dx_query_mob) 777 776 { 778 777 struct vmw_resource *dx_query_ctx; 779 778 struct vmw_private *dev_priv; ··· 822 821 struct ttm_resource *old_mem, 823 822 struct ttm_resource *new_mem) 824 823 { 825 - struct vmw_buffer_object *dx_query_mob; 824 + struct vmw_bo *dx_query_mob; 826 825 struct ttm_device *bdev = bo->bdev; 827 826 struct vmw_private *dev_priv; 828 827 ··· 835 834 old_mem->mem_type == VMW_PL_MOB) { 836 835 struct vmw_fence_obj *fence; 837 836 838 - dx_query_mob = container_of(bo, struct vmw_buffer_object, base); 837 + dx_query_mob = container_of(bo, struct vmw_bo, base); 839 838 if (!dx_query_mob || !dx_query_mob->dx_query_ctx) { 840 839 mutex_unlock(&dev_priv->binding_mutex); 841 840 return; ··· 959 958 goto out_no_reserve; 960 959 961 960 if (res->pin_count == 0) { 962 - struct vmw_buffer_object *vbo = NULL; 961 + struct vmw_bo *vbo = NULL; 963 962 964 963 if (res->backup) { 965 964 vbo = res->backup; ··· 1017 1016 1018 1017 WARN_ON(res->pin_count == 0); 1019 1018 if (--res->pin_count == 0 && res->backup) { 1020 - struct vmw_buffer_object *vbo = res->backup; 1019 + struct vmw_bo *vbo = res->backup; 1021 1020 1022 1021 (void) ttm_bo_reserve(&vbo->base, false, false, NULL); 1023 1022 vmw_bo_pin_reserved(vbo, false); ··· 1062 1061 * @num_prefault: Returns how many pages including the first have been 1063 1062 * cleaned and are ok to prefault 1064 1063 */ 1065 - int vmw_resources_clean(struct vmw_buffer_object *vbo, pgoff_t start, 1064 + int vmw_resources_clean(struct vmw_bo *vbo, pgoff_t start, 1066 1065 pgoff_t end, pgoff_t *num_prefault) 1067 1066 { 1068 1067 struct rb_node *cur = vbo->res_tree.rb_node;
+8 -7
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2011-2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2011-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 25 25 * 26 26 **************************************************************************/ 27 27 28 + #include "vmwgfx_bo.h" 29 + #include "vmwgfx_kms.h" 30 + 28 31 #include <drm/drm_atomic.h> 29 32 #include <drm/drm_atomic_helper.h> 30 33 #include <drm/drm_damage_helper.h> 31 34 #include <drm/drm_fourcc.h> 32 - 33 - #include "vmwgfx_kms.h" 34 35 35 36 #define vmw_crtc_to_sou(x) \ 36 37 container_of(x, struct vmw_screen_object_unit, base.crtc) ··· 90 89 struct vmw_display_unit base; 91 90 92 91 unsigned long buffer_size; /**< Size of allocated buffer */ 93 - struct vmw_buffer_object *buffer; /**< Backing store buffer */ 92 + struct vmw_bo *buffer; /**< Backing store buffer */ 94 93 95 94 bool defined; 96 95 }; ··· 948 947 static int do_bo_define_gmrfb(struct vmw_private *dev_priv, 949 948 struct vmw_framebuffer *framebuffer) 950 949 { 951 - struct vmw_buffer_object *buf = 950 + struct vmw_bo *buf = 952 951 container_of(framebuffer, struct vmw_framebuffer_bo, 953 952 base)->buffer; 954 953 int depth = framebuffer->base.format->depth; ··· 1217 1216 struct vmw_fence_obj **out_fence, 1218 1217 struct drm_crtc *crtc) 1219 1218 { 1220 - struct vmw_buffer_object *buf = 1219 + struct vmw_bo *buf = 1221 1220 container_of(framebuffer, struct vmw_framebuffer_bo, 1222 1221 base)->buffer; 1223 1222 struct vmw_kms_dirty dirty; ··· 1324 1323 uint32_t num_clips, 1325 1324 struct drm_crtc *crtc) 1326 1325 { 1327 - struct vmw_buffer_object *buf = 1326 + struct vmw_bo *buf = 1328 1327 container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; 1329 1328 struct vmw_kms_dirty dirty; 1330 1329 DECLARE_VAL_CONTEXT(val_ctx, NULL, 0);
+8 -7
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 27 27 28 28 #include <drm/ttm/ttm_placement.h> 29 29 30 + #include "vmwgfx_binding.h" 31 + #include "vmwgfx_bo.h" 30 32 #include "vmwgfx_drv.h" 31 33 #include "vmwgfx_resource_priv.h" 32 - #include "vmwgfx_binding.h" 33 34 34 35 struct vmw_shader { 35 36 struct vmw_resource res; ··· 159 158 SVGA3dShaderType type, 160 159 uint8_t num_input_sig, 161 160 uint8_t num_output_sig, 162 - struct vmw_buffer_object *byte_code, 161 + struct vmw_bo *byte_code, 163 162 void (*res_free) (struct vmw_resource *res)) 164 163 { 165 164 struct vmw_shader *shader = vmw_res_to_shader(res); ··· 681 680 } 682 681 683 682 static int vmw_user_shader_alloc(struct vmw_private *dev_priv, 684 - struct vmw_buffer_object *buffer, 683 + struct vmw_bo *buffer, 685 684 size_t shader_size, 686 685 size_t offset, 687 686 SVGA3dShaderType shader_type, ··· 735 734 736 735 737 736 static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv, 738 - struct vmw_buffer_object *buffer, 737 + struct vmw_bo *buffer, 739 738 size_t shader_size, 740 739 size_t offset, 741 740 SVGA3dShaderType shader_type) ··· 772 771 { 773 772 struct vmw_private *dev_priv = vmw_priv(dev); 774 773 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 775 - struct vmw_buffer_object *buffer = NULL; 774 + struct vmw_bo *buffer = NULL; 776 775 SVGA3dShaderType shader_type; 777 776 int ret; 778 777 ··· 884 883 struct list_head *list) 885 884 { 886 885 struct ttm_operation_ctx ctx = { false, true }; 887 - struct vmw_buffer_object *buf; 886 + struct vmw_bo *buf; 888 887 struct ttm_bo_kmap_obj map; 889 888 bool is_iomem; 890 889 int ret;
+7 -6
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /****************************************************************************** 3 3 * 4 - * COPYRIGHT (C) 2014-2022 VMware, Inc., Palo Alto, CA., USA 4 + * COPYRIGHT (C) 2014-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 25 25 * 26 26 ******************************************************************************/ 27 27 28 + #include "vmwgfx_bo.h" 29 + #include "vmwgfx_kms.h" 30 + #include "vmw_surface_cache.h" 31 + 28 32 #include <drm/drm_atomic.h> 29 33 #include <drm/drm_atomic_helper.h> 30 34 #include <drm/drm_damage_helper.h> 31 35 #include <drm/drm_fourcc.h> 32 - 33 - #include "vmwgfx_kms.h" 34 - #include "vmw_surface_cache.h" 35 36 36 37 #define vmw_crtc_to_stdu(x) \ 37 38 container_of(x, struct vmw_screen_target_display_unit, base.crtc) ··· 71 70 s32 fb_left, fb_top; 72 71 u32 pitch; 73 72 union { 74 - struct vmw_buffer_object *buf; 73 + struct vmw_bo *buf; 75 74 u32 sid; 76 75 }; 77 76 }; ··· 689 688 bool interruptible, 690 689 struct drm_crtc *crtc) 691 690 { 692 - struct vmw_buffer_object *buf = 691 + struct vmw_bo *buf = 693 692 container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; 694 693 struct vmw_stdu_dirty ddirty; 695 694 int ret;
+5 -4
drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright © 2018-2019 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright © 2018-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * All Rights Reserved. 6 6 * 7 7 * Permission is hereby granted, free of charge, to any person obtaining a ··· 26 26 * 27 27 **************************************************************************/ 28 28 29 - #include <drm/ttm/ttm_placement.h> 30 - 29 + #include "vmwgfx_binding.h" 30 + #include "vmwgfx_bo.h" 31 31 #include "vmwgfx_drv.h" 32 32 #include "vmwgfx_resource_priv.h" 33 - #include "vmwgfx_binding.h" 33 + 34 + #include <drm/ttm/ttm_placement.h> 34 35 35 36 /** 36 37 * struct vmw_dx_streamoutput - Streamoutput resource metadata.
+5 -4
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 25 25 * 26 26 **************************************************************************/ 27 27 28 - #include <drm/ttm/ttm_placement.h> 29 - 28 + #include "vmwgfx_bo.h" 30 29 #include "vmwgfx_drv.h" 31 30 #include "vmwgfx_resource_priv.h" 32 31 #include "vmwgfx_so.h" 33 32 #include "vmwgfx_binding.h" 34 33 #include "vmw_surface_cache.h" 35 34 #include "device_include/svga3d_surfacedefs.h" 35 + 36 + #include <drm/ttm/ttm_placement.h> 36 37 37 38 #define SVGA3D_FLAGS_64(upper32, lower32) (((uint64_t)upper32 << 32) | lower32) 38 39 #define SVGA3D_FLAGS_UPPER_32(svga3d_flags) (svga3d_flags >> 32) ··· 1530 1529 } 1531 1530 1532 1531 if (req->base.drm_surface_flags & drm_vmw_surface_flag_coherent) { 1533 - struct vmw_buffer_object *backup = res->backup; 1532 + struct vmw_bo *backup = res->backup; 1534 1533 1535 1534 ttm_bo_reserve(&backup->base, false, false, NULL); 1536 1535 if (!res->func->dirty_alloc)
+2 -1
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 7 * copy of this software and associated documentation files (the ··· 25 25 * 26 26 **************************************************************************/ 27 27 28 + #include "vmwgfx_bo.h" 28 29 #include "vmwgfx_drv.h" 29 30 #include <drm/ttm/ttm_placement.h> 30 31
+16 -14
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright © 2018 - 2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright © 2018 - 2023 VMware, Inc., Palo Alto, CA., USA 5 5 * All Rights Reserved. 6 6 * 7 7 * Permission is hereby granted, free of charge, to any person obtaining a ··· 25 25 * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 26 * 27 27 **************************************************************************/ 28 - #include <linux/slab.h> 29 - #include "vmwgfx_validation.h" 28 + #include "vmwgfx_bo.h" 30 29 #include "vmwgfx_drv.h" 30 + #include "vmwgfx_validation.h" 31 + 32 + #include <linux/slab.h> 31 33 32 34 33 35 #define VMWGFX_VALIDATION_MEM_GRAN (16*PAGE_SIZE) ··· 79 77 struct list_head head; 80 78 struct vmwgfx_hash_item hash; 81 79 struct vmw_resource *res; 82 - struct vmw_buffer_object *new_backup; 80 + struct vmw_bo *new_backup; 83 81 unsigned long new_backup_offset; 84 82 u32 no_buffer_needed : 1; 85 83 u32 switching_backup : 1; ··· 175 173 */ 176 174 static struct vmw_validation_bo_node * 177 175 vmw_validation_find_bo_dup(struct vmw_validation_context *ctx, 178 - struct vmw_buffer_object *vbo) 176 + struct vmw_bo *vbo) 179 177 { 180 178 struct vmw_validation_bo_node *bo_node = NULL; 181 179 ··· 266 264 * Return: Zero on success, negative error code otherwise. 267 265 */ 268 266 int vmw_validation_add_bo(struct vmw_validation_context *ctx, 269 - struct vmw_buffer_object *vbo, 267 + struct vmw_bo *vbo, 270 268 bool as_mob, 271 269 bool cpu_blit) 272 270 { ··· 412 410 */ 413 411 void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx, 414 412 void *val_private, 415 - struct vmw_buffer_object *vbo, 413 + struct vmw_bo *vbo, 416 414 unsigned long backup_offset) 417 415 { 418 416 struct vmw_validation_res_node *val; ··· 453 451 454 452 val->reserved = 1; 455 453 if (res->backup) { 456 - struct vmw_buffer_object *vbo = res->backup; 454 + struct vmw_bo *vbo = res->backup; 457 455 458 456 ret = vmw_validation_add_bo 459 457 (ctx, vbo, vmw_resource_needs_backup(res), ··· 528 526 bool interruptible, 529 527 bool validate_as_mob) 530 528 { 531 - struct vmw_buffer_object *vbo = 532 - container_of(bo, struct vmw_buffer_object, base); 529 + struct vmw_bo *vbo = 530 + container_of(bo, struct vmw_bo, base); 533 531 struct ttm_operation_ctx ctx = { 534 532 .interruptible = interruptible, 535 533 .no_wait_gpu = false ··· 580 578 int ret; 581 579 582 580 list_for_each_entry(entry, &ctx->bo_list, base.head) { 583 - struct vmw_buffer_object *vbo = 581 + struct vmw_bo *vbo = 584 582 container_of(entry->base.bo, typeof(*vbo), base); 585 583 586 584 if (entry->cpu_blit) { ··· 641 639 642 640 list_for_each_entry(val, &ctx->resource_list, head) { 643 641 struct vmw_resource *res = val->res; 644 - struct vmw_buffer_object *backup = res->backup; 642 + struct vmw_bo *backup = res->backup; 645 643 646 644 ret = vmw_resource_validate(res, intr, val->dirty_set && 647 645 val->dirty); ··· 653 651 654 652 /* Check if the resource switched backup buffer */ 655 653 if (backup && res->backup && (backup != res->backup)) { 656 - struct vmw_buffer_object *vbo = res->backup; 654 + struct vmw_bo *vbo = res->backup; 657 655 658 656 ret = vmw_validation_add_bo 659 657 (ctx, vbo, vmw_resource_needs_backup(res), ··· 891 889 list_for_each_entry(entry, &ctx->bo_list, base.head) { 892 890 if (entry->coherent_count) { 893 891 unsigned int coherent_count = entry->coherent_count; 894 - struct vmw_buffer_object *vbo = 892 + struct vmw_bo *vbo = 895 893 container_of(entry->base.bo, typeof(*vbo), 896 894 base); 897 895
+3 -3
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h
··· 73 73 size_t total_mem; 74 74 }; 75 75 76 - struct vmw_buffer_object; 76 + struct vmw_bo; 77 77 struct vmw_resource; 78 78 struct vmw_fence_obj; 79 79 ··· 159 159 } 160 160 161 161 int vmw_validation_add_bo(struct vmw_validation_context *ctx, 162 - struct vmw_buffer_object *vbo, 162 + struct vmw_bo *vbo, 163 163 bool as_mob, bool cpu_blit); 164 164 int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, 165 165 bool interruptible, ··· 179 179 bool backoff); 180 180 void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx, 181 181 void *val_private, 182 - struct vmw_buffer_object *vbo, 182 + struct vmw_bo *vbo, 183 183 unsigned long backup_offset); 184 184 int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr); 185 185