Skip to content

Commit b4945bb

Browse files
zackrkerneltoast
authored andcommitted
drm/vmwgfx: Rename vmw_buffer_object to vmw_bo
The rest of the drivers which are using ttm have mostly standardized on driver_prefix_bo as the name for subclasses of the TTM buffer object. Make vmwgfx match the rest of the drivers and follow the same naming semantics. This is especially clear given that the name of the file in which the object was defined is vmw_bo.c. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: Martin Krastev <[email protected]> Reviewed-by: Maaz Mombasawala <[email protected]> Acked-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 96d1eac commit b4945bb

25 files changed

+418
-381
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0 OR MIT
22
/**************************************************************************
33
*
4-
* Copyright © 2011-2018 VMware, Inc., Palo Alto, CA., USA
4+
* Copyright © 2011-2023 VMware, Inc., Palo Alto, CA., USA
55
* All Rights Reserved.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,55 +26,41 @@
2626
*
2727
**************************************************************************/
2828

29-
#include <drm/ttm/ttm_placement.h>
30-
29+
#include "vmwgfx_bo.h"
3130
#include "vmwgfx_drv.h"
32-
#include "ttm_object.h"
3331

3432

35-
/**
36-
* vmw_buffer_object - Convert a struct ttm_buffer_object to a struct
37-
* vmw_buffer_object.
38-
*
39-
* @bo: Pointer to the TTM buffer object.
40-
* Return: Pointer to the struct vmw_buffer_object embedding the
41-
* TTM buffer object.
42-
*/
43-
static struct vmw_buffer_object *
44-
vmw_buffer_object(struct ttm_buffer_object *bo)
45-
{
46-
return container_of(bo, struct vmw_buffer_object, base);
47-
}
33+
#include <drm/ttm/ttm_placement.h>
4834

4935
/**
50-
* vmw_bo_bo_free - vmw buffer object destructor
36+
* vmw_bo_free - vmw_bo destructor
5137
*
5238
* @bo: Pointer to the embedded struct ttm_buffer_object
5339
*/
54-
static void vmw_bo_bo_free(struct ttm_buffer_object *bo)
40+
static void vmw_bo_free(struct ttm_buffer_object *bo)
5541
{
56-
struct vmw_buffer_object *vmw_bo = vmw_buffer_object(bo);
42+
struct vmw_bo *vbo = to_vmw_bo(&bo->base);
5743

58-
WARN_ON(vmw_bo->dirty);
59-
WARN_ON(!RB_EMPTY_ROOT(&vmw_bo->res_tree));
60-
vmw_bo_unmap(vmw_bo);
44+
WARN_ON(vbo->dirty);
45+
WARN_ON(!RB_EMPTY_ROOT(&vbo->res_tree));
46+
vmw_bo_unmap(vbo);
6147
drm_gem_object_release(&bo->base);
62-
kfree(vmw_bo);
48+
kfree(vbo);
6349
}
6450

6551
/**
66-
* bo_is_vmw - check if the buffer object is a &vmw_buffer_object
52+
* bo_is_vmw - check if the buffer object is a &vmw_bo
6753
* @bo: ttm buffer object to be checked
6854
*
6955
* Uses destroy function associated with the object to determine if this is
70-
* a &vmw_buffer_object.
56+
* a &vmw_bo.
7157
*
7258
* Returns:
73-
* true if the object is of &vmw_buffer_object type, false if not.
59+
* true if the object is of &vmw_bo type, false if not.
7460
*/
7561
static bool bo_is_vmw(struct ttm_buffer_object *bo)
7662
{
77-
return bo->destroy == &vmw_bo_bo_free;
63+
return bo->destroy == &vmw_bo_free;
7864
}
7965

