Commit 09881d29 authored by Zack Rusin's avatar Zack Rusin

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: default avatarZack Rusin <zackr@vmware.com>
Reviewed-by: default avatarMartin Krastev <krastevm@vmware.com>
Reviewed-by: default avatarMaaz Mombasawala <mombasawalam@vmware.com>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230131033542.953249-4-zack@kde.org
parent 6b2e8aa4
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright © 2011-2018 VMware, Inc., Palo Alto, CA., USA * Copyright © 2011-2023 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
...@@ -26,55 +26,41 @@ ...@@ -26,55 +26,41 @@
* *
**************************************************************************/ **************************************************************************/
#include <drm/ttm/ttm_placement.h> #include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "ttm_object.h"
/** #include <drm/ttm/ttm_placement.h>
* vmw_buffer_object - Convert a struct ttm_buffer_object to a struct
* vmw_buffer_object.
*
* @bo: Pointer to the TTM buffer object.
* Return: Pointer to the struct vmw_buffer_object embedding the
* TTM buffer object.
*/
static struct vmw_buffer_object *
vmw_buffer_object(struct ttm_buffer_object *bo)
{
return container_of(bo, struct vmw_buffer_object, base);
}
/** /**
* vmw_bo_bo_free - vmw buffer object destructor * vmw_bo_free - vmw_bo destructor
* *
* @bo: Pointer to the embedded struct ttm_buffer_object * @bo: Pointer to the embedded struct ttm_buffer_object
*/ */
static void vmw_bo_bo_free(struct ttm_buffer_object *bo) static void vmw_bo_free(struct ttm_buffer_object *bo)
{ {
struct vmw_buffer_object *vmw_bo = vmw_buffer_object(bo); struct vmw_bo *vbo = to_vmw_bo(&bo->base);
WARN_ON(vmw_bo->dirty); WARN_ON(vbo->dirty);
WARN_ON(!RB_EMPTY_ROOT(&vmw_bo->res_tree)); WARN_ON(!RB_EMPTY_ROOT(&vbo->res_tree));
vmw_bo_unmap(vmw_bo); vmw_bo_unmap(vbo);
drm_gem_object_release(&bo->base); drm_gem_object_release(&bo->base);
kfree(vmw_bo); kfree(vbo);
} }
/** /**
* bo_is_vmw - check if the buffer object is a &vmw_buffer_object * bo_is_vmw - check if the buffer object is a &vmw_bo
* @bo: ttm buffer object to be checked * @bo: ttm buffer object to be checked
* *
* Uses destroy function associated with the object to determine if this is * Uses destroy function associated with the object to determine if this is
* a &vmw_buffer_object. * a &vmw_bo.
* *
* Returns: * Returns:
* true if the object is of &vmw_buffer_object type, false if not. * true if the object is of &vmw_bo type, false if not.
*/ */
static bool bo_is_vmw(struct ttm_buffer_object *bo) static bool bo_is_vmw(struct ttm_buffer_object *bo)
{ {
return bo->destroy == &vmw_bo_bo_free; return bo->destroy == &vmw_bo_free;
} }
/** /**
...@@ -88,7 +74,7 @@ static bool bo_is_vmw(struct ttm_buffer_object *bo) ...@@ -88,7 +74,7 @@ static bool bo_is_vmw(struct ttm_buffer_object *bo)
* -ERESTARTSYS if interrupted by a signal * -ERESTARTSYS if interrupted by a signal
*/ */
int vmw_bo_pin_in_placement(struct vmw_private *dev_priv, int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
struct ttm_placement *placement, struct ttm_placement *placement,
bool interruptible) bool interruptible)
{ {
...@@ -125,7 +111,7 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv, ...@@ -125,7 +111,7 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,
* -ERESTARTSYS if interrupted by a signal * -ERESTARTSYS if interrupted by a signal
*/ */
int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
bool interruptible) bool interruptible)
{ {
struct ttm_operation_ctx ctx = {interruptible, false }; struct ttm_operation_ctx ctx = {interruptible, false };
...@@ -167,7 +153,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, ...@@ -167,7 +153,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
* -ERESTARTSYS if interrupted by a signal * -ERESTARTSYS if interrupted by a signal
*/ */
int vmw_bo_pin_in_vram(struct vmw_private *dev_priv, int vmw_bo_pin_in_vram(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
bool interruptible) bool interruptible)
{ {
return vmw_bo_pin_in_placement(dev_priv, buf, &vmw_vram_placement, return vmw_bo_pin_in_placement(dev_priv, buf, &vmw_vram_placement,
...@@ -188,7 +174,7 @@ int vmw_bo_pin_in_vram(struct vmw_private *dev_priv, ...@@ -188,7 +174,7 @@ int vmw_bo_pin_in_vram(struct vmw_private *dev_priv,
* -ERESTARTSYS if interrupted by a signal * -ERESTARTSYS if interrupted by a signal
*/ */
int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
bool interruptible) bool interruptible)
{ {
struct ttm_operation_ctx ctx = {interruptible, false }; struct ttm_operation_ctx ctx = {interruptible, false };
...@@ -248,7 +234,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, ...@@ -248,7 +234,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,
* -ERESTARTSYS if interrupted by a signal * -ERESTARTSYS if interrupted by a signal
*/ */
int vmw_bo_unpin(struct vmw_private *dev_priv, int vmw_bo_unpin(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
bool interruptible) bool interruptible)
{ {
struct ttm_buffer_object *bo = &buf->base; struct ttm_buffer_object *bo = &buf->base;
...@@ -293,7 +279,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo, ...@@ -293,7 +279,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,
* @pin: Whether to pin or unpin. * @pin: Whether to pin or unpin.
* *
*/ */
void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin) void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin)
{ {
struct ttm_operation_ctx ctx = { false, true }; struct ttm_operation_ctx ctx = { false, true };
struct ttm_place pl; struct ttm_place pl;
...@@ -341,7 +327,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin) ...@@ -341,7 +327,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin)
* 3) Buffer object destruction * 3) Buffer object destruction
* *
*/ */
void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo) void *vmw_bo_map_and_cache(struct vmw_bo *vbo)
{ {
struct ttm_buffer_object *bo = &vbo->base; struct ttm_buffer_object *bo = &vbo->base;
bool not_used; bool not_used;
...@@ -366,9 +352,9 @@ void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo) ...@@ -366,9 +352,9 @@ void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo)
* @vbo: The buffer object whose map we are tearing down. * @vbo: The buffer object whose map we are tearing down.
* *
* This function tears down a cached map set up using * This function tears down a cached map set up using
* vmw_buffer_object_map_and_cache(). * vmw_bo_map_and_cache().
*/ */
void vmw_bo_unmap(struct vmw_buffer_object *vbo) void vmw_bo_unmap(struct vmw_bo *vbo)
{ {
if (vbo->map.bo == NULL) if (vbo->map.bo == NULL)
return; return;
...@@ -432,7 +418,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, ...@@ -432,7 +418,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,
int vmw_bo_create(struct vmw_private *vmw, int vmw_bo_create(struct vmw_private *vmw,
size_t size, struct ttm_placement *placement, size_t size, struct ttm_placement *placement,
bool interruptible, bool pin, bool interruptible, bool pin,
struct vmw_buffer_object **p_bo) struct vmw_bo **p_bo)
{ {
int ret; int ret;
...@@ -458,7 +444,7 @@ int vmw_bo_create(struct vmw_private *vmw, ...@@ -458,7 +444,7 @@ int vmw_bo_create(struct vmw_private *vmw,
* vmw_bo_init - Initialize a vmw buffer object * vmw_bo_init - Initialize a vmw buffer object
* *
* @dev_priv: Pointer to the device private struct * @dev_priv: Pointer to the device private struct
* @vmw_bo: Pointer to the struct vmw_buffer_object to initialize. * @vmw_bo: Pointer to the struct vmw_bo to initialize.
* @size: Buffer object size in bytes. * @size: Buffer object size in bytes.
* @placement: Initial placement. * @placement: Initial placement.
* @interruptible: Whether waits should be performed interruptible. * @interruptible: Whether waits should be performed interruptible.
...@@ -468,7 +454,7 @@ int vmw_bo_create(struct vmw_private *vmw, ...@@ -468,7 +454,7 @@ int vmw_bo_create(struct vmw_private *vmw,
* Note that on error, the code will free the buffer object. * Note that on error, the code will free the buffer object.
*/ */
int vmw_bo_init(struct vmw_private *dev_priv, int vmw_bo_init(struct vmw_private *dev_priv,
struct vmw_buffer_object *vmw_bo, struct vmw_bo *vmw_bo,
size_t size, struct ttm_placement *placement, size_t size, struct ttm_placement *placement,
bool interruptible, bool pin) bool interruptible, bool pin)
{ {
...@@ -489,7 +475,7 @@ int vmw_bo_init(struct vmw_private *dev_priv, ...@@ -489,7 +475,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,
drm_gem_private_object_init(vdev, &vmw_bo->base.base, size); drm_gem_private_object_init(vdev, &vmw_bo->base.base, size);
ret = ttm_bo_init_reserved(bdev, &vmw_bo->base, ttm_bo_type_device, ret = ttm_bo_init_reserved(bdev, &vmw_bo->base, ttm_bo_type_device,
placement, 0, &ctx, NULL, NULL, vmw_bo_bo_free); placement, 0, &ctx, NULL, NULL, vmw_bo_free);
if (unlikely(ret)) { if (unlikely(ret)) {
return ret; return ret;
} }
...@@ -502,7 +488,7 @@ int vmw_bo_init(struct vmw_private *dev_priv, ...@@ -502,7 +488,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,
} }
/** /**
* vmw_user_bo_synccpu_grab - Grab a struct vmw_buffer_object for cpu * vmw_user_bo_synccpu_grab - Grab a struct vmw_bo for cpu
* access, idling previous GPU operations on the buffer and optionally * access, idling previous GPU operations on the buffer and optionally
* blocking it for further command submissions. * blocking it for further command submissions.
* *
...@@ -515,7 +501,7 @@ int vmw_bo_init(struct vmw_private *dev_priv, ...@@ -515,7 +501,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,
* *
* A blocking grab will be automatically released when @tfile is closed. * A blocking grab will be automatically released when @tfile is closed.
*/ */
static int vmw_user_bo_synccpu_grab(struct vmw_buffer_object *vmw_bo, static int vmw_user_bo_synccpu_grab(struct vmw_bo *vmw_bo,
uint32_t flags) uint32_t flags)
{ {
bool nonblock = !!(flags & drm_vmw_synccpu_dontblock); bool nonblock = !!(flags & drm_vmw_synccpu_dontblock);
...@@ -562,7 +548,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp, ...@@ -562,7 +548,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,
uint32_t handle, uint32_t handle,
uint32_t flags) uint32_t flags)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
int ret = vmw_user_bo_lookup(filp, handle, &vmw_bo); int ret = vmw_user_bo_lookup(filp, handle, &vmw_bo);
if (!ret) { if (!ret) {
...@@ -593,7 +579,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data, ...@@ -593,7 +579,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
{ {
struct drm_vmw_synccpu_arg *arg = struct drm_vmw_synccpu_arg *arg =
(struct drm_vmw_synccpu_arg *) data; (struct drm_vmw_synccpu_arg *) data;
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
int ret; int ret;
if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0 if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0
...@@ -666,14 +652,14 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data, ...@@ -666,14 +652,14 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,
* @filp: The file the handle is registered with. * @filp: The file the handle is registered with.
* @handle: The user buffer object handle * @handle: The user buffer object handle
* @out: Pointer to a where a pointer to the embedded * @out: Pointer to a where a pointer to the embedded
* struct vmw_buffer_object should be placed. * struct vmw_bo should be placed.
* Return: Zero on success, Negative error code on error. * Return: Zero on success, Negative error code on error.
* *
* The vmw buffer object pointer will be refcounted. * The vmw buffer object pointer will be refcounted.
*/ */
int vmw_user_bo_lookup(struct drm_file *filp, int vmw_user_bo_lookup(struct drm_file *filp,
uint32_t handle, uint32_t handle,
struct vmw_buffer_object **out) struct vmw_bo **out)
{ {
struct drm_gem_object *gobj; struct drm_gem_object *gobj;
...@@ -684,7 +670,7 @@ int vmw_user_bo_lookup(struct drm_file *filp, ...@@ -684,7 +670,7 @@ int vmw_user_bo_lookup(struct drm_file *filp,
return -ESRCH; return -ESRCH;
} }
*out = gem_to_vmw_bo(gobj); *out = to_vmw_bo(gobj);
ttm_bo_get(&(*out)->base); ttm_bo_get(&(*out)->base);
drm_gem_object_put(gobj); drm_gem_object_put(gobj);
...@@ -744,7 +730,7 @@ int vmw_dumb_create(struct drm_file *file_priv, ...@@ -744,7 +730,7 @@ int vmw_dumb_create(struct drm_file *file_priv,
struct drm_mode_create_dumb *args) struct drm_mode_create_dumb *args)
{ {
struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_private *dev_priv = vmw_priv(dev);
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
int cpp = DIV_ROUND_UP(args->bpp, 8); int cpp = DIV_ROUND_UP(args->bpp, 8);
int ret; int ret;
...@@ -778,12 +764,12 @@ int vmw_dumb_create(struct drm_file *file_priv, ...@@ -778,12 +764,12 @@ int vmw_dumb_create(struct drm_file *file_priv,
*/ */
void vmw_bo_swap_notify(struct ttm_buffer_object *bo) void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
{ {
/* Is @bo embedded in a struct vmw_buffer_object? */ /* Is @bo embedded in a struct vmw_bo? */
if (!bo_is_vmw(bo)) if (!bo_is_vmw(bo))
return; return;
/* Kill any cached kernel maps before swapout */ /* Kill any cached kernel maps before swapout */
vmw_bo_unmap(vmw_buffer_object(bo)); vmw_bo_unmap(to_vmw_bo(&bo->base));
} }
...@@ -800,13 +786,13 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo) ...@@ -800,13 +786,13 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
void vmw_bo_move_notify(struct ttm_buffer_object *bo, void vmw_bo_move_notify(struct ttm_buffer_object *bo,
struct ttm_resource *mem) struct ttm_resource *mem)
{ {
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
/* Make sure @bo is embedded in a struct vmw_buffer_object? */ /* Make sure @bo is embedded in a struct vmw_bo? */
if (!bo_is_vmw(bo)) if (!bo_is_vmw(bo))
return; return;
vbo = container_of(bo, struct vmw_buffer_object, base); vbo = container_of(bo, struct vmw_bo, base);
/* /*
* Kill any cached kernel maps before move to or from VRAM. * Kill any cached kernel maps before move to or from VRAM.
......
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/**************************************************************************
*
* Copyright 2023 VMware, Inc., Palo Alto, CA., USA
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef VMWGFX_BO_H
#define VMWGFX_BO_H
#include "device_include/svga_reg.h"
#include <drm/ttm/ttm_bo.h>
#include <linux/rbtree_types.h>
#include <linux/types.h>
struct vmw_bo_dirty;
struct vmw_fence_obj;
struct vmw_private;
struct vmw_resource;
/**
* struct vmw_bo - TTM buffer object with vmwgfx additions
* @base: The TTM buffer object
* @res_tree: RB tree of resources using this buffer object as a backing MOB
* @base_mapped_count: ttm BO mapping count; used by KMS atomic helpers.
* @cpu_writers: Number of synccpu write grabs. Protected by reservation when
* increased. May be decreased without reservation.
* @dx_query_ctx: DX context if this buffer object is used as a DX query MOB
* @map: Kmap object for semi-persistent mappings
* @res_prios: Eviction priority counts for attached resources
* @dirty: structure for user-space dirty-tracking
*/
struct vmw_bo {
struct ttm_buffer_object base;
struct rb_root res_tree;
/* For KMS atomic helpers: ttm bo mapping count */
atomic_t base_mapped_count;
atomic_t cpu_writers;
/* Not ref-counted. Protected by binding_mutex */
struct vmw_resource *dx_query_ctx;
/* Protected by reservation */
struct ttm_bo_kmap_obj map;
u32 res_prios[TTM_MAX_BO_PRIORITY];
struct vmw_bo_dirty *dirty;
};
int vmw_bo_create_kernel(struct vmw_private *dev_priv,
unsigned long size,
struct ttm_placement *placement,
struct ttm_buffer_object **p_bo);
int vmw_bo_create(struct vmw_private *dev_priv,
size_t size, struct ttm_placement *placement,
bool interruptible, bool pin,
struct vmw_bo **p_bo);
int vmw_bo_init(struct vmw_private *dev_priv,
struct vmw_bo *vmw_bo,
size_t size, struct ttm_placement *placement,
bool interruptible, bool pin);
int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int vmw_bo_pin_in_placement(struct vmw_private *vmw_priv,
struct vmw_bo *bo,
struct ttm_placement *placement,
bool interruptible);
int vmw_bo_pin_in_vram(struct vmw_private *dev_priv,
struct vmw_bo *buf,
bool interruptible);
int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
struct vmw_bo *buf,
bool interruptible);
int vmw_bo_pin_in_start_of_vram(struct vmw_private *vmw_priv,
struct vmw_bo *bo,
bool interruptible);
void vmw_bo_pin_reserved(struct vmw_bo *bo, bool pin);
int vmw_bo_unpin(struct vmw_private *vmw_priv,
struct vmw_bo *bo,
bool interruptible);
void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf,
SVGAGuestPtr *ptr);
int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int vmw_user_bo_lookup(struct drm_file *filp,
uint32_t handle,
struct vmw_bo **out);
void vmw_bo_fence_single(struct ttm_buffer_object *bo,
struct vmw_fence_obj *fence);
void *vmw_bo_map_and_cache(struct vmw_bo *vbo);
void vmw_bo_unmap(struct vmw_bo *vbo);
void vmw_bo_move_notify(struct ttm_buffer_object *bo,
struct ttm_resource *mem);
void vmw_bo_swap_notify(struct ttm_buffer_object *bo);
/**
* vmw_bo_adjust_prio - Adjust the buffer object eviction priority
* according to attached resources
* @vbo: The struct vmw_bo
*/
static inline void vmw_bo_prio_adjust(struct vmw_bo *vbo)
{
int i = ARRAY_SIZE(vbo->res_prios);
while (i--) {
if (vbo->res_prios[i]) {
vbo->base.priority = i;
return;
}
}
vbo->base.priority = 3;
}
/**
* vmw_bo_prio_add - Notify a buffer object of a newly attached resource
* eviction priority
* @vbo: The struct vmw_bo
* @prio: The resource priority
*
* After being notified, the code assigns the highest resource eviction priority
* to the backing buffer object (mob).
*/
static inline void vmw_bo_prio_add(struct vmw_bo *vbo, int prio)
{
if (vbo->res_prios[prio]++ == 0)
vmw_bo_prio_adjust(vbo);
}
/**
* vmw_bo_prio_del - Notify a buffer object of a resource with a certain
* priority being removed
* @vbo: The struct vmw_bo
* @prio: The resource priority
*
* After being notified, the code assigns the highest resource eviction priority
* to the backing buffer object (mob).
*/
static inline void vmw_bo_prio_del(struct vmw_bo *vbo, int prio)
{
if (--vbo->res_prios[prio] == 0)
vmw_bo_prio_adjust(vbo);
}
static inline void vmw_bo_unreference(struct vmw_bo **buf)
{
struct vmw_bo *tmp_buf = *buf;
*buf = NULL;
if (tmp_buf)
ttm_bo_put(&tmp_buf->base);
}
static inline struct vmw_bo *vmw_bo_reference(struct vmw_bo *buf)
{
ttm_bo_get(&buf->base);
return buf;
}
static inline struct vmw_bo *to_vmw_bo(struct drm_gem_object *gobj)
{
return container_of((gobj), struct vmw_bo, base.base);
}
#endif // VMWGFX_BO_H
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2020 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include "vmwgfx_bo.h"
#include <linux/sched/signal.h> #include "vmwgfx_drv.h"
#include "vmwgfx_devcaps.h"
#include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_placement.h>
#include "vmwgfx_drv.h" #include <linux/sched/signal.h>
#include "vmwgfx_devcaps.h"
bool vmw_supports_3d(struct vmw_private *dev_priv) bool vmw_supports_3d(struct vmw_private *dev_priv)
{ {
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2015-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -25,12 +25,13 @@ ...@@ -25,12 +25,13 @@
* *
**************************************************************************/ **************************************************************************/
#include <linux/dmapool.h> #include "vmwgfx_bo.h"
#include <linux/pci.h> #include "vmwgfx_drv.h"
#include <drm/ttm/ttm_bo.h> #include <drm/ttm/ttm_bo.h>
#include "vmwgfx_drv.h" #include <linux/dmapool.h>
#include <linux/pci.h>
/* /*
* Size of inline command buffers. Try to make sure that a page size is a * Size of inline command buffers. Try to make sure that a page size is a
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
#include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_placement.h>
#include "vmwgfx_binding.h"
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_resource_priv.h" #include "vmwgfx_resource_priv.h"
#include "vmwgfx_binding.h"
struct vmw_user_context { struct vmw_user_context {
struct ttm_base_object base; struct ttm_base_object base;
...@@ -38,7 +39,7 @@ struct vmw_user_context { ...@@ -38,7 +39,7 @@ struct vmw_user_context {
struct vmw_cmdbuf_res_manager *man; struct vmw_cmdbuf_res_manager *man;
struct vmw_resource *cotables[SVGA_COTABLE_MAX]; struct vmw_resource *cotables[SVGA_COTABLE_MAX];
spinlock_t cotable_lock; spinlock_t cotable_lock;
struct vmw_buffer_object *dx_query_mob; struct vmw_bo *dx_query_mob;
}; };
static void vmw_user_context_free(struct vmw_resource *res); static void vmw_user_context_free(struct vmw_resource *res);
...@@ -853,7 +854,7 @@ vmw_context_binding_state(struct vmw_resource *ctx) ...@@ -853,7 +854,7 @@ vmw_context_binding_state(struct vmw_resource *ctx)
* specified in the parameter. 0 otherwise. * specified in the parameter. 0 otherwise.
*/ */
int vmw_context_bind_dx_query(struct vmw_resource *ctx_res, int vmw_context_bind_dx_query(struct vmw_resource *ctx_res,
struct vmw_buffer_object *mob) struct vmw_bo *mob)
{ {
struct vmw_user_context *uctx = struct vmw_user_context *uctx =
container_of(ctx_res, struct vmw_user_context, res); container_of(ctx_res, struct vmw_user_context, res);
...@@ -885,7 +886,7 @@ int vmw_context_bind_dx_query(struct vmw_resource *ctx_res, ...@@ -885,7 +886,7 @@ int vmw_context_bind_dx_query(struct vmw_resource *ctx_res,
* *
* @ctx_res: The context resource * @ctx_res: The context resource
*/ */
struct vmw_buffer_object * struct vmw_bo *
vmw_context_get_dx_query_mob(struct vmw_resource *ctx_res) vmw_context_get_dx_query_mob(struct vmw_resource *ctx_res)
{ {
struct vmw_user_context *uctx = struct vmw_user_context *uctx =
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2014-2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2014-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
* whenever the backing MOB is evicted. * whenever the backing MOB is evicted.
*/ */
#include <drm/ttm/ttm_placement.h> #include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_mksstat.h" #include "vmwgfx_mksstat.h"
#include "vmwgfx_resource_priv.h" #include "vmwgfx_resource_priv.h"
#include "vmwgfx_so.h" #include "vmwgfx_so.h"
#include <drm/ttm/ttm_placement.h>
/** /**
* struct vmw_cotable - Context Object Table resource * struct vmw_cotable - Context Object Table resource
* *
...@@ -399,7 +400,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) ...@@ -399,7 +400,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)
struct ttm_operation_ctx ctx = { false, false }; struct ttm_operation_ctx ctx = { false, false };
struct vmw_private *dev_priv = res->dev_priv; struct vmw_private *dev_priv = res->dev_priv;
struct vmw_cotable *vcotbl = vmw_cotable(res); struct vmw_cotable *vcotbl = vmw_cotable(res);
struct vmw_buffer_object *buf, *old_buf = res->backup; struct vmw_bo *buf, *old_buf = res->backup;
struct ttm_buffer_object *bo, *old_bo = &res->backup->base; struct ttm_buffer_object *bo, *old_bo = &res->backup->base;
size_t old_size = res->backup_size; size_t old_size = res->backup_size;
size_t old_size_read_back = vcotbl->size_read_back; size_t old_size_read_back = vcotbl->size_read_back;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2022 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_bo.h"
#include "vmwgfx_binding.h"
#include "vmwgfx_devcaps.h" #include "vmwgfx_devcaps.h"
#include "vmwgfx_mksstat.h" #include "vmwgfx_mksstat.h"
#include "vmwgfx_binding.h"
#include "ttm_object.h" #include "ttm_object.h"
#include <drm/drm_aperture.h> #include <drm/drm_aperture.h>
...@@ -386,7 +387,7 @@ static void vmw_print_sm_type(struct vmw_private *dev_priv) ...@@ -386,7 +387,7 @@ static void vmw_print_sm_type(struct vmw_private *dev_priv)
static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv) static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)
{ {
int ret; int ret;
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
struct ttm_bo_kmap_obj map; struct ttm_bo_kmap_obj map;
volatile SVGA3dQueryResult *result; volatile SVGA3dQueryResult *result;
bool dummy; bool dummy;
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009 - 2022 VMware, Inc., Palo Alto, CA., USA * Copyright 2009 - 2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -24,17 +24,17 @@ ...@@ -24,17 +24,17 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include <linux/sync_file.h> #include "vmwgfx_binding.h"
#include <linux/hashtable.h> #include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_reg.h" #include "vmwgfx_mksstat.h"
#include "vmwgfx_so.h"
#include <drm/ttm/ttm_bo.h> #include <drm/ttm/ttm_bo.h>
#include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_placement.h>
#include "vmwgfx_so.h"
#include "vmwgfx_binding.h"
#include "vmwgfx_mksstat.h"
#include <linux/sync_file.h>
#include <linux/hashtable.h>
/* /*
* Helper macro to get dx_ctx_node if available otherwise print an error * Helper macro to get dx_ctx_node if available otherwise print an error
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
*/ */
struct vmw_relocation { struct vmw_relocation {
struct list_head head; struct list_head head;
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
union { union {
SVGAMobId *mob_loc; SVGAMobId *mob_loc;
SVGAGuestPtr *location; SVGAGuestPtr *location;
...@@ -149,7 +149,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv, ...@@ -149,7 +149,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,
static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGAMobId *id, SVGAMobId *id,
struct vmw_buffer_object **vmw_bo_p); struct vmw_bo **vmw_bo_p);
/** /**
* vmw_ptr_diff - Compute the offset from a to b in bytes * vmw_ptr_diff - Compute the offset from a to b in bytes
* *
...@@ -475,7 +475,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv, ...@@ -475,7 +475,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,
if (has_sm4_context(dev_priv) && if (has_sm4_context(dev_priv) &&
vmw_res_type(ctx) == vmw_res_dx_context) { vmw_res_type(ctx) == vmw_res_dx_context) {
struct vmw_buffer_object *dx_query_mob; struct vmw_bo *dx_query_mob;
dx_query_mob = vmw_context_get_dx_query_mob(ctx); dx_query_mob = vmw_context_get_dx_query_mob(ctx);
if (dx_query_mob) if (dx_query_mob)
...@@ -596,7 +596,7 @@ static int vmw_resources_reserve(struct vmw_sw_context *sw_context) ...@@ -596,7 +596,7 @@ static int vmw_resources_reserve(struct vmw_sw_context *sw_context)
return ret; return ret;
if (sw_context->dx_query_mob) { if (sw_context->dx_query_mob) {
struct vmw_buffer_object *expected_dx_query_mob; struct vmw_bo *expected_dx_query_mob;
expected_dx_query_mob = expected_dx_query_mob =
vmw_context_get_dx_query_mob(sw_context->dx_query_ctx); vmw_context_get_dx_query_mob(sw_context->dx_query_ctx);
...@@ -703,7 +703,7 @@ vmw_cmd_res_check(struct vmw_private *dev_priv, ...@@ -703,7 +703,7 @@ vmw_cmd_res_check(struct vmw_private *dev_priv,
static int vmw_rebind_all_dx_query(struct vmw_resource *ctx_res) static int vmw_rebind_all_dx_query(struct vmw_resource *ctx_res)
{ {
struct vmw_private *dev_priv = ctx_res->dev_priv; struct vmw_private *dev_priv = ctx_res->dev_priv;
struct vmw_buffer_object *dx_query_mob; struct vmw_bo *dx_query_mob;
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindAllQuery); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindAllQuery);
dx_query_mob = vmw_context_get_dx_query_mob(ctx_res); dx_query_mob = vmw_context_get_dx_query_mob(ctx_res);
...@@ -1017,7 +1017,7 @@ static int vmw_cmd_present_check(struct vmw_private *dev_priv, ...@@ -1017,7 +1017,7 @@ static int vmw_cmd_present_check(struct vmw_private *dev_priv,
* after successful submission of the current command batch. * after successful submission of the current command batch.
*/ */
static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv, static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv,
struct vmw_buffer_object *new_query_bo, struct vmw_bo *new_query_bo,
struct vmw_sw_context *sw_context) struct vmw_sw_context *sw_context)
{ {
struct vmw_res_cache_entry *ctx_entry = struct vmw_res_cache_entry *ctx_entry =
...@@ -1145,9 +1145,9 @@ static void vmw_query_bo_switch_commit(struct vmw_private *dev_priv, ...@@ -1145,9 +1145,9 @@ static void vmw_query_bo_switch_commit(struct vmw_private *dev_priv,
static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGAMobId *id, SVGAMobId *id,
struct vmw_buffer_object **vmw_bo_p) struct vmw_bo **vmw_bo_p)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
uint32_t handle = *id; uint32_t handle = *id;
struct vmw_relocation *reloc; struct vmw_relocation *reloc;
int ret; int ret;
...@@ -1199,9 +1199,9 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, ...@@ -1199,9 +1199,9 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
static int vmw_translate_guest_ptr(struct vmw_private *dev_priv, static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGAGuestPtr *ptr, SVGAGuestPtr *ptr,
struct vmw_buffer_object **vmw_bo_p) struct vmw_bo **vmw_bo_p)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
uint32_t handle = ptr->gmrId; uint32_t handle = ptr->gmrId;
struct vmw_relocation *reloc; struct vmw_relocation *reloc;
int ret; int ret;
...@@ -1278,7 +1278,7 @@ static int vmw_cmd_dx_bind_query(struct vmw_private *dev_priv, ...@@ -1278,7 +1278,7 @@ static int vmw_cmd_dx_bind_query(struct vmw_private *dev_priv,
SVGA3dCmdHeader *header) SVGA3dCmdHeader *header)
{ {
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindQuery); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXBindQuery);
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
int ret; int ret;
cmd = container_of(header, typeof(*cmd), header); cmd = container_of(header, typeof(*cmd), header);
...@@ -1361,7 +1361,7 @@ static int vmw_cmd_end_gb_query(struct vmw_private *dev_priv, ...@@ -1361,7 +1361,7 @@ static int vmw_cmd_end_gb_query(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGA3dCmdHeader *header) SVGA3dCmdHeader *header)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndGBQuery); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndGBQuery);
int ret; int ret;
...@@ -1391,7 +1391,7 @@ static int vmw_cmd_end_query(struct vmw_private *dev_priv, ...@@ -1391,7 +1391,7 @@ static int vmw_cmd_end_query(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGA3dCmdHeader *header) SVGA3dCmdHeader *header)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndQuery); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdEndQuery);
int ret; int ret;
...@@ -1437,7 +1437,7 @@ static int vmw_cmd_wait_gb_query(struct vmw_private *dev_priv, ...@@ -1437,7 +1437,7 @@ static int vmw_cmd_wait_gb_query(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGA3dCmdHeader *header) SVGA3dCmdHeader *header)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForGBQuery); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForGBQuery);
int ret; int ret;
...@@ -1465,7 +1465,7 @@ static int vmw_cmd_wait_query(struct vmw_private *dev_priv, ...@@ -1465,7 +1465,7 @@ static int vmw_cmd_wait_query(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGA3dCmdHeader *header) SVGA3dCmdHeader *header)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForQuery); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdWaitForQuery);
int ret; int ret;
...@@ -1502,7 +1502,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv, ...@@ -1502,7 +1502,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
SVGA3dCmdHeader *header) SVGA3dCmdHeader *header)
{ {
struct vmw_buffer_object *vmw_bo = NULL; struct vmw_bo *vmw_bo = NULL;
struct vmw_surface *srf = NULL; struct vmw_surface *srf = NULL;
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSurfaceDMA); VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdSurfaceDMA);
int ret; int ret;
...@@ -1668,7 +1668,7 @@ static int vmw_cmd_check_define_gmrfb(struct vmw_private *dev_priv, ...@@ -1668,7 +1668,7 @@ static int vmw_cmd_check_define_gmrfb(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context, struct vmw_sw_context *sw_context,
void *buf) void *buf)
{ {
struct vmw_buffer_object *vmw_bo; struct vmw_bo *vmw_bo;
struct { struct {
uint32_t header; uint32_t header;
...@@ -1699,7 +1699,7 @@ static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv, ...@@ -1699,7 +1699,7 @@ static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv,
struct vmw_resource *res, uint32_t *buf_id, struct vmw_resource *res, uint32_t *buf_id,
unsigned long backup_offset) unsigned long backup_offset)
{ {
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
void *info; void *info;
int ret; int ret;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2011-2014 VMware, Inc., Palo Alto, CA., USA * Copyright 2011-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
......
/* SPDX-License-Identifier: GPL-2.0 OR MIT */ /* SPDX-License-Identifier: GPL-2.0 OR MIT */
/* /*
* Copyright 2021 VMware, Inc. * Copyright 2021-2023 VMware, Inc.
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
...@@ -24,25 +24,12 @@ ...@@ -24,25 +24,12 @@
* *
*/ */
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "drm/drm_prime.h" #include "drm/drm_prime.h"
#include "drm/drm_gem_ttm_helper.h" #include "drm/drm_gem_ttm_helper.h"
/**
* vmw_buffer_object - Convert a struct ttm_buffer_object to a struct
* vmw_buffer_object.
*
* @bo: Pointer to the TTM buffer object.
* Return: Pointer to the struct vmw_buffer_object embedding the
* TTM buffer object.
*/
static struct vmw_buffer_object *
vmw_buffer_object(struct ttm_buffer_object *bo)
{
return container_of(bo, struct vmw_buffer_object, base);
}
static void vmw_gem_object_free(struct drm_gem_object *gobj) static void vmw_gem_object_free(struct drm_gem_object *gobj)
{ {
struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gobj); struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gobj);
...@@ -65,7 +52,7 @@ static void vmw_gem_object_close(struct drm_gem_object *obj, ...@@ -65,7 +52,7 @@ static void vmw_gem_object_close(struct drm_gem_object *obj,
static int vmw_gem_pin_private(struct drm_gem_object *obj, bool do_pin) static int vmw_gem_pin_private(struct drm_gem_object *obj, bool do_pin)
{ {
struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(obj); struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(obj);
struct vmw_buffer_object *vbo = vmw_buffer_object(bo); struct vmw_bo *vbo = to_vmw_bo(obj);
int ret; int ret;
ret = ttm_bo_reserve(bo, false, false, NULL); ret = ttm_bo_reserve(bo, false, false, NULL);
...@@ -129,7 +116,7 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, ...@@ -129,7 +116,7 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,
struct drm_file *filp, struct drm_file *filp,
uint32_t size, uint32_t size,
uint32_t *handle, uint32_t *handle,
struct vmw_buffer_object **p_vbo) struct vmw_bo **p_vbo)
{ {
int ret; int ret;
...@@ -159,7 +146,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, ...@@ -159,7 +146,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data,
(union drm_vmw_alloc_dmabuf_arg *)data; (union drm_vmw_alloc_dmabuf_arg *)data;
struct drm_vmw_alloc_dmabuf_req *req = &arg->req; struct drm_vmw_alloc_dmabuf_req *req = &arg->req;
struct drm_vmw_dmabuf_rep *rep = &arg->rep; struct drm_vmw_dmabuf_rep *rep = &arg->rep;
struct vmw_buffer_object *vbo; struct vmw_bo *vbo;
uint32_t handle; uint32_t handle;
int ret; int ret;
...@@ -178,7 +165,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, ...@@ -178,7 +165,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data,
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
static void vmw_bo_print_info(int id, struct vmw_buffer_object *bo, struct seq_file *m) static void vmw_bo_print_info(int id, struct vmw_bo *bo, struct seq_file *m)
{ {
const char *placement; const char *placement;
const char *type; const char *type;
...@@ -259,7 +246,7 @@ static int vmw_debugfs_gem_info_show(struct seq_file *m, void *unused) ...@@ -259,7 +246,7 @@ static int vmw_debugfs_gem_info_show(struct seq_file *m, void *unused)
spin_lock(&file->table_lock); spin_lock(&file->table_lock);
idr_for_each_entry(&file->object_idr, gobj, id) { idr_for_each_entry(&file->object_idr, gobj, id) {
struct vmw_buffer_object *bo = gem_to_vmw_bo(gobj); struct vmw_bo *bo = to_vmw_bo(gobj);
vmw_bo_print_info(id, bo, m); vmw_bo_print_info(id, bo, m);
} }
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2022 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -24,8 +24,9 @@ ...@@ -24,8 +24,9 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include "vmwgfx_kms.h" #include "vmwgfx_kms.h"
#include "vmwgfx_bo.h"
#include "vmw_surface_cache.h" #include "vmw_surface_cache.h"
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
...@@ -1493,7 +1494,7 @@ static const struct drm_framebuffer_funcs vmw_framebuffer_bo_funcs = { ...@@ -1493,7 +1494,7 @@ static const struct drm_framebuffer_funcs vmw_framebuffer_bo_funcs = {
static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb) static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb)
{ {
struct vmw_private *dev_priv = vmw_priv(vfb->base.dev); struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
struct vmw_buffer_object *buf; struct vmw_bo *buf;
struct ttm_placement *placement; struct ttm_placement *placement;
int ret; int ret;
...@@ -1538,7 +1539,7 @@ static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb) ...@@ -1538,7 +1539,7 @@ static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb)
static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb) static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb)
{ {
struct vmw_private *dev_priv = vmw_priv(vfb->base.dev); struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
struct vmw_buffer_object *buf; struct vmw_bo *buf;
buf = vfb->bo ? vmw_framebuffer_to_vfbd(&vfb->base)->buffer : buf = vfb->bo ? vmw_framebuffer_to_vfbd(&vfb->base)->buffer :
vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.backup; vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.backup;
...@@ -1566,7 +1567,7 @@ static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb) ...@@ -1566,7 +1567,7 @@ static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb)
*/ */
static int vmw_create_bo_proxy(struct drm_device *dev, static int vmw_create_bo_proxy(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd, const struct drm_mode_fb_cmd2 *mode_cmd,
struct vmw_buffer_object *bo_mob, struct vmw_bo *bo_mob,
struct vmw_surface **srf_out) struct vmw_surface **srf_out)
{ {
struct vmw_surface_metadata metadata = {0}; struct vmw_surface_metadata metadata = {0};
...@@ -1630,7 +1631,7 @@ static int vmw_create_bo_proxy(struct drm_device *dev, ...@@ -1630,7 +1631,7 @@ static int vmw_create_bo_proxy(struct drm_device *dev,
static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv, static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv,
struct vmw_buffer_object *bo, struct vmw_bo *bo,
struct vmw_framebuffer **out, struct vmw_framebuffer **out,
const struct drm_mode_fb_cmd2 const struct drm_mode_fb_cmd2
*mode_cmd) *mode_cmd)
...@@ -1718,7 +1719,7 @@ vmw_kms_srf_ok(struct vmw_private *dev_priv, uint32_t width, uint32_t height) ...@@ -1718,7 +1719,7 @@ vmw_kms_srf_ok(struct vmw_private *dev_priv, uint32_t width, uint32_t height)
*/ */
struct vmw_framebuffer * struct vmw_framebuffer *
vmw_kms_new_framebuffer(struct vmw_private *dev_priv, vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
struct vmw_buffer_object *bo, struct vmw_bo *bo,
struct vmw_surface *surface, struct vmw_surface *surface,
bool only_2d, bool only_2d,
const struct drm_mode_fb_cmd2 *mode_cmd) const struct drm_mode_fb_cmd2 *mode_cmd)
...@@ -1782,7 +1783,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, ...@@ -1782,7 +1783,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_private *dev_priv = vmw_priv(dev);
struct vmw_framebuffer *vfb = NULL; struct vmw_framebuffer *vfb = NULL;
struct vmw_surface *surface = NULL; struct vmw_surface *surface = NULL;
struct vmw_buffer_object *bo = NULL; struct vmw_bo *bo = NULL;
int ret; int ret;
/* returns either a bo or surface */ /* returns either a bo or surface */
......
...@@ -233,7 +233,7 @@ struct vmw_clip_rect { ...@@ -233,7 +233,7 @@ struct vmw_clip_rect {
struct vmw_framebuffer_surface { struct vmw_framebuffer_surface {
struct vmw_framebuffer base; struct vmw_framebuffer base;
struct vmw_surface *surface; struct vmw_surface *surface;
struct vmw_buffer_object *buffer; struct vmw_bo *buffer;
struct list_head head; struct list_head head;
bool is_bo_proxy; /* true if this is proxy surface for DMA buf */ bool is_bo_proxy; /* true if this is proxy surface for DMA buf */
}; };
...@@ -241,7 +241,7 @@ struct vmw_framebuffer_surface { ...@@ -241,7 +241,7 @@ struct vmw_framebuffer_surface {
struct vmw_framebuffer_bo { struct vmw_framebuffer_bo {
struct vmw_framebuffer base; struct vmw_framebuffer base;
struct vmw_buffer_object *buffer; struct vmw_bo *buffer;
}; };
...@@ -293,7 +293,7 @@ struct vmw_cursor_plane_state { ...@@ -293,7 +293,7 @@ struct vmw_cursor_plane_state {
struct vmw_plane_state { struct vmw_plane_state {
struct drm_plane_state base; struct drm_plane_state base;
struct vmw_surface *surf; struct vmw_surface *surf;
struct vmw_buffer_object *bo; struct vmw_bo *bo;
int content_fb_type; int content_fb_type;
unsigned long bo_size; unsigned long bo_size;
...@@ -364,7 +364,7 @@ struct vmw_display_unit { ...@@ -364,7 +364,7 @@ struct vmw_display_unit {
struct vmw_cursor_plane cursor; struct vmw_cursor_plane cursor;
struct vmw_surface *cursor_surface; struct vmw_surface *cursor_surface;
struct vmw_buffer_object *cursor_bo; struct vmw_bo *cursor_bo;
size_t cursor_age; size_t cursor_age;
int cursor_x; int cursor_x;
...@@ -397,7 +397,7 @@ struct vmw_display_unit { ...@@ -397,7 +397,7 @@ struct vmw_display_unit {
struct vmw_validation_ctx { struct vmw_validation_ctx {
struct vmw_resource *res; struct vmw_resource *res;
struct vmw_buffer_object *buf; struct vmw_bo *buf;
}; };
#define vmw_crtc_to_du(x) \ #define vmw_crtc_to_du(x) \
...@@ -458,7 +458,7 @@ int vmw_kms_readback(struct vmw_private *dev_priv, ...@@ -458,7 +458,7 @@ int vmw_kms_readback(struct vmw_private *dev_priv,
uint32_t num_clips); uint32_t num_clips);
struct vmw_framebuffer * struct vmw_framebuffer *
vmw_kms_new_framebuffer(struct vmw_private *dev_priv, vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
struct vmw_buffer_object *bo, struct vmw_bo *bo,
struct vmw_surface *surface, struct vmw_surface *surface,
bool only_2d, bool only_2d,
const struct drm_mode_fb_cmd2 *mode_cmd); const struct drm_mode_fb_cmd2 *mode_cmd);
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2012-2021 VMware, Inc., Palo Alto, CA., USA * Copyright 2012-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
* *
**************************************************************************/ **************************************************************************/
#include <linux/highmem.h> #include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include <linux/highmem.h>
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
#define VMW_PPN_SIZE 8 #define VMW_PPN_SIZE 8
#define VMW_MOBFMT_PTDEPTH_0 SVGA3D_MOBFMT_PT64_0 #define VMW_MOBFMT_PTDEPTH_0 SVGA3D_MOBFMT_PT64_0
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2014 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -24,19 +24,19 @@ ...@@ -24,19 +24,19 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include "vmwgfx_bo.h"
#include <drm/ttm/ttm_placement.h> #include "vmwgfx_drv.h"
#include "device_include/svga_overlay.h" #include "device_include/svga_overlay.h"
#include "device_include/svga_escape.h" #include "device_include/svga_escape.h"
#include "vmwgfx_drv.h" #include <drm/ttm/ttm_placement.h>
#define VMW_MAX_NUM_STREAMS 1 #define VMW_MAX_NUM_STREAMS 1
#define VMW_OVERLAY_CAP_MASK (SVGA_FIFO_CAP_VIDEO | SVGA_FIFO_CAP_ESCAPE) #define VMW_OVERLAY_CAP_MASK (SVGA_FIFO_CAP_VIDEO | SVGA_FIFO_CAP_ESCAPE)
struct vmw_stream { struct vmw_stream {
struct vmw_buffer_object *buf; struct vmw_bo *buf;
bool claimed; bool claimed;
bool paused; bool paused;
struct drm_vmw_control_stream_arg saved; struct drm_vmw_control_stream_arg saved;
...@@ -92,7 +92,7 @@ static inline void fill_flush(struct vmw_escape_video_flush *cmd, ...@@ -92,7 +92,7 @@ static inline void fill_flush(struct vmw_escape_video_flush *cmd,
* -ERESTARTSYS if interrupted by a signal. * -ERESTARTSYS if interrupted by a signal.
*/ */
static int vmw_overlay_send_put(struct vmw_private *dev_priv, static int vmw_overlay_send_put(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
struct drm_vmw_control_stream_arg *arg, struct drm_vmw_control_stream_arg *arg,
bool interruptible) bool interruptible)
{ {
...@@ -223,7 +223,7 @@ static int vmw_overlay_send_stop(struct vmw_private *dev_priv, ...@@ -223,7 +223,7 @@ static int vmw_overlay_send_stop(struct vmw_private *dev_priv,
* used with GMRs instead of being locked to vram. * used with GMRs instead of being locked to vram.
*/ */
static int vmw_overlay_move_buffer(struct vmw_private *dev_priv, static int vmw_overlay_move_buffer(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
bool pin, bool inter) bool pin, bool inter)
{ {
if (!pin) if (!pin)
...@@ -295,7 +295,7 @@ static int vmw_overlay_stop(struct vmw_private *dev_priv, ...@@ -295,7 +295,7 @@ static int vmw_overlay_stop(struct vmw_private *dev_priv,
* -ERESTARTSYS if interrupted. * -ERESTARTSYS if interrupted.
*/ */
static int vmw_overlay_update_stream(struct vmw_private *dev_priv, static int vmw_overlay_update_stream(struct vmw_private *dev_priv,
struct vmw_buffer_object *buf, struct vmw_bo *buf,
struct drm_vmw_control_stream_arg *arg, struct drm_vmw_control_stream_arg *arg,
bool interruptible) bool interruptible)
{ {
...@@ -433,7 +433,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data, ...@@ -433,7 +433,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data,
struct vmw_overlay *overlay = dev_priv->overlay_priv; struct vmw_overlay *overlay = dev_priv->overlay_priv;
struct drm_vmw_control_stream_arg *arg = struct drm_vmw_control_stream_arg *arg =
(struct drm_vmw_control_stream_arg *)data; (struct drm_vmw_control_stream_arg *)data;
struct vmw_buffer_object *buf; struct vmw_bo *buf;
struct vmw_resource *res; struct vmw_resource *res;
int ret; int ret;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2019 VMware, Inc., Palo Alto, CA., USA * Copyright 2019-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
/* /*
...@@ -78,7 +79,7 @@ struct vmw_bo_dirty { ...@@ -78,7 +79,7 @@ struct vmw_bo_dirty {
* dirty structure with the results. This function may change the * dirty structure with the results. This function may change the
* dirty-tracking method. * dirty-tracking method.
*/ */
static void vmw_bo_dirty_scan_pagetable(struct vmw_buffer_object *vbo) static void vmw_bo_dirty_scan_pagetable(struct vmw_bo *vbo)
{ {
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
pgoff_t offset = drm_vma_node_start(&vbo->base.base.vma_node); pgoff_t offset = drm_vma_node_start(&vbo->base.base.vma_node);
...@@ -116,7 +117,7 @@ static void vmw_bo_dirty_scan_pagetable(struct vmw_buffer_object *vbo) ...@@ -116,7 +117,7 @@ static void vmw_bo_dirty_scan_pagetable(struct vmw_buffer_object *vbo)
* *
* This function may change the dirty-tracking method. * This function may change the dirty-tracking method.
*/ */
static void vmw_bo_dirty_scan_mkwrite(struct vmw_buffer_object *vbo) static void vmw_bo_dirty_scan_mkwrite(struct vmw_bo *vbo)
{ {
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
unsigned long offset = drm_vma_node_start(&vbo->base.base.vma_node); unsigned long offset = drm_vma_node_start(&vbo->base.base.vma_node);
...@@ -160,7 +161,7 @@ static void vmw_bo_dirty_scan_mkwrite(struct vmw_buffer_object *vbo) ...@@ -160,7 +161,7 @@ static void vmw_bo_dirty_scan_mkwrite(struct vmw_buffer_object *vbo)
* *
* This function may change the dirty tracking method. * This function may change the dirty tracking method.
*/ */
void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo) void vmw_bo_dirty_scan(struct vmw_bo *vbo)
{ {
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
...@@ -181,7 +182,7 @@ void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo) ...@@ -181,7 +182,7 @@ void vmw_bo_dirty_scan(struct vmw_buffer_object *vbo)
* when calling unmap_mapping_range(). This function makes sure we pick * when calling unmap_mapping_range(). This function makes sure we pick
* up all dirty pages. * up all dirty pages.
*/ */
static void vmw_bo_dirty_pre_unmap(struct vmw_buffer_object *vbo, static void vmw_bo_dirty_pre_unmap(struct vmw_bo *vbo,
pgoff_t start, pgoff_t end) pgoff_t start, pgoff_t end)
{ {
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
...@@ -206,7 +207,7 @@ static void vmw_bo_dirty_pre_unmap(struct vmw_buffer_object *vbo, ...@@ -206,7 +207,7 @@ static void vmw_bo_dirty_pre_unmap(struct vmw_buffer_object *vbo,
* *
* This is similar to ttm_bo_unmap_virtual() except it takes a subrange. * This is similar to ttm_bo_unmap_virtual() except it takes a subrange.
*/ */
void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, void vmw_bo_dirty_unmap(struct vmw_bo *vbo,
pgoff_t start, pgoff_t end) pgoff_t start, pgoff_t end)
{ {
unsigned long offset = drm_vma_node_start(&vbo->base.base.vma_node); unsigned long offset = drm_vma_node_start(&vbo->base.base.vma_node);
...@@ -227,7 +228,7 @@ void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo, ...@@ -227,7 +228,7 @@ void vmw_bo_dirty_unmap(struct vmw_buffer_object *vbo,
* *
* Return: Zero on success, -ENOMEM on memory allocation failure. * Return: Zero on success, -ENOMEM on memory allocation failure.
*/ */
int vmw_bo_dirty_add(struct vmw_buffer_object *vbo) int vmw_bo_dirty_add(struct vmw_bo *vbo)
{ {
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
pgoff_t num_pages = PFN_UP(vbo->base.resource->size); pgoff_t num_pages = PFN_UP(vbo->base.resource->size);
...@@ -284,7 +285,7 @@ int vmw_bo_dirty_add(struct vmw_buffer_object *vbo) ...@@ -284,7 +285,7 @@ int vmw_bo_dirty_add(struct vmw_buffer_object *vbo)
* *
* Return: Zero on success, -ENOMEM on memory allocation failure. * Return: Zero on success, -ENOMEM on memory allocation failure.
*/ */
void vmw_bo_dirty_release(struct vmw_buffer_object *vbo) void vmw_bo_dirty_release(struct vmw_bo *vbo)
{ {
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
...@@ -306,7 +307,7 @@ void vmw_bo_dirty_release(struct vmw_buffer_object *vbo) ...@@ -306,7 +307,7 @@ void vmw_bo_dirty_release(struct vmw_buffer_object *vbo)
*/ */
void vmw_bo_dirty_transfer_to_res(struct vmw_resource *res) void vmw_bo_dirty_transfer_to_res(struct vmw_resource *res)
{ {
struct vmw_buffer_object *vbo = res->backup; struct vmw_bo *vbo = res->backup;
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
pgoff_t start, cur, end; pgoff_t start, cur, end;
unsigned long res_start = res->backup_offset; unsigned long res_start = res->backup_offset;
...@@ -353,7 +354,7 @@ void vmw_bo_dirty_clear_res(struct vmw_resource *res) ...@@ -353,7 +354,7 @@ void vmw_bo_dirty_clear_res(struct vmw_resource *res)
{ {
unsigned long res_start = res->backup_offset; unsigned long res_start = res->backup_offset;
unsigned long res_end = res->backup_offset + res->backup_size; unsigned long res_end = res->backup_offset + res->backup_size;
struct vmw_buffer_object *vbo = res->backup; struct vmw_bo *vbo = res->backup;
struct vmw_bo_dirty *dirty = vbo->dirty; struct vmw_bo_dirty *dirty = vbo->dirty;
res_start >>= PAGE_SHIFT; res_start >>= PAGE_SHIFT;
...@@ -380,7 +381,7 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf) ...@@ -380,7 +381,7 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf)
vm_fault_t ret; vm_fault_t ret;
unsigned long page_offset; unsigned long page_offset;
unsigned int save_flags; unsigned int save_flags;
struct vmw_buffer_object *vbo = struct vmw_bo *vbo =
container_of(bo, typeof(*vbo), base); container_of(bo, typeof(*vbo), base);
/* /*
...@@ -419,8 +420,8 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf) ...@@ -419,8 +420,8 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf)
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
struct ttm_buffer_object *bo = (struct ttm_buffer_object *) struct ttm_buffer_object *bo = (struct ttm_buffer_object *)
vma->vm_private_data; vma->vm_private_data;
struct vmw_buffer_object *vbo = struct vmw_bo *vbo =
container_of(bo, struct vmw_buffer_object, base); container_of(bo, struct vmw_bo, base);
pgoff_t num_prefault; pgoff_t num_prefault;
pgprot_t prot; pgprot_t prot;
vm_fault_t ret; vm_fault_t ret;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
#include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_placement.h>
#include "vmwgfx_resource_priv.h"
#include "vmwgfx_binding.h" #include "vmwgfx_binding.h"
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_resource_priv.h"
#define VMW_RES_EVICT_ERR_COUNT 10 #define VMW_RES_EVICT_ERR_COUNT 10
...@@ -39,7 +40,7 @@ ...@@ -39,7 +40,7 @@
*/ */
void vmw_resource_mob_attach(struct vmw_resource *res) void vmw_resource_mob_attach(struct vmw_resource *res)
{ {
struct vmw_buffer_object *backup = res->backup; struct vmw_bo *backup = res->backup;
struct rb_node **new = &backup->res_tree.rb_node, *parent = NULL; struct rb_node **new = &backup->res_tree.rb_node, *parent = NULL;
dma_resv_assert_held(res->backup->base.base.resv); dma_resv_assert_held(res->backup->base.base.resv);
...@@ -67,7 +68,7 @@ void vmw_resource_mob_attach(struct vmw_resource *res) ...@@ -67,7 +68,7 @@ void vmw_resource_mob_attach(struct vmw_resource *res)
*/ */
void vmw_resource_mob_detach(struct vmw_resource *res) void vmw_resource_mob_detach(struct vmw_resource *res)
{ {
struct vmw_buffer_object *backup = res->backup; struct vmw_bo *backup = res->backup;
dma_resv_assert_held(backup->base.base.resv); dma_resv_assert_held(backup->base.base.resv);
if (vmw_resource_mob_attached(res)) { if (vmw_resource_mob_attached(res)) {
...@@ -290,7 +291,7 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv, ...@@ -290,7 +291,7 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv,
struct drm_file *filp, struct drm_file *filp,
uint32_t handle, uint32_t handle,
struct vmw_surface **out_surf, struct vmw_surface **out_surf,
struct vmw_buffer_object **out_buf) struct vmw_bo **out_buf)
{ {
struct ttm_object_file *tfile = vmw_fpriv(filp)->tfile; struct ttm_object_file *tfile = vmw_fpriv(filp)->tfile;
struct vmw_resource *res; struct vmw_resource *res;
...@@ -322,7 +323,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, ...@@ -322,7 +323,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res,
bool interruptible) bool interruptible)
{ {
unsigned long size = PFN_ALIGN(res->backup_size); unsigned long size = PFN_ALIGN(res->backup_size);
struct vmw_buffer_object *backup; struct vmw_bo *backup;
int ret; int ret;
if (likely(res->backup)) { if (likely(res->backup)) {
...@@ -438,7 +439,7 @@ void vmw_resource_unreserve(struct vmw_resource *res, ...@@ -438,7 +439,7 @@ void vmw_resource_unreserve(struct vmw_resource *res,
bool dirty_set, bool dirty_set,
bool dirty, bool dirty,
bool switch_backup, bool switch_backup,
struct vmw_buffer_object *new_backup, struct vmw_bo *new_backup,
unsigned long new_backup_offset) unsigned long new_backup_offset)
{ {
struct vmw_private *dev_priv = res->dev_priv; struct vmw_private *dev_priv = res->dev_priv;
...@@ -739,7 +740,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr, ...@@ -739,7 +740,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr,
* validation code, since resource validation and eviction * validation code, since resource validation and eviction
* both require the backup buffer to be reserved. * both require the backup buffer to be reserved.
*/ */
void vmw_resource_unbind_list(struct vmw_buffer_object *vbo) void vmw_resource_unbind_list(struct vmw_bo *vbo)
{ {
struct ttm_validate_buffer val_buf = { struct ttm_validate_buffer val_buf = {
.bo = &vbo->base, .bo = &vbo->base,
...@@ -772,7 +773,7 @@ void vmw_resource_unbind_list(struct vmw_buffer_object *vbo) ...@@ -772,7 +773,7 @@ void vmw_resource_unbind_list(struct vmw_buffer_object *vbo)
* Read back cached states from the device if they exist. This function * Read back cached states from the device if they exist. This function
* assumes binding_mutex is held. * assumes binding_mutex is held.
*/ */
int vmw_query_readback_all(struct vmw_buffer_object *dx_query_mob) int vmw_query_readback_all(struct vmw_bo *dx_query_mob)
{ {
struct vmw_resource *dx_query_ctx; struct vmw_resource *dx_query_ctx;
struct vmw_private *dev_priv; struct vmw_private *dev_priv;
...@@ -821,7 +822,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo, ...@@ -821,7 +822,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo,
struct ttm_resource *old_mem, struct ttm_resource *old_mem,
struct ttm_resource *new_mem) struct ttm_resource *new_mem)
{ {
struct vmw_buffer_object *dx_query_mob; struct vmw_bo *dx_query_mob;
struct ttm_device *bdev = bo->bdev; struct ttm_device *bdev = bo->bdev;
struct vmw_private *dev_priv; struct vmw_private *dev_priv;
...@@ -834,7 +835,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo, ...@@ -834,7 +835,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo,
old_mem->mem_type == VMW_PL_MOB) { old_mem->mem_type == VMW_PL_MOB) {
struct vmw_fence_obj *fence; struct vmw_fence_obj *fence;
dx_query_mob = container_of(bo, struct vmw_buffer_object, base); dx_query_mob = container_of(bo, struct vmw_bo, base);
if (!dx_query_mob || !dx_query_mob->dx_query_ctx) { if (!dx_query_mob || !dx_query_mob->dx_query_ctx) {
mutex_unlock(&dev_priv->binding_mutex); mutex_unlock(&dev_priv->binding_mutex);
return; return;
...@@ -958,7 +959,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible) ...@@ -958,7 +959,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)
goto out_no_reserve; goto out_no_reserve;
if (res->pin_count == 0) { if (res->pin_count == 0) {
struct vmw_buffer_object *vbo = NULL; struct vmw_bo *vbo = NULL;
if (res->backup) { if (res->backup) {
vbo = res->backup; vbo = res->backup;
...@@ -1016,7 +1017,7 @@ void vmw_resource_unpin(struct vmw_resource *res) ...@@ -1016,7 +1017,7 @@ void vmw_resource_unpin(struct vmw_resource *res)
WARN_ON(res->pin_count == 0); WARN_ON(res->pin_count == 0);
if (--res->pin_count == 0 && res->backup) { if (--res->pin_count == 0 && res->backup) {
struct vmw_buffer_object *vbo = res->backup; struct vmw_bo *vbo = res->backup;
(void) ttm_bo_reserve(&vbo->base, false, false, NULL); (void) ttm_bo_reserve(&vbo->base, false, false, NULL);
vmw_bo_pin_reserved(vbo, false); vmw_bo_pin_reserved(vbo, false);
...@@ -1061,7 +1062,7 @@ void vmw_resource_dirty_update(struct vmw_resource *res, pgoff_t start, ...@@ -1061,7 +1062,7 @@ void vmw_resource_dirty_update(struct vmw_resource *res, pgoff_t start,
* @num_prefault: Returns how many pages including the first have been * @num_prefault: Returns how many pages including the first have been
* cleaned and are ok to prefault * cleaned and are ok to prefault
*/ */
int vmw_resources_clean(struct vmw_buffer_object *vbo, pgoff_t start, int vmw_resources_clean(struct vmw_bo *vbo, pgoff_t start,
pgoff_t end, pgoff_t *num_prefault) pgoff_t end, pgoff_t *num_prefault)
{ {
struct rb_node *cur = vbo->res_tree.rb_node; struct rb_node *cur = vbo->res_tree.rb_node;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2011-2022 VMware, Inc., Palo Alto, CA., USA * Copyright 2011-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -25,13 +25,14 @@ ...@@ -25,13 +25,14 @@
* *
**************************************************************************/ **************************************************************************/
#include "vmwgfx_bo.h"
#include "vmwgfx_kms.h"
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_damage_helper.h> #include <drm/drm_damage_helper.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include "vmwgfx_kms.h"
#define vmw_crtc_to_sou(x) \ #define vmw_crtc_to_sou(x) \
container_of(x, struct vmw_screen_object_unit, base.crtc) container_of(x, struct vmw_screen_object_unit, base.crtc)
#define vmw_encoder_to_sou(x) \ #define vmw_encoder_to_sou(x) \
...@@ -89,7 +90,7 @@ struct vmw_screen_object_unit { ...@@ -89,7 +90,7 @@ struct vmw_screen_object_unit {
struct vmw_display_unit base; struct vmw_display_unit base;
unsigned long buffer_size; /**< Size of allocated buffer */ unsigned long buffer_size; /**< Size of allocated buffer */
struct vmw_buffer_object *buffer; /**< Backing store buffer */ struct vmw_bo *buffer; /**< Backing store buffer */
bool defined; bool defined;
}; };
...@@ -947,7 +948,7 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv) ...@@ -947,7 +948,7 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv)
static int do_bo_define_gmrfb(struct vmw_private *dev_priv, static int do_bo_define_gmrfb(struct vmw_private *dev_priv,
struct vmw_framebuffer *framebuffer) struct vmw_framebuffer *framebuffer)
{ {
struct vmw_buffer_object *buf = struct vmw_bo *buf =
container_of(framebuffer, struct vmw_framebuffer_bo, container_of(framebuffer, struct vmw_framebuffer_bo,
base)->buffer; base)->buffer;
int depth = framebuffer->base.format->depth; int depth = framebuffer->base.format->depth;
...@@ -1216,7 +1217,7 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv, ...@@ -1216,7 +1217,7 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,
struct vmw_fence_obj **out_fence, struct vmw_fence_obj **out_fence,
struct drm_crtc *crtc) struct drm_crtc *crtc)
{ {
struct vmw_buffer_object *buf = struct vmw_bo *buf =
container_of(framebuffer, struct vmw_framebuffer_bo, container_of(framebuffer, struct vmw_framebuffer_bo,
base)->buffer; base)->buffer;
struct vmw_kms_dirty dirty; struct vmw_kms_dirty dirty;
...@@ -1323,7 +1324,7 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv, ...@@ -1323,7 +1324,7 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,
uint32_t num_clips, uint32_t num_clips,
struct drm_crtc *crtc) struct drm_crtc *crtc)
{ {
struct vmw_buffer_object *buf = struct vmw_bo *buf =
container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;
struct vmw_kms_dirty dirty; struct vmw_kms_dirty dirty;
DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); DECLARE_VAL_CONTEXT(val_ctx, NULL, 0);
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
#include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_placement.h>
#include "vmwgfx_binding.h"
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_resource_priv.h" #include "vmwgfx_resource_priv.h"
#include "vmwgfx_binding.h"
struct vmw_shader { struct vmw_shader {
struct vmw_resource res; struct vmw_resource res;
...@@ -158,7 +159,7 @@ static int vmw_gb_shader_init(struct vmw_private *dev_priv, ...@@ -158,7 +159,7 @@ static int vmw_gb_shader_init(struct vmw_private *dev_priv,
SVGA3dShaderType type, SVGA3dShaderType type,
uint8_t num_input_sig, uint8_t num_input_sig,
uint8_t num_output_sig, uint8_t num_output_sig,
struct vmw_buffer_object *byte_code, struct vmw_bo *byte_code,
void (*res_free) (struct vmw_resource *res)) void (*res_free) (struct vmw_resource *res))
{ {
struct vmw_shader *shader = vmw_res_to_shader(res); struct vmw_shader *shader = vmw_res_to_shader(res);
...@@ -680,7 +681,7 @@ int vmw_shader_destroy_ioctl(struct drm_device *dev, void *data, ...@@ -680,7 +681,7 @@ int vmw_shader_destroy_ioctl(struct drm_device *dev, void *data,
} }
static int vmw_user_shader_alloc(struct vmw_private *dev_priv, static int vmw_user_shader_alloc(struct vmw_private *dev_priv,
struct vmw_buffer_object *buffer, struct vmw_bo *buffer,
size_t shader_size, size_t shader_size,
size_t offset, size_t offset,
SVGA3dShaderType shader_type, SVGA3dShaderType shader_type,
...@@ -734,7 +735,7 @@ static int vmw_user_shader_alloc(struct vmw_private *dev_priv, ...@@ -734,7 +735,7 @@ static int vmw_user_shader_alloc(struct vmw_private *dev_priv,
static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv, static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv,
struct vmw_buffer_object *buffer, struct vmw_bo *buffer,
size_t shader_size, size_t shader_size,
size_t offset, size_t offset,
SVGA3dShaderType shader_type) SVGA3dShaderType shader_type)
...@@ -771,7 +772,7 @@ static int vmw_shader_define(struct drm_device *dev, struct drm_file *file_priv, ...@@ -771,7 +772,7 @@ static int vmw_shader_define(struct drm_device *dev, struct drm_file *file_priv,
{ {
struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_private *dev_priv = vmw_priv(dev);
struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
struct vmw_buffer_object *buffer = NULL; struct vmw_bo *buffer = NULL;
SVGA3dShaderType shader_type; SVGA3dShaderType shader_type;
int ret; int ret;
...@@ -883,7 +884,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv, ...@@ -883,7 +884,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,
struct list_head *list) struct list_head *list)
{ {
struct ttm_operation_ctx ctx = { false, true }; struct ttm_operation_ctx ctx = { false, true };
struct vmw_buffer_object *buf; struct vmw_bo *buf;
struct ttm_bo_kmap_obj map; struct ttm_bo_kmap_obj map;
bool is_iomem; bool is_iomem;
int ret; int ret;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/****************************************************************************** /******************************************************************************
* *
* COPYRIGHT (C) 2014-2022 VMware, Inc., Palo Alto, CA., USA * COPYRIGHT (C) 2014-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -25,14 +25,15 @@ ...@@ -25,14 +25,15 @@
* *
******************************************************************************/ ******************************************************************************/
#include "vmwgfx_bo.h"
#include "vmwgfx_kms.h"
#include "vmw_surface_cache.h"
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_damage_helper.h> #include <drm/drm_damage_helper.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include "vmwgfx_kms.h"
#include "vmw_surface_cache.h"
#define vmw_crtc_to_stdu(x) \ #define vmw_crtc_to_stdu(x) \
container_of(x, struct vmw_screen_target_display_unit, base.crtc) container_of(x, struct vmw_screen_target_display_unit, base.crtc)
#define vmw_encoder_to_stdu(x) \ #define vmw_encoder_to_stdu(x) \
...@@ -70,7 +71,7 @@ struct vmw_stdu_dirty { ...@@ -70,7 +71,7 @@ struct vmw_stdu_dirty {
s32 fb_left, fb_top; s32 fb_left, fb_top;
u32 pitch; u32 pitch;
union { union {
struct vmw_buffer_object *buf; struct vmw_bo *buf;
u32 sid; u32 sid;
}; };
}; };
...@@ -688,7 +689,7 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv, ...@@ -688,7 +689,7 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
bool interruptible, bool interruptible,
struct drm_crtc *crtc) struct drm_crtc *crtc)
{ {
struct vmw_buffer_object *buf = struct vmw_bo *buf =
container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;
struct vmw_stdu_dirty ddirty; struct vmw_stdu_dirty ddirty;
int ret; int ret;
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright © 2018-2019 VMware, Inc., Palo Alto, CA., USA * Copyright © 2018-2023 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
...@@ -26,11 +26,12 @@ ...@@ -26,11 +26,12 @@
* *
**************************************************************************/ **************************************************************************/
#include <drm/ttm/ttm_placement.h> #include "vmwgfx_binding.h"
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_resource_priv.h" #include "vmwgfx_resource_priv.h"
#include "vmwgfx_binding.h"
#include <drm/ttm/ttm_placement.h>
/** /**
* struct vmw_dx_streamoutput - Streamoutput resource metadata. * struct vmw_dx_streamoutput - Streamoutput resource metadata.
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
* *
**************************************************************************/ **************************************************************************/
#include <drm/ttm/ttm_placement.h> #include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_resource_priv.h" #include "vmwgfx_resource_priv.h"
#include "vmwgfx_so.h" #include "vmwgfx_so.h"
...@@ -34,6 +33,8 @@ ...@@ -34,6 +33,8 @@
#include "vmw_surface_cache.h" #include "vmw_surface_cache.h"
#include "device_include/svga3d_surfacedefs.h" #include "device_include/svga3d_surfacedefs.h"
#include <drm/ttm/ttm_placement.h>
#define SVGA3D_FLAGS_64(upper32, lower32) (((uint64_t)upper32 << 32) | lower32) #define SVGA3D_FLAGS_64(upper32, lower32) (((uint64_t)upper32 << 32) | lower32)
#define SVGA3D_FLAGS_UPPER_32(svga3d_flags) (svga3d_flags >> 32) #define SVGA3D_FLAGS_UPPER_32(svga3d_flags) (svga3d_flags >> 32)
#define SVGA3D_FLAGS_LOWER_32(svga3d_flags) \ #define SVGA3D_FLAGS_LOWER_32(svga3d_flags) \
...@@ -1529,7 +1530,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev, ...@@ -1529,7 +1530,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev,
} }
if (req->base.drm_surface_flags & drm_vmw_surface_flag_coherent) { if (req->base.drm_surface_flags & drm_vmw_surface_flag_coherent) {
struct vmw_buffer_object *backup = res->backup; struct vmw_bo *backup = res->backup;
ttm_bo_reserve(&backup->base, false, false, NULL); ttm_bo_reserve(&backup->base, false, false, NULL);
if (!res->func->dirty_alloc) if (!res->func->dirty_alloc)
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright 2009-2015 VMware, Inc., Palo Alto, CA., USA * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* *
**************************************************************************/ **************************************************************************/
#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_placement.h>
......
// SPDX-License-Identifier: GPL-2.0 OR MIT // SPDX-License-Identifier: GPL-2.0 OR MIT
/************************************************************************** /**************************************************************************
* *
* Copyright © 2018 - 2022 VMware, Inc., Palo Alto, CA., USA * Copyright © 2018 - 2023 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ **************************************************************************/
#include <linux/slab.h> #include "vmwgfx_bo.h"
#include "vmwgfx_validation.h"
#include "vmwgfx_drv.h" #include "vmwgfx_drv.h"
#include "vmwgfx_validation.h"
#include <linux/slab.h>
#define VMWGFX_VALIDATION_MEM_GRAN (16*PAGE_SIZE) #define VMWGFX_VALIDATION_MEM_GRAN (16*PAGE_SIZE)
...@@ -77,7 +79,7 @@ struct vmw_validation_res_node { ...@@ -77,7 +79,7 @@ struct vmw_validation_res_node {
struct list_head head; struct list_head head;
struct vmwgfx_hash_item hash; struct vmwgfx_hash_item hash;
struct vmw_resource *res; struct vmw_resource *res;
struct vmw_buffer_object *new_backup; struct vmw_bo *new_backup;
unsigned long new_backup_offset; unsigned long new_backup_offset;
u32 no_buffer_needed : 1; u32 no_buffer_needed : 1;
u32 switching_backup : 1; u32 switching_backup : 1;
...@@ -173,7 +175,7 @@ static void vmw_validation_mem_free(struct vmw_validation_context *ctx) ...@@ -173,7 +175,7 @@ static void vmw_validation_mem_free(struct vmw_validation_context *ctx)
*/ */
static struct vmw_validation_bo_node * static struct vmw_validation_bo_node *
vmw_validation_find_bo_dup(struct vmw_validation_context *ctx, vmw_validation_find_bo_dup(struct vmw_validation_context *ctx,
struct vmw_buffer_object *vbo) struct vmw_bo *vbo)
{ {
struct vmw_validation_bo_node *bo_node = NULL; struct vmw_validation_bo_node *bo_node = NULL;
...@@ -264,7 +266,7 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx, ...@@ -264,7 +266,7 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx,
* Return: Zero on success, negative error code otherwise. * Return: Zero on success, negative error code otherwise.
*/ */
int vmw_validation_add_bo(struct vmw_validation_context *ctx, int vmw_validation_add_bo(struct vmw_validation_context *ctx,
struct vmw_buffer_object *vbo, struct vmw_bo *vbo,
bool as_mob, bool as_mob,
bool cpu_blit) bool cpu_blit)
{ {
...@@ -410,7 +412,7 @@ void vmw_validation_res_set_dirty(struct vmw_validation_context *ctx, ...@@ -410,7 +412,7 @@ void vmw_validation_res_set_dirty(struct vmw_validation_context *ctx,
*/ */
void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx, void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx,
void *val_private, void *val_private,
struct vmw_buffer_object *vbo, struct vmw_bo *vbo,
unsigned long backup_offset) unsigned long backup_offset)
{ {
struct vmw_validation_res_node *val; struct vmw_validation_res_node *val;
...@@ -451,7 +453,7 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx, ...@@ -451,7 +453,7 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx,
val->reserved = 1; val->reserved = 1;
if (res->backup) { if (res->backup) {
struct vmw_buffer_object *vbo = res->backup; struct vmw_bo *vbo = res->backup;
ret = vmw_validation_add_bo ret = vmw_validation_add_bo
(ctx, vbo, vmw_resource_needs_backup(res), (ctx, vbo, vmw_resource_needs_backup(res),
...@@ -526,8 +528,8 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, ...@@ -526,8 +528,8 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo,
bool interruptible, bool interruptible,
bool validate_as_mob) bool validate_as_mob)
{ {
struct vmw_buffer_object *vbo = struct vmw_bo *vbo =
container_of(bo, struct vmw_buffer_object, base); container_of(bo, struct vmw_bo, base);
struct ttm_operation_ctx ctx = { struct ttm_operation_ctx ctx = {
.interruptible = interruptible, .interruptible = interruptible,
.no_wait_gpu = false .no_wait_gpu = false
...@@ -578,7 +580,7 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr) ...@@ -578,7 +580,7 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)
int ret; int ret;
list_for_each_entry(entry, &ctx->bo_list, base.head) { list_for_each_entry(entry, &ctx->bo_list, base.head) {
struct vmw_buffer_object *vbo = struct vmw_bo *vbo =
container_of(entry->base.bo, typeof(*vbo), base); container_of(entry->base.bo, typeof(*vbo), base);
if (entry->cpu_blit) { if (entry->cpu_blit) {
...@@ -639,7 +641,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr) ...@@ -639,7 +641,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)
list_for_each_entry(val, &ctx->resource_list, head) { list_for_each_entry(val, &ctx->resource_list, head) {
struct vmw_resource *res = val->res; struct vmw_resource *res = val->res;
struct vmw_buffer_object *backup = res->backup; struct vmw_bo *backup = res->backup;
ret = vmw_resource_validate(res, intr, val->dirty_set && ret = vmw_resource_validate(res, intr, val->dirty_set &&
val->dirty); val->dirty);
...@@ -651,7 +653,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr) ...@@ -651,7 +653,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)
/* Check if the resource switched backup buffer */ /* Check if the resource switched backup buffer */
if (backup && res->backup && (backup != res->backup)) { if (backup && res->backup && (backup != res->backup)) {
struct vmw_buffer_object *vbo = res->backup; struct vmw_bo *vbo = res->backup;
ret = vmw_validation_add_bo ret = vmw_validation_add_bo
(ctx, vbo, vmw_resource_needs_backup(res), (ctx, vbo, vmw_resource_needs_backup(res),
...@@ -889,7 +891,7 @@ void vmw_validation_bo_backoff(struct vmw_validation_context *ctx) ...@@ -889,7 +891,7 @@ void vmw_validation_bo_backoff(struct vmw_validation_context *ctx)
list_for_each_entry(entry, &ctx->bo_list, base.head) { list_for_each_entry(entry, &ctx->bo_list, base.head) {
if (entry->coherent_count) { if (entry->coherent_count) {
unsigned int coherent_count = entry->coherent_count; unsigned int coherent_count = entry->coherent_count;
struct vmw_buffer_object *vbo = struct vmw_bo *vbo =
container_of(entry->base.bo, typeof(*vbo), container_of(entry->base.bo, typeof(*vbo),
base); base);
......
...@@ -73,7 +73,7 @@ struct vmw_validation_context { ...@@ -73,7 +73,7 @@ struct vmw_validation_context {
size_t total_mem; size_t total_mem;
}; };
struct vmw_buffer_object; struct vmw_bo;
struct vmw_resource; struct vmw_resource;
struct vmw_fence_obj; struct vmw_fence_obj;
...@@ -159,7 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) ...@@ -159,7 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val)
} }
int vmw_validation_add_bo(struct vmw_validation_context *ctx, int vmw_validation_add_bo(struct vmw_validation_context *ctx,
struct vmw_buffer_object *vbo, struct vmw_bo *vbo,
bool as_mob, bool cpu_blit); bool as_mob, bool cpu_blit);
int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo,
bool interruptible, bool interruptible,
...@@ -179,7 +179,7 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx, ...@@ -179,7 +179,7 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx,
bool backoff); bool backoff);
void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx, void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx,
void *val_private, void *val_private,
struct vmw_buffer_object *vbo, struct vmw_bo *vbo,
unsigned long backup_offset); unsigned long backup_offset);
int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr); int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment