drm/vmwgfx: Refactor the buffer object code
Subsystems (3)
v2 cover drm/vmwgfx: Refactor the buffer object code
From: Zack Rusin <[email protected]>
v2: Fix all the issues which Thomas pointed out in the initial review and split the "simplify fb pinning" change into two commits with the second one being just the rename.
The series refactors the buffer object code to make more alike the other ttm drivers. The placement becomes a property of the bo which makes it a lot easier to correctly validate based on the current usage. vmwgfx tends to do more validation due to forced moves, because the buffer placement sometimes need to change due to userspace commands, i.e. some commands e.g. SURFACE_DMA implies GMR's which are really deprecated in favor of MOB's, but the x11 driver still uses GMR's so buffers tend to flip between GMR's and MOB's a bit when running on X11.
The functionality remains largely unchanged, but the LOC are reduced by about 400 and the groundwork is done for adding prime support with SG ttm buffers.
Zack Rusin (8):
drm/vmwgfx: Use the common gem mmap instead of the custom code drm/vmwgfx: Remove the duplicate bo_free function drm/vmwgfx: Rename vmw_buffer_object to vmw_bo drm/vmwgfx: Simplify fb pinning
drm/vmwgfx: Cleanup the vmw bo usage in the cursor paths drm/vmwgfx: Rename dummy to is_iomem
drm/vmwgfx: Abstract placement selection
drm/vmwgfx: Stop using raw ttm_buffer_object's
drivers/gpu/drm/vmwgfx/Makefile | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 392 +++++++++--------- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 203 +++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 14 +- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 53 +-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 36 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 65 +-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 26 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 245 +++-------- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 102 +++-- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 89 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 230 ++++------ drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 43 +- drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 57 ++- drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 45 +- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 20 +- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 68 ++- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 243 +++++------ drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 10 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 53 +-- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 65 +-- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 323 ++------------- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 20 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 111 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 116 +----- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 110 ----- drivers/gpu/drm/vmwgfx/vmwgfx_va.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 150 +++---- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 10 +- 31 files changed, 1248 insertions(+), 1667 deletions(-) create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_bo.h delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
Signature · 1 line
2.38.1
PATCH v2 1/8 drm/vmwgfx: Use the common gem mmap instead of the custom code
From: Zack Rusin <[email protected]>
Before vmwgfx supported gem it needed to implement the entire mmap logic explicitly. With GEM support that's not needed and the generic code can be used by simply setting the vm_ops to vmwgfx specific ones on the gem object itself.
Removes a lot of code from vmwgfx without any functional difference.
--- drivers/gpu/drm/vmwgfx/Makefile | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 -- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 8 ++ drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 110 ----------------------- 5 files changed, 10 insertions(+), 118 deletions(-) delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
drivers/gpu/drm/vmwgfx/Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ vmwgfx_ioctl.o vmwgfx_resource.o vmwgfx_ttm_buffer.o \ - vmwgfx_cmd.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ + vmwgfx_cmd.o vmwgfx_irq.o vmwgfx_ldu.o \ vmwgfx_overlay.o vmwgfx_gmrid_manager.o vmwgfx_fence.o \ vmwgfx_bo.o vmwgfx_scrn.o vmwgfx_context.o \ vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -1
@@ -1566,7 +1566,7 @@ static const struct file_operations vmwgfx_driver_fops = { .open = drm_open, .release = drm_release, .unlocked_ioctl = vmw_unlocked_ioctl, - .mmap = vmw_mmap, + .mmap = drm_gem_mmap, .poll = drm_poll, .read = drm_read,#if defined(CONFIG_COMPAT )
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0 -6
@@ -1053,12 +1053,6 @@ vmw_is_cursor_bypass3_enabled(const struct vmw_private *dev_priv)return (vmw_fifo_caps (dev_priv) &SVGA_FIFO_CAP_CURSOR_BYPASS_3 ) !=0 ; } -/** -* TTM glue - vmwgfx_ttm_glue.c -*/ - -extern int vmw_mmap (struct file *filp,struct vm_area_struct *vma); -/** * TTM buffer object driver - vmwgfx_ttm_buffer.c */
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +8 -0
@@ -103,6 +103,13 @@ static struct sg_table *vmw_gem_object_get_sg_table(struct drm_gem_object *obj)return drm_prime_pages_to_sg (obj->dev, vmw_tt->dma_ttm.pages, vmw_tt->dma_ttm.num_pages); } +static const struct vm_operations_struct vmw_vm_ops = { + .pfn_mkwrite = vmw_bo_vm_mkwrite, + .page_mkwrite = vmw_bo_vm_mkwrite, + .fault = vmw_bo_vm_fault, + .open = ttm_bo_vm_open, + .close = ttm_bo_vm_close, +};static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .free = vmw_gem_object_free,
@@ -115,6 +122,7 @@ static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .vmap = drm_gem_ttm_vmap, .vunmap = drm_gem_ttm_vunmap, .mmap = drm_gem_ttm_mmap, + .vm_ops = &vmw_vm_ops, };/**
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c deleted +0 -110
110 lines not on this page · raw message
Signature · 1 line
2.38.1
Re: [PATCH v2 1/8] drm/vmwgfx: Use the common gem mmap instead of the custom code
From: Martin Krastev <[email protected]>
LGTM
Regards,
Martin
Quoted 206 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Before vmwgfx supported gem it needed to implement the entire mmap logic explicitly. With GEM support that's not needed and the generic code can be used by simply setting the
vm_opsto vmwgfx specific ones on the gem object itself.Removes a lot of code from vmwgfx without any functional difference.
Signed-off-by Zack Rusin <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Reviewed-by Martin Krastev <[email protected]>--- drivers/gpu/drm/vmwgfx/Makefile | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 -- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 8 ++ drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 110 ----------------------- 5 files changed, 10 insertions(+), 118 deletions(-)delete mode 100644
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.cdrivers/gpu/drm/vmwgfx/Makefile +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ vmwgfx_ioctl.o vmwgfx_resource.o vmwgfx_ttm_buffer.o \ - vmwgfx_cmd.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ + vmwgfx_cmd.o vmwgfx_irq.o vmwgfx_ldu.o \ vmwgfx_overlay.o vmwgfx_gmrid_manager.o vmwgfx_fence.o \ vmwgfx_bo.o vmwgfx_scrn.o vmwgfx_context.o \ vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1
-1@@ -1566,7 +1566,7 @@ static const struct file_operations vmwgfx_driver_fops = { .open = drm_open, .release = drm_release, .unlocked_ioctl = vmw_unlocked_ioctl, - .mmap = vmw_mmap, + .mmap = drm_gem_mmap, .poll = drm_poll, .read = drm_read,#if defined(CONFIG_COMPAT )drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0
-6@@ -1053,12 +1053,6 @@ vmw_is_cursor_bypass3_enabled(const struct vmw_private *dev_priv)return (vmw_fifo_caps (dev_priv) &SVGA_FIFO_CAP_CURSOR_BYPASS_3 ) !=0 ; } -/** -* TTM glue - vmwgfx_ttm_glue.c -*/ - -extern int vmw_mmap (struct file *filp,struct vm_area_struct *vma); -/** * TTM buffer object driver - vmwgfx_ttm_buffer.c */ drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +8
-0@@ -103,6 +103,13 @@ static struct sg_table *vmw_gem_object_get_sg_table(struct drm_gem_object *obj)return drm_prime_pages_to_sg (obj->dev, vmw_tt->dma_ttm.pages, vmw_tt->dma_ttm.num_pages); } +static const struct vm_operations_struct vmw_vm_ops = { + .pfn_mkwrite = vmw_bo_vm_mkwrite, + .page_mkwrite = vmw_bo_vm_mkwrite, + .fault = vmw_bo_vm_fault, + .open = ttm_bo_vm_open, + .close = ttm_bo_vm_close, +};static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .free = vmw_gem_object_free,@@ -115,6 +122,7 @@ static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .vmap = drm_gem_ttm_vmap, .vunmap = drm_gem_ttm_vunmap, .mmap = drm_gem_ttm_mmap, + .vm_ops = &vmw_vm_ops, };/** drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c deleted +0
-110@@ -1,110 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT -/************************************************************************** -* -* Copyright 2009-2011 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. -* -**************************************************************************/ - -#include "vmwgfx_drv.h" - -static int vmw_bo_vm_lookup (struct ttm_device *bdev, -struct drm_file *filp, -unsigned long offset, -unsigned long pages, -struct ttm_buffer_object **p_bo) -{ - struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, bdev); -struct drm_device *drm = &dev_priv->drm; -struct drm_vma_offset_node *node; -int ret; - - *p_bo =NULL ; - -drm_vma_offset_lock_lookup (bdev->vma_manager); - - node =drm_vma_offset_lookup_locked (bdev->vma_manager, offset, pages); -if (likely (node)) { - *p_bo = container_of(node, struct ttm_buffer_object, - base.vma_node); - *p_bo =ttm_bo_get_unless_zero (*p_bo); - } - -drm_vma_offset_unlock_lookup (bdev->vma_manager); - -if (!*p_bo) { -drm_err (drm,"Could not find buffer object to map\n" ); -return -EINVAL ; - } - -if (!drm_vma_node_is_allowed (node, filp)) { - ret = -EACCES ; - goto out_no_access; - } - -return 0 ; -out_no_access: -ttm_bo_put (*p_bo); -return ret; -} - -int vmw_mmap (struct file *filp,struct vm_area_struct *vma) -{ -static const struct vm_operations_struct vmw_vm_ops = { - .pfn_mkwrite = vmw_bo_vm_mkwrite, - .page_mkwrite = vmw_bo_vm_mkwrite, - .fault = vmw_bo_vm_fault, - .open = ttm_bo_vm_open, - .close = ttm_bo_vm_close, - }; -struct drm_file *file_priv = filp->private_data; -struct vmw_private *dev_priv =vmw_priv (file_priv->minor->dev); -struct ttm_device *bdev = &dev_priv->bdev; -struct ttm_buffer_object *bo; -int ret; - -if (unlikely (vma->vm_pgoff <DRM_FILE_PAGE_OFFSET_START )) -return -EINVAL ; - - ret =vmw_bo_vm_lookup (bdev, file_priv, vma->vm_pgoff,vma_pages (vma), &bo); -if (unlikely (ret !=0 )) -return ret; - - ret =ttm_bo_mmap_obj (vma, bo); -if (unlikely (ret !=0 )) - goto out_unref; - - vma->vm_ops = &vmw_vm_ops; - -/* Use VM_PFNMAP rather than VM_MIXEDMAP if not a COW mapping */ -if (!is_cow_mapping (vma->vm_flags)) - vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP ) |VM_PFNMAP ; - -ttm_bo_put (bo);/* release extra ref taken by ttm_bo_mmap_obj() */ - -return 0 ; - -out_unref: -ttm_bo_put (bo); -return ret; -} -
Re: [PATCH v2 1/8] drm/vmwgfx: Use the common gem mmap instead of the custom code
In reply to Zack RusinQuoted 196 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Before vmwgfx supported gem it needed to implement the entire mmap logic explicitly. With GEM support that's not needed and the generic code can be used by simply setting the
vm_opsto vmwgfx specific ones on the gem object itself.Removes a lot of code from vmwgfx without any functional difference.
Signed-off-by Zack Rusin <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Reviewed-by Martin Krastev <[email protected]>--- drivers/gpu/drm/vmwgfx/Makefile | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 -- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 8 ++ drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 110 ----------------------- 5 files changed, 10 insertions(+), 118 deletions(-) delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.cdrivers/gpu/drm/vmwgfx/Makefile +1
-1@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ vmwgfx_ioctl.o vmwgfx_resource.o vmwgfx_ttm_buffer.o \ - vmwgfx_cmd.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ + vmwgfx_cmd.o vmwgfx_irq.o vmwgfx_ldu.o \ vmwgfx_overlay.o vmwgfx_gmrid_manager.o vmwgfx_fence.o \ vmwgfx_bo.o vmwgfx_scrn.o vmwgfx_context.o \ vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1
-1@@ -1566,7 +1566,7 @@ static const struct file_operations vmwgfx_driver_fops = { .open = drm_open, .release = drm_release, .unlocked_ioctl = vmw_unlocked_ioctl, - .mmap = vmw_mmap, + .mmap = drm_gem_mmap, .poll = drm_poll, .read = drm_read,#if defined(CONFIG_COMPAT )drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0
-6@@ -1053,12 +1053,6 @@ vmw_is_cursor_bypass3_enabled(const struct vmw_private *dev_priv)return (vmw_fifo_caps (dev_priv) &SVGA_FIFO_CAP_CURSOR_BYPASS_3 ) !=0 ; } -/** -* TTM glue - vmwgfx_ttm_glue.c -*/ - -extern int vmw_mmap (struct file *filp,struct vm_area_struct *vma); -/** * TTM buffer object driver - vmwgfx_ttm_buffer.c */ drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +8
-0@@ -103,6 +103,13 @@ static struct sg_table *vmw_gem_object_get_sg_table(struct drm_gem_object *obj)return drm_prime_pages_to_sg (obj->dev, vmw_tt->dma_ttm.pages, vmw_tt->dma_ttm.num_pages); } +static const struct vm_operations_struct vmw_vm_ops = { + .pfn_mkwrite = vmw_bo_vm_mkwrite, + .page_mkwrite = vmw_bo_vm_mkwrite, + .fault = vmw_bo_vm_fault, + .open = ttm_bo_vm_open, + .close = ttm_bo_vm_close, +};static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .free = vmw_gem_object_free,@@ -115,6 +122,7 @@ static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .vmap = drm_gem_ttm_vmap, .vunmap = drm_gem_ttm_vunmap, .mmap = drm_gem_ttm_mmap, + .vm_ops = &vmw_vm_ops, };/** drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c deleted +0
-100@@ -1,110 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT -/************************************************************************** -* -* Copyright 2009-2011 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. -* -**************************************************************************/ - -#include "vmwgfx_drv.h" - -static int vmw_bo_vm_lookup (struct ttm_device *bdev, -struct drm_file *filp, -unsigned long offset, -unsigned long pages, -struct ttm_buffer_object **p_bo) -{ - struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, bdev); -struct drm_device *drm = &dev_priv->drm; -struct drm_vma_offset_node *node; -int ret; - - *p_bo =NULL ; - -drm_vma_offset_lock_lookup (bdev->vma_manager); - - node =drm_vma_offset_lookup_locked (bdev->vma_manager, offset, pages); -if (likely (node)) { - *p_bo = container_of(node, struct ttm_buffer_object, - base.vma_node); - *p_bo =ttm_bo_get_unless_zero (*p_bo); - } - -drm_vma_offset_unlock_lookup (bdev->vma_manager); - -if (!*p_bo) { -drm_err (drm,"Could not find buffer object to map\n" ); -return -EINVAL ; - } - -if (!drm_vma_node_is_allowed (node, filp)) { - ret = -EACCES ; - goto out_no_access; - } - -return 0 ; -out_no_access: -ttm_bo_put (*p_bo); -return ret; -} - -int vmw_mmap (struct file *filp,struct vm_area_struct *vma) -{ -static const struct vm_operations_struct vmw_vm_ops = { - .pfn_mkwrite = vmw_bo_vm_mkwrite, - .page_mkwrite = vmw_bo_vm_mkwrite, - .fault = vmw_bo_vm_fault, - .open = ttm_bo_vm_open, - .close = ttm_bo_vm_close, - }; -struct drm_file *file_priv = filp->private_data; -struct vmw_private *dev_priv =vmw_priv (file_priv->minor->dev); -struct ttm_device *bdev = &dev_priv->bdev; -struct ttm_buffer_object *bo; -int ret; - -if (unlikely (vma->vm_pgoff <DRM_FILE_PAGE_OFFSET_START )) -return -EINVAL ; - - ret =vmw_bo_vm_lookup (bdev, file_priv, vma->vm_pgoff,vma_pages (vma), &bo); -if (unlikely (ret !=0 )) -return ret; - - ret =ttm_bo_mmap_obj (vma, bo); -if (unlikely (ret !=0 )) - goto out_unref; - - vma->vm_ops = &vmw_vm_ops; - -/* Use VM_PFNMAP rather than VM_MIXEDMAP if not a COW mapping */ -if (!is_cow_mapping (vma->vm_flags)) - vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP ) |VM_PFNMAP ;
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c line 110
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c deleted +0
-10- -ttm_bo_put (bo);/* release extra ref taken by ttm_bo_mmap_obj() */ - -return 0 ; - -out_unref: -ttm_bo_put (bo); -return ret; -} -
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 2/8 drm/vmwgfx: Remove the duplicate bo_free function
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Remove the explicit bo_free parameter which was switching between vmw_bo_bo_free and vmw_gem_destroy which had exactly the same implementation.
It makes no sense to keep parameter which is always the same, remove it and all code referencing it. Instead use the vmw_bo_bo_free directly.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 49 ++++++++++-------------- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 +-- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 18 +-------- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 2 +- 8 files changed, 27 insertions(+), 58 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +20 -29
@@ -46,6 +46,22 @@ 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 +* +* @bo: Pointer to the embedded struct ttm_buffer_object +*/ +static void vmw_bo_bo_free (struct ttm_buffer_object *bo) +{ +struct vmw_buffer_object *vmw_bo =vmw_buffer_object (bo); + +WARN_ON (vmw_bo->dirty); +WARN_ON (!RB_EMPTY_ROOT (&vmw_bo->res_tree)); +vmw_bo_unmap (vmw_bo); +drm_gem_object_release (&bo->base); +kfree (vmw_bo); +} +/** * bo_is_vmw - check if the buffer object is a &vmw_buffer_object * @bo: ttm buffer object to be checked
@@ -58,8 +74,7 @@ vmw_buffer_object(struct ttm_buffer_object *bo)*/ static bool bo_is_vmw (struct ttm_buffer_object *bo) { -return bo->destroy == &vmw_bo_bo_free || - bo->destroy == &vmw_gem_destroy; +return bo->destroy == &vmw_bo_bo_free; }/**
@@ -376,23 +391,6 @@ void vmw_bo_unmap(struct vmw_buffer_object *vbo)ttm_bo_kunmap (&vbo->map); } - -/** -* vmw_bo_bo_free - vmw buffer object destructor -* -* @bo: Pointer to the embedded struct ttm_buffer_object -*/ -void vmw_bo_bo_free (struct ttm_buffer_object *bo) -{ -struct vmw_buffer_object *vmw_bo =vmw_buffer_object (bo); - -WARN_ON (vmw_bo->dirty); -WARN_ON (!RB_EMPTY_ROOT (&vmw_bo->res_tree)); -vmw_bo_unmap (vmw_bo); -drm_gem_object_release (&bo->base); -kfree (vmw_bo); -} -/* default destructor */ static void vmw_bo_default_destroy (struct ttm_buffer_object *bo) {
@@ -449,13 +447,10 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,int vmw_bo_create (struct vmw_private *vmw,size_t size,struct ttm_placement *placement,bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo),struct vmw_buffer_object **p_bo) {int ret; -BUG_ON (!bo_free); - *p_bo =kmalloc (sizeof (**p_bo),GFP_KERNEL );if (unlikely (!*p_bo)) {DRM_ERROR ("Failed to allocate a buffer.\n" );
@@ -463,8 +458,7 @@ int vmw_bo_create(struct vmw_private *vmw, } ret =vmw_bo_init (vmw, *p_bo, size, - placement, interruptible, pin, - bo_free); + placement, interruptible, pin);if (unlikely (ret !=0 )) goto out_error;
@@ -484,7 +478,6 @@ int vmw_bo_create(struct vmw_private *vmw,* @placement: Initial placement. * @interruptible: Whether waits should be performed interruptible. * @pin: If the BO should be created pinned at a fixed location. -* @bo_free: The buffer object destructor. * Returns: Zero on success, negative error code on error. * * Note that on error, the code will free the buffer object.
@@ -492,8 +485,7 @@ int vmw_bo_create(struct vmw_private *vmw,int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_buffer_object *vmw_bo,size_t size,struct ttm_placement *placement, -bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo)) +bool interruptible,bool pin) {struct ttm_operation_ctx ctx = { .interruptible = interruptible,
@@ -503,7 +495,6 @@ int vmw_bo_init(struct vmw_private *dev_priv,struct drm_device *vdev = &dev_priv->drm;int ret; -WARN_ON_ONCE (!bo_free);memset (vmw_bo,0 ,sizeof (*vmw_bo));BUILD_BUG_ON (TTM_MAX_BO_PRIORITY <=3 ); vmw_bo->base.priority =3 ;
@@ -513,7 +504,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - placement,0 , &ctx,NULL ,NULL , bo_free); + placement,0 , &ctx,NULL ,NULL , vmw_bo_bo_free);if (unlikely (ret)) {return ret; }
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +1 -1
@@ -424,7 +424,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)* we can use tryreserve without failure. */ ret =vmw_bo_create (dev_priv, new_size, &vmw_mob_placement, - true, true, vmw_bo_bo_free, &buf); + true, true, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" ); goto out_done;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -2
@@ -398,8 +398,7 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)* user of the bo currently. */ ret =vmw_bo_create (dev_priv,PAGE_SIZE , - &vmw_sys_placement, false, true, - &vmw_bo_bo_free, &vbo); + &vmw_sys_placement, false, true, &vbo);if (unlikely (ret !=0 ))return ret;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -5
@@ -891,7 +891,6 @@ extern int vmw_bo_unpin(struct vmw_private *vmw_priv,extern void vmw_bo_get_guest_ptr (const struct ttm_buffer_object *buf,SVGAGuestPtr *ptr);extern void vmw_bo_pin_reserved (struct vmw_buffer_object *bo,bool pin); -extern void vmw_bo_bo_free (struct ttm_buffer_object *bo); extern int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, struct ttm_placement *placement,
@@ -899,13 +898,11 @@ extern int vmw_bo_create_kernel(struct vmw_private *dev_priv,extern int vmw_bo_create (struct vmw_private *dev_priv,size_t size,struct ttm_placement *placement,bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo),struct vmw_buffer_object **p_bo);extern int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_buffer_object *vmw_bo,size_t size,struct ttm_placement *placement, -bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo)); +bool interruptible,bool pin);extern int vmw_bo_unref_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); extern int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,
@@ -980,7 +977,6 @@ extern int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, struct vmw_buffer_object **p_vbo);extern int vmw_gem_object_create_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); -extern void vmw_gem_destroy (struct ttm_buffer_object *bo);extern void vmw_debugfs_gem_init (struct vmw_private *vdev);/**
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +1 -17
@@ -125,22 +125,6 @@ static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .vm_ops = &vmw_vm_ops, }; -/** -* vmw_gem_destroy - vmw buffer object destructor -* -* @bo: Pointer to the embedded struct ttm_buffer_object -*/ -void vmw_gem_destroy (struct ttm_buffer_object *bo) -{ -struct vmw_buffer_object *vbo =vmw_buffer_object (bo); - -WARN_ON (vbo->dirty); -WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree)); -vmw_bo_unmap (vbo); -drm_gem_object_release (&vbo->base.base); -kfree (vbo); -} - int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, struct drm_file *filp, uint32_t size,
@@ -153,7 +137,7 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, (dev_priv->has_mob) ? &vmw_sys_placement : &vmw_vram_sys_placement, - true, false, &vmw_gem_destroy, p_vbo); + true, false, p_vbo); (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;if (ret !=0 )
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +1 -2
@@ -332,8 +332,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, ret =vmw_bo_create (res->dev_priv, res->backup_size, res->func->backup_placement, - interruptible, false, - &vmw_bo_bo_free, &backup); + interruptible, false, &backup);if (unlikely (ret !=0 )) goto out_no_bo;
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1 -1
@@ -445,7 +445,7 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,vmw_overlay_pause_all (dev_priv); ret =vmw_bo_create (dev_priv, size, &vmw_vram_placement, - false, true, &vmw_bo_bo_free, &vps->bo); + false, true, &vps->bo);vmw_overlay_resume_all (dev_priv);if (ret) { vps->bo =NULL ;/* vmw_bo_init frees on error */
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +1 -1
@@ -893,7 +893,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,return -EINVAL ; ret =vmw_bo_create (dev_priv, size, &vmw_sys_placement, - true, true, vmw_bo_bo_free, &buf); + true, true, &buf);if (unlikely (ret !=0 )) goto out;
Signature · 1 line
2.38.1
Re: [PATCH v2 2/8] drm/vmwgfx: Remove the duplicate bo_free function
Quoted 272 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Remove the explicit
bo_freeparameter which was switching betweenvmw_bo_bo_freeandvmw_gem_destroywhich had exactly the same implementation.It makes no sense to keep parameter which is always the same, remove it and all code referencing it. Instead use the
vmw_bo_bo_freedirectly.Signed-off-by Zack Rusin <[email protected]>Reviewed-by Martin Krastev <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 49 ++++++++++-------------- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 +-- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 18 +-------- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 2 +- 8 files changed, 27 insertions(+), 58 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +20
-29@@ -46,6 +46,22 @@ 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 +* +* @bo: Pointer to the embedded struct ttm_buffer_object +*/ +static void vmw_bo_bo_free (struct ttm_buffer_object *bo) +{ +struct vmw_buffer_object *vmw_bo =vmw_buffer_object (bo); + +WARN_ON (vmw_bo->dirty); +WARN_ON (!RB_EMPTY_ROOT (&vmw_bo->res_tree)); +vmw_bo_unmap (vmw_bo); +drm_gem_object_release (&bo->base); +kfree (vmw_bo); +} +/** * bo_is_vmw - check if the buffer object is a &vmw_buffer_object * @bo: ttm buffer object to be checked @@ -58,8 +74,7 @@ vmw_buffer_object(struct ttm_buffer_object *bo)*/ static bool bo_is_vmw (struct ttm_buffer_object *bo) { -return bo->destroy == &vmw_bo_bo_free || - bo->destroy == &vmw_gem_destroy; +return bo->destroy == &vmw_bo_bo_free; }/** @@ -376,23 +391,6 @@ void vmw_bo_unmap(struct vmw_buffer_object *vbo)ttm_bo_kunmap (&vbo->map); } - -/** -* vmw_bo_bo_free - vmw buffer object destructor -* -* @bo: Pointer to the embedded struct ttm_buffer_object -*/ -void vmw_bo_bo_free (struct ttm_buffer_object *bo) -{ -struct vmw_buffer_object *vmw_bo =vmw_buffer_object (bo); - -WARN_ON (vmw_bo->dirty); -WARN_ON (!RB_EMPTY_ROOT (&vmw_bo->res_tree)); -vmw_bo_unmap (vmw_bo); -drm_gem_object_release (&bo->base); -kfree (vmw_bo); -} -/* default destructor */ static void vmw_bo_default_destroy (struct ttm_buffer_object *bo) {@@ -449,13 +447,10 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,int vmw_bo_create (struct vmw_private *vmw,size_t size,struct ttm_placement *placement,bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo),struct vmw_buffer_object **p_bo) {int ret; -BUG_ON (!bo_free); - *p_bo =kmalloc (sizeof (**p_bo),GFP_KERNEL );if (unlikely (!*p_bo)) {DRM_ERROR ("Failed to allocate a buffer.\n" );@@ -463,8 +458,7 @@ int vmw_bo_create(struct vmw_private *vmw, } ret =vmw_bo_init (vmw, *p_bo, size, - placement, interruptible, pin, - bo_free); + placement, interruptible, pin);if (unlikely (ret !=0 )) goto out_error;@@ -484,7 +478,6 @@ int vmw_bo_create(struct vmw_private *vmw,* @placement: Initial placement. * @interruptible: Whether waits should be performed interruptible. * @pin: If the BO should be created pinned at a fixed location. -* @bo_free: The buffer object destructor. * Returns: Zero on success, negative error code on error. * * Note that on error, the code will free the buffer object. @@ -492,8 +485,7 @@ int vmw_bo_create(struct vmw_private *vmw,int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_buffer_object *vmw_bo,size_t size,struct ttm_placement *placement, -bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo)) +bool interruptible,bool pin) {struct ttm_operation_ctx ctx = { .interruptible = interruptible,@@ -503,7 +495,6 @@ int vmw_bo_init(struct vmw_private *dev_priv,struct drm_device *vdev = &dev_priv->drm;int ret; -WARN_ON_ONCE (!bo_free);memset (vmw_bo,0 ,sizeof (*vmw_bo));BUILD_BUG_ON (TTM_MAX_BO_PRIORITY <=3 ); vmw_bo->base.priority =3 ;@@ -513,7 +504,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - placement,0 , &ctx,NULL ,NULL , bo_free); + placement,0 , &ctx,NULL ,NULL , vmw_bo_bo_free);if (unlikely (ret)) {return ret; }drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +1
-1@@ -424,7 +424,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)* we can use tryreserve without failure. */ ret =vmw_bo_create (dev_priv, new_size, &vmw_mob_placement, - true, true, vmw_bo_bo_free, &buf); + true, true, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" ); goto out_done;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1
-2@@ -398,8 +398,7 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)* user of the bo currently. */ ret =vmw_bo_create (dev_priv,PAGE_SIZE , - &vmw_sys_placement, false, true, - &vmw_bo_bo_free, &vbo); + &vmw_sys_placement, false, true, &vbo);if (unlikely (ret !=0 ))return ret;drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1
-5@@ -891,7 +891,6 @@ extern int vmw_bo_unpin(struct vmw_private *vmw_priv,extern void vmw_bo_get_guest_ptr (const struct ttm_buffer_object *buf,SVGAGuestPtr *ptr);extern void vmw_bo_pin_reserved (struct vmw_buffer_object *bo,bool pin); -extern void vmw_bo_bo_free (struct ttm_buffer_object *bo); extern int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, struct ttm_placement *placement,@@ -899,13 +898,11 @@ extern int vmw_bo_create_kernel(struct vmw_private *dev_priv,extern int vmw_bo_create (struct vmw_private *dev_priv,size_t size,struct ttm_placement *placement,bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo),struct vmw_buffer_object **p_bo);extern int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_buffer_object *vmw_bo,size_t size,struct ttm_placement *placement, -bool interruptible,bool pin, -void (*bo_free)(struct ttm_buffer_object *bo)); +bool interruptible,bool pin);extern int vmw_bo_unref_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); extern int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,@@ -980,7 +977,6 @@ extern int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, struct vmw_buffer_object **p_vbo);extern int vmw_gem_object_create_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); -extern void vmw_gem_destroy (struct ttm_buffer_object *bo);extern void vmw_debugfs_gem_init (struct vmw_private *vdev);/** drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +1
-17@@ -125,22 +125,6 @@ static const struct drm_gem_object_funcs vmw_gem_object_funcs = { .vm_ops = &vmw_vm_ops, }; -/** -* vmw_gem_destroy - vmw buffer object destructor -* -* @bo: Pointer to the embedded struct ttm_buffer_object -*/ -void vmw_gem_destroy (struct ttm_buffer_object *bo) -{ -struct vmw_buffer_object *vbo =vmw_buffer_object (bo); - -WARN_ON (vbo->dirty); -WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree)); -vmw_bo_unmap (vbo); -drm_gem_object_release (&vbo->base.base); -kfree (vbo); -} - int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, struct drm_file *filp, uint32_t size,@@ -153,7 +137,7 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, (dev_priv->has_mob) ? &vmw_sys_placement : &vmw_vram_sys_placement, - true, false, &vmw_gem_destroy, p_vbo); + true, false, p_vbo); (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;if (ret !=0 )drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +1
-2@@ -332,8 +332,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, ret =vmw_bo_create (res->dev_priv, res->backup_size, res->func->backup_placement, - interruptible, false, - &vmw_bo_bo_free, &backup); + interruptible, false, &backup);if (unlikely (ret !=0 )) goto out_no_bo;drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1
-1@@ -445,7 +445,7 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,vmw_overlay_pause_all (dev_priv); ret =vmw_bo_create (dev_priv, size, &vmw_vram_placement, - false, true, &vmw_bo_bo_free, &vps->bo); + false, true, &vps->bo);vmw_overlay_resume_all (dev_priv);if (ret) { vps->bo =NULL ;/* vmw_bo_init frees on error */ drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +0
-0
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c int vmw_compat_shader_add(struct vmw_private *dev_priv, · line 899
Quoted 8 lines
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +1
-1@@ -893,7 +893,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,return -EINVAL ; ret =vmw_bo_create (dev_priv, size, &vmw_sys_placement, - true, true, vmw_bo_bo_free, &buf); + true, true, &buf);if (unlikely (ret !=0 )) goto out;
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 3/8 drm/vmwgfx: Rename vmw_buffer_object to vmw_bo
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
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.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 94 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 189 +++++++++++++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 10 +- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 184 ++---------------- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 53 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 27 +-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 17 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 12 +- drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 18 +- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 27 +-- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 29 +-- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 13 +- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 30 +-- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 6 +- 25 files changed, 419 insertions(+), 386 deletions(-) create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_bo.h
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +40 -54
@@ -1,7 +1,7 @@// 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. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,55 +26,41 @@* **************************************************************************/ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" -#include "ttm_object.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); -} +#include <drm/ttm/ttm_placement.h> /** -* vmw_bo_bo_free - vmw buffer object destructor +* vmw_bo_free - vmw_bo destructor * * @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 (!RB_EMPTY_ROOT (&vmw_bo->res_tree)); -vmw_bo_unmap (vmw_bo); +WARN_ON (vbo->dirty); +WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree)); +vmw_bo_unmap (vbo);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 * * Uses destroy function associated with the object to determine if this is -* a &vmw_buffer_object. +* a &vmw_bo. * * 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) { -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)* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_placement (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,struct ttm_placement *placement,bool interruptible) {
@@ -130,7 +116,7 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_vram_or_gmr (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false };
@@ -178,7 +164,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_vram (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) { 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,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_start_of_vram (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false };
@@ -263,7 +249,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_unpin (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) {struct ttm_buffer_object *bo = &buf->base;
@@ -308,7 +294,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,* @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_place pl;
@@ -356,7 +342,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin)* 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;bool not_used;
@@ -381,9 +367,9 @@ void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo)* @vbo: The buffer object whose map we are tearing down. * * 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 )return ;
@@ -447,7 +433,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,int vmw_bo_create (struct vmw_private *vmw,size_t size,struct ttm_placement *placement,bool interruptible,bool pin, -struct vmw_buffer_object **p_bo) +struct vmw_bo **p_bo) {int ret;
@@ -473,7 +459,7 @@ int vmw_bo_create(struct vmw_private *vmw,* vmw_bo_init - Initialize a vmw buffer object * * @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. * @placement: Initial placement. * @interruptible: Whether waits should be performed interruptible.
@@ -483,7 +469,7 @@ int vmw_bo_create(struct vmw_private *vmw,* Note that on error, the code will free the buffer object. */ 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,bool interruptible,bool pin) {
@@ -504,7 +490,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); 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)) {return ret; }
@@ -517,7 +503,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 * blocking it for further command submissions. *
@@ -530,7 +516,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,* * 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) {bool nonblock = !!(flags & drm_vmw_synccpu_dontblock);
@@ -577,7 +563,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp, uint32_t handle, uint32_t flags) { -struct vmw_buffer_object *vmw_bo; +struct vmw_bo *vmw_bo;int ret =vmw_user_bo_lookup (filp, handle, &vmw_bo);if (!ret) {
@@ -608,7 +594,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data, {struct drm_vmw_synccpu_arg *arg = (struct drm_vmw_synccpu_arg *) data; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;int ret; if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0
@@ -681,14 +667,14 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,* @filp: The file the handle is registered with. * @handle: The user buffer object handle * @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. * * The vmw buffer object pointer will be refcounted. */ int vmw_user_bo_lookup (struct drm_file *filp,uint32_t handle, -struct vmw_buffer_object **out) +struct vmw_bo **out) {struct drm_gem_object *gobj;
@@ -699,7 +685,7 @@ int vmw_user_bo_lookup(struct drm_file *filp,return -ESRCH ; } - *out =gem_to_vmw_bo (gobj); + *out =to_vmw_bo (gobj);ttm_bo_get (&(*out)->base);drm_gem_object_put (gobj);
@@ -759,7 +745,7 @@ int vmw_dumb_create(struct drm_file *file_priv, struct drm_mode_create_dumb *args) {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 ret;
@@ -793,12 +779,12 @@ int vmw_dumb_create(struct drm_file *file_priv,*/ 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))return ;/* Kill any cached kernel maps before swapout */ -vmw_bo_unmap (vmw_buffer_object (bo)); +vmw_bo_unmap (to_vmw_bo (&bo->base)); }
@@ -815,13 +801,13 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)void vmw_bo_move_notify (struct ttm_buffer_object *bo,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))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.
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h new file +189 -0
189 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c +5 -5
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -24,13 +24,13 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - -#include <linux/sched/signal.h> +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" +#include "vmwgfx_devcaps.h" #include <drm/ttm/ttm_placement.h> -#include "vmwgfx_drv.h" -#include "vmwgfx_devcaps.h" +#include <linux/sched/signal.h> bool vmw_supports_3d (struct vmw_private *dev_priv) {
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +5 -4
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -25,12 +25,13 @@* **************************************************************************/ -#include <linux/dmapool.h> -#include <linux/pci.h> +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" #include <drm/ttm/ttm_bo_api.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
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +6 -5
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -27,9 +27,10 @@#include <drm/ttm/ttm_placement.h> +#include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" -#include "vmwgfx_binding.h" struct vmw_user_context {struct ttm_base_object base;
@@ -38,7 +39,7 @@ struct vmw_user_context {struct vmw_cmdbuf_res_manager *man;struct vmw_resource *cotables[SVGA_COTABLE_MAX ];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);
@@ -853,7 +854,7 @@ vmw_context_binding_state(struct vmw_resource *ctx)* specified in the parameter. 0 otherwise. */ 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 = container_of(ctx_res, struct vmw_user_context, res);
@@ -885,7 +886,7 @@ int vmw_context_bind_dx_query(struct vmw_resource *ctx_res,* * @ctx_res: The context resource */ -struct vmw_buffer_object * +struct vmw_bo *vmw_context_get_dx_query_mob (struct vmw_resource *ctx_res) { struct vmw_user_context *uctx =
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +5 -4
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -30,13 +30,14 @@* whenever the backing MOB is evicted. */ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_mksstat.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h" +#include <drm/ttm/ttm_placement.h> +/** * struct vmw_cotable - Context Object Table resource *
@@ -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 vmw_private *dev_priv = res->dev_priv;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;size_t old_size = res->backup_size;size_t old_size_read_back = vcotbl->size_read_back;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4 -3
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -28,9 +28,10 @@#include "vmwgfx_drv.h" +#include "vmwgfx_bo.h" +#include "vmwgfx_binding.h" #include "vmwgfx_devcaps.h" #include "vmwgfx_mksstat.h" -#include "vmwgfx_binding.h" #include "ttm_object.h" #include <drm/drm_aperture.h>
@@ -387,7 +388,7 @@ static void vmw_print_sm_type(struct vmw_private *dev_priv)static int vmw_dummy_query_bo_create (struct vmw_private *dev_priv) {int ret; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;struct ttm_bo_kmap_obj map;volatile SVGA3dQueryResult *result;bool dummy;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +20 -164
284 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +26 -27
166 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +1 -1
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +7 -20
@@ -1,6 +1,6 @@/* 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 * obtaining a copy of this software and associated documentation
@@ -24,25 +24,12 @@* */ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "drm/drm_prime.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) {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,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 vmw_buffer_object *vbo =vmw_buffer_object (bo); +struct vmw_bo *vbo =to_vmw_bo (obj);int ret; ret =ttm_bo_reserve (bo, false, false,NULL );
@@ -129,7 +116,7 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,struct drm_file *filp, uint32_t size, uint32_t *handle, - struct vmw_buffer_object **p_vbo) + struct vmw_bo **p_vbo) { int ret;
@@ -159,7 +146,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, (union drm_vmw_alloc_dmabuf_arg *)data;struct drm_vmw_alloc_dmabuf_req *req = &arg->req;struct drm_vmw_dmabuf_rep *rep = &arg->rep; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;uint32_t handle;int ret;
@@ -178,7 +165,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data,#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 *type;
@@ -259,7 +246,7 @@ static int vmw_debugfs_gem_info_show(struct seq_file *m, void *unused)spin_lock (&file->table_lock);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); }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +9 -8
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -24,8 +24,9 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ -#include "vmwgfx_kms.h" + +#include "vmwgfx_bo.h" #include "vmw_surface_cache.h" #include <drm/drm_atomic.h>
@@ -1493,7 +1494,7 @@ static const struct drm_framebuffer_funcs vmw_framebuffer_bo_funcs = {static int vmw_framebuffer_pin (struct vmw_framebuffer *vfb) {struct vmw_private *dev_priv =vmw_priv (vfb->base.dev); -struct vmw_buffer_object *buf; +struct vmw_bo *buf;struct ttm_placement *placement;int ret;
@@ -1538,7 +1539,7 @@ static int vmw_framebuffer_pin(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_buffer_object *buf; +struct vmw_bo *buf; buf = vfb->bo ?vmw_framebuffer_to_vfbd (&vfb->base)->buffer :vmw_framebuffer_to_vfbs (&vfb->base)->surface->res.backup;
@@ -1566,7 +1567,7 @@ static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb)*/ static int vmw_create_bo_proxy (struct drm_device *dev,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_metadata metadata = {0 };
@@ -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, -struct vmw_buffer_object *bo, +struct vmw_bo *bo,struct vmw_framebuffer **out,const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -1718,7 +1719,7 @@ vmw_kms_srf_ok(struct vmw_private *dev_priv, uint32_t width, uint32_t height)*/ struct vmw_framebuffer *vmw_kms_new_framebuffer (struct vmw_private *dev_priv, -struct vmw_buffer_object *bo, +struct vmw_bo *bo,struct vmw_surface *surface,bool only_2d,const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -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_framebuffer *vfb =NULL ;struct vmw_surface *surface =NULL ; -struct vmw_buffer_object *bo =NULL ; +struct vmw_bo *bo =NULL ;int ret;/* returns either a bo or surface */
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +6 -6
@@ -233,7 +233,7 @@ struct vmw_clip_rect {struct vmw_framebuffer_surface {struct vmw_framebuffer base;struct vmw_surface *surface; -struct vmw_buffer_object *buffer; +struct vmw_bo *buffer;struct list_head head;bool is_bo_proxy;/* true if this is proxy surface for DMA buf */ };
@@ -241,7 +241,7 @@ struct vmw_framebuffer_surface {struct vmw_framebuffer_bo {struct vmw_framebuffer base; -struct vmw_buffer_object *buffer; +struct vmw_bo *buffer; };
@@ -293,7 +293,7 @@ struct vmw_cursor_plane_state {struct vmw_plane_state {struct drm_plane_state base;struct vmw_surface *surf; -struct vmw_buffer_object *bo; +struct vmw_bo *bo;int content_fb_type;unsigned long bo_size;
@@ -364,7 +364,7 @@ struct vmw_display_unit {struct vmw_cursor_plane cursor;struct vmw_surface *cursor_surface; -struct vmw_buffer_object *cursor_bo; +struct vmw_bo *cursor_bo;size_t cursor_age;int cursor_x;
@@ -397,7 +397,7 @@ struct vmw_display_unit {struct vmw_validation_ctx {struct vmw_resource *res; -struct vmw_buffer_object *buf; +struct vmw_bo *buf; };#define vmw_crtc_to_du (x) \
@@ -458,7 +458,7 @@ int vmw_kms_readback(struct vmw_private *dev_priv, uint32_t num_clips);struct vmw_framebuffer *vmw_kms_new_framebuffer (struct vmw_private *dev_priv, -struct vmw_buffer_object *bo, +struct vmw_bo *bo,struct vmw_surface *surface,bool only_2d,const struct drm_mode_fb_cmd2 *mode_cmd);
drivers/gpu/drm/vmwgfx/vmwgfx_mob.c +4 -3
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -25,10 +25,11 @@* **************************************************************************/ -#include <linux/highmem.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include <linux/highmem.h> +#ifdef CONFIG_64BIT #define VMW_PPN_SIZE 8#define VMW_MOBFMT_PTDEPTH_0 SVGA3D_MOBFMT_PT64_0
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +9 -9
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -24,19 +24,19 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - -#include <drm/ttm/ttm_placement.h> +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" #include "device_include/svga_overlay.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_OVERLAY_CAP_MASK (SVGA_FIFO_CAP_VIDEO | SVGA_FIFO_CAP_ESCAPE)struct vmw_stream { -struct vmw_buffer_object *buf; +struct vmw_bo *buf;bool claimed;bool paused;struct drm_vmw_control_stream_arg saved;
@@ -92,7 +92,7 @@ static inline void fill_flush(struct vmw_escape_video_flush *cmd,* -ERESTARTSYS if interrupted by a signal. */ 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,bool interruptible) {
@@ -223,7 +223,7 @@ static int vmw_overlay_send_stop(struct vmw_private *dev_priv,* used with GMRs instead of being locked to vram. */ static int vmw_overlay_move_buffer (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool pin,bool inter) {if (!pin)
@@ -295,7 +295,7 @@ static int vmw_overlay_stop(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted. */ 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,bool interruptible) {
@@ -433,7 +433,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data,struct vmw_overlay *overlay = dev_priv->overlay_priv;struct drm_vmw_control_stream_arg *arg = (struct drm_vmw_control_stream_arg *)data; -struct vmw_buffer_object *buf; +struct vmw_bo *buf;struct vmw_resource *res;int ret;
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +14 -13
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -24,6 +24,7 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" /*
@@ -78,7 +79,7 @@ struct vmw_bo_dirty {* dirty structure with the results. This function may change the * 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;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)* * 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;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)* * 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;
@@ -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 * 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) {struct vmw_bo_dirty *dirty = vbo->dirty;
@@ -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. */ -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) {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,* * 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;pgoff_t num_pages =PFN_UP (vbo->base.resource->size);
@@ -284,7 +285,7 @@ int vmw_bo_dirty_add(struct vmw_buffer_object *vbo)* * 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;
@@ -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) { -struct vmw_buffer_object *vbo = res->backup; +struct vmw_bo *vbo = res->backup;struct vmw_bo_dirty *dirty = vbo->dirty;pgoff_t start, cur, end;unsigned long res_start = res->backup_offset;
@@ -353,7 +354,7 @@ void vmw_bo_dirty_clear_res(struct vmw_resource *res) {unsigned long res_start = res->backup_offset;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; res_start >>=PAGE_SHIFT ;
@@ -380,7 +381,7 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf)vm_fault_t ret;unsigned long page_offset;unsigned int save_flags; -struct vmw_buffer_object *vbo = +struct vmw_bo *vbo =container_of (bo,typeof (*vbo), base);/*
@@ -419,8 +420,8 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf)struct vm_area_struct *vma = vmf->vma;struct ttm_buffer_object *bo = (struct ttm_buffer_object *) vma->vm_private_data; -struct vmw_buffer_object *vbo = - container_of(bo, struct vmw_buffer_object, base); +struct vmw_bo *vbo = + container_of(bo, struct vmw_bo, base);pgoff_t num_prefault;pgprot_t prot;vm_fault_t ret;
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +15 -14
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -27,9 +27,10 @@#include <drm/ttm/ttm_placement.h> -#include "vmwgfx_resource_priv.h" #include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_resource_priv.h" #define VMW_RES_EVICT_ERR_COUNT 10
@@ -39,7 +40,7 @@*/ 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 ;dma_resv_assert_held (res->backup->base.base.resv);
@@ -67,7 +68,7 @@ void vmw_resource_mob_attach(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);if (vmw_resource_mob_attached (res)) {
@@ -290,7 +291,7 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv,struct drm_file *filp, uint32_t handle, 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 vmw_resource *res;
@@ -322,7 +323,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, bool interruptible) {unsigned long size =PFN_ALIGN (res->backup_size); -struct vmw_buffer_object *backup; +struct vmw_bo *backup;int ret;if (likely (res->backup)) {
@@ -438,7 +439,7 @@ void vmw_resource_unreserve(struct vmw_resource *res,bool dirty_set, bool dirty, bool switch_backup, - struct vmw_buffer_object *new_backup, + struct vmw_bo *new_backup, unsigned long new_backup_offset) { struct vmw_private *dev_priv = res->dev_priv;
@@ -739,7 +740,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr,* validation code, since resource validation and eviction * 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 = { .bo = &vbo->base,
@@ -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 * 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_private *dev_priv;
@@ -821,7 +822,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo,struct ttm_resource *old_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 vmw_private *dev_priv;
@@ -834,7 +835,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo, old_mem->mem_type == VMW_PL_MOB) {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) {mutex_unlock (&dev_priv->binding_mutex);return ;
@@ -958,7 +959,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible) goto out_no_reserve;if (res->pin_count ==0 ) { -struct vmw_buffer_object *vbo =NULL ; +struct vmw_bo *vbo =NULL ;if (res->backup) { vbo = res->backup;
@@ -1016,7 +1017,7 @@ void vmw_resource_unpin(struct vmw_resource *res)WARN_ON (res->pin_count ==0 );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 );vmw_bo_pin_reserved (vbo, false);
@@ -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 * 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) {struct rb_node *cur = vbo->res_tree.rb_node;
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +8 -7
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -25,13 +25,14 @@* **************************************************************************/ +#include "vmwgfx_bo.h" +#include "vmwgfx_kms.h" +#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> -#include "vmwgfx_kms.h" -#define vmw_crtc_to_sou (x) \ container_of(x, struct vmw_screen_object_unit, base.crtc)#define vmw_encoder_to_sou (x) \
@@ -89,7 +90,7 @@ struct vmw_screen_object_unit {struct vmw_display_unit base;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; };
@@ -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,struct vmw_framebuffer *framebuffer) { -struct vmw_buffer_object *buf = +struct vmw_bo *buf = container_of(framebuffer, struct vmw_framebuffer_bo, base)->buffer;int depth = framebuffer->base.format->depth;
@@ -1216,7 +1217,7 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,struct vmw_fence_obj **out_fence, struct drm_crtc *crtc) { - struct vmw_buffer_object *buf = + struct vmw_bo *buf = container_of(framebuffer, struct vmw_framebuffer_bo, base)->buffer;struct vmw_kms_dirty dirty;
@@ -1323,7 +1324,7 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,uint32_t num_clips, struct drm_crtc *crtc) { - struct vmw_buffer_object *buf = + struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_kms_dirty dirty;DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +8 -7
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -27,9 +27,10 @@#include <drm/ttm/ttm_placement.h> +#include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" -#include "vmwgfx_binding.h" struct vmw_shader {struct vmw_resource res;
@@ -158,7 +159,7 @@ static int vmw_gb_shader_init(struct vmw_private *dev_priv,SVGA3dShaderType type, uint8_t num_input_sig, uint8_t num_output_sig, - struct vmw_buffer_object *byte_code, + struct vmw_bo *byte_code, void (*res_free) (struct vmw_resource *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, } 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 offset, SVGA3dShaderType shader_type,
@@ -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, -struct vmw_buffer_object *buffer, +struct vmw_bo *buffer,size_t shader_size,size_t offset,SVGA3dShaderType shader_type)
@@ -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 ttm_object_file *tfile =vmw_fpriv (file_priv)->tfile; -struct vmw_buffer_object *buffer =NULL ; +struct vmw_bo *buffer =NULL ;SVGA3dShaderType shader_type;int ret;
@@ -883,7 +884,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv, struct list_head *list) {struct ttm_operation_ctx ctx = { false, true }; -struct vmw_buffer_object *buf; +struct vmw_bo *buf;struct ttm_bo_kmap_obj map;bool is_iomem;int ret;
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +7 -6
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -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_helper.h> #include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> -#include "vmwgfx_kms.h" -#include "vmw_surface_cache.h" -#define vmw_crtc_to_stdu (x) \ container_of(x, struct vmw_screen_target_display_unit, base.crtc)#define vmw_encoder_to_stdu (x) \
@@ -70,7 +71,7 @@ struct vmw_stdu_dirty {s32 fb_left, fb_top;u32 pitch;union { -struct vmw_buffer_object *buf; +struct vmw_bo *buf;u32 sid; }; };
@@ -688,7 +689,7 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv,bool interruptible, struct drm_crtc *crtc) { - struct vmw_buffer_object *buf = + struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_stdu_dirty ddirty;int ret;
drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +5 -4
@@ -1,7 +1,7 @@// 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. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,11 +26,12 @@* **************************************************************************/ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" -#include "vmwgfx_binding.h" + +#include <drm/ttm/ttm_placement.h> /** * struct vmw_dx_streamoutput - Streamoutput resource metadata.
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +5 -4
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -25,8 +25,7 @@* **************************************************************************/ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h"
@@ -34,6 +33,8 @@#include "vmw_surface_cache.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_UPPER_32 (svga3d_flags) (svga3d_flags >> 32)#define SVGA3D_FLAGS_LOWER_32 (svga3d_flags) \
@@ -1529,7 +1530,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev, }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 );if (!res->func->dirty_alloc)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +2 -1
@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the
@@ -25,6 +25,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include <drm/ttm/ttm_bo_driver.h> #include <drm/ttm/ttm_placement.h>
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +16 -14
@@ -1,7 +1,7 @@// 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. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,9 +25,11 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ -#include <linux/slab.h> -#include "vmwgfx_validation.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_validation.h" + +#include <linux/slab.h> #define VMWGFX_VALIDATION_MEM_GRAN (16*PAGE_SIZE)
@@ -77,7 +79,7 @@ struct vmw_validation_res_node {struct list_head head;struct vmwgfx_hash_item hash;struct vmw_resource *res; -struct vmw_buffer_object *new_backup; +struct vmw_bo *new_backup;unsigned long new_backup_offset; u32 no_buffer_needed : 1; u32 switching_backup : 1;
@@ -173,7 +175,7 @@ static void vmw_validation_mem_free(struct vmw_validation_context *ctx)*/ static struct vmw_validation_bo_node *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 ;
@@ -264,7 +266,7 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx,* Return: Zero on success, negative error code otherwise. */ 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) {
@@ -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 *val_private, -struct vmw_buffer_object *vbo, +struct vmw_bo *vbo,unsigned long backup_offset) {struct vmw_validation_res_node *val;
@@ -451,7 +453,7 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx, val->reserved =1 ;if (res->backup) { -struct vmw_buffer_object *vbo = res->backup; +struct vmw_bo *vbo = res->backup; ret = vmw_validation_add_bo (ctx, vbo, vmw_resource_needs_backup(res),
@@ -526,8 +528,8 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, bool interruptible, bool validate_as_mob) { -struct vmw_buffer_object *vbo = - container_of(bo, struct vmw_buffer_object, base); +struct vmw_bo *vbo = + container_of(bo, struct vmw_bo, base);struct ttm_operation_ctx ctx = { .interruptible = interruptible, .no_wait_gpu = false
@@ -578,7 +580,7 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)int ret;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);if (entry->cpu_blit) {
@@ -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) {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 && val->dirty);
@@ -651,7 +653,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)/* Check if the resource switched backup buffer */ 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 (ctx, vbo, vmw_resource_needs_backup(res),
@@ -889,7 +891,7 @@ void vmw_validation_bo_backoff(struct vmw_validation_context *ctx)list_for_each_entry (entry, &ctx->bo_list, base.head) {if (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), base);
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +3 -3
@@ -73,7 +73,7 @@ struct vmw_validation_context {size_t total_mem; }; -struct vmw_buffer_object ; +struct vmw_bo ;struct vmw_resource ;struct vmw_fence_obj ;
@@ -159,7 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) }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); int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, bool interruptible,
@@ -179,7 +179,7 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx, bool backoff);void vmw_validation_res_switch_backup (struct vmw_validation_context *ctx,void *val_private, -struct vmw_buffer_object *vbo, +struct vmw_bo *vbo,unsigned long backup_offset);int vmw_validation_res_validate (struct vmw_validation_context *ctx,bool intr);
Signature · 1 line
2.38.1
Re: [PATCH v2 3/8] drm/vmwgfx: Rename vmw_buffer_object to vmw_bo
Quoted 2,216 lines · Zack Rusin
From: Zack Rusin <[email protected]>
The rest of the drivers which are using ttm have mostly standardized on
driver_prefix_boas 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]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 94 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 189 +++++++++++++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 10 +- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 184 ++---------------- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 53 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 27 +-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 17 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 12 +- drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 18 +- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 27 +-- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 29 +-- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 13 +- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 30 +-- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 6 +- 25 files changed, 419 insertions(+), 386 deletions(-) create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_bo.hdrivers/gpu/drm/vmwgfx/vmwgfx_bo.c +40
-54@@ -1,7 +1,7 @@// 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. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -26,55 +26,41 @@* **************************************************************************/ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" -#include "ttm_object.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); -} +#include <drm/ttm/ttm_placement.h> /** -* vmw_bo_bo_free - vmw buffer object destructor +* vmw_bo_free - vmw_bo destructor * * @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 (!RB_EMPTY_ROOT (&vmw_bo->res_tree)); -vmw_bo_unmap (vmw_bo); +WARN_ON (vbo->dirty); +WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree)); +vmw_bo_unmap (vbo);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 * * Uses destroy function associated with the object to determine if this is -* a &vmw_buffer_object. +* a &vmw_bo. * * 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) { -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)* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_placement (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,struct ttm_placement *placement,bool interruptible) {@@ -130,7 +116,7 @@ int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_vram_or_gmr (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false };@@ -178,7 +164,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_vram (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) { 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,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_pin_in_start_of_vram (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false };@@ -263,7 +249,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted by a signal */ int vmw_bo_unpin (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool interruptible) {struct ttm_buffer_object *bo = &buf->base;@@ -308,7 +294,7 @@ void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,* @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_place pl;@@ -356,7 +342,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin)* 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;bool not_used;@@ -381,9 +367,9 @@ void *vmw_bo_map_and_cache(struct vmw_buffer_object *vbo)* @vbo: The buffer object whose map we are tearing down. * * 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 )return ;@@ -447,7 +433,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size,int vmw_bo_create (struct vmw_private *vmw,size_t size,struct ttm_placement *placement,bool interruptible,bool pin, -struct vmw_buffer_object **p_bo) +struct vmw_bo **p_bo) {int ret;@@ -473,7 +459,7 @@ int vmw_bo_create(struct vmw_private *vmw,* vmw_bo_init - Initialize a vmw buffer object * * @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. * @placement: Initial placement. * @interruptible: Whether waits should be performed interruptible. @@ -483,7 +469,7 @@ int vmw_bo_create(struct vmw_private *vmw,* Note that on error, the code will free the buffer object. */ 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,bool interruptible,bool pin) {@@ -504,7 +490,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); 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)) {return ret; }@@ -517,7 +503,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 * blocking it for further command submissions. * @@ -530,7 +516,7 @@ int vmw_bo_init(struct vmw_private *dev_priv,* * 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) {bool nonblock = !!(flags & drm_vmw_synccpu_dontblock);@@ -577,7 +563,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp, uint32_t handle, uint32_t flags) { -struct vmw_buffer_object *vmw_bo; +struct vmw_bo *vmw_bo;int ret =vmw_user_bo_lookup (filp, handle, &vmw_bo);if (!ret) {@@ -608,7 +594,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data, {struct drm_vmw_synccpu_arg *arg = (struct drm_vmw_synccpu_arg *) data; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;int ret; if ((arg->flags & (drm_vmw_synccpu_read | drm_vmw_synccpu_write)) == 0@@ -681,14 +667,14 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,* @filp: The file the handle is registered with. * @handle: The user buffer object handle * @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. * * The vmw buffer object pointer will be refcounted. */ int vmw_user_bo_lookup (struct drm_file *filp,uint32_t handle, -struct vmw_buffer_object **out) +struct vmw_bo **out) {struct drm_gem_object *gobj;@@ -699,7 +685,7 @@ int vmw_user_bo_lookup(struct drm_file *filp,return -ESRCH ; } - *out =gem_to_vmw_bo (gobj); + *out =to_vmw_bo (gobj);ttm_bo_get (&(*out)->base);drm_gem_object_put (gobj);@@ -759,7 +745,7 @@ int vmw_dumb_create(struct drm_file *file_priv, struct drm_mode_create_dumb *args) {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 ret;@@ -793,12 +779,12 @@ int vmw_dumb_create(struct drm_file *file_priv,*/ 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))return ;/* Kill any cached kernel maps before swapout */ -vmw_bo_unmap (vmw_buffer_object (bo)); +vmw_bo_unmap (to_vmw_bo (&bo->base)); }@@ -815,13 +801,13 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)void vmw_bo_move_notify (struct ttm_buffer_object *bo,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))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. drivers/gpu/drm/vmwgfx/vmwgfx_bo.h new file +189
-0@@ -0,0 +1,189 @@ +/* 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_api.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 drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c +5
-5@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -24,13 +24,13 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - -#include <linux/sched/signal.h> +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" +#include "vmwgfx_devcaps.h" #include <drm/ttm/ttm_placement.h> -#include "vmwgfx_drv.h" -#include "vmwgfx_devcaps.h" +#include <linux/sched/signal.h> bool vmw_supports_3d (struct vmw_private *dev_priv) {drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +5
-4@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -25,12 +25,13 @@* **************************************************************************/ -#include <linux/dmapool.h> -#include <linux/pci.h> +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" #include <drm/ttm/ttm_bo_api.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 drivers/gpu/drm/vmwgfx/vmwgfx_context.c +6
-5@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -27,9 +27,10 @@#include <drm/ttm/ttm_placement.h> +#include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" -#include "vmwgfx_binding.h" struct vmw_user_context {struct ttm_base_object base;@@ -38,7 +39,7 @@ struct vmw_user_context {struct vmw_cmdbuf_res_manager *man;struct vmw_resource *cotables[SVGA_COTABLE_MAX ];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);@@ -853,7 +854,7 @@ vmw_context_binding_state(struct vmw_resource *ctx)* specified in the parameter. 0 otherwise. */ 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 = container_of(ctx_res, struct vmw_user_context, res);@@ -885,7 +886,7 @@ int vmw_context_bind_dx_query(struct vmw_resource *ctx_res,* * @ctx_res: The context resource */ -struct vmw_buffer_object * +struct vmw_bo *vmw_context_get_dx_query_mob (struct vmw_resource *ctx_res) { struct vmw_user_context *uctx =drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +5
-4@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -30,13 +30,14 @@* whenever the backing MOB is evicted. */ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_mksstat.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h" +#include <drm/ttm/ttm_placement.h> +/** * struct vmw_cotable - Context Object Table resource * @@ -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 vmw_private *dev_priv = res->dev_priv;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;size_t old_size = res->backup_size;size_t old_size_read_back = vcotbl->size_read_back;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4
-3@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -28,9 +28,10 @@#include "vmwgfx_drv.h" +#include "vmwgfx_bo.h" +#include "vmwgfx_binding.h" #include "vmwgfx_devcaps.h" #include "vmwgfx_mksstat.h" -#include "vmwgfx_binding.h" #include "ttm_object.h" #include <drm/drm_aperture.h> @@ -387,7 +388,7 @@ static void vmw_print_sm_type(struct vmw_private *dev_priv)static int vmw_dummy_query_bo_create (struct vmw_private *dev_priv) {int ret; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;struct ttm_bo_kmap_obj map;volatile SVGA3dQueryResult *result;bool dummy;drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +20
-164@@ -1,7 +1,7 @@/* 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 * copy of this software and associated documentation files (the @@ -115,32 +115,6 @@ struct vmwgfx_hash_item {unsigned long key; }; -/** -* struct vmw_buffer_object - 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_buffer_object { -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; -};/** * struct vmw_validate_buffer - Carries validation info about buffers. @@ -188,6 +162,7 @@ struct vmw_res_func;* @hw_destroy: Callback to destroy the resource on the device, as part of * resource destruction. */ +struct vmw_bo ;struct vmw_resource_dirty ;struct vmw_resource {struct kref kref;@@ -198,7 +173,7 @@ struct vmw_resource { u32 res_dirty : 1; u32 backup_dirty : 1; u32 coherent : 1; -struct vmw_buffer_object *backup; +struct vmw_bo *backup;unsigned long backup_offset;unsigned long pin_count;const struct vmw_res_func *func;@@ -444,7 +419,7 @@ struct vmw_sw_context{struct drm_file *filp;uint32_t *cmd_bounce;uint32_t cmd_bounce_size; -struct vmw_buffer_object *cur_query_bo; +struct vmw_bo *cur_query_bo;struct list_head bo_relocations;struct list_head res_relocations;uint32_t *buf_start;@@ -456,7 +431,7 @@ struct vmw_sw_context{struct list_head staged_cmd_res;struct list_head ctx_list;struct vmw_ctx_validation_info *dx_ctx_node; -struct vmw_buffer_object *dx_query_mob; +struct vmw_bo *dx_query_mob;struct vmw_resource *dx_query_ctx;struct vmw_cmdbuf_res_manager *man;struct vmw_validation_context *ctx;@@ -630,8 +605,8 @@ struct vmw_private {* are protected by the cmdbuf mutex. */ -struct vmw_buffer_object *dummy_query_bo; -struct vmw_buffer_object *pinned_bo; +struct vmw_bo *dummy_query_bo; +struct vmw_bo *pinned_bo;uint32_t query_cid;uint32_t query_cid_valid;bool dummy_query_bo_pinned;@@ -675,11 +650,6 @@ struct vmw_private {#endif }; -static inline struct vmw_buffer_object *gem_to_vmw_bo (struct drm_gem_object *gobj) -{ - return container_of((gobj), struct vmw_buffer_object, base.base); -} -static inline struct vmw_surface *vmw_res_to_srf (struct vmw_resource *res) { return container_of(res, struct vmw_surface, res);@@ -823,7 +793,7 @@ extern int vmw_user_lookup_handle(struct vmw_private *dev_priv,struct drm_file *filp, uint32_t handle, struct vmw_surface **out_surf, - struct vmw_buffer_object **out_buf); + struct vmw_bo **out_buf); extern int vmw_user_resource_lookup_handle( struct vmw_private *dev_priv, struct ttm_object_file *tfile,@@ -843,19 +813,19 @@ extern void vmw_resource_unreserve(struct vmw_resource *res,bool dirty_set, bool dirty, bool switch_backup, - struct vmw_buffer_object *new_backup, + struct vmw_bo *new_backup, unsigned long new_backup_offset);extern void vmw_query_move_notify (struct ttm_buffer_object *bo,struct ttm_resource *old_mem,struct ttm_resource *new_mem); -extern int vmw_query_readback_all (struct vmw_buffer_object *dx_query_mob); -extern void vmw_resource_evict_all (struct vmw_private *dev_priv); -extern void vmw_resource_unbind_list (struct vmw_buffer_object *vbo); +int vmw_query_readback_all (struct vmw_bo *dx_query_mob); +void vmw_resource_evict_all (struct vmw_private *dev_priv); +void vmw_resource_unbind_list (struct vmw_bo *vbo);void vmw_resource_mob_attach (struct vmw_resource *res);void vmw_resource_mob_detach (struct vmw_resource *res);void vmw_resource_dirty_update (struct vmw_resource *res,pgoff_t start,pgoff_t end); -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);/** @@ -869,104 +839,6 @@ static inline bool vmw_resource_mob_attached(const struct vmw_resource *res)return !RB_EMPTY_NODE (&res->mob_node); } -/** -* Buffer object helper functions - vmwgfx_bo.c -*/ -extern int vmw_bo_pin_in_placement (struct vmw_private *vmw_priv, -struct vmw_buffer_object *bo, -struct ttm_placement *placement, -bool interruptible); -extern int vmw_bo_pin_in_vram (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, -bool interruptible); -extern int vmw_bo_pin_in_vram_or_gmr (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, -bool interruptible); -extern int vmw_bo_pin_in_start_of_vram (struct vmw_private *vmw_priv, -struct vmw_buffer_object *bo, -bool interruptible); -extern int vmw_bo_unpin (struct vmw_private *vmw_priv, -struct vmw_buffer_object *bo, -bool interruptible); -extern void vmw_bo_get_guest_ptr (const struct ttm_buffer_object *buf, -SVGAGuestPtr *ptr); -extern void vmw_bo_pin_reserved (struct vmw_buffer_object *bo,bool pin); -extern int vmw_bo_create_kernel (struct vmw_private *dev_priv, -unsigned long size, -struct ttm_placement *placement, -struct ttm_buffer_object **p_bo); -extern int vmw_bo_create (struct vmw_private *dev_priv, -size_t size,struct ttm_placement *placement, -bool interruptible,bool pin, -struct vmw_buffer_object **p_bo); -extern int vmw_bo_init (struct vmw_private *dev_priv, -struct vmw_buffer_object *vmw_bo, -size_t size,struct ttm_placement *placement, -bool interruptible,bool pin); -extern int vmw_bo_unref_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv); -extern int vmw_user_bo_synccpu_ioctl (struct drm_device *dev,void *data, -struct drm_file *file_priv); -extern int vmw_user_bo_lookup (struct drm_file *filp, -uint32_t handle, -struct vmw_buffer_object **out); -extern void vmw_bo_fence_single (struct ttm_buffer_object *bo, -struct vmw_fence_obj *fence); -extern void *vmw_bo_map_and_cache (struct vmw_buffer_object *vbo); -extern void vmw_bo_unmap (struct vmw_buffer_object *vbo); -extern void vmw_bo_move_notify (struct ttm_buffer_object *bo, -struct ttm_resource *mem); -extern 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_buffer_object -*/ -static inline void vmw_bo_prio_adjust (struct vmw_buffer_object *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_buffer_object -* @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_buffer_object *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_buffer_object -* @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_buffer_object *vbo,int prio) -{ -if (--vbo->res_prios[prio] ==0 ) -vmw_bo_prio_adjust (vbo); -} -/** * GEM related functionality - vmwgfx_gem.c */ @@ -974,7 +846,7 @@ extern int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,struct drm_file *filp, uint32_t size, uint32_t *handle, - struct vmw_buffer_object **p_vbo); + struct vmw_bo **p_vbo);extern int vmw_gem_object_create_ioctl (struct drm_device *dev,void *data,struct drm_file *filp);extern void vmw_debugfs_gem_init (struct vmw_private *vdev);@@ -1285,8 +1157,8 @@ vmw_context_binding_state(struct vmw_resource *ctx);extern void vmw_dx_context_scrub_cotables (struct vmw_resource *ctx,bool readback);extern int vmw_context_bind_dx_query (struct vmw_resource *ctx_res, -struct vmw_buffer_object *mob); -extern struct vmw_buffer_object * +struct vmw_bo *mob); +extern struct vmw_bo *vmw_context_get_dx_query_mob (struct vmw_resource *ctx_res);@@ -1511,12 +1383,12 @@ int vmw_mksstat_remove_all(struct vmw_private *dev_priv); DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__) /* Resource dirtying - vmwgfx_page_dirty.c */ -void vmw_bo_dirty_scan (struct vmw_buffer_object *vbo); -int vmw_bo_dirty_add (struct vmw_buffer_object *vbo); +void vmw_bo_dirty_scan (struct vmw_bo *vbo); +int vmw_bo_dirty_add (struct vmw_bo *vbo);void vmw_bo_dirty_transfer_to_res (struct vmw_resource *res);void vmw_bo_dirty_clear_res (struct vmw_resource *res); -void vmw_bo_dirty_release (struct vmw_buffer_object *vbo); -void vmw_bo_dirty_unmap (struct vmw_buffer_object *vbo, +void vmw_bo_dirty_release (struct vmw_bo *vbo); +void vmw_bo_dirty_unmap (struct vmw_bo *vbo,pgoff_t start,pgoff_t end);vm_fault_t vmw_bo_vm_fault (struct vm_fault *vmf);vm_fault_t vmw_bo_vm_mkwrite (struct vm_fault *vmf);@@ -1549,22 +1421,6 @@ static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf)return srf; } -static inline void vmw_bo_unreference (struct vmw_buffer_object **buf) -{ -struct vmw_buffer_object *tmp_buf = *buf; - - *buf =NULL ; -if (tmp_buf !=NULL ) -ttm_bo_put (&tmp_buf->base); -} - -static inline struct vmw_buffer_object * -vmw_bo_reference (struct vmw_buffer_object *buf) -{ -ttm_bo_get (&buf->base); -return buf; -} -static inline void vmw_fifo_resource_inc (struct vmw_private *dev_priv) {atomic_inc (&dev_priv->num_fifo_resources);drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +26
-27@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -24,17 +24,16 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ -#include <linux/sync_file.h> -#include <linux/hashtable.h> - -#include "vmwgfx_drv.h" -#include "vmwgfx_reg.h" -#include <drm/ttm/ttm_bo_api.h> -#include <drm/ttm/ttm_placement.h> -#include "vmwgfx_so.h" #include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" #include "vmwgfx_mksstat.h" +#include "vmwgfx_so.h" + +#include <drm/ttm/ttm_bo_api.h> +#include <linux/sync_file.h> +#include <linux/hashtable.h> /* * Helper macro to get dx_ctx_node if available otherwise print an error @@ -65,7 +64,7 @@*/ struct vmw_relocation {struct list_head head; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;union {SVGAMobId *mob_loc;SVGAGuestPtr *location;@@ -149,7 +148,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,static int vmw_translate_mob_ptr (struct vmw_private *dev_priv,struct vmw_sw_context *sw_context,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 * @@ -475,7 +474,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,if (has_sm4_context (dev_priv) &&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);if (dx_query_mob)@@ -596,7 +595,7 @@ static int vmw_resources_reserve(struct vmw_sw_context *sw_context)return ret;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 =vmw_context_get_dx_query_mob (sw_context->dx_query_ctx);@@ -703,7 +702,7 @@ vmw_cmd_res_check(struct vmw_private *dev_priv,static int vmw_rebind_all_dx_query (struct vmw_resource *ctx_res) {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); dx_query_mob =vmw_context_get_dx_query_mob (ctx_res);@@ -1017,7 +1016,7 @@ static int vmw_cmd_present_check(struct vmw_private *dev_priv,* after successful submission of the current command batch. */ 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_res_cache_entry *ctx_entry =@@ -1145,9 +1144,9 @@ static void vmw_query_bo_switch_commit(struct vmw_private *dev_priv,static int vmw_translate_mob_ptr (struct vmw_private *dev_priv,struct vmw_sw_context *sw_context,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;struct vmw_relocation *reloc;int ret;@@ -1199,9 +1198,9 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,static int vmw_translate_guest_ptr (struct vmw_private *dev_priv,struct vmw_sw_context *sw_context,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;struct vmw_relocation *reloc;int ret;@@ -1278,7 +1277,7 @@ static int vmw_cmd_dx_bind_query(struct vmw_private *dev_priv, SVGA3dCmdHeader *header) {VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdDXBindQuery); -struct vmw_buffer_object *vmw_bo; +struct vmw_bo *vmw_bo;int ret; cmd =container_of (header,typeof (*cmd), header);@@ -1361,7 +1360,7 @@ static int vmw_cmd_end_gb_query(struct vmw_private *dev_priv,struct vmw_sw_context *sw_context, SVGA3dCmdHeader *header) { - struct vmw_buffer_object *vmw_bo; + struct vmw_bo *vmw_bo;VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdEndGBQuery);int ret;@@ -1391,7 +1390,7 @@ static int vmw_cmd_end_query(struct vmw_private *dev_priv,struct vmw_sw_context *sw_context, SVGA3dCmdHeader *header) { - struct vmw_buffer_object *vmw_bo; + struct vmw_bo *vmw_bo;VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdEndQuery);int ret;@@ -1437,7 +1436,7 @@ static int vmw_cmd_wait_gb_query(struct vmw_private *dev_priv,struct vmw_sw_context *sw_context, SVGA3dCmdHeader *header) { - struct vmw_buffer_object *vmw_bo; + struct vmw_bo *vmw_bo;VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdWaitForGBQuery);int ret;@@ -1465,7 +1464,7 @@ static int vmw_cmd_wait_query(struct vmw_private *dev_priv,struct vmw_sw_context *sw_context, SVGA3dCmdHeader *header) { - struct vmw_buffer_object *vmw_bo; + struct vmw_bo *vmw_bo;VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdWaitForQuery);int ret;@@ -1502,7 +1501,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv,struct vmw_sw_context *sw_context, SVGA3dCmdHeader *header) { - struct vmw_buffer_object *vmw_bo = NULL; + struct vmw_bo *vmw_bo = NULL;struct vmw_surface *srf =NULL ;VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdSurfaceDMA);int ret;@@ -1668,7 +1667,7 @@ static int vmw_cmd_check_define_gmrfb(struct vmw_private *dev_priv,struct vmw_sw_context *sw_context, void *buf) { - struct vmw_buffer_object *vmw_bo; + struct vmw_bo *vmw_bo; struct { uint32_t header;@@ -1699,7 +1698,7 @@ static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv, struct vmw_resource *res, uint32_t *buf_id, unsigned long backup_offset) { - struct vmw_buffer_object *vbo; + struct vmw_bo *vbo;void *info;int ret;drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +1
-1@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +7
-20@@ -1,6 +1,6 @@/* 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 * obtaining a copy of this software and associated documentation @@ -24,25 +24,12 @@* */ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "drm/drm_prime.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) {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,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 vmw_buffer_object *vbo =vmw_buffer_object (bo); +struct vmw_bo *vbo =to_vmw_bo (obj);int ret; ret =ttm_bo_reserve (bo, false, false,NULL );@@ -129,7 +116,7 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,struct drm_file *filp, uint32_t size, uint32_t *handle, - struct vmw_buffer_object **p_vbo) + struct vmw_bo **p_vbo) { int ret;@@ -159,7 +146,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, (union drm_vmw_alloc_dmabuf_arg *)data;struct drm_vmw_alloc_dmabuf_req *req = &arg->req;struct drm_vmw_dmabuf_rep *rep = &arg->rep; -struct vmw_buffer_object *vbo; +struct vmw_bo *vbo;uint32_t handle;int ret;@@ -178,7 +165,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data,#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 *type;@@ -259,7 +246,7 @@ static int vmw_debugfs_gem_info_show(struct seq_file *m, void *unused)spin_lock (&file->table_lock);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); }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +9
-8@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -24,8 +24,9 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ -#include "vmwgfx_kms.h" + +#include "vmwgfx_bo.h" #include "vmw_surface_cache.h" #include <drm/drm_atomic.h> @@ -1493,7 +1494,7 @@ static const struct drm_framebuffer_funcs vmw_framebuffer_bo_funcs = {static int vmw_framebuffer_pin (struct vmw_framebuffer *vfb) {struct vmw_private *dev_priv =vmw_priv (vfb->base.dev); -struct vmw_buffer_object *buf; +struct vmw_bo *buf;struct ttm_placement *placement;int ret;@@ -1538,7 +1539,7 @@ static int vmw_framebuffer_pin(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_buffer_object *buf; +struct vmw_bo *buf; buf = vfb->bo ?vmw_framebuffer_to_vfbd (&vfb->base)->buffer :vmw_framebuffer_to_vfbs (&vfb->base)->surface->res.backup;@@ -1566,7 +1567,7 @@ static int vmw_framebuffer_unpin(struct vmw_framebuffer *vfb)*/ static int vmw_create_bo_proxy (struct drm_device *dev,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_metadata metadata = {0 };@@ -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, -struct vmw_buffer_object *bo, +struct vmw_bo *bo,struct vmw_framebuffer **out,const struct drm_mode_fb_cmd2 *mode_cmd)@@ -1718,7 +1719,7 @@ vmw_kms_srf_ok(struct vmw_private *dev_priv, uint32_t width, uint32_t height)*/ struct vmw_framebuffer *vmw_kms_new_framebuffer (struct vmw_private *dev_priv, -struct vmw_buffer_object *bo, +struct vmw_bo *bo,struct vmw_surface *surface,bool only_2d,const struct drm_mode_fb_cmd2 *mode_cmd)@@ -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_framebuffer *vfb =NULL ;struct vmw_surface *surface =NULL ; -struct vmw_buffer_object *bo =NULL ; +struct vmw_bo *bo =NULL ;int ret;/* returns either a bo or surface */ drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +6
-6@@ -233,7 +233,7 @@ struct vmw_clip_rect {struct vmw_framebuffer_surface {struct vmw_framebuffer base;struct vmw_surface *surface; -struct vmw_buffer_object *buffer; +struct vmw_bo *buffer;struct list_head head;bool is_bo_proxy;/* true if this is proxy surface for DMA buf */ };@@ -241,7 +241,7 @@ struct vmw_framebuffer_surface {struct vmw_framebuffer_bo {struct vmw_framebuffer base; -struct vmw_buffer_object *buffer; +struct vmw_bo *buffer; };@@ -293,7 +293,7 @@ struct vmw_cursor_plane_state {struct vmw_plane_state {struct drm_plane_state base;struct vmw_surface *surf; -struct vmw_buffer_object *bo; +struct vmw_bo *bo;int content_fb_type;unsigned long bo_size;@@ -364,7 +364,7 @@ struct vmw_display_unit {struct vmw_cursor_plane cursor;struct vmw_surface *cursor_surface; -struct vmw_buffer_object *cursor_bo; +struct vmw_bo *cursor_bo;size_t cursor_age;int cursor_x;@@ -397,7 +397,7 @@ struct vmw_display_unit {struct vmw_validation_ctx {struct vmw_resource *res; -struct vmw_buffer_object *buf; +struct vmw_bo *buf; };#define vmw_crtc_to_du (x) \@@ -458,7 +458,7 @@ int vmw_kms_readback(struct vmw_private *dev_priv, uint32_t num_clips);struct vmw_framebuffer *vmw_kms_new_framebuffer (struct vmw_private *dev_priv, -struct vmw_buffer_object *bo, +struct vmw_bo *bo,struct vmw_surface *surface,bool only_2d,const struct drm_mode_fb_cmd2 *mode_cmd);drivers/gpu/drm/vmwgfx/vmwgfx_mob.c +4
-3@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -25,10 +25,11 @@* **************************************************************************/ -#include <linux/highmem.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include <linux/highmem.h> +#ifdef CONFIG_64BIT #define VMW_PPN_SIZE 8#define VMW_MOBFMT_PTDEPTH_0 SVGA3D_MOBFMT_PT64_0drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +9
-9@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -24,19 +24,19 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - -#include <drm/ttm/ttm_placement.h> +#include "vmwgfx_bo.h" +#include "vmwgfx_drv.h" #include "device_include/svga_overlay.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_OVERLAY_CAP_MASK (SVGA_FIFO_CAP_VIDEO | SVGA_FIFO_CAP_ESCAPE)struct vmw_stream { -struct vmw_buffer_object *buf; +struct vmw_bo *buf;bool claimed;bool paused;struct drm_vmw_control_stream_arg saved;@@ -92,7 +92,7 @@ static inline void fill_flush(struct vmw_escape_video_flush *cmd,* -ERESTARTSYS if interrupted by a signal. */ 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,bool interruptible) {@@ -223,7 +223,7 @@ static int vmw_overlay_send_stop(struct vmw_private *dev_priv,* used with GMRs instead of being locked to vram. */ static int vmw_overlay_move_buffer (struct vmw_private *dev_priv, -struct vmw_buffer_object *buf, +struct vmw_bo *buf,bool pin,bool inter) {if (!pin)@@ -295,7 +295,7 @@ static int vmw_overlay_stop(struct vmw_private *dev_priv,* -ERESTARTSYS if interrupted. */ 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,bool interruptible) {@@ -433,7 +433,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data,struct vmw_overlay *overlay = dev_priv->overlay_priv;struct drm_vmw_control_stream_arg *arg = (struct drm_vmw_control_stream_arg *)data; -struct vmw_buffer_object *buf; +struct vmw_bo *buf;struct vmw_resource *res;int ret;drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +14
-13@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -24,6 +24,7 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" /* @@ -78,7 +79,7 @@ struct vmw_bo_dirty {* dirty structure with the results. This function may change the * 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;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)* * 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;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)* * 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;@@ -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 * 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) {struct vmw_bo_dirty *dirty = vbo->dirty;@@ -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. */ -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) {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,* * 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;pgoff_t num_pages =PFN_UP (vbo->base.resource->size);@@ -284,7 +285,7 @@ int vmw_bo_dirty_add(struct vmw_buffer_object *vbo)* * 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;@@ -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) { -struct vmw_buffer_object *vbo = res->backup; +struct vmw_bo *vbo = res->backup;struct vmw_bo_dirty *dirty = vbo->dirty;pgoff_t start, cur, end;unsigned long res_start = res->backup_offset;@@ -353,7 +354,7 @@ void vmw_bo_dirty_clear_res(struct vmw_resource *res) {unsigned long res_start = res->backup_offset;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; res_start >>=PAGE_SHIFT ;@@ -380,7 +381,7 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf)vm_fault_t ret;unsigned long page_offset;unsigned int save_flags; -struct vmw_buffer_object *vbo = +struct vmw_bo *vbo =container_of (bo,typeof (*vbo), base);/* @@ -419,8 +420,8 @@ vm_fault_t vmw_bo_vm_fault(struct vm_fault *vmf)struct vm_area_struct *vma = vmf->vma;struct ttm_buffer_object *bo = (struct ttm_buffer_object *) vma->vm_private_data; -struct vmw_buffer_object *vbo = - container_of(bo, struct vmw_buffer_object, base); +struct vmw_bo *vbo = + container_of(bo, struct vmw_bo, base);pgoff_t num_prefault;pgprot_t prot;vm_fault_t ret;drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +15
-14@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -27,9 +27,10 @@#include <drm/ttm/ttm_placement.h> -#include "vmwgfx_resource_priv.h" #include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_resource_priv.h" #define VMW_RES_EVICT_ERR_COUNT 10@@ -39,7 +40,7 @@*/ 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 ;dma_resv_assert_held (res->backup->base.base.resv);@@ -67,7 +68,7 @@ void vmw_resource_mob_attach(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);if (vmw_resource_mob_attached (res)) {@@ -290,7 +291,7 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv,struct drm_file *filp, uint32_t handle, 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 vmw_resource *res;@@ -322,7 +323,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, bool interruptible) {unsigned long size =PFN_ALIGN (res->backup_size); -struct vmw_buffer_object *backup; +struct vmw_bo *backup;int ret;if (likely (res->backup)) {@@ -438,7 +439,7 @@ void vmw_resource_unreserve(struct vmw_resource *res,bool dirty_set, bool dirty, bool switch_backup, - struct vmw_buffer_object *new_backup, + struct vmw_bo *new_backup, unsigned long new_backup_offset) { struct vmw_private *dev_priv = res->dev_priv;@@ -739,7 +740,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr,* validation code, since resource validation and eviction * 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 = { .bo = &vbo->base,@@ -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 * 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_private *dev_priv;@@ -821,7 +822,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo,struct ttm_resource *old_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 vmw_private *dev_priv;@@ -834,7 +835,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo, old_mem->mem_type == VMW_PL_MOB) {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) {mutex_unlock (&dev_priv->binding_mutex);return ;@@ -958,7 +959,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible) goto out_no_reserve;if (res->pin_count ==0 ) { -struct vmw_buffer_object *vbo =NULL ; +struct vmw_bo *vbo =NULL ;if (res->backup) { vbo = res->backup;@@ -1016,7 +1017,7 @@ void vmw_resource_unpin(struct vmw_resource *res)WARN_ON (res->pin_count ==0 );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 );vmw_bo_pin_reserved (vbo, false);@@ -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 * 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) {struct rb_node *cur = vbo->res_tree.rb_node;drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +8
-7@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -25,13 +25,14 @@* **************************************************************************/ +#include "vmwgfx_bo.h" +#include "vmwgfx_kms.h" +#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> -#include "vmwgfx_kms.h" -#define vmw_crtc_to_sou (x) \ container_of(x, struct vmw_screen_object_unit, base.crtc)#define vmw_encoder_to_sou (x) \@@ -89,7 +90,7 @@ struct vmw_screen_object_unit {struct vmw_display_unit base;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; };@@ -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,struct vmw_framebuffer *framebuffer) { -struct vmw_buffer_object *buf = +struct vmw_bo *buf = container_of(framebuffer, struct vmw_framebuffer_bo, base)->buffer;int depth = framebuffer->base.format->depth;@@ -1216,7 +1217,7 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,struct vmw_fence_obj **out_fence, struct drm_crtc *crtc) { - struct vmw_buffer_object *buf = + struct vmw_bo *buf = container_of(framebuffer, struct vmw_framebuffer_bo, base)->buffer;struct vmw_kms_dirty dirty;@@ -1323,7 +1324,7 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,uint32_t num_clips, struct drm_crtc *crtc) { - struct vmw_buffer_object *buf = + struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_kms_dirty dirty;DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +8
-7@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -27,9 +27,10 @@#include <drm/ttm/ttm_placement.h> +#include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" -#include "vmwgfx_binding.h" struct vmw_shader {struct vmw_resource res;@@ -158,7 +159,7 @@ static int vmw_gb_shader_init(struct vmw_private *dev_priv,SVGA3dShaderType type, uint8_t num_input_sig, uint8_t num_output_sig, - struct vmw_buffer_object *byte_code, + struct vmw_bo *byte_code, void (*res_free) (struct vmw_resource *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, } 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 offset, SVGA3dShaderType shader_type,@@ -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, -struct vmw_buffer_object *buffer, +struct vmw_bo *buffer,size_t shader_size,size_t offset,SVGA3dShaderType shader_type)@@ -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 ttm_object_file *tfile =vmw_fpriv (file_priv)->tfile; -struct vmw_buffer_object *buffer =NULL ; +struct vmw_bo *buffer =NULL ;SVGA3dShaderType shader_type;int ret;@@ -883,7 +884,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv, struct list_head *list) {struct ttm_operation_ctx ctx = { false, true }; -struct vmw_buffer_object *buf; +struct vmw_bo *buf;struct ttm_bo_kmap_obj map;bool is_iomem;int ret;drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +7
-6@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -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_helper.h> #include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> -#include "vmwgfx_kms.h" -#include "vmw_surface_cache.h" -#define vmw_crtc_to_stdu (x) \ container_of(x, struct vmw_screen_target_display_unit, base.crtc)#define vmw_encoder_to_stdu (x) \@@ -70,7 +71,7 @@ struct vmw_stdu_dirty {s32 fb_left, fb_top;u32 pitch;union { -struct vmw_buffer_object *buf; +struct vmw_bo *buf;u32 sid; }; };@@ -688,7 +689,7 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv,bool interruptible, struct drm_crtc *crtc) { - struct vmw_buffer_object *buf = + struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_stdu_dirty ddirty;int ret;drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +5
-4@@ -1,7 +1,7 @@// 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. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -26,11 +26,12 @@* **************************************************************************/ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_binding.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" -#include "vmwgfx_binding.h" + +#include <drm/ttm/ttm_placement.h> /** * struct vmw_dx_streamoutput - Streamoutput resource metadata. drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +5
-4@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -25,8 +25,7 @@* **************************************************************************/ -#include <drm/ttm/ttm_placement.h> - +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h" @@ -34,6 +33,8 @@#include "vmw_surface_cache.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_UPPER_32 (svga3d_flags) (svga3d_flags >> 32)#define SVGA3D_FLAGS_LOWER_32 (svga3d_flags) \@@ -1529,7 +1530,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev, }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 );if (!res->func->dirty_alloc)drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +2
-1@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -25,6 +25,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include <drm/ttm/ttm_bo_driver.h> #include <drm/ttm/ttm_placement.h> drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +16
-14@@ -1,7 +1,7 @@// 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. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -25,9 +25,11 @@* USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ -#include <linux/slab.h> -#include "vmwgfx_validation.h" +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_validation.h" + +#include <linux/slab.h> #define VMWGFX_VALIDATION_MEM_GRAN (16*PAGE_SIZE)@@ -77,7 +79,7 @@ struct vmw_validation_res_node {struct list_head head;struct vmwgfx_hash_item hash;struct vmw_resource *res; -struct vmw_buffer_object *new_backup; +struct vmw_bo *new_backup;unsigned long new_backup_offset; u32 no_buffer_needed : 1; u32 switching_backup : 1;@@ -173,7 +175,7 @@ static void vmw_validation_mem_free(struct vmw_validation_context *ctx)*/ static struct vmw_validation_bo_node *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 ;@@ -264,7 +266,7 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx,* Return: Zero on success, negative error code otherwise. */ 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) {@@ -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 *val_private, -struct vmw_buffer_object *vbo, +struct vmw_bo *vbo,unsigned long backup_offset) {struct vmw_validation_res_node *val;@@ -451,7 +453,7 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx, val->reserved =1 ;if (res->backup) { -struct vmw_buffer_object *vbo = res->backup; +struct vmw_bo *vbo = res->backup; ret = vmw_validation_add_bo (ctx, vbo, vmw_resource_needs_backup(res),@@ -526,8 +528,8 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, bool interruptible, bool validate_as_mob) { -struct vmw_buffer_object *vbo = - container_of(bo, struct vmw_buffer_object, base); +struct vmw_bo *vbo = + container_of(bo, struct vmw_bo, base);struct ttm_operation_ctx ctx = { .interruptible = interruptible, .no_wait_gpu = false@@ -578,7 +580,7 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)int ret;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);if (entry->cpu_blit) {@@ -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) {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 && val->dirty);@@ -651,7 +653,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)/* Check if the resource switched backup buffer */ 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 (ctx, vbo, vmw_resource_needs_backup(res),@@ -889,7 +891,7 @@ void vmw_validation_bo_backoff(struct vmw_validation_context *ctx)list_for_each_entry (entry, &ctx->bo_list, base.head) {if (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), base);drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +2
-2@@ -73,7 +73,7 @@ struct vmw_validation_context {size_t total_mem; }; -struct vmw_buffer_object ; +struct vmw_bo ;struct vmw_resource ;struct vmw_fence_obj ;@@ -159,7 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) }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); int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo, bool interruptible,
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h void vmw_validation_res_unreserve(struct vmw_validation_context *ctx, · line 185
Quoted 8 lines
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +1
-1@@ -179,7 +179,7 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx, bool backoff);void vmw_validation_res_switch_backup (struct vmw_validation_context *ctx,void *val_private, -struct vmw_buffer_object *vbo, +struct vmw_bo *vbo,unsigned long backup_offset);int vmw_validation_res_validate (struct vmw_validation_context *ctx,bool intr);
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 4/8 drm/vmwgfx: Simplify fb pinning
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Only the legacy display unit requires pinning of the fb memory in vram. Both the screen objects and screen targets can present from any buffer. That makes the pinning abstraction pointless. Simplify all of the code and move it to the legacy display unit, the only place that needs it.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 8 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 4 -- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 66 ----------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 57 +++++++++++++++++++++---- 5 files changed, 54 insertions(+), 85 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +4 -4
@@ -73,10 +73,10 @@ static bool bo_is_vmw(struct ttm_buffer_object *bo)* Return: Zero on success, Negative error code on failure. In particular * -ERESTARTSYS if interrupted by a signal */ -int vmw_bo_pin_in_placement (struct vmw_private *dev_priv, -struct vmw_bo *buf, -struct ttm_placement *placement, -bool interruptible) +static int vmw_bo_pin_in_placement (struct vmw_private *dev_priv, +struct vmw_bo *buf, +struct ttm_placement *placement, +bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base;
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +0 -4
@@ -82,10 +82,6 @@ int vmw_bo_init(struct vmw_private *dev_priv,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);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -66
78 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +1 -3
@@ -1,7 +1,7 @@/* 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 * copy of this software and associated documentation files (the
@@ -217,8 +217,6 @@ struct vmw_kms_dirty {*/ struct vmw_framebuffer {struct drm_framebuffer base; -int (*pin)(struct vmw_framebuffer *fb); -int (*unpin)(struct vmw_framebuffer *fb);bool bo;uint32_t user_handle; };
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +49 -8
92 lines not on this page · raw message
Signature · 1 line
2.38.1
Re: [PATCH v2 4/8] drm/vmwgfx: Simplify fb pinning
Quoted 248 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Only the legacy display unit requires pinning of the fb memory in vram. Both the screen objects and screen targets can present from any buffer. That makes the pinning abstraction pointless. Simplify all of the code and move it to the legacy display unit, the only place that needs it.
Signed-off-by Zack Rusin <[email protected]>Reviewed-by Martin Krastev <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 8 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 4 -- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 66 ----------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 57 +++++++++++++++++++++---- 5 files changed, 54 insertions(+), 85 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +4
-4@@ -73,10 +73,10 @@ static bool bo_is_vmw(struct ttm_buffer_object *bo)* Return: Zero on success, Negative error code on failure. In particular * -ERESTARTSYS if interrupted by a signal */ -int vmw_bo_pin_in_placement (struct vmw_private *dev_priv, -struct vmw_bo *buf, -struct ttm_placement *placement, -bool interruptible) +static int vmw_bo_pin_in_placement (struct vmw_private *dev_priv, +struct vmw_bo *buf, +struct ttm_placement *placement, +bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base;drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +0
-4@@ -82,10 +82,6 @@ int vmw_bo_init(struct vmw_private *dev_priv,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);drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0
-66@@ -1487,69 +1487,6 @@ static const struct drm_framebuffer_funcs vmw_framebuffer_bo_funcs = { .dirty = vmw_framebuffer_bo_dirty_ext, }; -/* -* Pin the bofer in a location suitable for access by the -* display system. -*/ -static int vmw_framebuffer_pin (struct vmw_framebuffer *vfb) -{ -struct vmw_private *dev_priv =vmw_priv (vfb->base.dev); -struct vmw_bo *buf; -struct ttm_placement *placement; -int ret; - - buf = vfb->bo ?vmw_framebuffer_to_vfbd (&vfb->base)->buffer : -vmw_framebuffer_to_vfbs (&vfb->base)->surface->res.backup; - -if (!buf) -return 0 ; - -switch (dev_priv->active_display_unit) { -case vmw_du_legacy: -vmw_overlay_pause_all (dev_priv); - ret =vmw_bo_pin_in_start_of_vram (dev_priv, buf, false); -vmw_overlay_resume_all (dev_priv); -break ; -case vmw_du_screen_object: -case vmw_du_screen_target: -if (vfb->bo) { -if (dev_priv->capabilities &SVGA_CAP_3D ) { -/* -* Use surface DMA to get content to -* sreen target surface. -*/ - placement = &vmw_vram_gmr_placement; - }else { -/* Use CPU blit. */ - placement = &vmw_sys_placement; - } - }else { -/* Use surface / image update */ - placement = &vmw_mob_placement; - } - -return vmw_bo_pin_in_placement (dev_priv, buf, placement, false); -default : -return -EINVAL ; - } - -return ret; -} - -static int vmw_framebuffer_unpin (struct vmw_framebuffer *vfb) -{ -struct vmw_private *dev_priv =vmw_priv (vfb->base.dev); -struct vmw_bo *buf; - - buf = vfb->bo ?vmw_framebuffer_to_vfbd (&vfb->base)->buffer : -vmw_framebuffer_to_vfbs (&vfb->base)->surface->res.backup; - -if (WARN_ON (!buf)) -return 0 ; - -return vmw_bo_unpin (dev_priv, buf, false); -} -/** * vmw_create_bo_proxy - create a proxy surface for the buffer object * @@ -1766,9 +1703,6 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv,if (ret)return ERR_PTR (ret); - vfb->pin = vmw_framebuffer_pin; - vfb->unpin = vmw_framebuffer_unpin; -return vfb; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +1
-3@@ -1,7 +1,7 @@/* 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 * copy of this software and associated documentation files (the @@ -217,8 +217,6 @@ struct vmw_kms_dirty {*/ struct vmw_framebuffer {struct drm_framebuffer base; -int (*pin)(struct vmw_framebuffer *fb); -int (*unpin)(struct vmw_framebuffer *fb);bool bo;uint32_t user_handle; };drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +46
-5@@ -1,7 +1,7 @@// 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 * copy of this software and associated documentation files (the @@ -25,11 +25,13 @@* **************************************************************************/ +#include "vmwgfx_bo.h" +#include "vmwgfx_kms.h" +#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_fourcc.h> -#include "vmwgfx_kms.h" #define vmw_crtc_to_ldu (x) \ container_of(x, struct vmw_legacy_display_unit, base.crtc)@@ -134,6 +136,47 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)return 0 ; } +/* +* Pin the buffer in a location suitable for access by the +* display system. +*/ +static int vmw_ldu_fb_pin (struct vmw_framebuffer *vfb) +{ +struct vmw_private *dev_priv =vmw_priv (vfb->base.dev); +struct vmw_bo *buf; +int ret; + + buf = vfb->bo ?vmw_framebuffer_to_vfbd (&vfb->base)->buffer : +vmw_framebuffer_to_vfbs (&vfb->base)->surface->res.backup; + +if (!buf) +return 0 ; +WARN_ON (dev_priv->active_display_unit != vmw_du_legacy); + +if (dev_priv->active_display_unit == vmw_du_legacy) { +vmw_overlay_pause_all (dev_priv); + ret =vmw_bo_pin_in_start_of_vram (dev_priv, buf, false); +vmw_overlay_resume_all (dev_priv); + }else + ret = -EINVAL ; + +return ret; +} + +static int vmw_ldu_fb_unpin (struct vmw_framebuffer *vfb) +{ +struct vmw_private *dev_priv =vmw_priv (vfb->base.dev); +struct vmw_bo *buf; + + buf = vfb->bo ?vmw_framebuffer_to_vfbd (&vfb->base)->buffer : +vmw_framebuffer_to_vfbs (&vfb->base)->surface->res.backup; + +if (WARN_ON (!buf)) +return 0 ; + +return vmw_bo_unpin (dev_priv, buf, false); +} +static int vmw_ldu_del_active (struct vmw_private *vmw_priv,struct vmw_legacy_display_unit *ldu) {@@ -145,8 +188,7 @@ static int vmw_ldu_del_active(struct vmw_private *vmw_priv,list_del_init (&ldu->active);if (--(ld->num_active) ==0 ) {BUG_ON (!ld->fb); -if (ld->fb->unpin) - ld->fb->unpin (ld->fb); +WARN_ON (vmw_ldu_fb_unpin (ld->fb)); ld->fb =NULL ; }@@ -163,11 +205,10 @@ static int vmw_ldu_add_active(struct vmw_private *vmw_priv,BUG_ON (!ld->num_active && ld->fb);if (vfb != ld->fb) { -if (ld->fb && ld->fb->unpin)
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c static int vmw_ldu_add_active(struct vmw_private *vmw_priv, · line 214
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +3
-3- ld->fb->unpin (ld->fb); +if (ld->fb) +WARN_ON (vmw_ldu_fb_unpin (ld->fb));vmw_svga_enable (vmw_priv); -if (vfb->pin) - vfb->pin (vfb); +WARN_ON (vmw_ldu_fb_pin (vfb)); ld->fb = vfb; }
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 5/8 drm/vmwgfx: Cleanup the vmw bo usage in the cursor paths
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Base mapped count is useless because the ttm unmap functions handle null maps just fine so completely remove all the code related to it.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 3 --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 12 +----------- 2 files changed, 1 insertion(+), 14 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +0 -3
@@ -44,7 +44,6 @@ 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
@@ -55,8 +54,6 @@ struct vmw_resource;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 */
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1 -11
@@ -669,8 +669,7 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane,const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) { -if (atomic_read (&vps->bo->base_mapped_count) ==0 ) -ttm_bo_kunmap (&vps->bo->map); +ttm_bo_kunmap (&vps->bo->map);ttm_bo_unreserve (&vps->bo->base); } }
@@ -744,9 +743,6 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane, ret =ttm_bo_kmap (&vps->bo->base,0 ,PFN_UP (size), &vps->bo->map); -if (likely (ret ==0 )) -atomic_inc (&vps->bo->base_mapped_count); -ttm_bo_unreserve (&vps->bo->base);if (unlikely (ret !=0 ))
@@ -786,7 +782,6 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,struct vmw_plane_state *vps =vmw_plane_state_to_vps (new_state);struct vmw_plane_state *old_vps =vmw_plane_state_to_vps (old_state);s32 hotspot_x, hotspot_y; -bool dummy; hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y;
@@ -828,11 +823,6 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, hotspot_x, hotspot_y); } -if (vps->bo) { -if (ttm_kmap_obj_virtual (&vps->bo->map, &dummy)) -atomic_dec (&vps->bo->base_mapped_count); - } - du->cursor_x = new_state->crtc_x + du->set_gui_x; du->cursor_y = new_state->crtc_y + du->set_gui_y;
Signature · 1 line
2.38.1
Re: [PATCH v2 5/8] drm/vmwgfx: Cleanup the vmw bo usage in the cursor paths
Quoted 67 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Base mapped count is useless because the ttm unmap functions handle null maps just fine so completely remove all the code related to it.
Signed-off-by Zack Rusin <[email protected]>Reviewed-by Martin Krastev <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 3 --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 12 +----------- 2 files changed, 1 insertion(+), 14 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +0
-3@@ -44,7 +44,6 @@ 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 @@ -55,8 +54,6 @@ struct vmw_resource;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 */ drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1
-6@@ -669,8 +669,7 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane,const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) { -if (atomic_read (&vps->bo->base_mapped_count) ==0 ) -ttm_bo_kunmap (&vps->bo->map); +ttm_bo_kunmap (&vps->bo->map);ttm_bo_unreserve (&vps->bo->base); } }@@ -744,9 +743,6 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane, ret =ttm_bo_kmap (&vps->bo->base,0 ,PFN_UP (size), &vps->bo->map); -if (likely (ret ==0 )) -atomic_inc (&vps->bo->base_mapped_count); -ttm_bo_unreserve (&vps->bo->base);if (unlikely (ret !=0 ))@@ -786,7 +782,6 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,struct vmw_plane_state *vps =vmw_plane_state_to_vps (new_state);struct vmw_plane_state *old_vps =vmw_plane_state_to_vps (old_state);s32 hotspot_x, hotspot_y; -bool dummy; hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y;@@ -828,11 +823,6 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, hotspot_x, hotspot_y);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, · line 828
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0
-5} -if (vps->bo) { -if (ttm_kmap_obj_virtual (&vps->bo->map, &dummy)) -atomic_dec (&vps->bo->base_mapped_count); - } - du->cursor_x = new_state->crtc_x + du->set_gui_x; du->cursor_y = new_state->crtc_y + du->set_gui_y;
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 6/8 drm/vmwgfx: Rename dummy to is_iomem
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Rename dummy to is_iomem because that's what it is even if we're not activelly using it. Makes the code easier to read.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +8 -8
@@ -153,9 +153,9 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv,SVGAGBCursorHeader *header;SVGAGBAlphaCursorHeader *alpha_header;const u32 image_size = width * height *sizeof (*image); -bool dummy; +bool is_iomem; - header =ttm_kmap_obj_virtual (&vps->cursor.map, &dummy); + header =ttm_kmap_obj_virtual (&vps->cursor.map, &is_iomem); alpha_header = &header->header.alphaHeader;memset (header,0 ,sizeof (*header));
@@ -185,13 +185,13 @@ static u32 vmw_du_cursor_mob_size(u32 w, u32 h)*/ static u32 *vmw_du_cursor_plane_acquire_image (struct vmw_plane_state *vps) { -bool dummy; +bool is_iomem;if (vps->surf) {if (vps->surf_mapped)return vmw_bo_map_and_cache (vps->surf->res.backup);return vps->surf->snooper.image; }else if (vps->bo) -return ttm_kmap_obj_virtual (&vps->bo->map, &dummy); +return ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem);return NULL ; }
@@ -364,7 +364,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,SVGA3dCopyBox *box;unsigned box_count;void *virtual; -bool dummy; +bool is_iomem;struct vmw_dma_cmd {SVGA3dCmdHeader header;SVGA3dCmdSurfaceDMA dma;
@@ -424,7 +424,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,if (unlikely (ret !=0 )) goto err_unreserve; - virtual =ttm_kmap_obj_virtual (&map, &dummy); + virtual =ttm_kmap_obj_virtual (&map, &is_iomem);if (box->w ==VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) { memcpy(srf->snooper.image, virtual,
@@ -658,14 +658,14 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, {struct vmw_cursor_plane *vcp =vmw_plane_to_vcp (plane);struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state); -bool dummy; +bool is_iomem;if (vps->surf_mapped) {vmw_bo_unmap (vps->surf->res.backup); vps->surf_mapped = false; } -if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &dummy)) { +if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem)) {const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) {
Signature · 1 line
2.38.1
Re: [PATCH v2 6/8] drm/vmwgfx: Rename dummy to is_iomem
Am 31.01.23 um 04:35 schrieb Zack Rusin:
Quoted 6 lines
From: Zack Rusin <[email protected]>
Rename dummy to
is_iomembecause that's what it is even if we're not activelly using it. Makes the code easier to read.Signed-off-by Zack Rusin <[email protected]>
Quoted 71 lines
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +8
-8@@ -153,9 +153,9 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv,SVGAGBCursorHeader *header;SVGAGBAlphaCursorHeader *alpha_header;const u32 image_size = width * height *sizeof (*image); -bool dummy; +bool is_iomem; - header =ttm_kmap_obj_virtual (&vps->cursor.map, &dummy); + header =ttm_kmap_obj_virtual (&vps->cursor.map, &is_iomem); alpha_header = &header->header.alphaHeader;memset (header,0 ,sizeof (*header));@@ -185,13 +185,13 @@ static u32 vmw_du_cursor_mob_size(u32 w, u32 h)*/ static u32 *vmw_du_cursor_plane_acquire_image (struct vmw_plane_state *vps) { -bool dummy; +bool is_iomem;if (vps->surf) {if (vps->surf_mapped)return vmw_bo_map_and_cache (vps->surf->res.backup);return vps->surf->snooper.image; }else if (vps->bo) -return ttm_kmap_obj_virtual (&vps->bo->map, &dummy); +return ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem);return NULL ; }@@ -364,7 +364,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,SVGA3dCopyBox *box;unsigned box_count;void *virtual; -bool dummy; +bool is_iomem;struct vmw_dma_cmd {SVGA3dCmdHeader header;SVGA3dCmdSurfaceDMA dma;@@ -424,7 +424,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,if (unlikely (ret !=0 )) goto err_unreserve; - virtual =ttm_kmap_obj_virtual (&map, &dummy); + virtual =ttm_kmap_obj_virtual (&map, &is_iomem);if (box->w ==VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) { memcpy(srf->snooper.image, virtual,@@ -658,14 +658,14 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, {struct vmw_cursor_plane *vcp =vmw_plane_to_vcp (plane);struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state); -bool dummy; +bool is_iomem;if (vps->surf_mapped) {vmw_bo_unmap (vps->surf->res.backup); vps->surf_mapped = false; } -if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &dummy)) { +if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem)) {const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) {
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Re: [PATCH v2 6/8] drm/vmwgfx: Rename dummy to is_iomem
In reply to Zack RusinFrom: Martin Krastev <[email protected]>
LGTM
Regards,
Martin
Quoted 77 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Rename dummy to
is_iomembecause that's what it is even if we're not activelly using it. Makes the code easier to read.Signed-off-by Zack Rusin <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +8
-8@@ -153,9 +153,9 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv,SVGAGBCursorHeader *header;SVGAGBAlphaCursorHeader *alpha_header;const u32 image_size = width * height *sizeof (*image); -bool dummy; +bool is_iomem; - header =ttm_kmap_obj_virtual (&vps->cursor.map, &dummy); + header =ttm_kmap_obj_virtual (&vps->cursor.map, &is_iomem); alpha_header = &header->header.alphaHeader;memset (header,0 ,sizeof (*header));@@ -185,13 +185,13 @@ static u32 vmw_du_cursor_mob_size(u32 w, u32 h)*/ static u32 *vmw_du_cursor_plane_acquire_image (struct vmw_plane_state *vps) { -bool dummy; +bool is_iomem;if (vps->surf) {if (vps->surf_mapped)return vmw_bo_map_and_cache (vps->surf->res.backup);return vps->surf->snooper.image; }else if (vps->bo) -return ttm_kmap_obj_virtual (&vps->bo->map, &dummy); +return ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem);return NULL ; }@@ -364,7 +364,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,SVGA3dCopyBox *box;unsigned box_count;void *virtual; -bool dummy; +bool is_iomem;struct vmw_dma_cmd {SVGA3dCmdHeader header;SVGA3dCmdSurfaceDMA dma;@@ -424,7 +424,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,if (unlikely (ret !=0 )) goto err_unreserve; - virtual =ttm_kmap_obj_virtual (&map, &dummy); + virtual =ttm_kmap_obj_virtual (&map, &is_iomem);if (box->w ==VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) { memcpy(srf->snooper.image, virtual,@@ -658,14 +658,14 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, {struct vmw_cursor_plane *vcp =vmw_plane_to_vcp (plane);struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state); -bool dummy; +bool is_iomem;if (vps->surf_mapped) {vmw_bo_unmap (vps->surf->res.backup); vps->surf_mapped = false; } -if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &dummy)) { +if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem)) {const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) {
Re: [PATCH v2 6/8] drm/vmwgfx: Rename dummy to is_iomem
In reply to Zack RusinQuoted 67 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Rename dummy to
is_iomembecause that's what it is even if we're not activelly using it. Makes the code easier to read.Signed-off-by Zack Rusin <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +7
-7@@ -153,9 +153,9 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv,SVGAGBCursorHeader *header;SVGAGBAlphaCursorHeader *alpha_header;const u32 image_size = width * height *sizeof (*image); -bool dummy; +bool is_iomem; - header =ttm_kmap_obj_virtual (&vps->cursor.map, &dummy); + header =ttm_kmap_obj_virtual (&vps->cursor.map, &is_iomem); alpha_header = &header->header.alphaHeader;memset (header,0 ,sizeof (*header));@@ -185,13 +185,13 @@ static u32 vmw_du_cursor_mob_size(u32 w, u32 h)*/ static u32 *vmw_du_cursor_plane_acquire_image (struct vmw_plane_state *vps) { -bool dummy; +bool is_iomem;if (vps->surf) {if (vps->surf_mapped)return vmw_bo_map_and_cache (vps->surf->res.backup);return vps->surf->snooper.image; }else if (vps->bo) -return ttm_kmap_obj_virtual (&vps->bo->map, &dummy); +return ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem);return NULL ; }@@ -364,7 +364,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,SVGA3dCopyBox *box;unsigned box_count;void *virtual; -bool dummy; +bool is_iomem;struct vmw_dma_cmd {SVGA3dCmdHeader header;SVGA3dCmdSurfaceDMA dma;@@ -424,7 +424,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,if (unlikely (ret !=0 )) goto err_unreserve; - virtual =ttm_kmap_obj_virtual (&map, &dummy); + virtual =ttm_kmap_obj_virtual (&map, &is_iomem);if (box->w ==VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) { memcpy(srf->snooper.image, virtual,@@ -658,14 +658,14 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, {struct vmw_cursor_plane *vcp =vmw_plane_to_vcp (plane);struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state); -bool dummy; +bool is_iomem;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, · line 671
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1
-1if (vps->surf_mapped) {vmw_bo_unmap (vps->surf->res.backup); vps->surf_mapped = false; } -if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &dummy)) { +if (vps->bo &&ttm_kmap_obj_virtual (&vps->bo->map, &is_iomem)) {const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) {
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 7/8 drm/vmwgfx: Abstract placement selection
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Problem with explicit placement selection in vmwgfx is that by the time the buffer object needs to be validated the information about which placement was supposed to be used is lost. To workaround this the driver had a bunch of state in various places e.g. as_mob or cpu_blit to somehow convey the information on which placement was intended.
Fix it properly by allowing the buffer objects to hold their preferred placement so it can be reused whenever needed. This makes the entire validation pipeline a lot easier both to understand and maintain.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 145 +++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 25 +- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 35 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 5 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 22 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 21 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 13 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 304 ++---------------- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 47 --- drivers/gpu/drm/vmwgfx/vmwgfx_va.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 74 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 6 +- 22 files changed, 312 insertions(+), 456 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +126 -19
@@ -135,11 +135,17 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, goto out_unreserve; } - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (likely (ret ==0 ) || ret == -ERESTARTSYS ) goto out_unreserve; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx); out_unreserve:if (!ret)
@@ -190,17 +196,8 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, {struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base; -struct ttm_placement placement; -struct ttm_place place;int ret =0 ; - place = vmw_vram_placement.placement[0 ]; - place.lpfn =PFN_UP (bo->resource->size); - placement.num_placement =1 ; - placement.placement = &place; - placement.num_busy_placement =1 ; - placement.busy_placement = &place; -vmw_execbuf_release_pinned_bo (dev_priv); ret =ttm_bo_reserve (bo, interruptible, false,NULL );if (unlikely (ret !=0 ))
@@ -216,14 +213,21 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, bo->resource->start > 0 && buf->base.pin_count == 0) { ctx.interruptible = false; - (void )ttm_bo_validate (bo, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + (void )ttm_bo_validate (bo, &buf->placement, &ctx); } +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + buf->places[0 ].lpfn =PFN_UP (bo->resource->size);if (buf->base.pin_count >0 ) - ret =ttm_resource_compat (bo->resource, &placement) + ret =ttm_resource_compat (bo->resource, &buf->placement) ?0 : -EINVAL ;else - ret =ttm_bo_validate (bo, &placement, &ctx); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);/* For some reason we didn't end up at the start of vram */ WARN_ON (ret ==0 && bo->resource->start !=0 );
@@ -431,7 +435,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, }int vmw_bo_create (struct vmw_private *vmw, -size_t size,struct ttm_placement *placement, +size_t size,u32 domain,u32 busy_domain,bool interruptible,bool pin,struct vmw_bo **p_bo) {
@@ -444,7 +448,8 @@ int vmw_bo_create(struct vmw_private *vmw, } ret =vmw_bo_init (vmw, *p_bo, size, - placement, interruptible, pin); + domain, busy_domain, + interruptible, pin);if (unlikely (ret !=0 )) goto out_error;
@@ -461,7 +466,8 @@ int vmw_bo_create(struct vmw_private *vmw,* @dev_priv: Pointer to the device private struct * @vmw_bo: Pointer to the struct vmw_bo to initialize. * @size: Buffer object size in bytes. -* @placement: Initial placement. +* @domain: Domain to put the bo in. +* @busy_domain: Domain to put the bo if busy. * @interruptible: Whether waits should be performed interruptible. * @pin: If the BO should be created pinned at a fixed location. * Returns: Zero on success, negative error code on error.
@@ -470,7 +476,9 @@ int vmw_bo_create(struct vmw_private *vmw,*/ int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_bo *vmw_bo, -size_t size,struct ttm_placement *placement, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin) {struct ttm_operation_ctx ctx = {
@@ -489,8 +497,9 @@ int vmw_bo_init(struct vmw_private *dev_priv, size =ALIGN (size,PAGE_SIZE );drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); +vmw_bo_placement_set (vmw_bo, domain, busy_domain); ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - placement,0 , &ctx,NULL ,NULL , vmw_bo_free); + &vmw_bo->placement,0 , &ctx,NULL ,NULL , vmw_bo_free);if (unlikely (ret)) {return ret; }
@@ -825,3 +834,101 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo,if (mem->mem_type !=VMW_PL_MOB && bo->resource->mem_type ==VMW_PL_MOB )vmw_resource_unbind_list (vbo); } + +static u32 +set_placement_list (struct ttm_place *pl,u32 domain) +{ +u32 n =0 ; + +/* +* The placements are ordered according to our preferences +*/ +if (domain &VMW_BO_DOMAIN_MOB ) { + pl[n].mem_type =VMW_PL_MOB ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_GMR ) { + pl[n].mem_type =VMW_PL_GMR ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_VRAM ) { + pl[n].mem_type =TTM_PL_VRAM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +WARN_ON ((domain &VMW_BO_DOMAIN_WAITABLE_SYS ) !=0 ); +if (domain &VMW_BO_DOMAIN_WAITABLE_SYS ) { + pl[n].mem_type =VMW_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_SYS ) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } + +WARN_ON (!n); +if (!n) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +return n; +} + +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +struct ttm_placement *pl = &bo->placement; +bool mem_compatible = false; +u32 i; + + pl->placement = bo->places; + pl->num_placement =set_placement_list (bo->places, domain); + +if (drm_debug_enabled (DRM_UT_DRIVER ) && bo->base.resource) { +for (i =0 ; i < pl->num_placement; ++i) { +if (bo->base.resource->mem_type ==TTM_PL_SYSTEM || + bo->base.resource->mem_type == pl->placement[i].mem_type) + mem_compatible = true; + } +if (!mem_compatible) +drm_warn (&vmw->drm, +"%s: Incompatible transition from " +"bo->base.resource->mem_type = %u to domain = %u\n" , + __func__, bo->base.resource->mem_type, domain); + } + + pl->busy_placement = bo->busy_places; + pl->num_busy_placement =set_placement_list (bo->busy_places, busy_domain); +} + +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +u32 domain =VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ; + +if (vmw->has_mob) + domain =VMW_BO_DOMAIN_MOB ; + +vmw_bo_placement_set (bo, domain, domain); +}
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +23 -2
@@ -31,6 +31,7 @@#include "device_include/svga_reg.h" #include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_placement.h> #include <linux/rbtree_types.h> #include <linux/types.h>
@@ -40,6 +41,14 @@ struct vmw_fence_obj;struct vmw_private ;struct vmw_resource ; +enum vmw_bo_domain { +VMW_BO_DOMAIN_SYS =BIT (0 ), +VMW_BO_DOMAIN_WAITABLE_SYS =BIT (1 ), +VMW_BO_DOMAIN_VRAM =BIT (2 ), +VMW_BO_DOMAIN_GMR =BIT (3 ), +VMW_BO_DOMAIN_MOB =BIT (4 ), +}; +/** * struct vmw_bo - TTM buffer object with vmwgfx additions * @base: The TTM buffer object
@@ -53,6 +62,11 @@ struct vmw_resource;*/ struct vmw_bo {struct ttm_buffer_object base; + +struct ttm_placement placement; +struct ttm_place places[5 ]; +struct ttm_place busy_places[5 ]; +struct rb_root res_tree;atomic_t cpu_writers;
@@ -64,17 +78,24 @@ struct vmw_bo {struct vmw_bo_dirty *dirty; }; +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain); +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo); +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, +size_t size, +u32 domain, +u32 busy_domain,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, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin);int vmw_bo_unref_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +6 -3
@@ -76,7 +76,8 @@ static const struct vmw_res_func vmw_legacy_context_func = { .needs_backup = false, .may_evict = false, .type_name = "legacy contexts", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,
@@ -90,7 +91,8 @@ static const struct vmw_res_func vmw_gb_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_context_create, .destroy = vmw_gb_context_destroy, .bind = vmw_gb_context_bind,
@@ -104,7 +106,8 @@ static const struct vmw_res_func vmw_dx_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_context_create, .destroy = vmw_dx_context_destroy, .bind = vmw_dx_context_bind,
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +8 -3
@@ -136,7 +136,8 @@ static const struct vmw_res_func vmw_cotable_func = { .prio = 3, .dirty_prio = 3, .type_name = "context guest backed object tables", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_cotable_create, .destroy = vmw_cotable_destroy, .bind = vmw_cotable_bind,
@@ -424,7 +425,8 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)* for the new COTable. Initially pin the buffer object to make sure * we can use tryreserve without failure. */ - ret =vmw_bo_create (dev_priv, new_size, &vmw_mob_placement, + ret =vmw_bo_create (dev_priv, new_size, +VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB , true, true, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" );
@@ -465,7 +467,10 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) }/* Unpin new buffer, and switch backup buffers. */ - ret =ttm_bo_validate (bo, &vmw_mob_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (unlikely (ret !=0 )) {DRM_ERROR ("Failed validating new COTable backup buffer.\n" ); goto out_wait;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -1
@@ -399,7 +399,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)* user of the bo currently. */ ret =vmw_bo_create (dev_priv,PAGE_SIZE , - &vmw_sys_placement, false, true, &vbo); +VMW_BO_DOMAIN_SYS ,VMW_BO_DOMAIN_SYS , + false, true, &vbo);if (unlikely (ret !=0 ))return ret;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0 -2
@@ -930,9 +930,7 @@ extern struct ttm_placement vmw_vram_placement;extern struct ttm_placement vmw_vram_sys_placement;extern struct ttm_placement vmw_vram_gmr_placement;extern struct ttm_placement vmw_sys_placement; -extern struct ttm_placement vmw_srf_placement;extern struct ttm_placement vmw_mob_placement; -extern struct ttm_placement vmw_nonfixed_placement;extern struct ttm_device_funcs vmw_bo_driver;extern const struct vmw_sg_table *vmw_bo_sg_table (struct ttm_buffer_object *bo);
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +23 -12
@@ -477,9 +477,13 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,struct vmw_bo *dx_query_mob; dx_query_mob =vmw_context_get_dx_query_mob (ctx); -if (dx_query_mob) +if (dx_query_mob) { +vmw_bo_placement_set (dx_query_mob, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); ret =vmw_validation_add_bo (sw_context->ctx, - dx_query_mob, true, false); + dx_query_mob); + } }mutex_unlock (&dev_priv->binding_mutex);
@@ -1035,17 +1039,17 @@ static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv,if (unlikely (sw_context->cur_query_bo !=NULL )) { sw_context->needs_post_query_barrier = true; +vmw_bo_placement_set_default_accelerated (sw_context->cur_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - sw_context->cur_query_bo, - dev_priv->has_mob, false); + sw_context->cur_query_bo);if (unlikely (ret !=0 ))return ret; } sw_context->cur_query_bo = new_query_bo; +vmw_bo_placement_set_default_accelerated (dev_priv->dummy_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - dev_priv->dummy_query_bo, - dev_priv->has_mob, false); + dev_priv->dummy_query_bo);if (unlikely (ret !=0 ))return ret; }
@@ -1157,7 +1161,8 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use MOB buffer.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, true, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;
@@ -1211,7 +1216,9 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use GMR region.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, false, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;
@@ -4361,13 +4368,17 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,if (dev_priv->pinned_bo ==NULL ) goto out_unlock; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo, false, - false); +vmw_bo_placement_set (dev_priv->pinned_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo);if (ret) goto out_no_reserve; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo, false, - false); +vmw_bo_placement_set (dev_priv->dummy_query_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo);if (ret) goto out_no_reserve;
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +2 -3
@@ -121,9 +121,8 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,int ret; ret =vmw_bo_create (dev_priv, size, - (dev_priv->has_mob) ? - &vmw_sys_placement : - &vmw_vram_sys_placement, + (dev_priv->has_mob) ?VMW_BO_DOMAIN_SYS :VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_SYS , true, false, p_vbo); (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +17 -5
@@ -1270,9 +1270,9 @@ int vmw_kms_readback(struct vmw_private *dev_priv, user_fence_rep, vclips, num_clips, NULL);case vmw_du_screen_target: -return vmw_kms_stdu_dma (dev_priv, file_priv, vfb, - user_fence_rep,NULL , vclips, num_clips, -1 , false, true,NULL ); +return vmw_kms_stdu_readback (dev_priv, file_priv, vfb, + user_fence_rep,NULL , vclips, num_clips, +1 ,NULL );default :WARN_ONCE (true,"Readback called with invalid display system.\n" );
@@ -2999,8 +2999,20 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)struct vmw_framebuffer_bo *vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer, false, - update->cpu_blit); +/* +* For screen targets we want a mappable bo, for everything else we want +* accelerated i.e. host backed (vram or gmr) bo. If the display unit +* is not screen target then mob's shouldn't be available. +*/ +if (update->dev_priv->active_display_unit == vmw_du_screen_target) { +vmw_bo_placement_set (vfbbo->buffer, +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR ); + }else { +WARN_ON (update->dev_priv->has_mob); +vmw_bo_placement_set_default_accelerated (vfbbo->buffer); + } + ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer); }else {struct vmw_framebuffer_surface *vfbs =container_of (update->vfb,typeof (*vfbs), base);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +9 -12
@@ -126,7 +126,6 @@ struct vmw_du_update_plane {struct vmw_framebuffer *vfb;struct vmw_fence_obj **out_fence;struct mutex *mutex; -bool cpu_blit;bool intr; };
@@ -564,17 +563,15 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, unsigned num_clips, int inc, struct vmw_fence_obj **out_fence, struct drm_crtc *crtc); -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc); +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc);int vmw_du_helper_plane_update (struct vmw_du_update_plane *update);
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +8 -3
@@ -332,7 +332,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, } ret =vmw_bo_create (res->dev_priv, res->backup_size, - res->func->backup_placement, + res->func->domain, res->func->busy_domain, interruptible, false, &backup);if (unlikely (ret !=0 )) goto out_no_bo;
@@ -529,8 +529,10 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,return 0 ; backup_dirty = res->backup_dirty; +vmw_bo_placement_set (res->backup, res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&res->backup->base, - res->func->backup_placement, + &res->backup->placement, &ctx);if (unlikely (ret !=0 ))
@@ -968,9 +970,12 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)if (ret) goto out_no_validate;if (!vbo->base.pin_count) { +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&vbo->base, - res->func->backup_placement, + &vbo->placement, &ctx);if (ret) {ttm_bo_unreserve (&vbo->base);
drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +2 -1
@@ -83,7 +83,8 @@ struct vmw_res_func {enum vmw_res_type res_type;bool needs_backup;const char *type_name; -struct ttm_placement *backup_placement; +u32 domain; +u32 busy_domain;bool may_evict;u32 prio;u32 dirty_prio;
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +8 -5
@@ -445,7 +445,8 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,*/ vmw_overlay_pause_all (dev_priv); ret =vmw_bo_create (dev_priv, size, - &vmw_vram_placement, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM , false, true, &vps->bo);vmw_overlay_resume_all (dev_priv);if (ret) {
@@ -547,7 +548,6 @@ static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit = false; bo_update.base.intr = true; bo_update.base.calc_fifo_size = vmw_sou_bo_fifo_size;
@@ -708,7 +708,6 @@ static int vmw_sou_plane_update_surface(struct vmw_private *dev_priv, srf_update.base.vfb = vfb; srf_update.base.out_fence = out_fence; srf_update.base.mutex = &dev_priv->cmdbuf_mutex; - srf_update.base.cpu_blit = false; srf_update.base.intr = true; srf_update.base.calc_fifo_size = vmw_sou_surface_fifo_size;
@@ -1224,7 +1223,9 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;
@@ -1330,7 +1331,9 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +11 -4
@@ -94,7 +94,8 @@ static const struct vmw_res_func vmw_gb_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_shader_create, .destroy = vmw_gb_shader_destroy, .bind = vmw_gb_shader_bind,
@@ -108,7 +109,8 @@ static const struct vmw_res_func vmw_dx_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_shader_create,/* * The destroy callback is only called with a committed resource on
@@ -893,7 +895,9 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,if (!vmw_shader_id_ok (user_key, shader_type))return -EINVAL ; - ret =vmw_bo_create (dev_priv, size, &vmw_sys_placement, + ret =vmw_bo_create (dev_priv, size, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS , true, true, &buf);if (unlikely (ret !=0 )) goto out;
@@ -913,7 +917,10 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,WARN_ON (is_iomem);ttm_bo_kunmap (&map); - ret =ttm_bo_validate (&buf->base, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + ret =ttm_bo_validate (&buf->base, &buf->placement, &ctx);WARN_ON (ret !=0 );ttm_bo_unreserve (&buf->base);
drivers/gpu/drm/vmwgfx/vmwgfx_so.c +3 -1
@@ -24,6 +24,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h"
@@ -84,7 +85,8 @@ static const struct vmw_res_func vmw_view_func = { .needs_backup = false, .may_evict = false, .type_name = "DX view", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = vmw_view_create, .commit_notify = vmw_view_commit_notify, };
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +35 -269
401 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +2 -1
@@ -66,7 +66,8 @@ static const struct vmw_res_func vmw_dx_streamoutput_func = { .needs_backup = true, .may_evict = false, .type_name = "DX streamoutput", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_streamoutput_create, .destroy = NULL, /* Command buffer managed resource. */ .bind = vmw_dx_streamoutput_bind,
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +4 -2
@@ -131,7 +131,8 @@ static const struct vmw_res_func vmw_legacy_surface_func = { .prio = 1, .dirty_prio = 1, .type_name = "legacy surfaces", - .backup_placement = &vmw_srf_placement, + .domain = VMW_BO_DOMAIN_GMR, + .busy_domain = VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM, .create = &vmw_legacy_srf_create, .destroy = &vmw_legacy_srf_destroy, .bind = &vmw_legacy_srf_bind,
@@ -145,7 +146,8 @@ static const struct vmw_res_func vmw_gb_surface_func = { .prio = 1, .dirty_prio = 2, .type_name = "guest backed surfaces", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_surface_create, .destroy = vmw_gb_surface_destroy, .bind = vmw_gb_surface_bind,
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0 -47
65 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_va.c +3 -1
@@ -25,6 +25,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h"
@@ -83,7 +84,8 @@ static const struct vmw_simple_resource_func va_stream_func = { .needs_backup = false, .may_evict = false, .type_name = "overlay stream", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +19 -55
152 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +1 -5
@@ -159,11 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) }int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob,bool cpu_blit); -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob); +struct vmw_bo *vbo);int vmw_validation_bo_validate (struct vmw_validation_context *ctx,bool intr);void vmw_validation_unref_lists (struct vmw_validation_context *ctx); int vmw_validation_add_resource(struct vmw_validation_context *ctx,
Signature · 1 line
2.38.1
Re: [PATCH v2 7/8] drm/vmwgfx: Abstract placement selection
From: Martin Krastev <[email protected]>
LGTM
Regards,
Martin
Quoted 1,507 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Problem with explicit placement selection in vmwgfx is that by the time the buffer object needs to be validated the information about which placement was supposed to be used is lost. To workaround this the driver had a bunch of state in various places e.g.
as_moborcpu_blitto somehow convey the information on which placement was intended.Fix it properly by allowing the buffer objects to hold their preferred placement so it can be reused whenever needed. This makes the entire validation pipeline a lot easier both to understand and maintain.
Signed-off-by Zack Rusin <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 145 +++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 25 +- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 35 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 5 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 22 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 21 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 13 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 304 ++---------------- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 47 --- drivers/gpu/drm/vmwgfx/vmwgfx_va.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 74 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 6 +- 22 files changed, 312 insertions(+), 456 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +126
-19@@ -135,11 +135,17 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, goto out_unreserve; } - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (likely (ret ==0 ) || ret == -ERESTARTSYS ) goto out_unreserve; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx); out_unreserve:if (!ret)@@ -190,17 +196,8 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, {struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base; -struct ttm_placement placement; -struct ttm_place place;int ret =0 ; - place = vmw_vram_placement.placement[0 ]; - place.lpfn =PFN_UP (bo->resource->size); - placement.num_placement =1 ; - placement.placement = &place; - placement.num_busy_placement =1 ; - placement.busy_placement = &place; -vmw_execbuf_release_pinned_bo (dev_priv); ret =ttm_bo_reserve (bo, interruptible, false,NULL );if (unlikely (ret !=0 ))@@ -216,14 +213,21 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, bo->resource->start > 0 && buf->base.pin_count == 0) { ctx.interruptible = false; - (void )ttm_bo_validate (bo, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + (void )ttm_bo_validate (bo, &buf->placement, &ctx); } +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + buf->places[0 ].lpfn =PFN_UP (bo->resource->size);if (buf->base.pin_count >0 ) - ret =ttm_resource_compat (bo->resource, &placement) + ret =ttm_resource_compat (bo->resource, &buf->placement) ?0 : -EINVAL ;else - ret =ttm_bo_validate (bo, &placement, &ctx); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);/* For some reason we didn't end up at the start of vram */ WARN_ON (ret ==0 && bo->resource->start !=0 );@@ -431,7 +435,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, }int vmw_bo_create (struct vmw_private *vmw, -size_t size,struct ttm_placement *placement, +size_t size,u32 domain,u32 busy_domain,bool interruptible,bool pin,struct vmw_bo **p_bo) {@@ -444,7 +448,8 @@ int vmw_bo_create(struct vmw_private *vmw, } ret =vmw_bo_init (vmw, *p_bo, size, - placement, interruptible, pin); + domain, busy_domain, + interruptible, pin);if (unlikely (ret !=0 )) goto out_error;@@ -461,7 +466,8 @@ int vmw_bo_create(struct vmw_private *vmw,* @dev_priv: Pointer to the device private struct * @vmw_bo: Pointer to the struct vmw_bo to initialize. * @size: Buffer object size in bytes. -* @placement: Initial placement. +* @domain: Domain to put the bo in. +* @busy_domain: Domain to put the bo if busy. * @interruptible: Whether waits should be performed interruptible. * @pin: If the BO should be created pinned at a fixed location. * Returns: Zero on success, negative error code on error. @@ -470,7 +476,9 @@ int vmw_bo_create(struct vmw_private *vmw,*/ int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_bo *vmw_bo, -size_t size,struct ttm_placement *placement, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin) {struct ttm_operation_ctx ctx = {@@ -489,8 +497,9 @@ int vmw_bo_init(struct vmw_private *dev_priv, size =ALIGN (size,PAGE_SIZE );drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); +vmw_bo_placement_set (vmw_bo, domain, busy_domain); ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - placement,0 , &ctx,NULL ,NULL , vmw_bo_free); + &vmw_bo->placement,0 , &ctx,NULL ,NULL , vmw_bo_free);if (unlikely (ret)) {return ret; }@@ -825,3 +834,101 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo,if (mem->mem_type !=VMW_PL_MOB && bo->resource->mem_type ==VMW_PL_MOB )vmw_resource_unbind_list (vbo); } + +static u32 +set_placement_list (struct ttm_place *pl,u32 domain) +{ +u32 n =0 ; + +/* +* The placements are ordered according to our preferences +*/ +if (domain &VMW_BO_DOMAIN_MOB ) { + pl[n].mem_type =VMW_PL_MOB ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_GMR ) { + pl[n].mem_type =VMW_PL_GMR ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_VRAM ) { + pl[n].mem_type =TTM_PL_VRAM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +WARN_ON ((domain &VMW_BO_DOMAIN_WAITABLE_SYS ) !=0 ); +if (domain &VMW_BO_DOMAIN_WAITABLE_SYS ) { + pl[n].mem_type =VMW_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_SYS ) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } + +WARN_ON (!n); +if (!n) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +return n; +} + +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +struct ttm_placement *pl = &bo->placement; +bool mem_compatible = false; +u32 i; + + pl->placement = bo->places; + pl->num_placement =set_placement_list (bo->places, domain); + +if (drm_debug_enabled (DRM_UT_DRIVER ) && bo->base.resource) { +for (i =0 ; i < pl->num_placement; ++i) { +if (bo->base.resource->mem_type ==TTM_PL_SYSTEM || + bo->base.resource->mem_type == pl->placement[i].mem_type) + mem_compatible = true; + } +if (!mem_compatible) +drm_warn (&vmw->drm, +"%s: Incompatible transition from " +"bo->base.resource->mem_type = %u to domain = %u\n" , + __func__, bo->base.resource->mem_type, domain); + } + + pl->busy_placement = bo->busy_places; + pl->num_busy_placement =set_placement_list (bo->busy_places, busy_domain); +} + +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +u32 domain =VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ; + +if (vmw->has_mob) + domain =VMW_BO_DOMAIN_MOB ; + +vmw_bo_placement_set (bo, domain, domain); +}drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +23
-2@@ -31,6 +31,7 @@#include "device_include/svga_reg.h" #include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_placement.h> #include <linux/rbtree_types.h> #include <linux/types.h> @@ -40,6 +41,14 @@ struct vmw_fence_obj;struct vmw_private ;struct vmw_resource ; +enum vmw_bo_domain { +VMW_BO_DOMAIN_SYS =BIT (0 ), +VMW_BO_DOMAIN_WAITABLE_SYS =BIT (1 ), +VMW_BO_DOMAIN_VRAM =BIT (2 ), +VMW_BO_DOMAIN_GMR =BIT (3 ), +VMW_BO_DOMAIN_MOB =BIT (4 ), +}; +/** * struct vmw_bo - TTM buffer object with vmwgfx additions * @base: The TTM buffer object @@ -53,6 +62,11 @@ struct vmw_resource;*/ struct vmw_bo {struct ttm_buffer_object base; + +struct ttm_placement placement; +struct ttm_place places[5 ]; +struct ttm_place busy_places[5 ]; +struct rb_root res_tree;atomic_t cpu_writers;@@ -64,17 +78,24 @@ struct vmw_bo {struct vmw_bo_dirty *dirty; }; +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain); +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo); +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, +size_t size, +u32 domain, +u32 busy_domain,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, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin);int vmw_bo_unref_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);drivers/gpu/drm/vmwgfx/vmwgfx_context.c +6
-3@@ -76,7 +76,8 @@ static const struct vmw_res_func vmw_legacy_context_func = { .needs_backup = false, .may_evict = false, .type_name = "legacy contexts", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,@@ -90,7 +91,8 @@ static const struct vmw_res_func vmw_gb_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_context_create, .destroy = vmw_gb_context_destroy, .bind = vmw_gb_context_bind,@@ -104,7 +106,8 @@ static const struct vmw_res_func vmw_dx_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_context_create, .destroy = vmw_dx_context_destroy, .bind = vmw_dx_context_bind,drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +8
-3@@ -136,7 +136,8 @@ static const struct vmw_res_func vmw_cotable_func = { .prio = 3, .dirty_prio = 3, .type_name = "context guest backed object tables", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_cotable_create, .destroy = vmw_cotable_destroy, .bind = vmw_cotable_bind,@@ -424,7 +425,8 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)* for the new COTable. Initially pin the buffer object to make sure * we can use tryreserve without failure. */ - ret =vmw_bo_create (dev_priv, new_size, &vmw_mob_placement, + ret =vmw_bo_create (dev_priv, new_size, +VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB , true, true, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" );@@ -465,7 +467,10 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) }/* Unpin new buffer, and switch backup buffers. */ - ret =ttm_bo_validate (bo, &vmw_mob_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (unlikely (ret !=0 )) {DRM_ERROR ("Failed validating new COTable backup buffer.\n" ); goto out_wait;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2
-1@@ -399,7 +399,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)* user of the bo currently. */ ret =vmw_bo_create (dev_priv,PAGE_SIZE , - &vmw_sys_placement, false, true, &vbo); +VMW_BO_DOMAIN_SYS ,VMW_BO_DOMAIN_SYS , + false, true, &vbo);if (unlikely (ret !=0 ))return ret;drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0
-2@@ -930,9 +930,7 @@ extern struct ttm_placement vmw_vram_placement;extern struct ttm_placement vmw_vram_sys_placement;extern struct ttm_placement vmw_vram_gmr_placement;extern struct ttm_placement vmw_sys_placement; -extern struct ttm_placement vmw_srf_placement;extern struct ttm_placement vmw_mob_placement; -extern struct ttm_placement vmw_nonfixed_placement;extern struct ttm_device_funcs vmw_bo_driver;extern const struct vmw_sg_table *vmw_bo_sg_table (struct ttm_buffer_object *bo);drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +23
-12@@ -477,9 +477,13 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,struct vmw_bo *dx_query_mob; dx_query_mob =vmw_context_get_dx_query_mob (ctx); -if (dx_query_mob) +if (dx_query_mob) { +vmw_bo_placement_set (dx_query_mob, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); ret =vmw_validation_add_bo (sw_context->ctx, - dx_query_mob, true, false); + dx_query_mob); + } }mutex_unlock (&dev_priv->binding_mutex);@@ -1035,17 +1039,17 @@ static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv,if (unlikely (sw_context->cur_query_bo !=NULL )) { sw_context->needs_post_query_barrier = true; +vmw_bo_placement_set_default_accelerated (sw_context->cur_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - sw_context->cur_query_bo, - dev_priv->has_mob, false); + sw_context->cur_query_bo);if (unlikely (ret !=0 ))return ret; } sw_context->cur_query_bo = new_query_bo; +vmw_bo_placement_set_default_accelerated (dev_priv->dummy_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - dev_priv->dummy_query_bo, - dev_priv->has_mob, false); + dev_priv->dummy_query_bo);if (unlikely (ret !=0 ))return ret; }@@ -1157,7 +1161,8 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use MOB buffer.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, true, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;@@ -1211,7 +1216,9 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use GMR region.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, false, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;@@ -4361,13 +4368,17 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,if (dev_priv->pinned_bo ==NULL ) goto out_unlock; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo, false, - false); +vmw_bo_placement_set (dev_priv->pinned_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo);if (ret) goto out_no_reserve; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo, false, - false); +vmw_bo_placement_set (dev_priv->dummy_query_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo);if (ret) goto out_no_reserve;drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +2
-3@@ -121,9 +121,8 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,int ret; ret =vmw_bo_create (dev_priv, size, - (dev_priv->has_mob) ? - &vmw_sys_placement : - &vmw_vram_sys_placement, + (dev_priv->has_mob) ?VMW_BO_DOMAIN_SYS :VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_SYS , true, false, p_vbo); (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +17
-5@@ -1270,9 +1270,9 @@ int vmw_kms_readback(struct vmw_private *dev_priv, user_fence_rep, vclips, num_clips, NULL);case vmw_du_screen_target: -return vmw_kms_stdu_dma (dev_priv, file_priv, vfb, - user_fence_rep,NULL , vclips, num_clips, -1 , false, true,NULL ); +return vmw_kms_stdu_readback (dev_priv, file_priv, vfb, + user_fence_rep,NULL , vclips, num_clips, +1 ,NULL );default :WARN_ONCE (true,"Readback called with invalid display system.\n" );@@ -2999,8 +2999,20 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)struct vmw_framebuffer_bo *vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer, false, - update->cpu_blit); +/* +* For screen targets we want a mappable bo, for everything else we want +* accelerated i.e. host backed (vram or gmr) bo. If the display unit +* is not screen target then mob's shouldn't be available. +*/ +if (update->dev_priv->active_display_unit == vmw_du_screen_target) { +vmw_bo_placement_set (vfbbo->buffer, +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR ); + }else { +WARN_ON (update->dev_priv->has_mob); +vmw_bo_placement_set_default_accelerated (vfbbo->buffer); + } + ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer); }else {struct vmw_framebuffer_surface *vfbs =container_of (update->vfb,typeof (*vfbs), base);drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +9
-12@@ -126,7 +126,6 @@ struct vmw_du_update_plane {struct vmw_framebuffer *vfb;struct vmw_fence_obj **out_fence;struct mutex *mutex; -bool cpu_blit;bool intr; };@@ -564,17 +563,15 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, unsigned num_clips, int inc, struct vmw_fence_obj **out_fence, struct drm_crtc *crtc); -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc); +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc);int vmw_du_helper_plane_update (struct vmw_du_update_plane *update);drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +8
-3@@ -332,7 +332,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, } ret =vmw_bo_create (res->dev_priv, res->backup_size, - res->func->backup_placement, + res->func->domain, res->func->busy_domain, interruptible, false, &backup);if (unlikely (ret !=0 )) goto out_no_bo;@@ -529,8 +529,10 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,return 0 ; backup_dirty = res->backup_dirty; +vmw_bo_placement_set (res->backup, res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&res->backup->base, - res->func->backup_placement, + &res->backup->placement, &ctx);if (unlikely (ret !=0 ))@@ -968,9 +970,12 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)if (ret) goto out_no_validate;if (!vbo->base.pin_count) { +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&vbo->base, - res->func->backup_placement, + &vbo->placement, &ctx);if (ret) {ttm_bo_unreserve (&vbo->base);drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +2
-1@@ -83,7 +83,8 @@ struct vmw_res_func {enum vmw_res_type res_type;bool needs_backup;const char *type_name; -struct ttm_placement *backup_placement; +u32 domain; +u32 busy_domain;bool may_evict;u32 prio;u32 dirty_prio;drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +8
-5@@ -445,7 +445,8 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,*/ vmw_overlay_pause_all (dev_priv); ret =vmw_bo_create (dev_priv, size, - &vmw_vram_placement, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM , false, true, &vps->bo);vmw_overlay_resume_all (dev_priv);if (ret) {@@ -547,7 +548,6 @@ static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit = false; bo_update.base.intr = true; bo_update.base.calc_fifo_size = vmw_sou_bo_fifo_size;@@ -708,7 +708,6 @@ static int vmw_sou_plane_update_surface(struct vmw_private *dev_priv, srf_update.base.vfb = vfb; srf_update.base.out_fence = out_fence; srf_update.base.mutex = &dev_priv->cmdbuf_mutex; - srf_update.base.cpu_blit = false; srf_update.base.intr = true; srf_update.base.calc_fifo_size = vmw_sou_surface_fifo_size;@@ -1224,7 +1223,9 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;@@ -1330,7 +1331,9 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +11
-4@@ -94,7 +94,8 @@ static const struct vmw_res_func vmw_gb_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_shader_create, .destroy = vmw_gb_shader_destroy, .bind = vmw_gb_shader_bind,@@ -108,7 +109,8 @@ static const struct vmw_res_func vmw_dx_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_shader_create,/* * The destroy callback is only called with a committed resource on @@ -893,7 +895,9 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,if (!vmw_shader_id_ok (user_key, shader_type))return -EINVAL ; - ret =vmw_bo_create (dev_priv, size, &vmw_sys_placement, + ret =vmw_bo_create (dev_priv, size, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS , true, true, &buf);if (unlikely (ret !=0 )) goto out;@@ -913,7 +917,10 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,WARN_ON (is_iomem);ttm_bo_kunmap (&map); - ret =ttm_bo_validate (&buf->base, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + ret =ttm_bo_validate (&buf->base, &buf->placement, &ctx);WARN_ON (ret !=0 );ttm_bo_unreserve (&buf->base);drivers/gpu/drm/vmwgfx/vmwgfx_so.c +3
-1@@ -24,6 +24,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h" @@ -84,7 +85,8 @@ static const struct vmw_res_func vmw_view_func = { .needs_backup = false, .may_evict = false, .type_name = "DX view", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = vmw_view_create, .commit_notify = vmw_view_commit_notify, };drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +35
-269@@ -66,7 +66,6 @@ enum stdu_content_type {*/ struct vmw_stdu_dirty {struct vmw_kms_dirty base; -SVGA3dTransferType transfer;s32 left, right, top, bottom;s32 fb_left, fb_top;u32 pitch;@@ -137,12 +136,6 @@ static void vmw_stdu_destroy(struct vmw_screen_target_display_unit *stdu);* Screen Target Display Unit CRTC Functions *****************************************************************************/ -static bool vmw_stdu_use_cpu_blit (const struct vmw_private *vmw) -{ -return !(vmw->capabilities &SVGA_CAP_3D ) || vmw->vram_size < (32 *1024 *1024 ); -} - -/** * vmw_stdu_crtc_destroy - cleans up the STDU * @@ -451,93 +444,6 @@ static void vmw_stdu_crtc_atomic_disable(struct drm_crtc *crtc, } } -/** -* vmw_stdu_bo_clip - Callback to encode a suface DMA command cliprect -* -* @dirty: The closure structure. -* -* Encodes a surface DMA command cliprect and updates the bounding box -* for the DMA. -*/ -static void vmw_stdu_bo_clip (struct vmw_kms_dirty *dirty) -{ -struct vmw_stdu_dirty *ddirty = - container_of(dirty, struct vmw_stdu_dirty, base); -struct vmw_stdu_dma *cmd = dirty->cmd; -struct SVGA3dCopyBox *blit = (struct SVGA3dCopyBox *) &cmd[1 ]; - - blit += dirty->num_hits; - blit->srcx = dirty->fb_x; - blit->srcy = dirty->fb_y; - blit->x = dirty->unit_x1; - blit->y = dirty->unit_y1; - blit->d =1 ; - blit->w = dirty->unit_x2 - dirty->unit_x1; - blit->h = dirty->unit_y2 - dirty->unit_y1; - dirty->num_hits++; - -if (ddirty->transfer !=SVGA3D_WRITE_HOST_VRAM ) -return ; - -/* Destination bounding box */ - ddirty->left =min_t (s32, ddirty->left, dirty->unit_x1); - ddirty->top =min_t (s32, ddirty->top, dirty->unit_y1); - ddirty->right =max_t (s32, ddirty->right, dirty->unit_x2); - ddirty->bottom =max_t (s32, ddirty->bottom, dirty->unit_y2); -} - -/** -* vmw_stdu_bo_fifo_commit - Callback to fill in and submit a DMA command. -* -* @dirty: The closure structure. -* -* Fills in the missing fields in a DMA command, and optionally encodes -* a screen target update command, depending on transfer direction. -*/ -static void vmw_stdu_bo_fifo_commit (struct vmw_kms_dirty *dirty) -{ -struct vmw_stdu_dirty *ddirty = - container_of(dirty, struct vmw_stdu_dirty, base); -struct vmw_screen_target_display_unit *stdu = -container_of (dirty->unit,typeof (*stdu), base); -struct vmw_stdu_dma *cmd = dirty->cmd; -struct SVGA3dCopyBox *blit = (struct SVGA3dCopyBox *) &cmd[1 ]; -SVGA3dCmdSurfaceDMASuffix *suffix = - (SVGA3dCmdSurfaceDMASuffix *) &blit[dirty->num_hits]; -size_t blit_size =sizeof (*blit) * dirty->num_hits +sizeof (*suffix); - -if (!dirty->num_hits) { -vmw_cmd_commit (dirty->dev_priv,0 ); -return ; - } - - cmd->header.id =SVGA_3D_CMD_SURFACE_DMA ; - cmd->header.size =sizeof (cmd->body) + blit_size; -vmw_bo_get_guest_ptr (&ddirty->buf->base, &cmd->body.guest.ptr); - cmd->body.guest.pitch = ddirty->pitch; - cmd->body.host.sid = stdu->display_srf->res.id; - cmd->body.host.face =0 ; - cmd->body.host.mipmap =0 ; - cmd->body.transfer = ddirty->transfer; - suffix->suffixSize =sizeof (*suffix); - suffix->maximumOffset = ddirty->buf->base.base.size; - -if (ddirty->transfer ==SVGA3D_WRITE_HOST_VRAM ) { - blit_size +=sizeof (struct vmw_stdu_update ); - -vmw_stdu_populate_update (&suffix[1 ], stdu->base.unit, - ddirty->left, ddirty->right, - ddirty->top, ddirty->bottom); - } - -vmw_cmd_commit (dirty->dev_priv,sizeof (*cmd) + blit_size); - - stdu->display_srf->res.res_dirty = true; - ddirty->left = ddirty->top =S32_MAX ; - ddirty->right = ddirty->bottom =S32_MIN ; -} - -/** * vmw_stdu_bo_cpu_clip - Callback to encode a CPU blit * @@ -598,62 +504,21 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)return ;/* Assume we are blitting from Guest (bo) to Host (display_srf) */ - dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; - dst_bo = &stdu->display_srf->res.backup->base; - dst_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; - - src_pitch = ddirty->pitch; - src_bo = &ddirty->buf->base; - src_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; + src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; + src_bo = &stdu->display_srf->res.backup->base; + src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; -/* Swap src and dst if the assumption was wrong. */ -if (ddirty->transfer !=SVGA3D_WRITE_HOST_VRAM ) { -swap (dst_pitch, src_pitch); -swap (dst_bo, src_bo); -swap (src_offset, dst_offset); - } + dst_pitch = ddirty->pitch; + dst_bo = &ddirty->buf->base; + dst_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; (void )vmw_bo_cpu_blit (dst_bo, dst_offset, dst_pitch, src_bo, src_offset, src_pitch, width * stdu->cpp, height, &diff); - -if (ddirty->transfer ==SVGA3D_WRITE_HOST_VRAM && -drm_rect_visible (&diff.rect)) { -struct vmw_private *dev_priv; -struct vmw_stdu_update *cmd; -struct drm_clip_rect region; -int ret; - -/* We are updating the actual surface, not a proxy */ - region.x1 = diff.rect.x1; - region.x2 = diff.rect.x2; - region.y1 = diff.rect.y1; - region.y2 = diff.rect.y2; - ret =vmw_kms_update_proxy (&stdu->display_srf->res, ®ion, -1 ,1 ); -if (ret) - goto out_cleanup; - - - dev_priv =vmw_priv (stdu->base.crtc.dev); - cmd =VMW_CMD_RESERVE (dev_priv,sizeof (*cmd)); -if (!cmd) - goto out_cleanup; - -vmw_stdu_populate_update (cmd, stdu->base.unit, - region.x1, region.x2, - region.y1, region.y2); - -vmw_cmd_commit (dev_priv,sizeof (*cmd)); - } - -out_cleanup: - ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top =S32_MAX ; - ddirty->right = ddirty->bottom =S32_MIN ; }/** -* vmw_kms_stdu_dma - Perform a DMA transfer between a buffer-object backed +* vmw_kms_stdu_readback - Perform a readback from a buffer-object backed * framebuffer and the screen target system. * * @dev_priv: Pointer to the device private structure. @@ -666,9 +531,6 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)* be NULL. * @num_clips: Number of clip rects in @clips or @vclips. * @increment: Increment to use when looping over @clips or @vclips. -* @to_surface: Whether to DMA to the screen target system as opposed to -* from the screen target system. -* @interruptible: Whether to perform waits interruptible if possible. * @crtc: If crtc is passed, perform stdu dma on that crtc only. * * If DMA-ing till the screen target system, the function will also notify @@ -677,59 +539,49 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)* Returns 0 on success, negative error code on failure. -ERESTARTSYS if * interrupted. */ -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc) +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc) {struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_stdu_dirty ddirty;int ret; -bool cpu_blit =vmw_stdu_use_cpu_blit (dev_priv);DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );/* -* VMs without 3D support don't have the surface DMA command and -* we'll be using a CPU blit, and the framebuffer should be moved out -* of VRAM. +* The GMR domain might seem confusing because it might seem like it should +* never happen with screen targets but e.g. the xorg vmware driver issues +* CMD_SURFACE_DMA for various pixmap updates which might transition our bo to +* a GMR. Instead of forcing another transition we can optimize the readback +* by reading directly from the GMR. */ - ret =vmw_validation_add_bo (&val_ctx, buf, false, cpu_blit); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_GMR ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret; - ret =vmw_validation_prepare (&val_ctx,NULL , interruptible); + ret =vmw_validation_prepare (&val_ctx,NULL , true);if (ret) goto out_unref; - ddirty.transfer = (to_surface) ?SVGA3D_WRITE_HOST_VRAM : -SVGA3D_READ_HOST_VRAM ; ddirty.left = ddirty.top =S32_MAX ; ddirty.right = ddirty.bottom =S32_MIN ; ddirty.fb_left = ddirty.fb_top =S32_MAX ; ddirty.pitch = vfb->base.pitches[0 ]; ddirty.buf = buf; - ddirty.base.fifo_commit = vmw_stdu_bo_fifo_commit; - ddirty.base.clip = vmw_stdu_bo_clip; - ddirty.base.fifo_reserve_size =sizeof (struct vmw_stdu_dma ) + - num_clips *sizeof (SVGA3dCopyBox) + -sizeof (SVGA3dCmdSurfaceDMASuffix); -if (to_surface) - ddirty.base.fifo_reserve_size +=sizeof (struct vmw_stdu_update ); - - -if (cpu_blit) { - ddirty.base.fifo_commit = vmw_stdu_bo_cpu_commit; - ddirty.base.clip = vmw_stdu_bo_cpu_clip; - ddirty.base.fifo_reserve_size =0 ; - } + + ddirty.base.fifo_commit = vmw_stdu_bo_cpu_commit; + ddirty.base.clip = vmw_stdu_bo_cpu_clip; + ddirty.base.fifo_reserve_size =0 ; ddirty.base.crtc = crtc;@@ -1161,11 +1013,8 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,/* * This should only happen if the buffer object is too large to create a * proxy surface for. -* If we are a 2D VM with a buffer object then we have to use CPU blit -* so cache these mappings */ -if (vps->content_fb_type ==SEPARATE_BO && -vmw_stdu_use_cpu_blit (dev_priv)) +if (vps->content_fb_type ==SEPARATE_BO ) vps->cpp = new_fb->pitches[0 ] / new_fb->width;return 0 ;@@ -1175,14 +1024,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,return ret; } -static uint32_t vmw_stdu_bo_fifo_size (struct vmw_du_update_plane *update, -uint32_t num_hits) -{ -return sizeof (struct vmw_stdu_dma ) +sizeof (SVGA3dCopyBox) * num_hits + -sizeof (SVGA3dCmdSurfaceDMASuffix) + -sizeof (struct vmw_stdu_update ); -} -static uint32_t vmw_stdu_bo_fifo_size_cpu (struct vmw_du_update_plane *update,uint32_t num_hits) {@@ -1190,68 +1031,6 @@ static uint32_t vmw_stdu_bo_fifo_size_cpu(struct vmw_du_update_plane *update,sizeof (struct vmw_stdu_update ); } -static uint32_t vmw_stdu_bo_populate_dma (struct vmw_du_update_plane *update, -void *cmd,uint32_t num_hits) -{ -struct vmw_screen_target_display_unit *stdu; -struct vmw_framebuffer_bo *vfbbo; -struct vmw_stdu_dma *cmd_dma = cmd; - - stdu =container_of (update->du,typeof (*stdu), base); - vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - - cmd_dma->header.id =SVGA_3D_CMD_SURFACE_DMA ; - cmd_dma->header.size =sizeof (cmd_dma->body) + -sizeof (struct SVGA3dCopyBox ) * num_hits + -sizeof (SVGA3dCmdSurfaceDMASuffix); -vmw_bo_get_guest_ptr (&vfbbo->buffer->base, &cmd_dma->body.guest.ptr); - cmd_dma->body.guest.pitch = update->vfb->base.pitches[0 ]; - cmd_dma->body.host.sid = stdu->display_srf->res.id; - cmd_dma->body.host.face =0 ; - cmd_dma->body.host.mipmap =0 ; - cmd_dma->body.transfer =SVGA3D_WRITE_HOST_VRAM ; - -return sizeof (*cmd_dma); -} - -static uint32_t vmw_stdu_bo_populate_clip (struct vmw_du_update_plane *update, -void *cmd,struct drm_rect *clip, -uint32_t fb_x,uint32_t fb_y) -{ -struct SVGA3dCopyBox *box = cmd; - - box->srcx = fb_x; - box->srcy = fb_y; - box->srcz =0 ; - box->x = clip->x1; - box->y = clip->y1; - box->z =0 ; - box->w =drm_rect_width (clip); - box->h =drm_rect_height (clip); - box->d =1 ; - -return sizeof (*box); -} - -static uint32_t vmw_stdu_bo_populate_update (struct vmw_du_update_plane *update, -void *cmd,struct drm_rect *bb) -{ -struct vmw_screen_target_display_unit *stdu; -struct vmw_framebuffer_bo *vfbbo; -SVGA3dCmdSurfaceDMASuffix *suffix = cmd; - - stdu =container_of (update->du,typeof (*stdu), base); - vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - - suffix->suffixSize =sizeof (*suffix); - suffix->maximumOffset = vfbbo->buffer->base.base.size; - -vmw_stdu_populate_update (&suffix[1 ], stdu->base.unit, bb->x1, bb->x2, - bb->y1, bb->y2); - -return sizeof (*suffix) +sizeof (struct vmw_stdu_update ); -} -static uint32_t vmw_stdu_bo_pre_clip_cpu (struct vmw_du_update_plane *update,void *cmd,uint32_t num_hits) {@@ -1369,24 +1148,12 @@ static int vmw_stdu_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit =vmw_stdu_use_cpu_blit (dev_priv); bo_update.base.intr = false; -/* -* VM without 3D support don't have surface DMA command and framebuffer -* should be moved out of VRAM. -*/ -if (bo_update.base.cpu_blit) { - bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size_cpu; - bo_update.base.pre_clip = vmw_stdu_bo_pre_clip_cpu; - bo_update.base.clip = vmw_stdu_bo_clip_cpu; - bo_update.base.post_clip = vmw_stdu_bo_populate_update_cpu; - }else { - bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size; - bo_update.base.pre_clip = vmw_stdu_bo_populate_dma; - bo_update.base.clip = vmw_stdu_bo_populate_clip; - bo_update.base.post_clip = vmw_stdu_bo_populate_update; - } + bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size_cpu; + bo_update.base.pre_clip = vmw_stdu_bo_pre_clip_cpu; + bo_update.base.clip = vmw_stdu_bo_clip_cpu; + bo_update.base.post_clip = vmw_stdu_bo_populate_update_cpu;return vmw_du_helper_plane_update (&bo_update.base); }@@ -1549,7 +1316,6 @@ static int vmw_stdu_plane_update_surface(struct vmw_private *dev_priv, srf_update.vfb = vfb; srf_update.out_fence = out_fence; srf_update.mutex = &dev_priv->cmdbuf_mutex; - srf_update.cpu_blit = false; srf_update.intr = true;if (vfbs->is_bo_proxy)drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +2
-1@@ -66,7 +66,8 @@ static const struct vmw_res_func vmw_dx_streamoutput_func = { .needs_backup = true, .may_evict = false, .type_name = "DX streamoutput", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_streamoutput_create, .destroy = NULL, /* Command buffer managed resource. */ .bind = vmw_dx_streamoutput_bind,drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +4
-2@@ -131,7 +131,8 @@ static const struct vmw_res_func vmw_legacy_surface_func = { .prio = 1, .dirty_prio = 1, .type_name = "legacy surfaces", - .backup_placement = &vmw_srf_placement, + .domain = VMW_BO_DOMAIN_GMR, + .busy_domain = VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM, .create = &vmw_legacy_srf_create, .destroy = &vmw_legacy_srf_destroy, .bind = &vmw_legacy_srf_bind,@@ -145,7 +146,8 @@ static const struct vmw_res_func vmw_gb_surface_func = { .prio = 1, .dirty_prio = 2, .type_name = "guest backed surfaces", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_surface_create, .destroy = vmw_gb_surface_destroy, .bind = vmw_gb_surface_bind,drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0
-47@@ -79,20 +79,6 @@ static const struct ttm_place vram_gmr_placement_flags[] = { } }; -static const struct ttm_place gmr_vram_placement_flags[] = { - { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_GMR , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =TTM_PL_VRAM , - .flags =0 - } -}; -static const struct ttm_place vmw_sys_placement_flags = { .fpfn =0 , .lpfn =0 ,@@ -128,32 +114,6 @@ struct ttm_placement vmw_pt_sys_placement = { .busy_placement = &vmw_sys_placement_flags }; -static const struct ttm_place nonfixed_placement_flags[] = { - { - .fpfn =0 , - .lpfn =0 , - .mem_type =TTM_PL_SYSTEM , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_GMR , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_MOB , - .flags =0 - } -}; - -struct ttm_placement vmw_srf_placement = { - .num_placement =1 , - .num_busy_placement =2 , - .placement = &gmr_placement_flags, - .busy_placement = gmr_vram_placement_flags -}; -struct ttm_placement vmw_mob_placement = { .num_placement =1 , .num_busy_placement =1 ,@@ -161,13 +121,6 @@ struct ttm_placement vmw_mob_placement = { .busy_placement = &mob_placement_flags }; -struct ttm_placement vmw_nonfixed_placement = { - .num_placement =3 , - .placement = nonfixed_placement_flags, - .num_busy_placement =1 , - .busy_placement = &sys_placement_flags -}; -const size_t vmw_tt_size =sizeof (struct vmw_ttm_tt );/** drivers/gpu/drm/vmwgfx/vmwgfx_va.c +3
-1@@ -25,6 +25,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" @@ -83,7 +84,8 @@ static const struct vmw_simple_resource_func va_stream_func = { .needs_backup = false, .may_evict = false, .type_name = "overlay stream", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +19
-55@@ -27,6 +27,7 @@**************************************************************************/ #include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_resource_priv.h" #include "vmwgfx_validation.h" #include <linux/slab.h> @@ -40,8 +41,6 @@* @hash: A hash entry used for the duplicate detection hash table. * @coherent_count: If switching backup buffers, number of new coherent * resources that will have this buffer as a backup buffer. -* @as_mob: Validate as mob. -* @cpu_blit: Validate for cpu blit access. * * Bit fields are used since these structures are allocated and freed in * large numbers and space conservation is desired. @@ -50,8 +49,6 @@ struct vmw_validation_bo_node {struct ttm_validate_buffer base;struct vmwgfx_hash_item hash;unsigned int coherent_count; - u32 as_mob : 1; - u32 cpu_blit : 1; };/** * struct vmw_validation_res_node - Resource validation metadata. @@ -260,26 +257,16 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx,* vmw_validation_add_bo - Add a buffer object to the validation context. * @ctx: The validation context. * @vbo: The buffer object. -* @as_mob: Validate as mob, otherwise suitable for GMR operations. -* @cpu_blit: Validate in a page-mappable location. * * Return: Zero on success, negative error code otherwise. */ int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob, -bool cpu_blit) +struct vmw_bo *vbo) {struct vmw_validation_bo_node *bo_node; bo_node =vmw_validation_find_bo_dup (ctx, vbo); -if (bo_node) { -if (bo_node->as_mob != as_mob || - bo_node->cpu_blit != cpu_blit) { -DRM_ERROR ("Inconsistent buffer usage.\n" ); -return -EINVAL ; - } - }else { +if (!bo_node) {struct ttm_validate_buffer *val_buf; bo_node =vmw_validation_mem_alloc (ctx,sizeof (*bo_node));@@ -297,8 +284,6 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx,return -ESRCH ; val_buf->num_shared =0 ;list_add_tail (&val_buf->head, &ctx->bo_list); - bo_node->as_mob = as_mob; - bo_node->cpu_blit = cpu_blit; }return 0 ;@@ -455,9 +440,10 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx,if (res->backup) {struct vmw_bo *vbo = res->backup; - ret =vmw_validation_add_bo - (ctx, vbo,vmw_resource_needs_backup (res), - false); +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); + ret =vmw_validation_add_bo (ctx, vbo);if (ret) goto out_unreserve; }@@ -519,14 +505,12 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx,* vmw_validation_bo_validate_single - Validate a single buffer object. * @bo: The TTM buffer object base. * @interruptible: Whether to perform waits interruptible if possible. -* @validate_as_mob: Whether to validate in MOB memory. * * Return: Zero on success, -ERESTARTSYS if interrupted. Negative error * code on failure. */ -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob) +static int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, +bool interruptible) {struct vmw_bo *vbo = container_of(bo, struct vmw_bo, base);@@ -542,27 +526,17 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo,if (vbo->base.pin_count >0 )return 0 ; -if (validate_as_mob) -return ttm_bo_validate (bo, &vmw_mob_placement, &ctx); - -/** -* Put BO in VRAM if there is space, otherwise as a GMR. -* If there is no space in VRAM and GMR ids are all used up, -* start evicting GMRs to make room. If the DMA buffer can't be -* used as a GMR, this will return -ENOMEM. -*/ - - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); + ret =ttm_bo_validate (bo, &vbo->placement, &ctx);if (ret ==0 || ret == -ERESTARTSYS )return ret; -/** -* If that failed, try VRAM again, this time evicting +/* +* If that failed, try again, this time evicting * previous contents. */ + ctx.allow_res_evict = true; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); -return ret; +return ttm_bo_validate (bo, &vbo->placement, &ctx); }/** @@ -583,18 +557,8 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)struct vmw_bo *vbo =container_of (entry->base.bo,typeof (*vbo), base); -if (entry->cpu_blit) { -struct ttm_operation_ctx ttm_ctx = { - .interruptible = intr, - .no_wait_gpu = false - }; - - ret =ttm_bo_validate (entry->base.bo, - &vmw_nonfixed_placement, &ttm_ctx); - }else { - ret =vmw_validation_bo_validate_single - (entry->base.bo, intr, entry->as_mob); - } + ret =vmw_validation_bo_validate_single (entry->base.bo, intr); +if (ret)return ret;@@ -655,9 +619,9 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)if (backup && res->backup && (backup != res->backup)) {struct vmw_bo *vbo = res->backup; - ret =vmw_validation_add_bo - (ctx, vbo,vmw_resource_needs_backup (res), - false); +vmw_bo_placement_set (vbo, res->func->domain, + res->func->busy_domain); + ret =vmw_validation_add_bo (ctx, vbo);if (ret)return ret; }drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +1
-5@@ -159,11 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) }int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob,bool cpu_blit); -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob); +struct vmw_bo *vbo);int vmw_validation_bo_validate (struct vmw_validation_context *ctx,bool intr);void vmw_validation_unref_lists (struct vmw_validation_context *ctx); int vmw_validation_add_resource(struct vmw_validation_context *ctx,
Re: [PATCH v2 7/8] drm/vmwgfx: Abstract placement selection
In reply to Zack RusinQuoted 1,497 lines · Zack Rusin
From: Zack Rusin <[email protected]>
Problem with explicit placement selection in vmwgfx is that by the time the buffer object needs to be validated the information about which placement was supposed to be used is lost. To workaround this the driver had a bunch of state in various places e.g.
as_moborcpu_blitto somehow convey the information on which placement was intended.Fix it properly by allowing the buffer objects to hold their preferred placement so it can be reused whenever needed. This makes the entire validation pipeline a lot easier both to understand and maintain.
Signed-off-by Zack Rusin <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 145 +++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 25 +- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 35 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 5 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 22 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 21 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 13 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 304 ++---------------- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 47 --- drivers/gpu/drm/vmwgfx/vmwgfx_va.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 74 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 6 +- 22 files changed, 312 insertions(+), 456 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +126
-19@@ -135,11 +135,17 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, goto out_unreserve; } - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (likely (ret ==0 ) || ret == -ERESTARTSYS ) goto out_unreserve; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx); out_unreserve:if (!ret)@@ -190,17 +196,8 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, {struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base; -struct ttm_placement placement; -struct ttm_place place;int ret =0 ; - place = vmw_vram_placement.placement[0 ]; - place.lpfn =PFN_UP (bo->resource->size); - placement.num_placement =1 ; - placement.placement = &place; - placement.num_busy_placement =1 ; - placement.busy_placement = &place; -vmw_execbuf_release_pinned_bo (dev_priv); ret =ttm_bo_reserve (bo, interruptible, false,NULL );if (unlikely (ret !=0 ))@@ -216,14 +213,21 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, bo->resource->start > 0 && buf->base.pin_count == 0) { ctx.interruptible = false; - (void )ttm_bo_validate (bo, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + (void )ttm_bo_validate (bo, &buf->placement, &ctx); } +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + buf->places[0 ].lpfn =PFN_UP (bo->resource->size);if (buf->base.pin_count >0 ) - ret =ttm_resource_compat (bo->resource, &placement) + ret =ttm_resource_compat (bo->resource, &buf->placement) ?0 : -EINVAL ;else - ret =ttm_bo_validate (bo, &placement, &ctx); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);/* For some reason we didn't end up at the start of vram */ WARN_ON (ret ==0 && bo->resource->start !=0 );@@ -431,7 +435,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, }int vmw_bo_create (struct vmw_private *vmw, -size_t size,struct ttm_placement *placement, +size_t size,u32 domain,u32 busy_domain,bool interruptible,bool pin,struct vmw_bo **p_bo) {@@ -444,7 +448,8 @@ int vmw_bo_create(struct vmw_private *vmw, } ret =vmw_bo_init (vmw, *p_bo, size, - placement, interruptible, pin); + domain, busy_domain, + interruptible, pin);if (unlikely (ret !=0 )) goto out_error;@@ -461,7 +466,8 @@ int vmw_bo_create(struct vmw_private *vmw,* @dev_priv: Pointer to the device private struct * @vmw_bo: Pointer to the struct vmw_bo to initialize. * @size: Buffer object size in bytes. -* @placement: Initial placement. +* @domain: Domain to put the bo in. +* @busy_domain: Domain to put the bo if busy. * @interruptible: Whether waits should be performed interruptible. * @pin: If the BO should be created pinned at a fixed location. * Returns: Zero on success, negative error code on error. @@ -470,7 +476,9 @@ int vmw_bo_create(struct vmw_private *vmw,*/ int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_bo *vmw_bo, -size_t size,struct ttm_placement *placement, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin) {struct ttm_operation_ctx ctx = {@@ -489,8 +497,9 @@ int vmw_bo_init(struct vmw_private *dev_priv, size =ALIGN (size,PAGE_SIZE );drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); +vmw_bo_placement_set (vmw_bo, domain, busy_domain); ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - placement,0 , &ctx,NULL ,NULL , vmw_bo_free); + &vmw_bo->placement,0 , &ctx,NULL ,NULL , vmw_bo_free);if (unlikely (ret)) {return ret; }@@ -825,3 +834,101 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo,if (mem->mem_type !=VMW_PL_MOB && bo->resource->mem_type ==VMW_PL_MOB )vmw_resource_unbind_list (vbo); } + +static u32 +set_placement_list (struct ttm_place *pl,u32 domain) +{ +u32 n =0 ; + +/* +* The placements are ordered according to our preferences +*/ +if (domain &VMW_BO_DOMAIN_MOB ) { + pl[n].mem_type =VMW_PL_MOB ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_GMR ) { + pl[n].mem_type =VMW_PL_GMR ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_VRAM ) { + pl[n].mem_type =TTM_PL_VRAM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +WARN_ON ((domain &VMW_BO_DOMAIN_WAITABLE_SYS ) !=0 ); +if (domain &VMW_BO_DOMAIN_WAITABLE_SYS ) { + pl[n].mem_type =VMW_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_SYS ) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } + +WARN_ON (!n); +if (!n) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +return n; +} + +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +struct ttm_placement *pl = &bo->placement; +bool mem_compatible = false; +u32 i; + + pl->placement = bo->places; + pl->num_placement =set_placement_list (bo->places, domain); + +if (drm_debug_enabled (DRM_UT_DRIVER ) && bo->base.resource) { +for (i =0 ; i < pl->num_placement; ++i) { +if (bo->base.resource->mem_type ==TTM_PL_SYSTEM || + bo->base.resource->mem_type == pl->placement[i].mem_type) + mem_compatible = true; + } +if (!mem_compatible) +drm_warn (&vmw->drm, +"%s: Incompatible transition from " +"bo->base.resource->mem_type = %u to domain = %u\n" , + __func__, bo->base.resource->mem_type, domain); + } + + pl->busy_placement = bo->busy_places; + pl->num_busy_placement =set_placement_list (bo->busy_places, busy_domain); +} + +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +u32 domain =VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ; + +if (vmw->has_mob) + domain =VMW_BO_DOMAIN_MOB ; + +vmw_bo_placement_set (bo, domain, domain); +}drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +23
-2@@ -31,6 +31,7 @@#include "device_include/svga_reg.h" #include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_placement.h> #include <linux/rbtree_types.h> #include <linux/types.h> @@ -40,6 +41,14 @@ struct vmw_fence_obj;struct vmw_private ;struct vmw_resource ; +enum vmw_bo_domain { +VMW_BO_DOMAIN_SYS =BIT (0 ), +VMW_BO_DOMAIN_WAITABLE_SYS =BIT (1 ), +VMW_BO_DOMAIN_VRAM =BIT (2 ), +VMW_BO_DOMAIN_GMR =BIT (3 ), +VMW_BO_DOMAIN_MOB =BIT (4 ), +}; +/** * struct vmw_bo - TTM buffer object with vmwgfx additions * @base: The TTM buffer object @@ -53,6 +62,11 @@ struct vmw_resource;*/ struct vmw_bo {struct ttm_buffer_object base; + +struct ttm_placement placement; +struct ttm_place places[5 ]; +struct ttm_place busy_places[5 ]; +struct rb_root res_tree;atomic_t cpu_writers;@@ -64,17 +78,24 @@ struct vmw_bo {struct vmw_bo_dirty *dirty; }; +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain); +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo); +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, +size_t size, +u32 domain, +u32 busy_domain,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, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin);int vmw_bo_unref_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);drivers/gpu/drm/vmwgfx/vmwgfx_context.c +6
-3@@ -76,7 +76,8 @@ static const struct vmw_res_func vmw_legacy_context_func = { .needs_backup = false, .may_evict = false, .type_name = "legacy contexts", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,@@ -90,7 +91,8 @@ static const struct vmw_res_func vmw_gb_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_context_create, .destroy = vmw_gb_context_destroy, .bind = vmw_gb_context_bind,@@ -104,7 +106,8 @@ static const struct vmw_res_func vmw_dx_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_context_create, .destroy = vmw_dx_context_destroy, .bind = vmw_dx_context_bind,drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +8
-3@@ -136,7 +136,8 @@ static const struct vmw_res_func vmw_cotable_func = { .prio = 3, .dirty_prio = 3, .type_name = "context guest backed object tables", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_cotable_create, .destroy = vmw_cotable_destroy, .bind = vmw_cotable_bind,@@ -424,7 +425,8 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)* for the new COTable. Initially pin the buffer object to make sure * we can use tryreserve without failure. */ - ret =vmw_bo_create (dev_priv, new_size, &vmw_mob_placement, + ret =vmw_bo_create (dev_priv, new_size, +VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB , true, true, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" );@@ -465,7 +467,10 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) }/* Unpin new buffer, and switch backup buffers. */ - ret =ttm_bo_validate (bo, &vmw_mob_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (unlikely (ret !=0 )) {DRM_ERROR ("Failed validating new COTable backup buffer.\n" ); goto out_wait;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2
-1@@ -399,7 +399,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)* user of the bo currently. */ ret =vmw_bo_create (dev_priv,PAGE_SIZE , - &vmw_sys_placement, false, true, &vbo); +VMW_BO_DOMAIN_SYS ,VMW_BO_DOMAIN_SYS , + false, true, &vbo);if (unlikely (ret !=0 ))return ret;drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0
-2@@ -930,9 +930,7 @@ extern struct ttm_placement vmw_vram_placement;extern struct ttm_placement vmw_vram_sys_placement;extern struct ttm_placement vmw_vram_gmr_placement;extern struct ttm_placement vmw_sys_placement; -extern struct ttm_placement vmw_srf_placement;extern struct ttm_placement vmw_mob_placement; -extern struct ttm_placement vmw_nonfixed_placement;extern struct ttm_device_funcs vmw_bo_driver;extern const struct vmw_sg_table *vmw_bo_sg_table (struct ttm_buffer_object *bo);drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +23
-12@@ -477,9 +477,13 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,struct vmw_bo *dx_query_mob; dx_query_mob =vmw_context_get_dx_query_mob (ctx); -if (dx_query_mob) +if (dx_query_mob) { +vmw_bo_placement_set (dx_query_mob, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); ret =vmw_validation_add_bo (sw_context->ctx, - dx_query_mob, true, false); + dx_query_mob); + } }mutex_unlock (&dev_priv->binding_mutex);@@ -1035,17 +1039,17 @@ static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv,if (unlikely (sw_context->cur_query_bo !=NULL )) { sw_context->needs_post_query_barrier = true; +vmw_bo_placement_set_default_accelerated (sw_context->cur_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - sw_context->cur_query_bo, - dev_priv->has_mob, false); + sw_context->cur_query_bo);if (unlikely (ret !=0 ))return ret; } sw_context->cur_query_bo = new_query_bo; +vmw_bo_placement_set_default_accelerated (dev_priv->dummy_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - dev_priv->dummy_query_bo, - dev_priv->has_mob, false); + dev_priv->dummy_query_bo);if (unlikely (ret !=0 ))return ret; }@@ -1157,7 +1161,8 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use MOB buffer.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, true, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;@@ -1211,7 +1216,9 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use GMR region.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, false, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;@@ -4361,13 +4368,17 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,if (dev_priv->pinned_bo ==NULL ) goto out_unlock; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo, false, - false); +vmw_bo_placement_set (dev_priv->pinned_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo);if (ret) goto out_no_reserve; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo, false, - false); +vmw_bo_placement_set (dev_priv->dummy_query_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo);if (ret) goto out_no_reserve;drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +2
-3@@ -121,9 +121,8 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,int ret; ret =vmw_bo_create (dev_priv, size, - (dev_priv->has_mob) ? - &vmw_sys_placement : - &vmw_vram_sys_placement, + (dev_priv->has_mob) ?VMW_BO_DOMAIN_SYS :VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_SYS , true, false, p_vbo); (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +17
-5@@ -1270,9 +1270,9 @@ int vmw_kms_readback(struct vmw_private *dev_priv, user_fence_rep, vclips, num_clips, NULL);case vmw_du_screen_target: -return vmw_kms_stdu_dma (dev_priv, file_priv, vfb, - user_fence_rep,NULL , vclips, num_clips, -1 , false, true,NULL ); +return vmw_kms_stdu_readback (dev_priv, file_priv, vfb, + user_fence_rep,NULL , vclips, num_clips, +1 ,NULL );default :WARN_ONCE (true,"Readback called with invalid display system.\n" );@@ -2999,8 +2999,20 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)struct vmw_framebuffer_bo *vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer, false, - update->cpu_blit); +/* +* For screen targets we want a mappable bo, for everything else we want +* accelerated i.e. host backed (vram or gmr) bo. If the display unit +* is not screen target then mob's shouldn't be available. +*/ +if (update->dev_priv->active_display_unit == vmw_du_screen_target) { +vmw_bo_placement_set (vfbbo->buffer, +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR ); + }else { +WARN_ON (update->dev_priv->has_mob); +vmw_bo_placement_set_default_accelerated (vfbbo->buffer); + } + ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer); }else {struct vmw_framebuffer_surface *vfbs =container_of (update->vfb,typeof (*vfbs), base);drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +9
-12@@ -126,7 +126,6 @@ struct vmw_du_update_plane {struct vmw_framebuffer *vfb;struct vmw_fence_obj **out_fence;struct mutex *mutex; -bool cpu_blit;bool intr; };@@ -564,17 +563,15 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, unsigned num_clips, int inc, struct vmw_fence_obj **out_fence, struct drm_crtc *crtc); -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc); +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc);int vmw_du_helper_plane_update (struct vmw_du_update_plane *update);drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +8
-3@@ -332,7 +332,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, } ret =vmw_bo_create (res->dev_priv, res->backup_size, - res->func->backup_placement, + res->func->domain, res->func->busy_domain, interruptible, false, &backup);if (unlikely (ret !=0 )) goto out_no_bo;@@ -529,8 +529,10 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,return 0 ; backup_dirty = res->backup_dirty; +vmw_bo_placement_set (res->backup, res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&res->backup->base, - res->func->backup_placement, + &res->backup->placement, &ctx);if (unlikely (ret !=0 ))@@ -968,9 +970,12 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)if (ret) goto out_no_validate;if (!vbo->base.pin_count) { +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&vbo->base, - res->func->backup_placement, + &vbo->placement, &ctx);if (ret) {ttm_bo_unreserve (&vbo->base);drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +2
-1@@ -83,7 +83,8 @@ struct vmw_res_func {enum vmw_res_type res_type;bool needs_backup;const char *type_name; -struct ttm_placement *backup_placement; +u32 domain; +u32 busy_domain;bool may_evict;u32 prio;u32 dirty_prio;drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +8
-5@@ -445,7 +445,8 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,*/ vmw_overlay_pause_all (dev_priv); ret =vmw_bo_create (dev_priv, size, - &vmw_vram_placement, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM , false, true, &vps->bo);vmw_overlay_resume_all (dev_priv);if (ret) {@@ -547,7 +548,6 @@ static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit = false; bo_update.base.intr = true; bo_update.base.calc_fifo_size = vmw_sou_bo_fifo_size;@@ -708,7 +708,6 @@ static int vmw_sou_plane_update_surface(struct vmw_private *dev_priv, srf_update.base.vfb = vfb; srf_update.base.out_fence = out_fence; srf_update.base.mutex = &dev_priv->cmdbuf_mutex; - srf_update.base.cpu_blit = false; srf_update.base.intr = true; srf_update.base.calc_fifo_size = vmw_sou_surface_fifo_size;@@ -1224,7 +1223,9 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;@@ -1330,7 +1331,9 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +11
-4@@ -94,7 +94,8 @@ static const struct vmw_res_func vmw_gb_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_shader_create, .destroy = vmw_gb_shader_destroy, .bind = vmw_gb_shader_bind,@@ -108,7 +109,8 @@ static const struct vmw_res_func vmw_dx_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_shader_create,/* * The destroy callback is only called with a committed resource on @@ -893,7 +895,9 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,if (!vmw_shader_id_ok (user_key, shader_type))return -EINVAL ; - ret =vmw_bo_create (dev_priv, size, &vmw_sys_placement, + ret =vmw_bo_create (dev_priv, size, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS , true, true, &buf);if (unlikely (ret !=0 )) goto out;@@ -913,7 +917,10 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,WARN_ON (is_iomem);ttm_bo_kunmap (&map); - ret =ttm_bo_validate (&buf->base, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + ret =ttm_bo_validate (&buf->base, &buf->placement, &ctx);WARN_ON (ret !=0 );ttm_bo_unreserve (&buf->base);drivers/gpu/drm/vmwgfx/vmwgfx_so.c +3
-1@@ -24,6 +24,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h" @@ -84,7 +85,8 @@ static const struct vmw_res_func vmw_view_func = { .needs_backup = false, .may_evict = false, .type_name = "DX view", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = vmw_view_create, .commit_notify = vmw_view_commit_notify, };drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +35
-269@@ -66,7 +66,6 @@ enum stdu_content_type {*/ struct vmw_stdu_dirty {struct vmw_kms_dirty base; -SVGA3dTransferType transfer;s32 left, right, top, bottom;s32 fb_left, fb_top;u32 pitch;@@ -137,12 +136,6 @@ static void vmw_stdu_destroy(struct vmw_screen_target_display_unit *stdu);* Screen Target Display Unit CRTC Functions *****************************************************************************/ -static bool vmw_stdu_use_cpu_blit (const struct vmw_private *vmw) -{ -return !(vmw->capabilities &SVGA_CAP_3D ) || vmw->vram_size < (32 *1024 *1024 ); -} - -/** * vmw_stdu_crtc_destroy - cleans up the STDU * @@ -451,93 +444,6 @@ static void vmw_stdu_crtc_atomic_disable(struct drm_crtc *crtc, } } -/** -* vmw_stdu_bo_clip - Callback to encode a suface DMA command cliprect -* -* @dirty: The closure structure. -* -* Encodes a surface DMA command cliprect and updates the bounding box -* for the DMA. -*/ -static void vmw_stdu_bo_clip (struct vmw_kms_dirty *dirty) -{ -struct vmw_stdu_dirty *ddirty = - container_of(dirty, struct vmw_stdu_dirty, base); -struct vmw_stdu_dma *cmd = dirty->cmd; -struct SVGA3dCopyBox *blit = (struct SVGA3dCopyBox *) &cmd[1 ]; - - blit += dirty->num_hits; - blit->srcx = dirty->fb_x; - blit->srcy = dirty->fb_y; - blit->x = dirty->unit_x1; - blit->y = dirty->unit_y1; - blit->d =1 ; - blit->w = dirty->unit_x2 - dirty->unit_x1; - blit->h = dirty->unit_y2 - dirty->unit_y1; - dirty->num_hits++; - -if (ddirty->transfer !=SVGA3D_WRITE_HOST_VRAM ) -return ; - -/* Destination bounding box */ - ddirty->left =min_t (s32, ddirty->left, dirty->unit_x1); - ddirty->top =min_t (s32, ddirty->top, dirty->unit_y1); - ddirty->right =max_t (s32, ddirty->right, dirty->unit_x2); - ddirty->bottom =max_t (s32, ddirty->bottom, dirty->unit_y2); -} - -/** -* vmw_stdu_bo_fifo_commit - Callback to fill in and submit a DMA command. -* -* @dirty: The closure structure. -* -* Fills in the missing fields in a DMA command, and optionally encodes -* a screen target update command, depending on transfer direction. -*/ -static void vmw_stdu_bo_fifo_commit (struct vmw_kms_dirty *dirty) -{ -struct vmw_stdu_dirty *ddirty = - container_of(dirty, struct vmw_stdu_dirty, base); -struct vmw_screen_target_display_unit *stdu = -container_of (dirty->unit,typeof (*stdu), base); -struct vmw_stdu_dma *cmd = dirty->cmd; -struct SVGA3dCopyBox *blit = (struct SVGA3dCopyBox *) &cmd[1 ]; -SVGA3dCmdSurfaceDMASuffix *suffix = - (SVGA3dCmdSurfaceDMASuffix *) &blit[dirty->num_hits]; -size_t blit_size =sizeof (*blit) * dirty->num_hits +sizeof (*suffix); - -if (!dirty->num_hits) { -vmw_cmd_commit (dirty->dev_priv,0 ); -return ; - } - - cmd->header.id =SVGA_3D_CMD_SURFACE_DMA ; - cmd->header.size =sizeof (cmd->body) + blit_size; -vmw_bo_get_guest_ptr (&ddirty->buf->base, &cmd->body.guest.ptr); - cmd->body.guest.pitch = ddirty->pitch; - cmd->body.host.sid = stdu->display_srf->res.id; - cmd->body.host.face =0 ; - cmd->body.host.mipmap =0 ; - cmd->body.transfer = ddirty->transfer; - suffix->suffixSize =sizeof (*suffix); - suffix->maximumOffset = ddirty->buf->base.base.size; - -if (ddirty->transfer ==SVGA3D_WRITE_HOST_VRAM ) { - blit_size +=sizeof (struct vmw_stdu_update ); - -vmw_stdu_populate_update (&suffix[1 ], stdu->base.unit, - ddirty->left, ddirty->right, - ddirty->top, ddirty->bottom); - } - -vmw_cmd_commit (dirty->dev_priv,sizeof (*cmd) + blit_size); - - stdu->display_srf->res.res_dirty = true; - ddirty->left = ddirty->top =S32_MAX ; - ddirty->right = ddirty->bottom =S32_MIN ; -} - -/** * vmw_stdu_bo_cpu_clip - Callback to encode a CPU blit * @@ -598,62 +504,21 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)return ;/* Assume we are blitting from Guest (bo) to Host (display_srf) */ - dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; - dst_bo = &stdu->display_srf->res.backup->base; - dst_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; - - src_pitch = ddirty->pitch; - src_bo = &ddirty->buf->base; - src_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; + src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; + src_bo = &stdu->display_srf->res.backup->base; + src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; -/* Swap src and dst if the assumption was wrong. */ -if (ddirty->transfer !=SVGA3D_WRITE_HOST_VRAM ) { -swap (dst_pitch, src_pitch); -swap (dst_bo, src_bo); -swap (src_offset, dst_offset); - } + dst_pitch = ddirty->pitch; + dst_bo = &ddirty->buf->base; + dst_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; (void )vmw_bo_cpu_blit (dst_bo, dst_offset, dst_pitch, src_bo, src_offset, src_pitch, width * stdu->cpp, height, &diff); - -if (ddirty->transfer ==SVGA3D_WRITE_HOST_VRAM && -drm_rect_visible (&diff.rect)) { -struct vmw_private *dev_priv; -struct vmw_stdu_update *cmd; -struct drm_clip_rect region; -int ret; - -/* We are updating the actual surface, not a proxy */ - region.x1 = diff.rect.x1; - region.x2 = diff.rect.x2; - region.y1 = diff.rect.y1; - region.y2 = diff.rect.y2; - ret =vmw_kms_update_proxy (&stdu->display_srf->res, ®ion, -1 ,1 ); -if (ret) - goto out_cleanup; - - - dev_priv =vmw_priv (stdu->base.crtc.dev); - cmd =VMW_CMD_RESERVE (dev_priv,sizeof (*cmd)); -if (!cmd) - goto out_cleanup; - -vmw_stdu_populate_update (cmd, stdu->base.unit, - region.x1, region.x2, - region.y1, region.y2); - -vmw_cmd_commit (dev_priv,sizeof (*cmd)); - } - -out_cleanup: - ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top =S32_MAX ; - ddirty->right = ddirty->bottom =S32_MIN ; }/** -* vmw_kms_stdu_dma - Perform a DMA transfer between a buffer-object backed +* vmw_kms_stdu_readback - Perform a readback from a buffer-object backed * framebuffer and the screen target system. * * @dev_priv: Pointer to the device private structure. @@ -666,9 +531,6 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)* be NULL. * @num_clips: Number of clip rects in @clips or @vclips. * @increment: Increment to use when looping over @clips or @vclips. -* @to_surface: Whether to DMA to the screen target system as opposed to -* from the screen target system. -* @interruptible: Whether to perform waits interruptible if possible. * @crtc: If crtc is passed, perform stdu dma on that crtc only. * * If DMA-ing till the screen target system, the function will also notify @@ -677,59 +539,49 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)* Returns 0 on success, negative error code on failure. -ERESTARTSYS if * interrupted. */ -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc) +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc) {struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_stdu_dirty ddirty;int ret; -bool cpu_blit =vmw_stdu_use_cpu_blit (dev_priv);DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );/* -* VMs without 3D support don't have the surface DMA command and -* we'll be using a CPU blit, and the framebuffer should be moved out -* of VRAM. +* The GMR domain might seem confusing because it might seem like it should +* never happen with screen targets but e.g. the xorg vmware driver issues +* CMD_SURFACE_DMA for various pixmap updates which might transition our bo to +* a GMR. Instead of forcing another transition we can optimize the readback +* by reading directly from the GMR. */ - ret =vmw_validation_add_bo (&val_ctx, buf, false, cpu_blit); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_GMR ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret; - ret =vmw_validation_prepare (&val_ctx,NULL , interruptible); + ret =vmw_validation_prepare (&val_ctx,NULL , true);if (ret) goto out_unref; - ddirty.transfer = (to_surface) ?SVGA3D_WRITE_HOST_VRAM : -SVGA3D_READ_HOST_VRAM ; ddirty.left = ddirty.top =S32_MAX ; ddirty.right = ddirty.bottom =S32_MIN ; ddirty.fb_left = ddirty.fb_top =S32_MAX ; ddirty.pitch = vfb->base.pitches[0 ]; ddirty.buf = buf; - ddirty.base.fifo_commit = vmw_stdu_bo_fifo_commit; - ddirty.base.clip = vmw_stdu_bo_clip; - ddirty.base.fifo_reserve_size =sizeof (struct vmw_stdu_dma ) + - num_clips *sizeof (SVGA3dCopyBox) + -sizeof (SVGA3dCmdSurfaceDMASuffix); -if (to_surface) - ddirty.base.fifo_reserve_size +=sizeof (struct vmw_stdu_update ); - - -if (cpu_blit) { - ddirty.base.fifo_commit = vmw_stdu_bo_cpu_commit; - ddirty.base.clip = vmw_stdu_bo_cpu_clip; - ddirty.base.fifo_reserve_size =0 ; - } + + ddirty.base.fifo_commit = vmw_stdu_bo_cpu_commit; + ddirty.base.clip = vmw_stdu_bo_cpu_clip; + ddirty.base.fifo_reserve_size =0 ; ddirty.base.crtc = crtc;@@ -1161,11 +1013,8 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,/* * This should only happen if the buffer object is too large to create a * proxy surface for. -* If we are a 2D VM with a buffer object then we have to use CPU blit -* so cache these mappings */ -if (vps->content_fb_type ==SEPARATE_BO && -vmw_stdu_use_cpu_blit (dev_priv)) +if (vps->content_fb_type ==SEPARATE_BO ) vps->cpp = new_fb->pitches[0 ] / new_fb->width;return 0 ;@@ -1175,14 +1024,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,return ret; } -static uint32_t vmw_stdu_bo_fifo_size (struct vmw_du_update_plane *update, -uint32_t num_hits) -{ -return sizeof (struct vmw_stdu_dma ) +sizeof (SVGA3dCopyBox) * num_hits + -sizeof (SVGA3dCmdSurfaceDMASuffix) + -sizeof (struct vmw_stdu_update ); -} -static uint32_t vmw_stdu_bo_fifo_size_cpu (struct vmw_du_update_plane *update,uint32_t num_hits) {@@ -1190,68 +1031,6 @@ static uint32_t vmw_stdu_bo_fifo_size_cpu(struct vmw_du_update_plane *update,sizeof (struct vmw_stdu_update ); } -static uint32_t vmw_stdu_bo_populate_dma (struct vmw_du_update_plane *update, -void *cmd,uint32_t num_hits) -{ -struct vmw_screen_target_display_unit *stdu; -struct vmw_framebuffer_bo *vfbbo; -struct vmw_stdu_dma *cmd_dma = cmd; - - stdu =container_of (update->du,typeof (*stdu), base); - vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - - cmd_dma->header.id =SVGA_3D_CMD_SURFACE_DMA ; - cmd_dma->header.size =sizeof (cmd_dma->body) + -sizeof (struct SVGA3dCopyBox ) * num_hits + -sizeof (SVGA3dCmdSurfaceDMASuffix); -vmw_bo_get_guest_ptr (&vfbbo->buffer->base, &cmd_dma->body.guest.ptr); - cmd_dma->body.guest.pitch = update->vfb->base.pitches[0 ]; - cmd_dma->body.host.sid = stdu->display_srf->res.id; - cmd_dma->body.host.face =0 ; - cmd_dma->body.host.mipmap =0 ; - cmd_dma->body.transfer =SVGA3D_WRITE_HOST_VRAM ; - -return sizeof (*cmd_dma); -} - -static uint32_t vmw_stdu_bo_populate_clip (struct vmw_du_update_plane *update, -void *cmd,struct drm_rect *clip, -uint32_t fb_x,uint32_t fb_y) -{ -struct SVGA3dCopyBox *box = cmd; - - box->srcx = fb_x; - box->srcy = fb_y; - box->srcz =0 ; - box->x = clip->x1; - box->y = clip->y1; - box->z =0 ; - box->w =drm_rect_width (clip); - box->h =drm_rect_height (clip); - box->d =1 ; - -return sizeof (*box); -} - -static uint32_t vmw_stdu_bo_populate_update (struct vmw_du_update_plane *update, -void *cmd,struct drm_rect *bb) -{ -struct vmw_screen_target_display_unit *stdu; -struct vmw_framebuffer_bo *vfbbo; -SVGA3dCmdSurfaceDMASuffix *suffix = cmd; - - stdu =container_of (update->du,typeof (*stdu), base); - vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - - suffix->suffixSize =sizeof (*suffix); - suffix->maximumOffset = vfbbo->buffer->base.base.size; - -vmw_stdu_populate_update (&suffix[1 ], stdu->base.unit, bb->x1, bb->x2, - bb->y1, bb->y2); - -return sizeof (*suffix) +sizeof (struct vmw_stdu_update ); -} -static uint32_t vmw_stdu_bo_pre_clip_cpu (struct vmw_du_update_plane *update,void *cmd,uint32_t num_hits) {@@ -1369,24 +1148,12 @@ static int vmw_stdu_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit =vmw_stdu_use_cpu_blit (dev_priv); bo_update.base.intr = false; -/* -* VM without 3D support don't have surface DMA command and framebuffer -* should be moved out of VRAM. -*/ -if (bo_update.base.cpu_blit) { - bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size_cpu; - bo_update.base.pre_clip = vmw_stdu_bo_pre_clip_cpu; - bo_update.base.clip = vmw_stdu_bo_clip_cpu; - bo_update.base.post_clip = vmw_stdu_bo_populate_update_cpu; - }else { - bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size; - bo_update.base.pre_clip = vmw_stdu_bo_populate_dma; - bo_update.base.clip = vmw_stdu_bo_populate_clip; - bo_update.base.post_clip = vmw_stdu_bo_populate_update; - } + bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size_cpu; + bo_update.base.pre_clip = vmw_stdu_bo_pre_clip_cpu; + bo_update.base.clip = vmw_stdu_bo_clip_cpu; + bo_update.base.post_clip = vmw_stdu_bo_populate_update_cpu;return vmw_du_helper_plane_update (&bo_update.base); }@@ -1549,7 +1316,6 @@ static int vmw_stdu_plane_update_surface(struct vmw_private *dev_priv, srf_update.vfb = vfb; srf_update.out_fence = out_fence; srf_update.mutex = &dev_priv->cmdbuf_mutex; - srf_update.cpu_blit = false; srf_update.intr = true;if (vfbs->is_bo_proxy)drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +2
-1@@ -66,7 +66,8 @@ static const struct vmw_res_func vmw_dx_streamoutput_func = { .needs_backup = true, .may_evict = false, .type_name = "DX streamoutput", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_streamoutput_create, .destroy = NULL, /* Command buffer managed resource. */ .bind = vmw_dx_streamoutput_bind,drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +4
-2@@ -131,7 +131,8 @@ static const struct vmw_res_func vmw_legacy_surface_func = { .prio = 1, .dirty_prio = 1, .type_name = "legacy surfaces", - .backup_placement = &vmw_srf_placement, + .domain = VMW_BO_DOMAIN_GMR, + .busy_domain = VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM, .create = &vmw_legacy_srf_create, .destroy = &vmw_legacy_srf_destroy, .bind = &vmw_legacy_srf_bind,@@ -145,7 +146,8 @@ static const struct vmw_res_func vmw_gb_surface_func = { .prio = 1, .dirty_prio = 2, .type_name = "guest backed surfaces", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_surface_create, .destroy = vmw_gb_surface_destroy, .bind = vmw_gb_surface_bind,drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0
-47@@ -79,20 +79,6 @@ static const struct ttm_place vram_gmr_placement_flags[] = { } }; -static const struct ttm_place gmr_vram_placement_flags[] = { - { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_GMR , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =TTM_PL_VRAM , - .flags =0 - } -}; -static const struct ttm_place vmw_sys_placement_flags = { .fpfn =0 , .lpfn =0 ,@@ -128,32 +114,6 @@ struct ttm_placement vmw_pt_sys_placement = { .busy_placement = &vmw_sys_placement_flags }; -static const struct ttm_place nonfixed_placement_flags[] = { - { - .fpfn =0 , - .lpfn =0 , - .mem_type =TTM_PL_SYSTEM , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_GMR , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_MOB , - .flags =0 - } -}; - -struct ttm_placement vmw_srf_placement = { - .num_placement =1 , - .num_busy_placement =2 , - .placement = &gmr_placement_flags, - .busy_placement = gmr_vram_placement_flags -}; -struct ttm_placement vmw_mob_placement = { .num_placement =1 , .num_busy_placement =1 ,@@ -161,13 +121,6 @@ struct ttm_placement vmw_mob_placement = { .busy_placement = &mob_placement_flags }; -struct ttm_placement vmw_nonfixed_placement = { - .num_placement =3 , - .placement = nonfixed_placement_flags, - .num_busy_placement =1 , - .busy_placement = &sys_placement_flags -}; -const size_t vmw_tt_size =sizeof (struct vmw_ttm_tt );/** drivers/gpu/drm/vmwgfx/vmwgfx_va.c +3
-1@@ -25,6 +25,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" @@ -83,7 +84,8 @@ static const struct vmw_simple_resource_func va_stream_func = { .needs_backup = false, .may_evict = false, .type_name = "overlay stream", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +19
-55@@ -27,6 +27,7 @@**************************************************************************/ #include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_resource_priv.h" #include "vmwgfx_validation.h" #include <linux/slab.h> @@ -40,8 +41,6 @@* @hash: A hash entry used for the duplicate detection hash table. * @coherent_count: If switching backup buffers, number of new coherent * resources that will have this buffer as a backup buffer. -* @as_mob: Validate as mob. -* @cpu_blit: Validate for cpu blit access. * * Bit fields are used since these structures are allocated and freed in * large numbers and space conservation is desired. @@ -50,8 +49,6 @@ struct vmw_validation_bo_node {struct ttm_validate_buffer base;struct vmwgfx_hash_item hash;unsigned int coherent_count; - u32 as_mob : 1; - u32 cpu_blit : 1; };/** * struct vmw_validation_res_node - Resource validation metadata. @@ -260,26 +257,16 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx,* vmw_validation_add_bo - Add a buffer object to the validation context. * @ctx: The validation context. * @vbo: The buffer object. -* @as_mob: Validate as mob, otherwise suitable for GMR operations. -* @cpu_blit: Validate in a page-mappable location. * * Return: Zero on success, negative error code otherwise. */ int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob, -bool cpu_blit) +struct vmw_bo *vbo) {struct vmw_validation_bo_node *bo_node; bo_node =vmw_validation_find_bo_dup (ctx, vbo); -if (bo_node) { -if (bo_node->as_mob != as_mob || - bo_node->cpu_blit != cpu_blit) { -DRM_ERROR ("Inconsistent buffer usage.\n" ); -return -EINVAL ; - } - }else { +if (!bo_node) {struct ttm_validate_buffer *val_buf; bo_node =vmw_validation_mem_alloc (ctx,sizeof (*bo_node));@@ -297,8 +284,6 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx,return -ESRCH ; val_buf->num_shared =0 ;list_add_tail (&val_buf->head, &ctx->bo_list); - bo_node->as_mob = as_mob; - bo_node->cpu_blit = cpu_blit; }return 0 ;@@ -455,9 +440,10 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx,if (res->backup) {struct vmw_bo *vbo = res->backup; - ret =vmw_validation_add_bo - (ctx, vbo,vmw_resource_needs_backup (res), - false); +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); + ret =vmw_validation_add_bo (ctx, vbo);if (ret) goto out_unreserve; }@@ -519,14 +505,12 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx,* vmw_validation_bo_validate_single - Validate a single buffer object. * @bo: The TTM buffer object base. * @interruptible: Whether to perform waits interruptible if possible. -* @validate_as_mob: Whether to validate in MOB memory. * * Return: Zero on success, -ERESTARTSYS if interrupted. Negative error * code on failure. */ -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob) +static int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, +bool interruptible) {struct vmw_bo *vbo = container_of(bo, struct vmw_bo, base);@@ -542,27 +526,17 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo,if (vbo->base.pin_count >0 )return 0 ; -if (validate_as_mob) -return ttm_bo_validate (bo, &vmw_mob_placement, &ctx); - -/** -* Put BO in VRAM if there is space, otherwise as a GMR. -* If there is no space in VRAM and GMR ids are all used up, -* start evicting GMRs to make room. If the DMA buffer can't be -* used as a GMR, this will return -ENOMEM. -*/ - - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); + ret =ttm_bo_validate (bo, &vbo->placement, &ctx);if (ret ==0 || ret == -ERESTARTSYS )return ret; -/** -* If that failed, try VRAM again, this time evicting +/* +* If that failed, try again, this time evicting * previous contents. */ + ctx.allow_res_evict = true; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); -return ret; +return ttm_bo_validate (bo, &vbo->placement, &ctx); }/** @@ -583,18 +557,8 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)struct vmw_bo *vbo =container_of (entry->base.bo,typeof (*vbo), base); -if (entry->cpu_blit) { -struct ttm_operation_ctx ttm_ctx = { - .interruptible = intr, - .no_wait_gpu = false - }; - - ret =ttm_bo_validate (entry->base.bo, - &vmw_nonfixed_placement, &ttm_ctx); - }else { - ret =vmw_validation_bo_validate_single - (entry->base.bo, intr, entry->as_mob); - } + ret =vmw_validation_bo_validate_single (entry->base.bo, intr); +if (ret)return ret;@@ -655,9 +619,9 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)if (backup && res->backup && (backup != res->backup)) {struct vmw_bo *vbo = res->backup; - ret =vmw_validation_add_bo - (ctx, vbo,vmw_resource_needs_backup (res), - false); +vmw_bo_placement_set (vbo, res->func->domain, + res->func->busy_domain); + ret =vmw_validation_add_bo (ctx, vbo);if (ret)return ret; }drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +0
-0@@ -159,11 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) }
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h static inline unsigned int vmw_validation_align(unsigned int val) · line 165
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +1
-5int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob,bool cpu_blit); -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob); +struct vmw_bo *vbo);int vmw_validation_bo_validate (struct vmw_validation_context *ctx,bool intr);void vmw_validation_unref_lists (struct vmw_validation_context *ctx); int vmw_validation_add_resource(struct vmw_validation_context *ctx,
LGTM!
Signature · 1 line
Maaz Mombasawala (VMware) <[email protected]>
Dave Airlie
maintainerRe: [PATCH v2 7/8] drm/vmwgfx: Abstract placement selection
Quoted 10 lines
Quoted 10 lines
Problem with explicit placement selection in vmwgfx is that by the time the buffer object needs to be validated the information about which placement was supposed to be used is lost. To workaround this the driver had a bunch of state in various places e.g.
as_moborcpu_blitto somehow convey the information on which placement was intended.Fix it properly by allowing the buffer objects to hold their preferred placement so it can be reused whenever needed. This makes the entire validation pipeline a lot easier both to understand and maintain.
I think this patch mixes up src/dst_pitch in the stdu code.
CC [M] drivers/gpu/drm/etnaviv/etnaviv_gem_submit.o/home/airlied/devel/kernel/dim/src/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:509:29:
error: variable 'dst_pitch' is uninitialized when used here [-Werror,-Wuninitialized]
src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp;
^~~~~~~~~
/home/airlied/devel/kernel/dim/src/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:492:26:
note: initialize the variable 'dst_pitch' to silence this warning
s32 src_pitch, dst_pitch;
^
= 0Dave.
Quoted 1,504 lines
Quoted 1,486 lines
Signed-off-by Zack Rusin <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 145 +++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 25 +- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 9 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 35 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 5 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 22 +- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 21 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 11 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 13 +- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 304 ++---------------- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 47 --- drivers/gpu/drm/vmwgfx/vmwgfx_va.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 74 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 6 +- 22 files changed, 312 insertions(+), 456 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +126
-19@@ -135,11 +135,17 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, goto out_unreserve; } - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (likely (ret ==0 ) || ret == -ERESTARTSYS ) goto out_unreserve; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx); out_unreserve:if (!ret)@@ -190,17 +196,8 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, {struct ttm_operation_ctx ctx = {interruptible, false };struct ttm_buffer_object *bo = &buf->base; -struct ttm_placement placement; -struct ttm_place place;int ret =0 ; - place = vmw_vram_placement.placement[0 ]; - place.lpfn =PFN_UP (bo->resource->size); - placement.num_placement =1 ; - placement.placement = &place; - placement.num_busy_placement =1 ; - placement.busy_placement = &place; -vmw_execbuf_release_pinned_bo (dev_priv); ret =ttm_bo_reserve (bo, interruptible, false,NULL );if (unlikely (ret !=0 ))@@ -216,14 +213,21 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, bo->resource->start > 0 && buf->base.pin_count == 0) { ctx.interruptible = false; - (void )ttm_bo_validate (bo, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + (void )ttm_bo_validate (bo, &buf->placement, &ctx); } +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM ); + buf->places[0 ].lpfn =PFN_UP (bo->resource->size);if (buf->base.pin_count >0 ) - ret =ttm_resource_compat (bo->resource, &placement) + ret =ttm_resource_compat (bo->resource, &buf->placement) ?0 : -EINVAL ;else - ret =ttm_bo_validate (bo, &placement, &ctx); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);/* For some reason we didn't end up at the start of vram */ WARN_ON (ret ==0 && bo->resource->start !=0 );@@ -431,7 +435,7 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, }int vmw_bo_create (struct vmw_private *vmw, -size_t size,struct ttm_placement *placement, +size_t size,u32 domain,u32 busy_domain,bool interruptible,bool pin,struct vmw_bo **p_bo) {@@ -444,7 +448,8 @@ int vmw_bo_create(struct vmw_private *vmw, } ret =vmw_bo_init (vmw, *p_bo, size, - placement, interruptible, pin); + domain, busy_domain, + interruptible, pin);if (unlikely (ret !=0 )) goto out_error;@@ -461,7 +466,8 @@ int vmw_bo_create(struct vmw_private *vmw,* @dev_priv: Pointer to the device private struct * @vmw_bo: Pointer to the struct vmw_bo to initialize. * @size: Buffer object size in bytes. -* @placement: Initial placement. +* @domain: Domain to put the bo in. +* @busy_domain: Domain to put the bo if busy. * @interruptible: Whether waits should be performed interruptible. * @pin: If the BO should be created pinned at a fixed location. * Returns: Zero on success, negative error code on error. @@ -470,7 +476,9 @@ int vmw_bo_create(struct vmw_private *vmw,*/ int vmw_bo_init (struct vmw_private *dev_priv,struct vmw_bo *vmw_bo, -size_t size,struct ttm_placement *placement, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin) {struct ttm_operation_ctx ctx = {@@ -489,8 +497,9 @@ int vmw_bo_init(struct vmw_private *dev_priv, size =ALIGN (size,PAGE_SIZE );drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); +vmw_bo_placement_set (vmw_bo, domain, busy_domain); ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - placement,0 , &ctx,NULL ,NULL , vmw_bo_free); + &vmw_bo->placement,0 , &ctx,NULL ,NULL , vmw_bo_free);if (unlikely (ret)) {return ret; }@@ -825,3 +834,101 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo,if (mem->mem_type !=VMW_PL_MOB && bo->resource->mem_type ==VMW_PL_MOB )vmw_resource_unbind_list (vbo); } + +static u32 +set_placement_list (struct ttm_place *pl,u32 domain) +{ +u32 n =0 ; + +/* +* The placements are ordered according to our preferences +*/ +if (domain &VMW_BO_DOMAIN_MOB ) { + pl[n].mem_type =VMW_PL_MOB ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_GMR ) { + pl[n].mem_type =VMW_PL_GMR ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_VRAM ) { + pl[n].mem_type =TTM_PL_VRAM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +WARN_ON ((domain &VMW_BO_DOMAIN_WAITABLE_SYS ) !=0 ); +if (domain &VMW_BO_DOMAIN_WAITABLE_SYS ) { + pl[n].mem_type =VMW_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +if (domain &VMW_BO_DOMAIN_SYS ) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } + +WARN_ON (!n); +if (!n) { + pl[n].mem_type =TTM_PL_SYSTEM ; + pl[n].flags =0 ; + pl[n].fpfn =0 ; + pl[n].lpfn =0 ; + n++; + } +return n; +} + +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +struct ttm_placement *pl = &bo->placement; +bool mem_compatible = false; +u32 i; + + pl->placement = bo->places; + pl->num_placement =set_placement_list (bo->places, domain); + +if (drm_debug_enabled (DRM_UT_DRIVER ) && bo->base.resource) { +for (i =0 ; i < pl->num_placement; ++i) { +if (bo->base.resource->mem_type ==TTM_PL_SYSTEM || + bo->base.resource->mem_type == pl->placement[i].mem_type) + mem_compatible = true; + } +if (!mem_compatible) +drm_warn (&vmw->drm, +"%s: Incompatible transition from " +"bo->base.resource->mem_type = %u to domain = %u\n" , + __func__, bo->base.resource->mem_type, domain); + } + + pl->busy_placement = bo->busy_places; + pl->num_busy_placement =set_placement_list (bo->busy_places, busy_domain); +} + +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo) +{ +struct ttm_device *bdev = bo->base.bdev; +struct vmw_private *vmw = + container_of(bdev, struct vmw_private, bdev); +u32 domain =VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ; + +if (vmw->has_mob) + domain =VMW_BO_DOMAIN_MOB ; + +vmw_bo_placement_set (bo, domain, domain); +}drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +23
-2@@ -31,6 +31,7 @@#include "device_include/svga_reg.h" #include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_placement.h> #include <linux/rbtree_types.h> #include <linux/types.h> @@ -40,6 +41,14 @@ struct vmw_fence_obj;struct vmw_private ;struct vmw_resource ; +enum vmw_bo_domain { +VMW_BO_DOMAIN_SYS =BIT (0 ), +VMW_BO_DOMAIN_WAITABLE_SYS =BIT (1 ), +VMW_BO_DOMAIN_VRAM =BIT (2 ), +VMW_BO_DOMAIN_GMR =BIT (3 ), +VMW_BO_DOMAIN_MOB =BIT (4 ), +}; +/** * struct vmw_bo - TTM buffer object with vmwgfx additions * @base: The TTM buffer object @@ -53,6 +62,11 @@ struct vmw_resource;*/ struct vmw_bo {struct ttm_buffer_object base; + +struct ttm_placement placement; +struct ttm_place places[5 ]; +struct ttm_place busy_places[5 ]; +struct rb_root res_tree;atomic_t cpu_writers;@@ -64,17 +78,24 @@ struct vmw_bo {struct vmw_bo_dirty *dirty; }; +void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain); +void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo); +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, +size_t size, +u32 domain, +u32 busy_domain,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, +size_t size, +u32 domain, +u32 busy_domain,bool interruptible,bool pin);int vmw_bo_unref_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);drivers/gpu/drm/vmwgfx/vmwgfx_context.c +6
-3@@ -76,7 +76,8 @@ static const struct vmw_res_func vmw_legacy_context_func = { .needs_backup = false, .may_evict = false, .type_name = "legacy contexts", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,@@ -90,7 +91,8 @@ static const struct vmw_res_func vmw_gb_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_context_create, .destroy = vmw_gb_context_destroy, .bind = vmw_gb_context_bind,@@ -104,7 +106,8 @@ static const struct vmw_res_func vmw_dx_context_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx contexts", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_context_create, .destroy = vmw_dx_context_destroy, .bind = vmw_dx_context_bind,drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +8
-3@@ -136,7 +136,8 @@ static const struct vmw_res_func vmw_cotable_func = { .prio = 3, .dirty_prio = 3, .type_name = "context guest backed object tables", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_cotable_create, .destroy = vmw_cotable_destroy, .bind = vmw_cotable_bind,@@ -424,7 +425,8 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)* for the new COTable. Initially pin the buffer object to make sure * we can use tryreserve without failure. */ - ret =vmw_bo_create (dev_priv, new_size, &vmw_mob_placement, + ret =vmw_bo_create (dev_priv, new_size, +VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB , true, true, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" );@@ -465,7 +467,10 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) }/* Unpin new buffer, and switch backup buffers. */ - ret =ttm_bo_validate (bo, &vmw_mob_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); + ret =ttm_bo_validate (bo, &buf->placement, &ctx);if (unlikely (ret !=0 )) {DRM_ERROR ("Failed validating new COTable backup buffer.\n" ); goto out_wait;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2
-1@@ -399,7 +399,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)* user of the bo currently. */ ret =vmw_bo_create (dev_priv,PAGE_SIZE , - &vmw_sys_placement, false, true, &vbo); +VMW_BO_DOMAIN_SYS ,VMW_BO_DOMAIN_SYS , + false, true, &vbo);if (unlikely (ret !=0 ))return ret;drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0
-2@@ -930,9 +930,7 @@ extern struct ttm_placement vmw_vram_placement;extern struct ttm_placement vmw_vram_sys_placement;extern struct ttm_placement vmw_vram_gmr_placement;extern struct ttm_placement vmw_sys_placement; -extern struct ttm_placement vmw_srf_placement;extern struct ttm_placement vmw_mob_placement; -extern struct ttm_placement vmw_nonfixed_placement;extern struct ttm_device_funcs vmw_bo_driver;extern const struct vmw_sg_table *vmw_bo_sg_table (struct ttm_buffer_object *bo);drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +23
-12@@ -477,9 +477,13 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,struct vmw_bo *dx_query_mob; dx_query_mob =vmw_context_get_dx_query_mob (ctx); -if (dx_query_mob) +if (dx_query_mob) { +vmw_bo_placement_set (dx_query_mob, +VMW_BO_DOMAIN_MOB , +VMW_BO_DOMAIN_MOB ); ret =vmw_validation_add_bo (sw_context->ctx, - dx_query_mob, true, false); + dx_query_mob); + } }mutex_unlock (&dev_priv->binding_mutex);@@ -1035,17 +1039,17 @@ static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv,if (unlikely (sw_context->cur_query_bo !=NULL )) { sw_context->needs_post_query_barrier = true; +vmw_bo_placement_set_default_accelerated (sw_context->cur_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - sw_context->cur_query_bo, - dev_priv->has_mob, false); + sw_context->cur_query_bo);if (unlikely (ret !=0 ))return ret; } sw_context->cur_query_bo = new_query_bo; +vmw_bo_placement_set_default_accelerated (dev_priv->dummy_query_bo); ret =vmw_validation_add_bo (sw_context->ctx, - dev_priv->dummy_query_bo, - dev_priv->has_mob, false); + dev_priv->dummy_query_bo);if (unlikely (ret !=0 ))return ret; }@@ -1157,7 +1161,8 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use MOB buffer.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, true, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;@@ -1211,7 +1216,9 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,drm_dbg (&dev_priv->drm,"Could not find or use GMR region.\n" );return PTR_ERR (vmw_bo); } - ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo, false, false); +vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo);ttm_bo_put (&vmw_bo->base);if (unlikely (ret !=0 ))return ret;@@ -4361,13 +4368,17 @@ void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,if (dev_priv->pinned_bo ==NULL ) goto out_unlock; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo, false, - false); +vmw_bo_placement_set (dev_priv->pinned_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->pinned_bo);if (ret) goto out_no_reserve; - ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo, false, - false); +vmw_bo_placement_set (dev_priv->dummy_query_bo, +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, dev_priv->dummy_query_bo);if (ret) goto out_no_reserve;drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +2
-3@@ -121,9 +121,8 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv,int ret; ret =vmw_bo_create (dev_priv, size, - (dev_priv->has_mob) ? - &vmw_sys_placement : - &vmw_vram_sys_placement, + (dev_priv->has_mob) ?VMW_BO_DOMAIN_SYS :VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_SYS , true, false, p_vbo); (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs;drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +17
-5@@ -1270,9 +1270,9 @@ int vmw_kms_readback(struct vmw_private *dev_priv, user_fence_rep, vclips, num_clips, NULL);case vmw_du_screen_target: -return vmw_kms_stdu_dma (dev_priv, file_priv, vfb, - user_fence_rep,NULL , vclips, num_clips, -1 , false, true,NULL ); +return vmw_kms_stdu_readback (dev_priv, file_priv, vfb, + user_fence_rep,NULL , vclips, num_clips, +1 ,NULL );default :WARN_ONCE (true,"Readback called with invalid display system.\n" );@@ -2999,8 +2999,20 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)struct vmw_framebuffer_bo *vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer, false, - update->cpu_blit); +/* +* For screen targets we want a mappable bo, for everything else we want +* accelerated i.e. host backed (vram or gmr) bo. If the display unit +* is not screen target then mob's shouldn't be available. +*/ +if (update->dev_priv->active_display_unit == vmw_du_screen_target) { +vmw_bo_placement_set (vfbbo->buffer, +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_GMR ); + }else { +WARN_ON (update->dev_priv->has_mob); +vmw_bo_placement_set_default_accelerated (vfbbo->buffer); + } + ret =vmw_validation_add_bo (&val_ctx, vfbbo->buffer); }else {struct vmw_framebuffer_surface *vfbs =container_of (update->vfb,typeof (*vfbs), base);drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +9
-12@@ -126,7 +126,6 @@ struct vmw_du_update_plane {struct vmw_framebuffer *vfb;struct vmw_fence_obj **out_fence;struct mutex *mutex; -bool cpu_blit;bool intr; };@@ -564,17 +563,15 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, unsigned num_clips, int inc, struct vmw_fence_obj **out_fence, struct drm_crtc *crtc); -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc); +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc);int vmw_du_helper_plane_update (struct vmw_du_update_plane *update);drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +8
-3@@ -332,7 +332,7 @@ static int vmw_resource_buf_alloc(struct vmw_resource *res, } ret =vmw_bo_create (res->dev_priv, res->backup_size, - res->func->backup_placement, + res->func->domain, res->func->busy_domain, interruptible, false, &backup);if (unlikely (ret !=0 )) goto out_no_bo;@@ -529,8 +529,10 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,return 0 ; backup_dirty = res->backup_dirty; +vmw_bo_placement_set (res->backup, res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&res->backup->base, - res->func->backup_placement, + &res->backup->placement, &ctx);if (unlikely (ret !=0 ))@@ -968,9 +970,12 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)if (ret) goto out_no_validate;if (!vbo->base.pin_count) { +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); ret =ttm_bo_validate (&vbo->base, - res->func->backup_placement, + &vbo->placement, &ctx);if (ret) {ttm_bo_unreserve (&vbo->base);drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +2
-1@@ -83,7 +83,8 @@ struct vmw_res_func {enum vmw_res_type res_type;bool needs_backup;const char *type_name; -struct ttm_placement *backup_placement; +u32 domain; +u32 busy_domain;bool may_evict;u32 prio;u32 dirty_prio;drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +8
-5@@ -445,7 +445,8 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,*/ vmw_overlay_pause_all (dev_priv); ret =vmw_bo_create (dev_priv, size, - &vmw_vram_placement, +VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_VRAM , false, true, &vps->bo);vmw_overlay_resume_all (dev_priv);if (ret) {@@ -547,7 +548,6 @@ static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit = false; bo_update.base.intr = true; bo_update.base.calc_fifo_size = vmw_sou_bo_fifo_size;@@ -708,7 +708,6 @@ static int vmw_sou_plane_update_surface(struct vmw_private *dev_priv, srf_update.base.vfb = vfb; srf_update.base.out_fence = out_fence; srf_update.base.mutex = &dev_priv->cmdbuf_mutex; - srf_update.base.cpu_blit = false; srf_update.base.intr = true; srf_update.base.calc_fifo_size = vmw_sou_surface_fifo_size;@@ -1224,7 +1223,9 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;@@ -1330,7 +1331,9 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );int ret; - ret =vmw_validation_add_bo (&val_ctx, buf, false, false); +vmw_bo_placement_set (buf,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM , +VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret;drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +11
-4@@ -94,7 +94,8 @@ static const struct vmw_res_func vmw_gb_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "guest backed shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_shader_create, .destroy = vmw_gb_shader_destroy, .bind = vmw_gb_shader_bind,@@ -108,7 +109,8 @@ static const struct vmw_res_func vmw_dx_shader_func = { .prio = 3, .dirty_prio = 3, .type_name = "dx shaders", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_shader_create,/* * The destroy callback is only called with a committed resource on @@ -893,7 +895,9 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,if (!vmw_shader_id_ok (user_key, shader_type))return -EINVAL ; - ret =vmw_bo_create (dev_priv, size, &vmw_sys_placement, + ret =vmw_bo_create (dev_priv, size, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS , true, true, &buf);if (unlikely (ret !=0 )) goto out;@@ -913,7 +917,10 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,WARN_ON (is_iomem);ttm_bo_kunmap (&map); - ret =ttm_bo_validate (&buf->base, &vmw_sys_placement, &ctx); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_SYS , +VMW_BO_DOMAIN_SYS ); + ret =ttm_bo_validate (&buf->base, &buf->placement, &ctx);WARN_ON (ret !=0 );ttm_bo_unreserve (&buf->base);drivers/gpu/drm/vmwgfx/vmwgfx_so.c +3
-1@@ -24,6 +24,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h" @@ -84,7 +85,8 @@ static const struct vmw_res_func vmw_view_func = { .needs_backup = false, .may_evict = false, .type_name = "DX view", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = vmw_view_create, .commit_notify = vmw_view_commit_notify, };drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +35
-269@@ -66,7 +66,6 @@ enum stdu_content_type {*/ struct vmw_stdu_dirty {struct vmw_kms_dirty base; -SVGA3dTransferType transfer;s32 left, right, top, bottom;s32 fb_left, fb_top;u32 pitch;@@ -137,12 +136,6 @@ static void vmw_stdu_destroy(struct vmw_screen_target_display_unit *stdu);* Screen Target Display Unit CRTC Functions *****************************************************************************/ -static bool vmw_stdu_use_cpu_blit (const struct vmw_private *vmw) -{ -return !(vmw->capabilities &SVGA_CAP_3D ) || vmw->vram_size < (32 *1024 *1024 ); -} - -/** * vmw_stdu_crtc_destroy - cleans up the STDU * @@ -451,93 +444,6 @@ static void vmw_stdu_crtc_atomic_disable(struct drm_crtc *crtc, } } -/** -* vmw_stdu_bo_clip - Callback to encode a suface DMA command cliprect -* -* @dirty: The closure structure. -* -* Encodes a surface DMA command cliprect and updates the bounding box -* for the DMA. -*/ -static void vmw_stdu_bo_clip (struct vmw_kms_dirty *dirty) -{ -struct vmw_stdu_dirty *ddirty = - container_of(dirty, struct vmw_stdu_dirty, base); -struct vmw_stdu_dma *cmd = dirty->cmd; -struct SVGA3dCopyBox *blit = (struct SVGA3dCopyBox *) &cmd[1 ]; - - blit += dirty->num_hits; - blit->srcx = dirty->fb_x; - blit->srcy = dirty->fb_y; - blit->x = dirty->unit_x1; - blit->y = dirty->unit_y1; - blit->d =1 ; - blit->w = dirty->unit_x2 - dirty->unit_x1; - blit->h = dirty->unit_y2 - dirty->unit_y1; - dirty->num_hits++; - -if (ddirty->transfer !=SVGA3D_WRITE_HOST_VRAM ) -return ; - -/* Destination bounding box */ - ddirty->left =min_t (s32, ddirty->left, dirty->unit_x1); - ddirty->top =min_t (s32, ddirty->top, dirty->unit_y1); - ddirty->right =max_t (s32, ddirty->right, dirty->unit_x2); - ddirty->bottom =max_t (s32, ddirty->bottom, dirty->unit_y2); -} - -/** -* vmw_stdu_bo_fifo_commit - Callback to fill in and submit a DMA command. -* -* @dirty: The closure structure. -* -* Fills in the missing fields in a DMA command, and optionally encodes -* a screen target update command, depending on transfer direction. -*/ -static void vmw_stdu_bo_fifo_commit (struct vmw_kms_dirty *dirty) -{ -struct vmw_stdu_dirty *ddirty = - container_of(dirty, struct vmw_stdu_dirty, base); -struct vmw_screen_target_display_unit *stdu = -container_of (dirty->unit,typeof (*stdu), base); -struct vmw_stdu_dma *cmd = dirty->cmd; -struct SVGA3dCopyBox *blit = (struct SVGA3dCopyBox *) &cmd[1 ]; -SVGA3dCmdSurfaceDMASuffix *suffix = - (SVGA3dCmdSurfaceDMASuffix *) &blit[dirty->num_hits]; -size_t blit_size =sizeof (*blit) * dirty->num_hits +sizeof (*suffix); - -if (!dirty->num_hits) { -vmw_cmd_commit (dirty->dev_priv,0 ); -return ; - } - - cmd->header.id =SVGA_3D_CMD_SURFACE_DMA ; - cmd->header.size =sizeof (cmd->body) + blit_size; -vmw_bo_get_guest_ptr (&ddirty->buf->base, &cmd->body.guest.ptr); - cmd->body.guest.pitch = ddirty->pitch; - cmd->body.host.sid = stdu->display_srf->res.id; - cmd->body.host.face =0 ; - cmd->body.host.mipmap =0 ; - cmd->body.transfer = ddirty->transfer; - suffix->suffixSize =sizeof (*suffix); - suffix->maximumOffset = ddirty->buf->base.base.size; - -if (ddirty->transfer ==SVGA3D_WRITE_HOST_VRAM ) { - blit_size +=sizeof (struct vmw_stdu_update ); - -vmw_stdu_populate_update (&suffix[1 ], stdu->base.unit, - ddirty->left, ddirty->right, - ddirty->top, ddirty->bottom); - } - -vmw_cmd_commit (dirty->dev_priv,sizeof (*cmd) + blit_size); - - stdu->display_srf->res.res_dirty = true; - ddirty->left = ddirty->top =S32_MAX ; - ddirty->right = ddirty->bottom =S32_MIN ; -} - -/** * vmw_stdu_bo_cpu_clip - Callback to encode a CPU blit * @@ -598,62 +504,21 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)return ;/* Assume we are blitting from Guest (bo) to Host (display_srf) */ - dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; - dst_bo = &stdu->display_srf->res.backup->base; - dst_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; - - src_pitch = ddirty->pitch; - src_bo = &ddirty->buf->base; - src_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; + src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; + src_bo = &stdu->display_srf->res.backup->base; + src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; -/* Swap src and dst if the assumption was wrong. */ -if (ddirty->transfer !=SVGA3D_WRITE_HOST_VRAM ) { -swap (dst_pitch, src_pitch); -swap (dst_bo, src_bo); -swap (src_offset, dst_offset); - } + dst_pitch = ddirty->pitch; + dst_bo = &ddirty->buf->base; + dst_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; (void )vmw_bo_cpu_blit (dst_bo, dst_offset, dst_pitch, src_bo, src_offset, src_pitch, width * stdu->cpp, height, &diff); - -if (ddirty->transfer ==SVGA3D_WRITE_HOST_VRAM && -drm_rect_visible (&diff.rect)) { -struct vmw_private *dev_priv; -struct vmw_stdu_update *cmd; -struct drm_clip_rect region; -int ret; - -/* We are updating the actual surface, not a proxy */ - region.x1 = diff.rect.x1; - region.x2 = diff.rect.x2; - region.y1 = diff.rect.y1; - region.y2 = diff.rect.y2; - ret =vmw_kms_update_proxy (&stdu->display_srf->res, ®ion, -1 ,1 ); -if (ret) - goto out_cleanup; - - - dev_priv =vmw_priv (stdu->base.crtc.dev); - cmd =VMW_CMD_RESERVE (dev_priv,sizeof (*cmd)); -if (!cmd) - goto out_cleanup; - -vmw_stdu_populate_update (cmd, stdu->base.unit, - region.x1, region.x2, - region.y1, region.y2); - -vmw_cmd_commit (dev_priv,sizeof (*cmd)); - } - -out_cleanup: - ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top =S32_MAX ; - ddirty->right = ddirty->bottom =S32_MIN ; }/** -* vmw_kms_stdu_dma - Perform a DMA transfer between a buffer-object backed +* vmw_kms_stdu_readback - Perform a readback from a buffer-object backed * framebuffer and the screen target system. * * @dev_priv: Pointer to the device private structure. @@ -666,9 +531,6 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)* be NULL. * @num_clips: Number of clip rects in @clips or @vclips. * @increment: Increment to use when looping over @clips or @vclips. -* @to_surface: Whether to DMA to the screen target system as opposed to -* from the screen target system. -* @interruptible: Whether to perform waits interruptible if possible. * @crtc: If crtc is passed, perform stdu dma on that crtc only. * * If DMA-ing till the screen target system, the function will also notify @@ -677,59 +539,49 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)* Returns 0 on success, negative error code on failure. -ERESTARTSYS if * interrupted. */ -int vmw_kms_stdu_dma (struct vmw_private *dev_priv, -struct drm_file *file_priv, -struct vmw_framebuffer *vfb, -struct drm_vmw_fence_rep __user *user_fence_rep, -struct drm_clip_rect *clips, -struct drm_vmw_rect *vclips, -uint32_t num_clips, -int increment, -bool to_surface, -bool interruptible, -struct drm_crtc *crtc) +int vmw_kms_stdu_readback (struct vmw_private *dev_priv, +struct drm_file *file_priv, +struct vmw_framebuffer *vfb, +struct drm_vmw_fence_rep __user *user_fence_rep, +struct drm_clip_rect *clips, +struct drm_vmw_rect *vclips, +uint32_t num_clips, +int increment, +struct drm_crtc *crtc) {struct vmw_bo *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer;struct vmw_stdu_dirty ddirty;int ret; -bool cpu_blit =vmw_stdu_use_cpu_blit (dev_priv);DECLARE_VAL_CONTEXT (val_ctx,NULL ,0 );/* -* VMs without 3D support don't have the surface DMA command and -* we'll be using a CPU blit, and the framebuffer should be moved out -* of VRAM. +* The GMR domain might seem confusing because it might seem like it should +* never happen with screen targets but e.g. the xorg vmware driver issues +* CMD_SURFACE_DMA for various pixmap updates which might transition our bo to +* a GMR. Instead of forcing another transition we can optimize the readback +* by reading directly from the GMR. */ - ret =vmw_validation_add_bo (&val_ctx, buf, false, cpu_blit); +vmw_bo_placement_set (buf, +VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_GMR , +VMW_BO_DOMAIN_MOB |VMW_BO_DOMAIN_SYS |VMW_BO_DOMAIN_GMR ); + ret =vmw_validation_add_bo (&val_ctx, buf);if (ret)return ret; - ret =vmw_validation_prepare (&val_ctx,NULL , interruptible); + ret =vmw_validation_prepare (&val_ctx,NULL , true);if (ret) goto out_unref; - ddirty.transfer = (to_surface) ?SVGA3D_WRITE_HOST_VRAM : -SVGA3D_READ_HOST_VRAM ; ddirty.left = ddirty.top =S32_MAX ; ddirty.right = ddirty.bottom =S32_MIN ; ddirty.fb_left = ddirty.fb_top =S32_MAX ; ddirty.pitch = vfb->base.pitches[0 ]; ddirty.buf = buf; - ddirty.base.fifo_commit = vmw_stdu_bo_fifo_commit; - ddirty.base.clip = vmw_stdu_bo_clip; - ddirty.base.fifo_reserve_size =sizeof (struct vmw_stdu_dma ) + - num_clips *sizeof (SVGA3dCopyBox) + -sizeof (SVGA3dCmdSurfaceDMASuffix); -if (to_surface) - ddirty.base.fifo_reserve_size +=sizeof (struct vmw_stdu_update ); - - -if (cpu_blit) { - ddirty.base.fifo_commit = vmw_stdu_bo_cpu_commit; - ddirty.base.clip = vmw_stdu_bo_cpu_clip; - ddirty.base.fifo_reserve_size =0 ; - } + + ddirty.base.fifo_commit = vmw_stdu_bo_cpu_commit; + ddirty.base.clip = vmw_stdu_bo_cpu_clip; + ddirty.base.fifo_reserve_size =0 ; ddirty.base.crtc = crtc;@@ -1161,11 +1013,8 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,/* * This should only happen if the buffer object is too large to create a * proxy surface for. -* If we are a 2D VM with a buffer object then we have to use CPU blit -* so cache these mappings */ -if (vps->content_fb_type ==SEPARATE_BO && -vmw_stdu_use_cpu_blit (dev_priv)) +if (vps->content_fb_type ==SEPARATE_BO ) vps->cpp = new_fb->pitches[0 ] / new_fb->width;return 0 ;@@ -1175,14 +1024,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,return ret; } -static uint32_t vmw_stdu_bo_fifo_size (struct vmw_du_update_plane *update, -uint32_t num_hits) -{ -return sizeof (struct vmw_stdu_dma ) +sizeof (SVGA3dCopyBox) * num_hits + -sizeof (SVGA3dCmdSurfaceDMASuffix) + -sizeof (struct vmw_stdu_update ); -} -static uint32_t vmw_stdu_bo_fifo_size_cpu (struct vmw_du_update_plane *update,uint32_t num_hits) {@@ -1190,68 +1031,6 @@ static uint32_t vmw_stdu_bo_fifo_size_cpu(struct vmw_du_update_plane *update,sizeof (struct vmw_stdu_update ); } -static uint32_t vmw_stdu_bo_populate_dma (struct vmw_du_update_plane *update, -void *cmd,uint32_t num_hits) -{ -struct vmw_screen_target_display_unit *stdu; -struct vmw_framebuffer_bo *vfbbo; -struct vmw_stdu_dma *cmd_dma = cmd; - - stdu =container_of (update->du,typeof (*stdu), base); - vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - - cmd_dma->header.id =SVGA_3D_CMD_SURFACE_DMA ; - cmd_dma->header.size =sizeof (cmd_dma->body) + -sizeof (struct SVGA3dCopyBox ) * num_hits + -sizeof (SVGA3dCmdSurfaceDMASuffix); -vmw_bo_get_guest_ptr (&vfbbo->buffer->base, &cmd_dma->body.guest.ptr); - cmd_dma->body.guest.pitch = update->vfb->base.pitches[0 ]; - cmd_dma->body.host.sid = stdu->display_srf->res.id; - cmd_dma->body.host.face =0 ; - cmd_dma->body.host.mipmap =0 ; - cmd_dma->body.transfer =SVGA3D_WRITE_HOST_VRAM ; - -return sizeof (*cmd_dma); -} - -static uint32_t vmw_stdu_bo_populate_clip (struct vmw_du_update_plane *update, -void *cmd,struct drm_rect *clip, -uint32_t fb_x,uint32_t fb_y) -{ -struct SVGA3dCopyBox *box = cmd; - - box->srcx = fb_x; - box->srcy = fb_y; - box->srcz =0 ; - box->x = clip->x1; - box->y = clip->y1; - box->z =0 ; - box->w =drm_rect_width (clip); - box->h =drm_rect_height (clip); - box->d =1 ; - -return sizeof (*box); -} - -static uint32_t vmw_stdu_bo_populate_update (struct vmw_du_update_plane *update, -void *cmd,struct drm_rect *bb) -{ -struct vmw_screen_target_display_unit *stdu; -struct vmw_framebuffer_bo *vfbbo; -SVGA3dCmdSurfaceDMASuffix *suffix = cmd; - - stdu =container_of (update->du,typeof (*stdu), base); - vfbbo =container_of (update->vfb,typeof (*vfbbo), base); - - suffix->suffixSize =sizeof (*suffix); - suffix->maximumOffset = vfbbo->buffer->base.base.size; - -vmw_stdu_populate_update (&suffix[1 ], stdu->base.unit, bb->x1, bb->x2, - bb->y1, bb->y2); - -return sizeof (*suffix) +sizeof (struct vmw_stdu_update ); -} -static uint32_t vmw_stdu_bo_pre_clip_cpu (struct vmw_du_update_plane *update,void *cmd,uint32_t num_hits) {@@ -1369,24 +1148,12 @@ static int vmw_stdu_plane_update_bo(struct vmw_private *dev_priv, bo_update.base.vfb = vfb; bo_update.base.out_fence = out_fence; bo_update.base.mutex =NULL ; - bo_update.base.cpu_blit =vmw_stdu_use_cpu_blit (dev_priv); bo_update.base.intr = false; -/* -* VM without 3D support don't have surface DMA command and framebuffer -* should be moved out of VRAM. -*/ -if (bo_update.base.cpu_blit) { - bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size_cpu; - bo_update.base.pre_clip = vmw_stdu_bo_pre_clip_cpu; - bo_update.base.clip = vmw_stdu_bo_clip_cpu; - bo_update.base.post_clip = vmw_stdu_bo_populate_update_cpu; - }else { - bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size; - bo_update.base.pre_clip = vmw_stdu_bo_populate_dma; - bo_update.base.clip = vmw_stdu_bo_populate_clip; - bo_update.base.post_clip = vmw_stdu_bo_populate_update; - } + bo_update.base.calc_fifo_size = vmw_stdu_bo_fifo_size_cpu; + bo_update.base.pre_clip = vmw_stdu_bo_pre_clip_cpu; + bo_update.base.clip = vmw_stdu_bo_clip_cpu; + bo_update.base.post_clip = vmw_stdu_bo_populate_update_cpu;return vmw_du_helper_plane_update (&bo_update.base); }@@ -1549,7 +1316,6 @@ static int vmw_stdu_plane_update_surface(struct vmw_private *dev_priv, srf_update.vfb = vfb; srf_update.out_fence = out_fence; srf_update.mutex = &dev_priv->cmdbuf_mutex; - srf_update.cpu_blit = false; srf_update.intr = true;if (vfbs->is_bo_proxy)drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +2
-1@@ -66,7 +66,8 @@ static const struct vmw_res_func vmw_dx_streamoutput_func = { .needs_backup = true, .may_evict = false, .type_name = "DX streamoutput", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_dx_streamoutput_create, .destroy = NULL, /* Command buffer managed resource. */ .bind = vmw_dx_streamoutput_bind,drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +4
-2@@ -131,7 +131,8 @@ static const struct vmw_res_func vmw_legacy_surface_func = { .prio = 1, .dirty_prio = 1, .type_name = "legacy surfaces", - .backup_placement = &vmw_srf_placement, + .domain = VMW_BO_DOMAIN_GMR, + .busy_domain = VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM, .create = &vmw_legacy_srf_create, .destroy = &vmw_legacy_srf_destroy, .bind = &vmw_legacy_srf_bind,@@ -145,7 +146,8 @@ static const struct vmw_res_func vmw_gb_surface_func = { .prio = 1, .dirty_prio = 2, .type_name = "guest backed surfaces", - .backup_placement = &vmw_mob_placement, + .domain = VMW_BO_DOMAIN_MOB, + .busy_domain = VMW_BO_DOMAIN_MOB, .create = vmw_gb_surface_create, .destroy = vmw_gb_surface_destroy, .bind = vmw_gb_surface_bind,drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0
-47@@ -79,20 +79,6 @@ static const struct ttm_place vram_gmr_placement_flags[] = { } }; -static const struct ttm_place gmr_vram_placement_flags[] = { - { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_GMR , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =TTM_PL_VRAM , - .flags =0 - } -}; -static const struct ttm_place vmw_sys_placement_flags = { .fpfn =0 , .lpfn =0 ,@@ -128,32 +114,6 @@ struct ttm_placement vmw_pt_sys_placement = { .busy_placement = &vmw_sys_placement_flags }; -static const struct ttm_place nonfixed_placement_flags[] = { - { - .fpfn =0 , - .lpfn =0 , - .mem_type =TTM_PL_SYSTEM , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_GMR , - .flags =0 - }, { - .fpfn =0 , - .lpfn =0 , - .mem_type =VMW_PL_MOB , - .flags =0 - } -}; - -struct ttm_placement vmw_srf_placement = { - .num_placement =1 , - .num_busy_placement =2 , - .placement = &gmr_placement_flags, - .busy_placement = gmr_vram_placement_flags -}; -struct ttm_placement vmw_mob_placement = { .num_placement =1 , .num_busy_placement =1 ,@@ -161,13 +121,6 @@ struct ttm_placement vmw_mob_placement = { .busy_placement = &mob_placement_flags }; -struct ttm_placement vmw_nonfixed_placement = { - .num_placement =3 , - .placement = nonfixed_placement_flags, - .num_busy_placement =1 , - .busy_placement = &sys_placement_flags -}; -const size_t vmw_tt_size =sizeof (struct vmw_ttm_tt );/** drivers/gpu/drm/vmwgfx/vmwgfx_va.c +3
-1@@ -25,6 +25,7 @@* **************************************************************************/ +#include "vmwgfx_bo.h" #include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" @@ -83,7 +84,8 @@ static const struct vmw_simple_resource_func va_stream_func = { .needs_backup = false, .may_evict = false, .type_name = "overlay stream", - .backup_placement = NULL, + .domain = VMW_BO_DOMAIN_SYS, + .busy_domain = VMW_BO_DOMAIN_SYS, .create = NULL, .destroy = NULL, .bind = NULL,drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +19
-55@@ -27,6 +27,7 @@**************************************************************************/ #include "vmwgfx_bo.h" #include "vmwgfx_drv.h" +#include "vmwgfx_resource_priv.h" #include "vmwgfx_validation.h" #include <linux/slab.h> @@ -40,8 +41,6 @@* @hash: A hash entry used for the duplicate detection hash table. * @coherent_count: If switching backup buffers, number of new coherent * resources that will have this buffer as a backup buffer. -* @as_mob: Validate as mob. -* @cpu_blit: Validate for cpu blit access. * * Bit fields are used since these structures are allocated and freed in * large numbers and space conservation is desired. @@ -50,8 +49,6 @@ struct vmw_validation_bo_node {struct ttm_validate_buffer base;struct vmwgfx_hash_item hash;unsigned int coherent_count; - u32 as_mob : 1; - u32 cpu_blit : 1; };/** * struct vmw_validation_res_node - Resource validation metadata. @@ -260,26 +257,16 @@ vmw_validation_find_res_dup(struct vmw_validation_context *ctx,* vmw_validation_add_bo - Add a buffer object to the validation context. * @ctx: The validation context. * @vbo: The buffer object. -* @as_mob: Validate as mob, otherwise suitable for GMR operations. -* @cpu_blit: Validate in a page-mappable location. * * Return: Zero on success, negative error code otherwise. */ int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob, -bool cpu_blit) +struct vmw_bo *vbo) {struct vmw_validation_bo_node *bo_node; bo_node =vmw_validation_find_bo_dup (ctx, vbo); -if (bo_node) { -if (bo_node->as_mob != as_mob || - bo_node->cpu_blit != cpu_blit) { -DRM_ERROR ("Inconsistent buffer usage.\n" ); -return -EINVAL ; - } - }else { +if (!bo_node) {struct ttm_validate_buffer *val_buf; bo_node =vmw_validation_mem_alloc (ctx,sizeof (*bo_node));@@ -297,8 +284,6 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx,return -ESRCH ; val_buf->num_shared =0 ;list_add_tail (&val_buf->head, &ctx->bo_list); - bo_node->as_mob = as_mob; - bo_node->cpu_blit = cpu_blit; }return 0 ;@@ -455,9 +440,10 @@ int vmw_validation_res_reserve(struct vmw_validation_context *ctx,if (res->backup) {struct vmw_bo *vbo = res->backup; - ret =vmw_validation_add_bo - (ctx, vbo,vmw_resource_needs_backup (res), - false); +vmw_bo_placement_set (vbo, + res->func->domain, + res->func->busy_domain); + ret =vmw_validation_add_bo (ctx, vbo);if (ret) goto out_unreserve; }@@ -519,14 +505,12 @@ void vmw_validation_res_unreserve(struct vmw_validation_context *ctx,* vmw_validation_bo_validate_single - Validate a single buffer object. * @bo: The TTM buffer object base. * @interruptible: Whether to perform waits interruptible if possible. -* @validate_as_mob: Whether to validate in MOB memory. * * Return: Zero on success, -ERESTARTSYS if interrupted. Negative error * code on failure. */ -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob) +static int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, +bool interruptible) {struct vmw_bo *vbo = container_of(bo, struct vmw_bo, base);@@ -542,27 +526,17 @@ int vmw_validation_bo_validate_single(struct ttm_buffer_object *bo,if (vbo->base.pin_count >0 )return 0 ; -if (validate_as_mob) -return ttm_bo_validate (bo, &vmw_mob_placement, &ctx); - -/** -* Put BO in VRAM if there is space, otherwise as a GMR. -* If there is no space in VRAM and GMR ids are all used up, -* start evicting GMRs to make room. If the DMA buffer can't be -* used as a GMR, this will return -ENOMEM. -*/ - - ret =ttm_bo_validate (bo, &vmw_vram_gmr_placement, &ctx); + ret =ttm_bo_validate (bo, &vbo->placement, &ctx);if (ret ==0 || ret == -ERESTARTSYS )return ret; -/** -* If that failed, try VRAM again, this time evicting +/* +* If that failed, try again, this time evicting * previous contents. */ + ctx.allow_res_evict = true; - ret =ttm_bo_validate (bo, &vmw_vram_placement, &ctx); -return ret; +return ttm_bo_validate (bo, &vbo->placement, &ctx); }/** @@ -583,18 +557,8 @@ int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr)struct vmw_bo *vbo =container_of (entry->base.bo,typeof (*vbo), base); -if (entry->cpu_blit) { -struct ttm_operation_ctx ttm_ctx = { - .interruptible = intr, - .no_wait_gpu = false - }; - - ret =ttm_bo_validate (entry->base.bo, - &vmw_nonfixed_placement, &ttm_ctx); - }else { - ret =vmw_validation_bo_validate_single - (entry->base.bo, intr, entry->as_mob); - } + ret =vmw_validation_bo_validate_single (entry->base.bo, intr); +if (ret)return ret;@@ -655,9 +619,9 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)if (backup && res->backup && (backup != res->backup)) {struct vmw_bo *vbo = res->backup; - ret =vmw_validation_add_bo - (ctx, vbo,vmw_resource_needs_backup (res), - false); +vmw_bo_placement_set (vbo, res->func->domain, + res->func->busy_domain); + ret =vmw_validation_add_bo (ctx, vbo);if (ret)return ret; }drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +0
-0@@ -159,11 +159,7 @@ static inline unsigned int vmw_validation_align(unsigned int val) }drivers/gpu/drm/vmwgfx/vmwgfx_validation.h static inline unsigned int vmw_validation_align(unsigned int val) · line 165
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +1
-5int vmw_validation_add_bo (struct vmw_validation_context *ctx, -struct vmw_bo *vbo, -bool as_mob,bool cpu_blit); -int vmw_validation_bo_validate_single (struct ttm_buffer_object *bo, -bool interruptible, -bool validate_as_mob); +struct vmw_bo *vbo);int vmw_validation_bo_validate (struct vmw_validation_context *ctx,bool intr);void vmw_validation_unref_lists (struct vmw_validation_context *ctx); int vmw_validation_add_resource(struct vmw_validation_context *ctx,LGTM!
Reviewed-by Maaz Mombasawala <[email protected]>--
Maaz Mombasawala (VMware) <[email protected]>
PATCH v2 8/8 drm/vmwgfx: Stop using raw ttm_buffer_object's
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Various bits of the driver used raw ttm_buffer_object instead of the driver specific vmw_bo object. All those places used to duplicate the mapped bo caching policy of vmw_bo.
Instead of duplicating all of that code and special casing various functions to work both with vmw_bo and raw ttm_buffer_object's unify the buffer object handling code.
As part of that work fix the naming of bo's, e.g. insted of generic backup use 'guest_memory' because that's what it really is.
All of it makes the driver easier to maintain and the code easier to read. Saves 100+ loc as well.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 204 +++++----------- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 60 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 44 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 16 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 51 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 17 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 53 +++-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 14 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 37 +-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 105 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 38 +-- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c | 51 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 220 +++++++++--------- drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h | 7 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 29 ++- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 49 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 8 +- drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 8 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 98 ++++---- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 66 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_va.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 62 +++-- 27 files changed, 566 insertions(+), 691 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +60 -144
@@ -32,6 +32,12 @@#include <drm/ttm/ttm_placement.h> +static void vmw_bo_release (struct vmw_bo *vbo) +{ +vmw_bo_unmap (vbo); +drm_gem_object_release (&vbo->tbo.base); +} +/** * vmw_bo_free - vmw_bo destructor *
@@ -43,26 +49,10 @@ static void vmw_bo_free(struct ttm_buffer_object *bo)WARN_ON (vbo->dirty);WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree)); -vmw_bo_unmap (vbo); -drm_gem_object_release (&bo->base); +vmw_bo_release (vbo);kfree (vbo); } -/** -* bo_is_vmw - check if the buffer object is a &vmw_bo -* @bo: ttm buffer object to be checked -* -* Uses destroy function associated with the object to determine if this is -* a &vmw_bo. -* -* Returns: -* true if the object is of &vmw_bo type, false if not. -*/ -static bool bo_is_vmw (struct ttm_buffer_object *bo) -{ -return bo->destroy == &vmw_bo_free; -} -/** * vmw_bo_pin_in_placement - Validate a buffer to placement. *
@@ -79,7 +69,7 @@ static int vmw_bo_pin_in_placement(struct vmw_private *dev_priv, bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false }; -struct ttm_buffer_object *bo = &buf->base; +struct ttm_buffer_object *bo = &buf->tbo;int ret;vmw_execbuf_release_pinned_bo (dev_priv);
@@ -88,7 +78,7 @@ static int vmw_bo_pin_in_placement(struct vmw_private *dev_priv,if (unlikely (ret !=0 )) goto err; -if (buf->base.pin_count >0 ) +if (buf->tbo.pin_count >0 ) ret =ttm_resource_compat (bo->resource, placement) ?0 : -EINVAL ;else
@@ -120,7 +110,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv, bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false }; -struct ttm_buffer_object *bo = &buf->base; +struct ttm_buffer_object *bo = &buf->tbo;int ret;vmw_execbuf_release_pinned_bo (dev_priv);
@@ -129,7 +119,7 @@ int vmw_bo_pin_in_vram_or_gmr(struct vmw_private *dev_priv,if (unlikely (ret !=0 )) goto err; -if (buf->base.pin_count >0 ) { +if (buf->tbo.pin_count >0 ) { ret =ttm_resource_compat (bo->resource, &vmw_vram_gmr_placement) ?0 : -EINVAL ; goto out_unreserve;
@@ -195,7 +185,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv, bool interruptible) {struct ttm_operation_ctx ctx = {interruptible, false }; -struct ttm_buffer_object *bo = &buf->base; +struct ttm_buffer_object *bo = &buf->tbo;int ret =0 ;vmw_execbuf_release_pinned_bo (dev_priv);
@@ -211,7 +201,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,if (bo->resource->mem_type ==TTM_PL_VRAM && bo->resource->start <PFN_UP (bo->resource->size) && bo->resource->start >0 && - buf->base.pin_count ==0 ) { + buf->tbo.pin_count ==0 ) { ctx.interruptible = false; vmw_bo_placement_set(buf, VMW_BO_DOMAIN_SYS,
@@ -223,7 +213,7 @@ int vmw_bo_pin_in_start_of_vram(struct vmw_private *dev_priv,VMW_BO_DOMAIN_VRAM , VMW_BO_DOMAIN_VRAM); buf->places[0 ].lpfn =PFN_UP (bo->resource->size); -if (buf->base.pin_count >0 ) +if (buf->tbo.pin_count >0 ) ret =ttm_resource_compat (bo->resource, &buf->placement) ?0 : -EINVAL ;else
@@ -256,7 +246,7 @@ int vmw_bo_unpin(struct vmw_private *dev_priv, struct vmw_bo *buf, bool interruptible) { -struct ttm_buffer_object *bo = &buf->base; +struct ttm_buffer_object *bo = &buf->tbo;int ret; ret =ttm_bo_reserve (bo, interruptible, false,NULL );
@@ -303,7 +293,7 @@ void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin)struct ttm_operation_ctx ctx = { false, true };struct ttm_place pl;struct ttm_placement placement; -struct ttm_buffer_object *bo = &vbo->base; +struct ttm_buffer_object *bo = &vbo->tbo;uint32_t old_mem_type = bo->resource->mem_type;int ret;
@@ -348,7 +338,7 @@ void vmw_bo_pin_reserved(struct vmw_bo *vbo, bool pin)*/ void *vmw_bo_map_and_cache (struct vmw_bo *vbo) { -struct ttm_buffer_object *bo = &vbo->base; +struct ttm_buffer_object *bo = &vbo->tbo;bool not_used;void *virtual;int ret;
@@ -379,64 +369,58 @@ void vmw_bo_unmap(struct vmw_bo *vbo)return ;ttm_bo_kunmap (&vbo->map); + vbo->map.bo =NULL ; } -/* default destructor */ -static void vmw_bo_default_destroy (struct ttm_buffer_object *bo) -{ -kfree (bo); -}/** -* vmw_bo_create_kernel - Create a pinned BO for internal kernel use. +* vmw_bo_init - Initialize a vmw buffer object * * @dev_priv: Pointer to the device private struct -* @size: size of the BO we need -* @placement: where to put it -* @p_bo: resulting BO +* @vmw_bo: Buffer object to initialize +* @params: Parameters used to initialize the buffer object +* @destroy: The function used to delete the buffer object +* Returns: Zero on success, negative error code on error. * -* Creates and pin a simple BO for in kernel use. */ -int vmw_bo_create_kernel (struct vmw_private *dev_priv,unsigned long size, -struct ttm_placement *placement, -struct ttm_buffer_object **p_bo) +static int vmw_bo_init (struct vmw_private *dev_priv, +struct vmw_bo *vmw_bo, +struct vmw_bo_params *params, +void (*destroy)(struct ttm_buffer_object *)) {struct ttm_operation_ctx ctx = { - .interruptible = false, + .interruptible = params->bo_type != ttm_bo_type_kernel, .no_wait_gpu = false }; -struct ttm_buffer_object *bo; +struct ttm_device *bdev = &dev_priv->bdev;struct drm_device *vdev = &dev_priv->drm;int ret; - bo =kzalloc (sizeof (*bo),GFP_KERNEL ); -if (unlikely (!bo)) -return -ENOMEM ; +memset (vmw_bo,0 ,sizeof (*vmw_bo)); - size =ALIGN (size,PAGE_SIZE ); +BUILD_BUG_ON (TTM_MAX_BO_PRIORITY <=3 ); + vmw_bo->tbo.priority =3 ; + vmw_bo->res_tree =RB_ROOT ; -drm_gem_private_object_init (vdev, &bo->base, size); + params->size =ALIGN (params->size,PAGE_SIZE ); +drm_gem_private_object_init (vdev, &vmw_bo->tbo.base, params->size); - ret =ttm_bo_init_reserved (&dev_priv->bdev, bo, ttm_bo_type_kernel, - placement,0 , &ctx,NULL ,NULL , - vmw_bo_default_destroy); +vmw_bo_placement_set (vmw_bo, params->domain, params->busy_domain); + ret =ttm_bo_init_reserved (bdev, &vmw_bo->tbo, params->bo_type, + &vmw_bo->placement,0 , &ctx,NULL , +NULL , destroy);if (unlikely (ret)) - goto error_free; +return ret; -ttm_bo_pin (bo); -ttm_bo_unreserve (bo); - *p_bo = bo; +if (params->pin) +ttm_bo_pin (&vmw_bo->tbo); +ttm_bo_unreserve (&vmw_bo->tbo);return 0 ; - -error_free: -kfree (bo); -return ret; }int vmw_bo_create (struct vmw_private *vmw, -size_t size,u32 domain,u32 busy_domain, -bool interruptible,bool pin, +struct vmw_bo_params *params,struct vmw_bo **p_bo) {int ret;
@@ -447,9 +431,7 @@ int vmw_bo_create(struct vmw_private *vmw,return -ENOMEM ; } - ret =vmw_bo_init (vmw, *p_bo, size, - domain, busy_domain, - interruptible, pin); + ret =vmw_bo_init (vmw, *p_bo, params, vmw_bo_free);if (unlikely (ret !=0 )) goto out_error;
@@ -460,57 +442,6 @@ int vmw_bo_create(struct vmw_private *vmw,return ret; } -/** -* vmw_bo_init - Initialize a vmw buffer object -* -* @dev_priv: Pointer to the device private struct -* @vmw_bo: Pointer to the struct vmw_bo to initialize. -* @size: Buffer object size in bytes. -* @domain: Domain to put the bo in. -* @busy_domain: Domain to put the bo if busy. -* @interruptible: Whether waits should be performed interruptible. -* @pin: If the BO should be created pinned at a fixed location. -* Returns: Zero on success, negative error code on error. -* -* Note that on error, the code will free the buffer object. -*/ -int vmw_bo_init (struct vmw_private *dev_priv, -struct vmw_bo *vmw_bo, -size_t size, -u32 domain, -u32 busy_domain, -bool interruptible,bool pin) -{ -struct ttm_operation_ctx ctx = { - .interruptible = interruptible, - .no_wait_gpu = false - }; -struct ttm_device *bdev = &dev_priv->bdev; -struct drm_device *vdev = &dev_priv->drm; -int ret; - -memset (vmw_bo,0 ,sizeof (*vmw_bo)); -BUILD_BUG_ON (TTM_MAX_BO_PRIORITY <=3 ); - vmw_bo->base.priority =3 ; - vmw_bo->res_tree =RB_ROOT ; - - size =ALIGN (size,PAGE_SIZE ); -drm_gem_private_object_init (vdev, &vmw_bo->base.base, size); - -vmw_bo_placement_set (vmw_bo, domain, busy_domain); - ret =ttm_bo_init_reserved (bdev, &vmw_bo->base, ttm_bo_type_device, - &vmw_bo->placement,0 , &ctx,NULL ,NULL , vmw_bo_free); -if (unlikely (ret)) { -return ret; - } - -if (pin) -ttm_bo_pin (&vmw_bo->base); -ttm_bo_unreserve (&vmw_bo->base); - -return 0 ; -} -/** * vmw_user_bo_synccpu_grab - Grab a struct vmw_bo for cpu * access, idling previous GPU operations on the buffer and optionally
@@ -529,7 +460,7 @@ static int vmw_user_bo_synccpu_grab(struct vmw_bo *vmw_bo, uint32_t flags) {bool nonblock = !!(flags & drm_vmw_synccpu_dontblock); -struct ttm_buffer_object *bo = &vmw_bo->base; +struct ttm_buffer_object *bo = &vmw_bo->tbo;int ret;if (flags & drm_vmw_synccpu_allow_cs) {
@@ -579,7 +510,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,if (!(flags & drm_vmw_synccpu_allow_cs)) {atomic_dec (&vmw_bo->cpu_writers); } -ttm_bo_put (&vmw_bo->base); +ttm_bo_put (&vmw_bo->tbo); }return ret;
@@ -665,8 +596,7 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,struct drm_vmw_unref_dmabuf_arg *arg = (struct drm_vmw_unref_dmabuf_arg *)data; -drm_gem_handle_delete (file_priv, arg->handle); -return 0 ; +return drm_gem_handle_delete (file_priv, arg->handle); }
@@ -682,7 +612,7 @@ int vmw_bo_unref_ioctl(struct drm_device *dev, void *data,* The vmw buffer object pointer will be refcounted. */ int vmw_user_bo_lookup (struct drm_file *filp, -uint32_t handle, +u32 handle,struct vmw_bo **out) {struct drm_gem_object *gobj;
@@ -695,7 +625,7 @@ int vmw_user_bo_lookup(struct drm_file *filp, } *out =to_vmw_bo (gobj); -ttm_bo_get (&(*out)->base); +ttm_bo_get (&(*out)->tbo);drm_gem_object_put (gobj);return 0 ;
@@ -717,8 +647,7 @@ void vmw_bo_fence_single(struct ttm_buffer_object *bo, struct vmw_fence_obj *fence) {struct ttm_device *bdev = bo->bdev; -struct vmw_private *dev_priv = - container_of(bdev, struct vmw_private, bdev); +struct vmw_private *dev_priv =vmw_priv_from_ttm (bdev);int ret;if (fence ==NULL )
@@ -788,10 +717,6 @@ int vmw_dumb_create(struct drm_file *file_priv,*/ void vmw_bo_swap_notify (struct ttm_buffer_object *bo) { -/* Is @bo embedded in a struct vmw_bo? */ -if (!bo_is_vmw (bo)) -return ; -/* Kill any cached kernel maps before swapout */ vmw_bo_unmap (to_vmw_bo (&bo->base)); }
@@ -810,13 +735,7 @@ void vmw_bo_swap_notify(struct ttm_buffer_object *bo)void vmw_bo_move_notify (struct ttm_buffer_object *bo,struct ttm_resource *mem) { -struct vmw_bo *vbo; - -/* Make sure @bo is embedded in a struct vmw_bo? */ -if (!bo_is_vmw (bo)) -return ; - - vbo = container_of(bo, struct vmw_bo, base); +struct vmw_bo *vbo =to_vmw_bo (&bo->base);/* * Kill any cached kernel maps before move to or from VRAM.
@@ -864,7 +783,6 @@ set_placement_list(struct ttm_place *pl, u32 domain) pl[n].lpfn =0 ; n++; } -WARN_ON ((domain &VMW_BO_DOMAIN_WAITABLE_SYS ) !=0 );if (domain &VMW_BO_DOMAIN_WAITABLE_SYS ) { pl[n].mem_type =VMW_PL_SYSTEM ; pl[n].flags =0 ;
@@ -893,9 +811,8 @@ set_placement_list(struct ttm_place *pl, u32 domain)void vmw_bo_placement_set (struct vmw_bo *bo,u32 domain,u32 busy_domain) { -struct ttm_device *bdev = bo->base.bdev; -struct vmw_private *vmw = - container_of(bdev, struct vmw_private, bdev); +struct ttm_device *bdev = bo->tbo.bdev; +struct vmw_private *vmw =vmw_priv_from_ttm (bdev);struct ttm_placement *pl = &bo->placement;bool mem_compatible = false;u32 i;
@@ -903,17 +820,17 @@ void vmw_bo_placement_set(struct vmw_bo *bo, u32 domain, u32 busy_domain) pl->placement = bo->places; pl->num_placement =set_placement_list (bo->places, domain); -if (drm_debug_enabled (DRM_UT_DRIVER ) && bo->base.resource) { +if (drm_debug_enabled (DRM_UT_DRIVER ) && bo->tbo.resource) {for (i =0 ; i < pl->num_placement; ++i) { -if (bo->base.resource->mem_type ==TTM_PL_SYSTEM || - bo->base.resource->mem_type == pl->placement[i].mem_type) +if (bo->tbo.resource->mem_type ==TTM_PL_SYSTEM || + bo->tbo.resource->mem_type == pl->placement[i].mem_type) mem_compatible = true; }if (!mem_compatible)drm_warn (&vmw->drm,"%s: Incompatible transition from " "bo->base.resource->mem_type = %u to domain = %u\n" , - __func__, bo->base.resource->mem_type, domain); + __func__, bo->tbo.resource->mem_type, domain); } pl->busy_placement = bo->busy_places;
@@ -922,9 +839,8 @@ void vmw_bo_placement_set(struct vmw_bo *bo, u32 domain, u32 busy_domain)void vmw_bo_placement_set_default_accelerated (struct vmw_bo *bo) { -struct ttm_device *bdev = bo->base.bdev; -struct vmw_private *vmw = - container_of(bdev, struct vmw_private, bdev); +struct ttm_device *bdev = bo->tbo.bdev; +struct vmw_private *vmw =vmw_priv_from_ttm (bdev);u32 domain =VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ;if (vmw->has_mob)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +30 -30
136 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c +2 -2
@@ -567,7 +567,7 @@ static int vmw_cmd_emit_dummy_legacy_query(struct vmw_private *dev_priv,* without writing to the query result structure. */ -struct ttm_buffer_object *bo = &dev_priv->dummy_query_bo->base; +struct ttm_buffer_object *bo = &dev_priv->dummy_query_bo->tbo;struct {SVGA3dCmdHeader header;SVGA3dCmdWaitForQuery body;
@@ -613,7 +613,7 @@ static int vmw_cmd_emit_dummy_gb_query(struct vmw_private *dev_priv,* without writing to the query result structure. */ -struct ttm_buffer_object *bo = &dev_priv->dummy_query_bo->base; +struct ttm_buffer_object *bo = &dev_priv->dummy_query_bo->tbo;struct {SVGA3dCmdHeader header;SVGA3dCmdWaitForGBQuery body;
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +15 -29
97 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_context.c +8 -8
@@ -73,7 +73,7 @@ const struct vmw_user_resource_conv *user_context_converter =static const struct vmw_res_func vmw_legacy_context_func = { .res_type = vmw_res_context, - .needs_backup = false, + .needs_guest_memory = false, .may_evict = false, .type_name ="legacy contexts" , .domain =VMW_BO_DOMAIN_SYS ,
@@ -86,7 +86,7 @@ static const struct vmw_res_func vmw_legacy_context_func = {static const struct vmw_res_func vmw_gb_context_func = { .res_type = vmw_res_context, - .needs_backup = true, + .needs_guest_memory = true, .may_evict = true, .prio =3 , .dirty_prio =3 ,
@@ -101,7 +101,7 @@ static const struct vmw_res_func vmw_gb_context_func = {static const struct vmw_res_func vmw_dx_context_func = { .res_type = vmw_res_dx_context, - .needs_backup = true, + .needs_guest_memory = true, .may_evict = true, .prio =3 , .dirty_prio =3 ,
@@ -186,7 +186,7 @@ static int vmw_gb_context_init(struct vmw_private *dev_priv,struct vmw_user_context *uctx = container_of(res, struct vmw_user_context, res); - res->backup_size = (dx ?sizeof (SVGADXContextMobFormat) : + res->guest_memory_size = (dx ?sizeof (SVGADXContextMobFormat) :sizeof (SVGAGBContextData)); ret = vmw_resource_init(dev_priv, res, true, res_free,
@@ -358,8 +358,8 @@ static int vmw_gb_context_bind(struct vmw_resource *res, cmd->header.size =sizeof (cmd->body); cmd->body.cid = res->id; cmd->body.mobid = bo->resource->start; - cmd->body.validContents = res->backup_dirty; - res->backup_dirty = false; + cmd->body.validContents = res->guest_memory_dirty; + res->guest_memory_dirty = false;vmw_cmd_commit (dev_priv,sizeof (*cmd));return 0 ;
@@ -525,8 +525,8 @@ static int vmw_dx_context_bind(struct vmw_resource *res, cmd->header.size =sizeof (cmd->body); cmd->body.cid = res->id; cmd->body.mobid = bo->resource->start; - cmd->body.validContents = res->backup_dirty; - res->backup_dirty = false; + cmd->body.validContents = res->guest_memory_dirty; + res->guest_memory_dirty = false;vmw_cmd_commit (dev_priv,sizeof (*cmd));
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +28 -23
146 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +11 -6
@@ -392,23 +392,28 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)struct ttm_bo_kmap_obj map;volatile SVGA3dQueryResult *result;bool dummy; +struct vmw_bo_params bo_params = { + .domain =VMW_BO_DOMAIN_SYS , + .busy_domain =VMW_BO_DOMAIN_SYS , + .bo_type = ttm_bo_type_kernel, + .size =PAGE_SIZE , + .pin = true + };/* * Create the vbo as pinned, so that a tryreserve will * immediately succeed. This is because we're the only * user of the bo currently. */ - ret =vmw_bo_create (dev_priv,PAGE_SIZE , -VMW_BO_DOMAIN_SYS ,VMW_BO_DOMAIN_SYS , - false, true, &vbo); + ret =vmw_bo_create (dev_priv, &bo_params, &vbo);if (unlikely (ret !=0 ))return ret; - ret =ttm_bo_reserve (&vbo->base, false, true,NULL ); + ret =ttm_bo_reserve (&vbo->tbo, false, true,NULL );BUG_ON (ret !=0 );vmw_bo_pin_reserved (vbo, true); - ret =ttm_bo_kmap (&vbo->base,0 ,1 , &map); + ret =ttm_bo_kmap (&vbo->tbo,0 ,1 , &map);if (likely (ret ==0 )) { result =ttm_kmap_obj_virtual (&map, &dummy); result->totalSize =sizeof (*result);
@@ -417,7 +422,7 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)ttm_bo_kunmap (&map); }vmw_bo_pin_reserved (vbo, false); -ttm_bo_unreserve (&vbo->base); +ttm_bo_unreserve (&vbo->tbo);if (unlikely (ret !=0 )) {DRM_ERROR ("Dummy query buffer map failed.\n" );
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +30 -23
107 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +7 -7
@@ -721,7 +721,7 @@ static int vmw_rebind_all_dx_query(struct vmw_resource *ctx_res) cmd->header.id =SVGA_3D_CMD_DX_BIND_ALL_QUERY ; cmd->header.size =sizeof (cmd->body); cmd->body.cid = ctx_res->id; - cmd->body.mobid = dx_query_mob->base.resource->start; + cmd->body.mobid = dx_query_mob->tbo.resource->start;vmw_cmd_commit (dev_priv,sizeof (*cmd));vmw_context_bind_dx_query (ctx_res, dx_query_mob);
@@ -1032,7 +1032,7 @@ static int vmw_query_bo_switch_prepare(struct vmw_private *dev_priv,if (unlikely (new_query_bo != sw_context->cur_query_bo)) { -if (unlikely (PFN_UP (new_query_bo->base.resource->size) >4 )) { +if (unlikely (PFN_UP (new_query_bo->tbo.resource->size) >4 )) {VMW_DEBUG_USER ("Query buffer too large.\n" );return -EINVAL ; }
@@ -1163,7 +1163,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, }vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB ); ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo); -ttm_bo_put (&vmw_bo->base); +ttm_bo_put (&vmw_bo->tbo);if (unlikely (ret !=0 ))return ret;
@@ -1219,7 +1219,7 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ,VMW_BO_DOMAIN_GMR |VMW_BO_DOMAIN_VRAM ); ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo); -ttm_bo_put (&vmw_bo->base); +ttm_bo_put (&vmw_bo->tbo);if (unlikely (ret !=0 ))return ret;
@@ -1532,7 +1532,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv,return ret;/* Make sure DMA doesn't cross BO boundaries. */ - bo_size = vmw_bo->base.base.size; + bo_size = vmw_bo->tbo.base.size;if (unlikely (cmd->body.guest.ptr.offset > bo_size)) {VMW_DEBUG_USER ("Invalid DMA offset.\n" );return -EINVAL ;
@@ -1555,7 +1555,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv, srf =vmw_res_to_srf (sw_context->res_cache[vmw_res_surface].res); -vmw_kms_cursor_snoop (srf, sw_context->fp->tfile, &vmw_bo->base, header); +vmw_kms_cursor_snoop (srf, sw_context->fp->tfile, &vmw_bo->tbo, header);return 0 ; }
@@ -3758,7 +3758,7 @@ static void vmw_apply_relocations(struct vmw_sw_context *sw_context)struct ttm_buffer_object *bo;list_for_each_entry (reloc, &sw_context->bo_relocations, head) { - bo = &reloc->vbo->base; + bo = &reloc->vbo->tbo;switch (bo->resource->mem_type) {case TTM_PL_VRAM : reloc->location->offset += bo->resource->start <<PAGE_SHIFT ;
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +20 -17
@@ -33,9 +33,8 @@static void vmw_gem_object_free (struct drm_gem_object *gobj) {struct ttm_buffer_object *bo =drm_gem_ttm_of_gem (gobj); -if (bo) { +if (bo)ttm_bo_put (bo); - } } static int vmw_gem_object_open(struct drm_gem_object *obj,
@@ -119,19 +118,23 @@ int vmw_gem_object_create_with_handle(struct vmw_private *dev_priv, struct vmw_bo **p_vbo) {int ret; +struct vmw_bo_params params = { + .domain = (dev_priv->has_mob) ?VMW_BO_DOMAIN_SYS :VMW_BO_DOMAIN_VRAM , + .busy_domain =VMW_BO_DOMAIN_SYS , + .bo_type = ttm_bo_type_device, + .size = size, + .pin = false + }; - ret =vmw_bo_create (dev_priv, size, - (dev_priv->has_mob) ?VMW_BO_DOMAIN_SYS :VMW_BO_DOMAIN_VRAM , -VMW_BO_DOMAIN_SYS , - true, false, p_vbo); + ret =vmw_bo_create (dev_priv, ¶ms, p_vbo); - (*p_vbo)->base.base.funcs = &vmw_gem_object_funcs; + (*p_vbo)->tbo.base.funcs = &vmw_gem_object_funcs;if (ret !=0 ) goto out_no_bo; - ret =drm_gem_handle_create (filp, &(*p_vbo)->base.base, handle); + ret =drm_gem_handle_create (filp, &(*p_vbo)->tbo.base, handle);/* drop reference from allocate - handle holds it now */ -drm_gem_object_put (&(*p_vbo)->base.base); +drm_gem_object_put (&(*p_vbo)->tbo.base); out_no_bo:return ret; }
@@ -155,7 +158,7 @@ int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, goto out_no_bo; rep->handle = handle; - rep->map_handle =drm_vma_node_offset_addr (&vbo->base.base.vma_node); + rep->map_handle =drm_vma_node_offset_addr (&vbo->tbo.base.vma_node); rep->cur_gmr_id = handle; rep->cur_gmr_offset =0 ; out_no_bo:
@@ -169,7 +172,7 @@ static void vmw_bo_print_info(int id, struct vmw_bo *bo, struct seq_file *m)const char *placement;const char *type; -switch (bo->base.resource->mem_type) { +switch (bo->tbo.resource->mem_type) {case TTM_PL_SYSTEM : placement =" CPU" ;break ;
@@ -190,7 +193,7 @@ static void vmw_bo_print_info(int id, struct vmw_bo *bo, struct seq_file *m)break ; } -switch (bo->base.type) { +switch (bo->tbo.type) {case ttm_bo_type_device: type ="device" ;break ;
@@ -206,12 +209,12 @@ static void vmw_bo_print_info(int id, struct vmw_bo *bo, struct seq_file *m) }seq_printf (m,"\t\t0x%08x: %12zu bytes %s, type = %s" , - id, bo->base.base.size, placement, type); + id, bo->tbo.base.size, placement, type);seq_printf (m,", priority = %u, pin_count = %u, GEM refs = %d, TTM refs = %d" , - bo->base.priority, - bo->base.pin_count, -kref_read (&bo->base.base.refcount), -kref_read (&bo->base.kref)); + bo->tbo.priority, + bo->tbo.pin_count, +kref_read (&bo->tbo.base.refcount), +kref_read (&bo->tbo.kref));seq_puts (m,"\n" ); }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +45 -60
261 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -4
@@ -270,9 +270,7 @@ struct vmw_crtc_state { };struct vmw_cursor_plane_state { -struct ttm_buffer_object *bo; -struct ttm_bo_kmap_obj map; -bool mapped; +struct vmw_bo *bo;s32 hotspot_x;s32 hotspot_y; };
@@ -343,7 +341,7 @@ struct vmw_connector_state {struct vmw_cursor_plane {struct drm_plane base; -struct ttm_buffer_object *cursor_mobs[3 ]; +struct vmw_bo *cursor_mobs[3 ]; };/**
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +2 -2
@@ -147,7 +147,7 @@ static int vmw_ldu_fb_pin(struct vmw_framebuffer *vfb)int ret; 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.guest_memory_bo;if (!buf)return 0 ;
@@ -169,7 +169,7 @@ static int vmw_ldu_fb_unpin(struct vmw_framebuffer *vfb)struct vmw_bo *buf; 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.guest_memory_bo;if (WARN_ON (!buf))return 0 ;
drivers/gpu/drm/vmwgfx/vmwgfx_mob.c +20 -18
@@ -51,7 +51,7 @@* @pt_root_page DMA address of the level 0 page of the page table. */ struct vmw_mob { -struct ttm_buffer_object *pt_bo; +struct vmw_bo *pt_bo;unsigned long num_pages;unsigned pt_level;dma_addr_t pt_root_page;
@@ -204,7 +204,7 @@ static void vmw_takedown_otable_base(struct vmw_private *dev_priv,if (otable->page_table ==NULL )return ; - bo = otable->page_table->pt_bo; + bo = &otable->page_table->pt_bo->tbo; cmd =VMW_CMD_RESERVE (dev_priv,sizeof (*cmd));if (unlikely (cmd ==NULL ))return ;
@@ -252,7 +252,9 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv, bo_size += otables[i].size; } - ret =vmw_bo_create_and_populate (dev_priv, bo_size, &batch->otable_bo); + ret =vmw_bo_create_and_populate (dev_priv, bo_size, +VMW_BO_DOMAIN_WAITABLE_SYS , + &batch->otable_bo);if (unlikely (ret !=0 ))return ret;
@@ -261,7 +263,8 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv,if (!batch->otables[i].enabled)continue ; - ret =vmw_setup_otable_base (dev_priv, i, batch->otable_bo, + ret =vmw_setup_otable_base (dev_priv, i, + &batch->otable_bo->tbo, offset, &otables[i]);if (unlikely (ret !=0 ))
@@ -278,8 +281,8 @@ static int vmw_otable_batch_setup(struct vmw_private *dev_priv, &batch->otables[i]); } -vmw_bo_unpin_unlocked (batch->otable_bo); -ttm_bo_put (batch->otable_bo); +vmw_bo_unpin_unlocked (&batch->otable_bo->tbo); +ttm_bo_put (&batch->otable_bo->tbo); batch->otable_bo =NULL ;return ret; }
@@ -330,7 +333,7 @@ static void vmw_otable_batch_takedown(struct vmw_private *dev_priv, struct vmw_otable_batch *batch) {SVGAOTableType i; -struct ttm_buffer_object *bo = batch->otable_bo; +struct ttm_buffer_object *bo = &batch->otable_bo->tbo;int ret;for (i =0 ; i < batch->num_otables; ++i)
@@ -345,8 +348,7 @@ static void vmw_otable_batch_takedown(struct vmw_private *dev_priv,ttm_bo_unpin (bo);ttm_bo_unreserve (bo); -ttm_bo_put (batch->otable_bo); - batch->otable_bo =NULL ; +vmw_bo_unreference (&batch->otable_bo); }/*
@@ -414,7 +416,9 @@ static int vmw_mob_pt_populate(struct vmw_private *dev_priv, {BUG_ON (mob->pt_bo !=NULL ); -return vmw_bo_create_and_populate (dev_priv, mob->num_pages *PAGE_SIZE , &mob->pt_bo); +return vmw_bo_create_and_populate (dev_priv, mob->num_pages *PAGE_SIZE , +VMW_BO_DOMAIN_WAITABLE_SYS , + &mob->pt_bo); }/**
@@ -495,7 +499,7 @@ static void vmw_mob_pt_setup(struct vmw_mob *mob, unsigned long num_data_pages) {unsigned long num_pt_pages =0 ; -struct ttm_buffer_object *bo = mob->pt_bo; +struct ttm_buffer_object *bo = &mob->pt_bo->tbo;struct vmw_piter save_pt_iter = {0 };struct vmw_piter pt_iter;const struct vmw_sg_table *vsgt;
@@ -532,9 +536,8 @@ static void vmw_mob_pt_setup(struct vmw_mob *mob,void vmw_mob_destroy (struct vmw_mob *mob) {if (mob->pt_bo) { -vmw_bo_unpin_unlocked (mob->pt_bo); -ttm_bo_put (mob->pt_bo); - mob->pt_bo =NULL ; +vmw_bo_unpin_unlocked (&mob->pt_bo->tbo); +vmw_bo_unreference (&mob->pt_bo); }kfree (mob); }
@@ -553,7 +556,7 @@ void vmw_mob_unbind(struct vmw_private *dev_priv,SVGA3dCmdDestroyGBMob body; } *cmd;int ret; -struct ttm_buffer_object *bo = mob->pt_bo; +struct ttm_buffer_object *bo = &mob->pt_bo->tbo;if (bo) { ret =ttm_bo_reserve (bo, false, true,NULL );
@@ -645,9 +648,8 @@ int vmw_mob_bind(struct vmw_private *dev_priv, out_no_cmd_space:vmw_fifo_resource_dec (dev_priv);if (pt_set_up) { -vmw_bo_unpin_unlocked (mob->pt_bo); -ttm_bo_put (mob->pt_bo); - mob->pt_bo =NULL ; +vmw_bo_unpin_unlocked (&mob->pt_bo->tbo); +vmw_bo_unreference (&mob->pt_bo); }return -ENOMEM ;
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +1 -1
@@ -140,7 +140,7 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,for (i =0 ; i < num_items; i++) items[i].registerId = i; -vmw_bo_get_guest_ptr (&buf->base, &ptr); +vmw_bo_get_guest_ptr (&buf->tbo, &ptr); ptr.offset += arg->offset; items[SVGA_VIDEO_ENABLED ].value = true;
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c +24 -27
122 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +112 -108
535 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h +4 -3
@@ -58,10 +58,11 @@ struct vmw_user_resource_conv {* struct vmw_res_func - members and functions common for a resource type * * @res_type: Enum that identifies the lru list to use for eviction. -* @needs_backup: Whether the resource is guest-backed and needs +* @needs_guest_memory:Whether the resource is guest-backed and needs * persistent buffer storage. * @type_name: String that identifies the resource type. -* @backup_placement: TTM placement for backup buffers. +* @domain: TTM placement for guest memory buffers. +* @busy_domain: TTM busy placement for guest memory buffers. * @may_evict Whether the resource may be evicted. * @create: Create a hardware resource. * @destroy: Destroy a hardware resource.
@@ -81,7 +82,7 @@ struct vmw_user_resource_conv {*/ struct vmw_res_func {enum vmw_res_type res_type; -bool needs_backup; +bool needs_guest_memory;const char *type_name;u32 domain;u32 busy_domain;
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +14 -15
@@ -149,7 +149,7 @@ static int vmw_sou_fifo_create(struct vmw_private *dev_priv, sou->base.set_gui_y = cmd->obj.root.y;/* Ok to assume that buffer is pinned in vram */ -vmw_bo_get_guest_ptr (&sou->buffer->base, &cmd->obj.backingStore.ptr); +vmw_bo_get_guest_ptr (&sou->buffer->tbo, &cmd->obj.backingStore.ptr); cmd->obj.backingStore.pitch = mode->hdisplay *4 ;vmw_cmd_commit (dev_priv, fifo_size);
@@ -410,9 +410,13 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,struct drm_crtc *crtc = plane->state->crtc ?: new_state->crtc;struct vmw_plane_state *vps =vmw_plane_state_to_vps (new_state);struct vmw_private *dev_priv; -size_t size;int ret; - +struct vmw_bo_params bo_params = { + .domain =VMW_BO_DOMAIN_VRAM , + .busy_domain =VMW_BO_DOMAIN_VRAM , + .bo_type = ttm_bo_type_device, + .pin = true + };if (!new_fb) {vmw_bo_unreference (&vps->bo);
@@ -421,11 +425,11 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,return 0 ; } - size = new_state->crtc_w * new_state->crtc_h *4 ; + bo_params.size = new_state->crtc_w * new_state->crtc_h *4 ; dev_priv =vmw_priv (crtc->dev);if (vps->bo) { -if (vps->bo_size == size) { +if (vps->bo_size == bo_params.size) {/* * Note that this might temporarily up the pin-count * to 2, until cleanup_fb() is called.
@@ -444,17 +448,12 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,* resume the overlays, this is preferred to failing to alloc. */ vmw_overlay_pause_all (dev_priv); - ret =vmw_bo_create (dev_priv, size, -VMW_BO_DOMAIN_VRAM , -VMW_BO_DOMAIN_VRAM , - false, true, &vps->bo); + ret =vmw_bo_create (dev_priv, &bo_params, &vps->bo);vmw_overlay_resume_all (dev_priv); -if (ret) { - vps->bo =NULL ;/* vmw_bo_init frees on error */ +if (ret)return ret; - } - vps->bo_size = size; + vps->bo_size = bo_params.size;/* * TTM already thinks the buffer is pinned, but make sure the
@@ -491,7 +490,7 @@ static uint32_t vmw_sou_bo_define_gmrfb(struct vmw_du_update_plane *update, gmr->body.format.colorDepth = depth; gmr->body.format.reserved =0 ; gmr->body.bytesPerLine = update->vfb->base.pitches[0 ]; -vmw_bo_get_guest_ptr (&vfbbo->buffer->base, &gmr->body.ptr); +vmw_bo_get_guest_ptr (&vfbbo->buffer->tbo, &gmr->body.ptr);return sizeof (*gmr); }
@@ -973,7 +972,7 @@ static int do_bo_define_gmrfb(struct vmw_private *dev_priv, cmd->body.format.reserved =0 ; cmd->body.bytesPerLine = framebuffer->base.pitches[0 ];/* Buffer is reserved in vram or GMR */ -vmw_bo_get_guest_ptr (&buf->base, &cmd->body.ptr); +vmw_bo_get_guest_ptr (&buf->tbo, &cmd->body.ptr);vmw_cmd_commit (dev_priv,sizeof (*cmd));return 0 ;
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +25 -24
123 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_so.c +1 -1
@@ -82,7 +82,7 @@ static void vmw_view_commit_notify(struct vmw_resource *res,static const struct vmw_res_func vmw_view_func = { .res_type = vmw_res_view, - .needs_backup = false, + .needs_guest_memory = false, .may_evict = false, .type_name ="DX view" , .domain =VMW_BO_DOMAIN_SYS ,
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +4 -4
@@ -505,11 +505,11 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)/* Assume we are blitting from Guest (bo) to Host (display_srf) */ src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; - src_bo = &stdu->display_srf->res.backup->base; + src_bo = &stdu->display_srf->res.guest_memory_bo->tbo; src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; dst_pitch = ddirty->pitch; - dst_bo = &ddirty->buf->base; + dst_bo = &ddirty->buf->tbo; dst_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; (void) vmw_bo_cpu_blit(dst_bo, dst_offset, dst_pitch,
@@ -1080,11 +1080,11 @@ vmw_stdu_bo_populate_update_cpu(struct vmw_du_update_plane *update, void *cmd, diff.cpp = stdu->cpp; - dst_bo = &stdu->display_srf->res.backup->base; + dst_bo = &stdu->display_srf->res.guest_memory_bo->tbo; dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; dst_offset = bb->y1 * dst_pitch + bb->x1 * stdu->cpp; - src_bo = &vfbbo->buffer->base; + src_bo = &vfbbo->buffer->tbo; src_pitch = update->vfb->base.pitches[0 ]; src_offset = bo_update->fb_top * src_pitch + bo_update->fb_left * stdu->cpp;
drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c +4 -4
@@ -63,7 +63,7 @@ static void vmw_dx_streamoutput_commit_notify(struct vmw_resource *res,static const struct vmw_res_func vmw_dx_streamoutput_func = { .res_type = vmw_res_streamoutput, - .needs_backup = true, + .needs_guest_memory = true, .may_evict = false, .type_name ="DX streamoutput" , .domain =VMW_BO_DOMAIN_MOB ,
@@ -106,8 +106,8 @@ static int vmw_dx_streamoutput_unscrub(struct vmw_resource *res) cmd->header.id =SVGA_3D_CMD_DX_BIND_STREAMOUTPUT ; cmd->header.size =sizeof (cmd->body); cmd->body.soid = so->id; - cmd->body.mobid = res->backup->base.resource->start; - cmd->body.offsetInBytes = res->backup_offset; + cmd->body.mobid = res->guest_memory_bo->tbo.resource->start; + cmd->body.offsetInBytes = res->guest_memory_offset; cmd->body.sizeInBytes = so->size;vmw_cmd_commit (dev_priv,sizeof (*cmd));
@@ -197,7 +197,7 @@ static int vmw_dx_streamoutput_unbind(struct vmw_resource *res, bool readback,struct vmw_fence_obj *fence;int ret; -if (WARN_ON (res->backup->base.resource->mem_type !=VMW_PL_MOB )) +if (WARN_ON (res->guest_memory_bo->tbo.resource->mem_type !=VMW_PL_MOB ))return -EINVAL ;mutex_lock (&dev_priv->binding_mutex);
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +49 -49
289 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +18 -48
125 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_va.c +1 -1
@@ -81,7 +81,7 @@ static void vmw_stream_set_arg_handle(void *data, u32 handle)static const struct vmw_simple_resource_func va_stream_func = { .res_func = { .res_type = vmw_res_stream, - .needs_backup = false, + .needs_guest_memory = false, .may_evict = false, .type_name ="overlay stream" , .domain =VMW_BO_DOMAIN_SYS ,
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +29 -33
99 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.38.1
Part of the diff is not shown here. View the raw message.