8066
/**
@@ -88,7 +74,7 @@ static bool bo_is_vmw(struct ttm_buffer_object *bo)
8874
* -ERESTARTSYS if interrupted by a signal
8975
*/
9076
int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,
91-
struct vmw_buffer_object *buf,
77+
struct vmw_bo *buf,
9278
struct ttm_placement *placement,
9379
bool interruptible)
9480
{
@@ -130,7 +116,7 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,
130116
* -ERESTARTSYS if interrupted by a signal
131117
*/
132118
int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
133-
struct vmw_buffer_object *buf,
119+
struct vmw_bo *buf,
134120
bool interruptible)
135121
{
136122
struct ttm_operation_ctx ctx = {interruptible, false };
@@ -178,7 +164,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
178164
* -ERESTARTSYS if interrupted by a signal
179165
*/
180166
int vmw_bo_pin_in_vram(struct vmw_private *dev_priv,
181-
struct vmw_buffer_object *buf,
167+
struct vmw_bo *buf,
182168
bool interruptible)
183169
{
184170
return vmw_bo_pin_in_placement(dev_priv, buf, &vmw_vram_placement,
@@ -199,7 +185,7 @@ int vmw_bo_pin_in_vram(struct vmw_private *dev_priv,
199185
* -ERESTARTSYS if interrupted by a signal
200186
*/
201187
int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,
202-
struct vmw_buffer_object *buf,
188+
struct vmw_bo *buf,
203189
bool interruptible)
204190
{
205191
struct ttm_operation_ctx ctx = {interruptible, false };
@@ -263,7 +249,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,
263249
* -ERESTARTSYS if interrupted by a signal
264250
*/
265251
int vmw_bo_unpin(struct vmw_private *dev_priv,
266-
struct vmw_buffer_object *buf,
252+
struct vmw_bo *buf,
267253
bool interruptible)
268254
{
269255
struct ttm_buffer_object *bo = &buf->base;
@@ -308,7 +294,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,
308294
* @pin: Whether to pin or unpin.
309295
*
310296
*/
311-
void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin)
297+
void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin)
312298
{
313299
struct ttm_operation_ctx ctx = { false, true };
314300
struct ttm_place pl;
@@ -356,7 +342,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin)
356342
* 3) Buffer object destruction
357343
*
358344
*/
359-
void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo)
345+
void *vmw_bo_map_and_cache(struct vmw_bo *vbo)
360346
{
361347
struct ttm_buffer_object *bo = &vbo->base;
362348
bool not_used;
@@ -381,9 +367,9 @@ void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo)
381367
* @vbo: The buffer object whose map we are tearing down.
382368
*
383369
* This function tears down a cached map set up using
384-
* vmw_buffer_object_map_and_cache().
370+
* vmw_bo_map_and_cache().
385371
*/
386-
void vmw_bo_unmap(struct vmw_buffer_object *vbo)
372+
void vmw_bo_unmap(struct vmw_bo *vbo)
387373
{
388374
if (vbo->map.bo == NULL)
389375
return;
@@ -447,7 +433,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,
447433
int vmw_bo_create(struct vmw_private *vmw,
448434
size_t size, struct ttm_placement *placement,
449435
bool interruptible, bool pin,
450-
struct vmw_buffer_object **p_bo)
436+
struct vmw_bo **p_bo)
451437
{
452438
int ret;
453439

@@ -473,7 +459,7 @@ int vmw_bo_create(struct vmw_private *vmw,
473459
* vmw_bo_init - Initialize a vmw buffer object
474460
*
475461
* @dev_priv: Pointer to the device private struct
476-
* @vmw_bo: Pointer to the struct vmw_buffer_object to initialize.
462+
* @vmw_bo: Pointer to the struct vmw_bo to initialize.
477463
* @size: Buffer object size in bytes.
478464
* @placement: Initial placement.
479465
* @interruptible: Whether waits should be performed interruptible.
@@ -483,7 +469,7 @@ int vmw_bo_create(struct vmw_private *vmw,
483469
* Note that on error, the code will free the buffer object.
484470
*/
485471
int vmw_bo_init(struct vmw_private *dev_priv,
486-
struct vmw_buffer_object *vmw_bo,
472+
struct vmw_bo *vmw_bo,
487473
size_t size, struct ttm_placement *placement,
488474
bool interruptible, bool pin)
489475
{
@@ -506,7 +492,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,
506492
ret = ttm_bo_init_reserved(bdev, &vmw_bo->base, size,
507493
ttm_bo_type_device,
508494
placement,
509-
0, &ctx, NULL, NULL, vmw_bo_bo_free);
495+
0, &ctx, NULL, NULL, vmw_bo_free);
510496
if (unlikely(ret)) {
511497
return ret;
512498
}
@@ -519,7 +505,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,
519505
}
520506

521507
/**
522-
* vmw_user_bo_synccpu_grab - Grab a struct vmw_buffer_object for cpu
508+
* vmw_user_bo_synccpu_grab - Grab a struct vmw_bo for cpu
523509
* access, idling previous GPU operations on the buffer and optionally
524510
* blocking it for further command submissions.
525511
*
@@ -532,7 +518,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,
532518
*
533519
* A blocking grab will be automatically released when @tfile is closed.
534520
*/
535-
static int vmw_user_bo_synccpu_grab(struct vmw_buffer_object *vmw_bo,
521+
static int vmw_user_bo_synccpu_grab(struct vmw_bo *vmw_bo,
536522
uint32_t flags)
537523
{
538524
bool nonblock = !!(flags & drm_vmw_synccpu_dontblock);
@@ -579,7 +565,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,
579565
uint32_t handle,
580566
uint32_t flags)
581567
{
582-
struct vmw_buffer_object *vmw_bo;
568+
struct vmw_bo *vmw_bo;
583569
int ret = vmw_user_bo_lookup(filp, handle, &vmw_bo);
584570

585571
if (!ret) {
@@ -611,7 +597,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
611597
{
612598
struct drm_vmw_synccpu_arg *arg =
613599
(struct drm_vmw_synccpu_arg *) data;
614-
struct vmw_buffer_object *vbo;
600+
struct vmw_bo *vbo;
615601
int ret;
616602

617603
if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0
@@ -685,14 +671,14 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,
685671
* @filp: The file the handle is registered with.
686672
* @handle: The user buffer object handle
687673
* @out: Pointer to a where a pointer to the embedded
688-
* struct vmw_buffer_object should be placed.
674+
* struct vmw_bo should be placed.
689675
* Return: Zero on success, Negative error code on error.
690676
*
691677
* The vmw buffer object pointer will be refcounted (both ttm and gem)
692678
*/
693679
int vmw_user_bo_lookup(struct drm_file *filp,
694680
uint32_t handle,
695-
struct vmw_buffer_object **out)
681+
struct vmw_bo **out)
696682
{
697683
struct drm_gem_object *gobj;
698684

@@ -703,7 +689,7 @@ int vmw_user_bo_lookup(struct drm_file *filp,
703689
return -ESRCH;
704690
}
705691

706-
*out = gem_to_vmw_bo(gobj);
692+
*out = to_vmw_bo(gobj);
707693
ttm_bo_get(&(*out)->base);
708694

709695
return 0;
@@ -762,7 +748,7 @@ int vmw_dumb_create(struct drm_file *file_priv,
762748
struct drm_mode_create_dumb *args)
763749
{
764750
struct vmw_private *dev_priv = vmw_priv(dev);
765-
struct vmw_buffer_object *vbo;
751+
struct vmw_bo *vbo;
766752
int ret;
767753

768754
args->pitch = args->width * ((args->bpp + 7) / 8);
@@ -783,12 +769,12 @@ int vmw_dumb_create(struct drm_file *file_priv,
783769
*/
784770
void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
785771
{
786-
/* Is @bo embedded in a struct vmw_buffer_object? */
772+
/* Is @bo embedded in a struct vmw_bo? */
787773
if (!bo_is_vmw(bo))
788774
return;
789775

790776
/* Kill any cached kernel maps before swapout */
791-
vmw_bo_unmap(vmw_buffer_object(bo));
777+
vmw_bo_unmap(to_vmw_bo(&bo->base));
792778
}
793779

794780

@@ -805,13 +791,13 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)
805791
void vmw_bo_move_notify(struct ttm_buffer_object *bo,
806792
struct ttm_resource *mem)
807793
{
808-
struct vmw_buffer_object *vbo;
794+
struct vmw_bo *vbo;
809795

810-
/* Make sure @bo is embedded in a struct vmw_buffer_object? */
796+
/* Make sure @bo is embedded in a struct vmw_bo? */
811797
if (!bo_is_vmw(bo))
812798
return;
813799

814-
vbo = container_of(bo, struct vmw_buffer_object, base);
800+
vbo = container_of(bo, struct vmw_bo, base);
815801

816802
/*
817803
* Kill any cached kernel maps before move to or from VRAM.

0 commit comments

Comments
 (0)