drm/vmwgfx: fb, cursors and hashtable refactor
Subsystems (4)
v4 cover drm/vmwgfx: fb, cursors and hashtable refactor
From: Zack Rusin <[email protected]>
v4: Fix one more LPK warning found in the "Fix frame-size warning in
vmw_mksstat_add_ioctl" change
v3: Add improvements suggested by Thomas for the fb port change and add a commit that fixes a sparse kernel doc warning
v2: Fix LKP and sparse reported issues
This is a bit larger series than usual but these are all connected in various ways. The most important changes around everything is centered include:
- finally getting rid of vmwgfx_hashtab and porting the driver to linux/hashtable
- cleaning up the cursor mob handling, which fixes a bunch of cursor issues on kde configs
- removing vmwgfx fb code and porting it to drm fb helpers
- removing vmwgfx faked vblank handling
The rest is largely support code to make the transition easier (with some igt fixes to get more of it running for regression testing). The result is removal of over 1000loc with no loss in functionality.
Maaz Mombasawala (5):
drm/vmwgfx: Refactor resource manager's hashtable to use
linux/hashtable implementation.
drm/vmwgfx: Remove ttm object hashtable drm/vmwgfx: Refactor resource validation hashtable to use
linux/hashtable implementation.
drm/vmwgfx: Refactor ttm reference object hashtable to use
linux/hashtable.
drm/vmwgfx: Remove vmwgfx_hashtab
Martin Krastev (1):
drm/vmwgfx: Fix frame-size warning in vmw_mksstat_add_ioctl
Michael Banack (4):
drm/vmwgfx: Clean up cursor mobs
drm/vmwgfx: Start diffing new mob cursors against old ones drm/vmwgfx: Support cursor surfaces with mob cursor drm/vmwgfx: Diff cursors when using cmds
Zack Rusin (7):
drm/vmwgfx: Write the driver id registers drm/vmwgfx: Do not allow invalid bpp's for dumb buffers drm/vmwgfx: Port the framebuffer code to drm fb helpers drm/vmwgfx: Remove explicit and broken vblank handling drm/vmwgfx: Add a mksstat counter for cotable resizes drm/vmwgfx: Optimize initial sizes of cotables drm/vmwgfx: Fix a sparse warning in kernel docs
Documentation/gpu/todo.rst | 11 - drivers/gpu/drm/vmwgfx/Kconfig | 7 - drivers/gpu/drm/vmwgfx/Makefile | 4 +- drivers/gpu/drm/vmwgfx/ttm_object.c | 123 ++- drivers/gpu/drm/vmwgfx/ttm_object.h | 20 +- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 16 +- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 62 +- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 29 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 129 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 49 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 15 +- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 831 --------------------- drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.c | 199 ----- drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.h | 83 -- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 641 ++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 31 +- drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 8 - drivers/gpu/drm/vmwgfx/vmwgfx_mksstat.h | 2 + drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 59 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 31 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 26 - drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 55 +- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 26 +- 23 files changed, 654 insertions(+), 1803 deletions(-) delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.c delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.h
Signature · 1 line
2.34.1
PATCH v4 1/17 drm/vmwgfx: Write the driver id registers
From: Zack Rusin <[email protected]>
Driver id registers are a new mechanism in the svga device to hint to the device which driver is running. This should not change device behavior in any way, but might be convenient to work-around specific bugs in guest drivers.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 43 +++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +34 -9
@@ -25,10 +25,13 @@* **************************************************************************/ -#include <linux/dma-mapping.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/cc_platform.h> + +#include "vmwgfx_drv.h" + +#include "vmwgfx_devcaps.h" +#include "vmwgfx_mksstat.h" +#include "vmwgfx_binding.h" +#include "ttm_object.h" #include <drm/drm_aperture.h> #include <drm/drm_drv.h>
@@ -41,11 +44,11 @@#include <drm/ttm/ttm_placement.h> #include <generated/utsrelease.h> -#include "ttm_object.h" -#include "vmwgfx_binding.h" -#include "vmwgfx_devcaps.h" -#include "vmwgfx_drv.h" -#include "vmwgfx_mksstat.h" +#include <linux/cc_platform.h> +#include <linux/dma-mapping.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/version.h> #define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"
@@ -806,6 +809,27 @@ static int vmw_detect_version(struct vmw_private *dev)return 0 ; } +static void vmw_write_driver_id (struct vmw_private *dev) +{ +if ((dev->capabilities2 &SVGA_CAP2_DX2 ) !=0 ) { +vmw_write (dev,SVGA_REG_GUEST_DRIVER_ID , +SVGA_REG_GUEST_DRIVER_ID_LINUX ); + +vmw_write (dev,SVGA_REG_GUEST_DRIVER_VERSION1 , +LINUX_VERSION_MAJOR <<24 | +LINUX_VERSION_PATCHLEVEL <<16 | +LINUX_VERSION_SUBLEVEL ); +vmw_write (dev,SVGA_REG_GUEST_DRIVER_VERSION2 , +VMWGFX_DRIVER_MAJOR <<24 | +VMWGFX_DRIVER_MINOR <<16 | +VMWGFX_DRIVER_PATCHLEVEL ); +vmw_write (dev,SVGA_REG_GUEST_DRIVER_VERSION3 ,0 ); + +vmw_write (dev,SVGA_REG_GUEST_DRIVER_ID , +SVGA_REG_GUEST_DRIVER_ID_SUBMIT ); + } +} +static int vmw_driver_load (struct vmw_private *dev_priv,u32 pci_id) {int ret;
@@ -1091,6 +1115,7 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)vmw_host_printf ("vmwgfx: Module Version: %d.%d.%d (kernel: %s)" ,VMWGFX_DRIVER_MAJOR ,VMWGFX_DRIVER_MINOR ,VMWGFX_DRIVER_PATCHLEVEL ,UTS_RELEASE ); +vmw_write_driver_id (dev_priv);if (dev_priv->enable_fb) {vmw_fifo_resource_inc (dev_priv);
Signature · 1 line
2.34.1
PATCH v4 2/17 drm/vmwgfx: Fix frame-size warning in vmw_mksstat_add_ioctl
In reply to Zack RusinFrom: Martin Krastev <[email protected]>
Function vmw_mksstat_add_ioctl allocates three big arrays on stack. That triggers frame-size [-Wframe-larger-than=] warning. Refactor that function to use kmalloc_array instead.
v2: Initialize page to null to avoid possible uninitialized use of it,
spotted by the kernel test robot <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 43 +++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +29 -14
@@ -1014,8 +1014,6 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,struct vmw_private *const dev_priv =vmw_priv (dev); -struct page *page; -MKSGuestStatInstanceDescriptor *pdesc;const size_t num_pages_stat =PFN_UP (arg->stat_len);const size_t num_pages_info =PFN_UP (arg->info_len);const size_t num_pages_strs =PFN_UP (arg->strs_len);
@@ -1023,10 +1021,13 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,long nr_pinned_stat;long nr_pinned_info;long nr_pinned_strs; -struct page *pages_stat[ARRAY_SIZE (pdesc->statPPNs)]; -struct page *pages_info[ARRAY_SIZE (pdesc->infoPPNs)]; -struct page *pages_strs[ARRAY_SIZE (pdesc->strsPPNs)]; +MKSGuestStatInstanceDescriptor *pdesc; +struct page *page =NULL ; +struct page **pages_stat =NULL ; +struct page **pages_info =NULL ; +struct page **pages_strs =NULL ;size_t i, slot; +int ret_err = -ENOMEM ; arg->id =-1 ;
@@ -1054,13 +1055,23 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,BUG_ON (dev_priv->mksstat_user_pages[slot]); +/* Allocate statically-sized temp arrays for pages -- too big to keep in frame */ + pages_stat = (struct page **)kmalloc_array ( +ARRAY_SIZE (pdesc->statPPNs) + +ARRAY_SIZE (pdesc->infoPPNs) + +ARRAY_SIZE (pdesc->strsPPNs),sizeof (*pages_stat),GFP_KERNEL ); + +if (!pages_stat) + goto err_nomem; + + pages_info = pages_stat +ARRAY_SIZE (pdesc->statPPNs); + pages_strs = pages_info +ARRAY_SIZE (pdesc->infoPPNs); +/* Allocate a page for the instance descriptor */ page =alloc_page (GFP_KERNEL | __GFP_ZERO); -if (!page) { -atomic_set (&dev_priv->mksstat_user_pids[slot],0 ); -return -ENOMEM ; - } +if (!page) + goto err_nomem;/* Set up the instance descriptor */ pdesc =page_address (page);
@@ -1075,9 +1086,8 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data, ARRAY_SIZE(pdesc->description) - 1);if (desc_len <0 ) { -atomic_set (&dev_priv->mksstat_user_pids[slot],0 ); -__free_page (page); -return -EFAULT ; + ret_err = -EFAULT ; + goto err_nomem; }reset_ppn_array (pdesc->statPPNs,ARRAY_SIZE (pdesc->statPPNs));
@@ -1118,6 +1128,7 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,DRM_DEV_INFO (dev->dev,"pid=%d arg.description='%.*s' id=%zu\n" , current->pid, (int )desc_len, pdesc->description, slot); +kfree (pages_stat);return 0 ; err_pin_strs:
@@ -1132,9 +1143,13 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,if (nr_pinned_stat >0 )unpin_user_pages (pages_stat, nr_pinned_stat); +err_nomem:atomic_set (&dev_priv->mksstat_user_pids[slot],0 ); -__free_page (page); -return -ENOMEM ; +if (page) +__free_page (page); +kfree (pages_stat); + +return ret_err; }/**
Signature · 1 line
2.34.1
PATCH v4 3/17 drm/vmwgfx: Refactor resource manager's hashtable to use linux/hashtable implementation.
In reply to Zack RusinFrom: Maaz Mombasawala <[email protected]>
Vmwgfx's hashtab implementation needs to be replaced with linux/hashtable to reduce maintenance burden.
Refactor cmdbuf resource manager to use linux/hashtable.h implementation as part of this effort.
--- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 62 +++++++++------------- 1 file changed, 26 insertions(+), 36 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +26 -36
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR MIT /************************************************************************** * -* Copyright 2014-2015 VMware, Inc., Palo Alto, CA., USA +* Copyright 2014-2022 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,6 +28,8 @@#include "vmwgfx_drv.h" #include "vmwgfx_resource_priv.h" +#include <linux/hashtable.h> +#define VMW_CMDBUF_RES_MAN_HT_ORDER 12/**
@@ -59,7 +61,7 @@ struct vmw_cmdbuf_res {* @resources and @list are protected by the cmdbuf mutex for now. */ struct vmw_cmdbuf_res_manager { -struct vmwgfx_open_hash resources; + DECLARE_HASHTABLE(resources, VMW_CMDBUF_RES_MAN_HT_ORDER);struct list_head list;struct vmw_private *dev_priv; };
@@ -82,14 +84,13 @@ vmw_cmdbuf_res_lookup(struct vmw_cmdbuf_res_manager *man, u32 user_key) {struct vmwgfx_hash_item *hash; -int ret;unsigned long key = user_key | (res_type <<24 ); - ret =vmwgfx_ht_find_item (&man->resources, key, &hash); -if (unlikely (ret !=0 )) -return ERR_PTR (ret); - - return drm_hash_entry(hash, struct vmw_cmdbuf_res, hash)->res; +hash_for_each_possible_rcu (man->resources, hash, head, key) { +if (hash->key == key) + return drm_hash_entry(hash, struct vmw_cmdbuf_res, hash)->res; + } +return ERR_PTR (-EINVAL ); }/**
@@ -105,7 +106,7 @@ static void vmw_cmdbuf_res_free(struct vmw_cmdbuf_res_manager *man, struct vmw_cmdbuf_res *entry) {list_del (&entry->head); -WARN_ON (vmwgfx_ht_remove_item (&man->resources, &entry->hash)); +hash_del_rcu (&entry->hash.head);vmw_resource_unreference (&entry->res);kfree (entry); }
@@ -159,7 +160,6 @@ void vmw_cmdbuf_res_commit(struct list_head *list)void vmw_cmdbuf_res_revert (struct list_head *list) {struct vmw_cmdbuf_res *entry, *next; -int ret;list_for_each_entry_safe (entry, next, list, head) {switch (entry->state) {
@@ -167,8 +167,8 @@ void vmw_cmdbuf_res_revert(struct list_head *list)vmw_cmdbuf_res_free (entry->man, entry);break ;case VMW_CMDBUF_RES_DEL : - ret =vmwgfx_ht_insert_item (&entry->man->resources, &entry->hash); -BUG_ON (ret); +hash_add_rcu (entry->man->resources, &entry->hash.head, + entry->hash.key);list_move_tail (&entry->head, &entry->man->list); entry->state =VMW_CMDBUF_RES_COMMITTED ;break ;
@@ -199,26 +199,20 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man, struct list_head *list) {struct vmw_cmdbuf_res *cres; -int ret; cres =kzalloc (sizeof (*cres),GFP_KERNEL );if (unlikely (!cres))return -ENOMEM ; cres->hash.key = user_key | (res_type <<24 ); - ret =vmwgfx_ht_insert_item (&man->resources, &cres->hash); -if (unlikely (ret !=0 )) { -kfree (cres); - goto out_invalid_key; - } +hash_add_rcu (man->resources, &cres->hash.head, cres->hash.key); cres->state =VMW_CMDBUF_RES_ADD ; cres->res =vmw_resource_reference (res); cres->man = man;list_add_tail (&cres->head, list); -out_invalid_key: -return ret; +return 0 ; }/**
@@ -243,24 +237,26 @@ int vmw_cmdbuf_res_remove(struct vmw_cmdbuf_res_manager *man,struct list_head *list, struct vmw_resource **res_p) { - struct vmw_cmdbuf_res *entry; + struct vmw_cmdbuf_res *entry = NULL;struct vmwgfx_hash_item *hash; -int ret; +unsigned long key = user_key | (res_type <<24 ); - ret =vmwgfx_ht_find_item (&man->resources, user_key | (res_type <<24 ), - &hash); -if (likely (ret !=0 )) +hash_for_each_possible_rcu (man->resources, hash, head, key) { +if (hash->key == key) { + entry = drm_hash_entry(hash, struct vmw_cmdbuf_res, hash); +break ; + } + } +if (unlikely (!entry))return -EINVAL ; - entry = drm_hash_entry(hash, struct vmw_cmdbuf_res, hash); -switch (entry->state) {case VMW_CMDBUF_RES_ADD :vmw_cmdbuf_res_free (man, entry); *res_p =NULL ;break ;case VMW_CMDBUF_RES_COMMITTED : - (void )vmwgfx_ht_remove_item (&man->resources, &entry->hash); +hash_del_rcu (&entry->hash.head);list_del (&entry->head); entry->state =VMW_CMDBUF_RES_DEL ;list_add_tail (&entry->head, list);
@@ -287,7 +283,6 @@ struct vmw_cmdbuf_res_manager * vmw_cmdbuf_res_man_create(struct vmw_private *dev_priv) {struct vmw_cmdbuf_res_manager *man; -int ret; man =kzalloc (sizeof (*man),GFP_KERNEL );if (!man)
@@ -295,12 +290,8 @@ vmw_cmdbuf_res_man_create(struct vmw_private *dev_priv) man->dev_priv = dev_priv;INIT_LIST_HEAD (&man->list); - ret =vmwgfx_ht_create (&man->resources,VMW_CMDBUF_RES_MAN_HT_ORDER ); -if (ret ==0 ) -return man; - -kfree (man); -return ERR_PTR (ret); +hash_init (man->resources); +return man; }/**
@@ -320,7 +311,6 @@ void vmw_cmdbuf_res_man_destroy(struct vmw_cmdbuf_res_manager *man)list_for_each_entry_safe (entry, next, &man->list, head)vmw_cmdbuf_res_free (man, entry); -vmwgfx_ht_remove (&man->resources);kfree (man); }
Signature · 1 line
2.34.1
PATCH v4 4/17 drm/vmwgfx: Remove ttm object hashtable
In reply to Zack RusinFrom: Maaz Mombasawala <[email protected]>
The object_hash hashtable for ttm objects is not being used. Remove it and perform refactoring in ttm_object init function.
--- drivers/gpu/drm/vmwgfx/ttm_object.c | 24 ++++++------------------ drivers/gpu/drm/vmwgfx/ttm_object.h | 6 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- 3 files changed, 9 insertions(+), 23 deletions(-)
drivers/gpu/drm/vmwgfx/ttm_object.c +6 -18
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 OR MIT */ /************************************************************************** * -* Copyright (c) 2009-2013 VMware, Inc., Palo Alto, CA., USA +* Copyright (c) 2009-2022 VMware, Inc., Palo Alto, CA., USA * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -44,13 +44,14 @@#define pr_fmt (fmt) "[TTM] " fmt +#include "ttm_object.h" +#include "vmwgfx_drv.h" +#include <linux/list.h> #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/atomic.h> #include <linux/module.h> -#include "ttm_object.h" -#include "vmwgfx_drv.h" MODULE_IMPORT_NS (DMA_BUF );
@@ -81,9 +82,7 @@ struct ttm_object_file {/* * struct ttm_object_device * -* @object_lock: lock that protects the object_hash hash table. -* -* @object_hash: hash table for fast lookup of object global names. +* @object_lock: lock that protects idr. * * @object_count: Per device object count. *
@@ -92,7 +91,6 @@ struct ttm_object_file {struct ttm_object_device {spinlock_t object_lock; -struct vmwgfx_open_hash object_hash;atomic_t object_count;struct dma_buf_ops ops;void (*dmabuf_release)(struct dma_buf *dma_buf);
@@ -449,20 +447,15 @@ struct ttm_object_file *ttm_object_file_init(struct ttm_object_device *tdev, }struct ttm_object_device * -ttm_object_device_init (unsigned int hash_order, -const struct dma_buf_ops *ops) +ttm_object_device_init (const struct dma_buf_ops *ops) {struct ttm_object_device *tdev =kmalloc (sizeof (*tdev),GFP_KERNEL ); -int ret;if (unlikely (tdev ==NULL ))return NULL ;spin_lock_init (&tdev->object_lock);atomic_set (&tdev->object_count,0 ); - ret =vmwgfx_ht_create (&tdev->object_hash, hash_order); -if (ret !=0 ) - goto out_no_object_hash;/* * Our base is at VMWGFX_NUM_MOB + 1 because we want to create
@@ -477,10 +470,6 @@ ttm_object_device_init(unsigned int hash_order, tdev->dmabuf_release = tdev->ops.release; tdev->ops.release = ttm_prime_dmabuf_release;return tdev; - -out_no_object_hash: -kfree (tdev); -return NULL ; }void ttm_object_device_release (struct ttm_object_device **p_tdev)
@@ -491,7 +480,6 @@ void ttm_object_device_release(struct ttm_object_device **p_tdev)WARN_ON_ONCE (!idr_is_empty (&tdev->idr));idr_destroy (&tdev->idr); -vmwgfx_ht_remove (&tdev->object_hash);kfree (tdev); }
drivers/gpu/drm/vmwgfx/ttm_object.h +2 -4
@@ -1,6 +1,6 @@/************************************************************************** * -* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA +* Copyright (c) 2006-2022 VMware, Inc., Palo Alto, CA., USA * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -262,7 +262,6 @@ extern void ttm_object_file_release(struct ttm_object_file **p_tfile);/** * ttm_object device init - initialize a struct ttm_object_device * -* @hash_order: Order of hash table used to hash the base objects. * @ops: DMA buf ops for prime objects of this device. * * This function is typically called on device initialization to prepare
@@ -270,8 +269,7 @@ extern void ttm_object_file_release(struct ttm_object_file **p_tfile);*/ extern struct ttm_object_device * -ttm_object_device_init (unsigned int hash_order, -const struct dma_buf_ops *ops); +ttm_object_device_init (const struct dma_buf_ops *ops);/** * ttm_object_device_release - release data held by a ttm_object_device
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -1
@@ -994,7 +994,7 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) goto out_err0; } - dev_priv->tdev =ttm_object_device_init (12 , &vmw_prime_dmabuf_ops); + dev_priv->tdev =ttm_object_device_init (&vmw_prime_dmabuf_ops);if (unlikely (dev_priv->tdev ==NULL )) { drm_err(&dev_priv->drm,
Signature · 1 line
2.34.1
PATCH v4 5/17 drm/vmwgfx: Refactor resource validation hashtable to use linux/hashtable implementation.
In reply to Zack RusinFrom: Maaz Mombasawala <[email protected]>
Vmwgfx's hashtab implementation needs to be replaced with linux/hashtable to reduce maintenence burden.
As part of this effort, refactor the res_ht hashtable used for resource validation during execbuf execution to use linux/hashtable implementation. This also refactors vmw_validation_context to use vmw_sw_context as the container for the hashtable, whereas before it used a vmwgfx_open_hash directly. This makes vmw_validation_context less generic, but there is no functional change since res_ht is the only instance where validation context used a hashtable in vmwgfx driver.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 24 ++++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 5 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 14 ++---- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 55 +++++++++++----------- drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 26 +++------- 5 files changed, 58 insertions(+), 66 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +19 -5
@@ -830,6 +830,22 @@ static void vmw_write_driver_id(struct vmw_private *dev) } } +static void vmw_sw_context_init (struct vmw_private *dev_priv) +{ +struct vmw_sw_context *sw_context = &dev_priv->ctx; + +hash_init (sw_context->res_ht); +} + +static void vmw_sw_context_fini (struct vmw_private *dev_priv) +{ +struct vmw_sw_context *sw_context = &dev_priv->ctx; + +vfree (sw_context->cmd_bounce); +if (sw_context->staged_bindings) +vmw_binding_state_free (sw_context->staged_bindings); +} +static int vmw_driver_load (struct vmw_private *dev_priv,u32 pci_id) {int ret;
@@ -839,6 +855,8 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id) dev_priv->drm.dev_private = dev_priv; +vmw_sw_context_init (dev_priv); +mutex_init (&dev_priv->cmdbuf_mutex);mutex_init (&dev_priv->binding_mutex);spin_lock_init (&dev_priv->resource_lock);
@@ -1168,9 +1186,7 @@ static void vmw_driver_unload(struct drm_device *dev)unregister_pm_notifier (&dev_priv->pm_nb); -if (dev_priv->ctx.res_ht_initialized) -vmwgfx_ht_remove (&dev_priv->ctx.res_ht); -vfree (dev_priv->ctx.cmd_bounce); +vmw_sw_context_fini (dev_priv);if (dev_priv->enable_fb) {vmw_fb_off (dev_priv);vmw_fb_close (dev_priv);
@@ -1198,8 +1214,6 @@ static void vmw_driver_unload(struct drm_device *dev)vmw_irq_uninstall (&dev_priv->drm);ttm_object_device_release (&dev_priv->tdev); -if (dev_priv->ctx.staged_bindings) -vmw_binding_state_free (dev_priv->ctx.staged_bindings);for (i = vmw_res_context; i < vmw_res_max; ++i)idr_destroy (&dev_priv->res_idr[i]);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +3 -2
@@ -30,6 +30,7 @@#include <linux/suspend.h> #include <linux/sync_file.h> +#include <linux/hashtable.h> #include <drm/drm_auth.h> #include <drm/drm_device.h>
@@ -93,6 +94,7 @@#define VMW_RES_STREAM ttm_driver_type2#define VMW_RES_FENCE ttm_driver_type3#define VMW_RES_SHADER ttm_driver_type4 +#define VMW_RES_HT_ORDER 12#define MKSSTAT_CAPACITY_LOG2 5U#define MKSSTAT_CAPACITY (1U << MKSSTAT_CAPACITY_LOG2)
@@ -425,8 +427,7 @@ struct vmw_ctx_validation_info;* @ctx: The validation context */ struct vmw_sw_context { -struct vmwgfx_open_hash res_ht; -bool res_ht_initialized; + DECLARE_HASHTABLE(res_ht, VMW_RES_HT_ORDER);bool kernel;struct vmw_fpriv *fp;struct drm_file *filp;
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +3 -11
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 OR MIT /************************************************************************** * -* Copyright 2009 - 2015 VMware, Inc., Palo Alto, CA., USA +* Copyright 2009 - 2022 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 <linux/sync_file.h> +#include <linux/hashtable.h> #include "vmwgfx_drv.h" #include "vmwgfx_reg.h"
@@ -34,7 +35,6 @@#include "vmwgfx_binding.h" #include "vmwgfx_mksstat.h" -#define VMW_RES_HT_ORDER 12/* * Helper macro to get dx_ctx_node if available otherwise print an error
@@ -4101,7 +4101,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,int ret;int32_t out_fence_fd =-1 ;struct sync_file *sync_file =NULL ; -DECLARE_VAL_CONTEXT (val_ctx, &sw_context->res_ht,1 ); +DECLARE_VAL_CONTEXT (val_ctx, sw_context,1 );if (flags &DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD ) { out_fence_fd =get_unused_fd_flags (O_CLOEXEC );
@@ -4164,14 +4164,6 @@ int vmw_execbuf_process(struct drm_file *file_priv,if (sw_context->staged_bindings)vmw_binding_state_reset (sw_context->staged_bindings); -if (!sw_context->res_ht_initialized) { - ret =vmwgfx_ht_create (&sw_context->res_ht,VMW_RES_HT_ORDER ); -if (unlikely (ret !=0 )) - goto out_unlock; - - sw_context->res_ht_initialized = true; - } -INIT_LIST_HEAD (&sw_context->staged_cmd_res); sw_context->ctx = &val_ctx; ret =vmw_execbuf_tie_context (dev_priv, sw_context, dx_context_handle);
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +27 -28
116 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h +6 -20
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 OR MIT */ /************************************************************************** * -* Copyright © 2018 VMware, Inc., Palo Alto, CA., USA +* Copyright © 2018 - 2022 VMware, Inc., Palo Alto, CA., USA * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,12 +29,11 @@#define _VMWGFX_VALIDATION_H_#include <linux/list.h> +#include <linux/hashtable.h> #include <linux/ww_mutex.h> #include <drm/ttm/ttm_execbuf_util.h> -#include "vmwgfx_hashtab.h" -#define VMW_RES_DIRTY_NONE 0#define VMW_RES_DIRTY_SET BIT(0)#define VMW_RES_DIRTY_CLEAR BIT(1)
@@ -59,7 +58,7 @@* @total_mem: Amount of reserved memory. */ struct vmw_validation_context { -struct vmwgfx_open_hash *ht; +struct vmw_sw_context *sw_context;struct list_head resource_list;struct list_head resource_ctx_list;struct list_head bo_list;
@@ -82,16 +81,16 @@ struct vmw_fence_obj;/** * DECLARE_VAL_CONTEXT - Declare a validation context with initialization * @_name: The name of the variable -* @_ht: The hash table used to find dups or NULL if none +* @_sw_context: Contains the hash table used to find dups or NULL if none * @_merge_dups: Whether to merge duplicate buffer object- or resource * entries. If set to true, ideally a hash table pointer should be supplied * as well unless the number of resources and buffer objects per validation * is known to be very small */ #endif -#define DECLARE_VAL_CONTEXT (_name, _ht, _merge_dups) \ +#define DECLARE_VAL_CONTEXT (_name, _sw_context, _merge_dups) \ struct vmw_validation_context _name = \ - { .ht = _ht, \ + { .sw_context = _sw_context, \ .resource_list = LIST_HEAD_INIT((_name).resource_list), \ .resource_ctx_list = LIST_HEAD_INIT((_name).resource_ctx_list), \ .bo_list = LIST_HEAD_INIT((_name).bo_list), \
@@ -114,19 +113,6 @@ vmw_validation_has_bos(struct vmw_validation_context *ctx)return !list_empty (&ctx->bo_list); } -/** -* vmw_validation_set_ht - Register a hash table for duplicate finding -* @ctx: The validation context -* @ht: Pointer to a hash table to use for duplicate finding -* This function is intended to be used if the hash table wasn't -* available at validation context declaration time -*/ -static inline void vmw_validation_set_ht (struct vmw_validation_context *ctx, -struct vmwgfx_open_hash *ht) -{ - ctx->ht = ht; -} -/** * vmw_validation_bo_reserve - Reserve buffer objects registered with a * validation context
Signature · 1 line
2.34.1
PATCH v4 6/17 drm/vmwgfx: Clean up cursor mobs
In reply to Zack RusinFrom: Michael Banack <[email protected]>
Clean up the cursor mob path by moving ownership of the mobs into the plane_state, and just leaving a cache of unused mobs in the plane itself.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 441 ++++++++++++++++------------ drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 19 +- 2 files changed, 267 insertions(+), 193 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +259 -182
@@ -53,33 +53,33 @@ void vmw_du_cleanup(struct vmw_display_unit *du)*/ static void vmw_cursor_update_mob (struct vmw_private *dev_priv, -struct ttm_buffer_object *bo, -struct ttm_bo_kmap_obj *map, +struct vmw_plane_state *vps,u32 *image,u32 width,u32 height,u32 hotspotX,u32 hotspotY); +static int vmw_du_cursor_plane_unmap_cm (struct vmw_plane_state *vps);struct vmw_svga_fifo_cmd_define_cursor {u32 cmd;SVGAFifoCmdDefineAlphaCursor cursor; }; -static void vmw_cursor_update_image (struct vmw_private *dev_priv, -struct ttm_buffer_object *cm_bo, -struct ttm_bo_kmap_obj *cm_map, -u32 *image,u32 width,u32 height, -u32 hotspotX,u32 hotspotY) +/** +* vmw_send_define_cursor_cmd - queue a define cursor command +* @dev_priv: the private driver struct +* @image: buffer which holds the cursor image +* @width: width of the mouse cursor image +* @height: height of the mouse cursor image +* @hotspotX: the horizontal position of mouse hotspot +* @hotspotY: the vertical position of mouse hotspot +*/ +static void vmw_send_define_cursor_cmd (struct vmw_private *dev_priv, +u32 *image,u32 width,u32 height, +u32 hotspotX,u32 hotspotY) {struct vmw_svga_fifo_cmd_define_cursor *cmd;const u32 image_size = width * height *sizeof (*image);const u32 cmd_size =sizeof (*cmd) + image_size; -if (cm_bo !=NULL ) { -vmw_cursor_update_mob (dev_priv, cm_bo, cm_map, image, - width, height, - hotspotX, hotspotY); -return ; - } -/* Try to reserve fifocmd space and swallow any failures; such reservations cannot be left unconsumed for long under the risk of clogging other fifocmd users, so
@@ -104,12 +104,39 @@ static void vmw_cursor_update_image(struct vmw_private *dev_priv,vmw_cmd_commit_flush (dev_priv, cmd_size); } +/** +* vmw_cursor_update_image - update the cursor image on the provided plane +* @dev_priv: the private driver struct +* @vps: the plane state of the cursor plane +* @image: buffer which holds the cursor image +* @width: width of the mouse cursor image +* @height: height of the mouse cursor image +* @hotspotX: the horizontal position of mouse hotspot +* @hotspotY: the vertical position of mouse hotspot +*/ +static void vmw_cursor_update_image (struct vmw_private *dev_priv, +struct vmw_plane_state *vps, +u32 *image,u32 width,u32 height, +u32 hotspotX,u32 hotspotY) +{ +if (vps->cursor.bo !=NULL ) +vmw_cursor_update_mob (dev_priv, vps, image, + width, height, + hotspotX, hotspotY); +else +vmw_send_define_cursor_cmd (dev_priv, image, width, height, + hotspotX, hotspotY); +} + +/** * vmw_cursor_update_mob - Update cursor vis CursorMob mechanism * +* Called from inside vmw_du_cursor_plane_atomic_update to actually +* make the cursor-image live. +* * @dev_priv: device to work with -* @bo: BO for the MOB -* @map: kmap obj for the BO +* @vps: the plane state of the cursor plane * @image: cursor source data to fill the MOB with * @width: source data width * @height: source data height
@@ -117,8 +144,7 @@ static void vmw_cursor_update_image(struct vmw_private *dev_priv,* @hotspotY: cursor hotspot Y */ static void vmw_cursor_update_mob (struct vmw_private *dev_priv, -struct ttm_buffer_object *bo, -struct ttm_bo_kmap_obj *map, +struct vmw_plane_state *vps,u32 *image,u32 width,u32 height,u32 hotspotX,u32 hotspotY) {
@@ -127,11 +153,11 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv,const u32 image_size = width * height *sizeof (*image);bool dummy; -BUG_ON (!image); - - header = (SVGAGBCursorHeader *)ttm_kmap_obj_virtual (map, &dummy); + header =ttm_kmap_obj_virtual (&vps->cursor.map, &dummy); alpha_header = &header->header.alphaHeader; +memset (header,0 ,sizeof (*header)); + header->type =SVGA_ALPHA_CURSOR ; header->sizeInBytes = image_size;
@@ -141,102 +167,116 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv, alpha_header->height = height;memcpy (header +1 , image, image_size); +vmw_write (dev_priv,SVGA_REG_CURSOR_MOBID , + vps->cursor.bo->resource->start); +} -vmw_write (dev_priv,SVGA_REG_CURSOR_MOBID , bo->resource->start); +static u32 vmw_du_cursor_mob_size (u32 w,u32 h) +{ +return w * h *sizeof (u32) +sizeof (SVGAGBCursorHeader); } -void vmw_du_destroy_cursor_mob_array (struct vmw_cursor_plane *vcp) +static void vmw_du_destroy_cursor_mob (struct ttm_buffer_object **bo) { -size_t i; +if (*bo ==NULL ) +return ; -for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mob); i++) { -if (vcp->cursor_mob[i] !=NULL ) { -ttm_bo_unpin (vcp->cursor_mob[i]); -ttm_bo_put (vcp->cursor_mob[i]); -kfree (vcp->cursor_mob[i]); - vcp->cursor_mob[i] =NULL ; - } - } +ttm_bo_unpin (*bo); +ttm_bo_put (*bo); +kfree (*bo); + *bo =NULL ; } -#define CURSOR_MOB_SIZE (dimension) \ - ((dimension) * (dimension) * sizeof(u32) + sizeof(SVGAGBCursorHeader)) - -int vmw_du_create_cursor_mob_array (struct vmw_cursor_plane *cursor) +static void vmw_du_put_cursor_mob (struct vmw_cursor_plane *vcp, +struct vmw_plane_state *vps) { -struct vmw_private *dev_priv = cursor->base.dev->dev_private; -uint32_t cursor_max_dim, mob_max_size; -int ret =0 ; -size_t i; - -if (!dev_priv->has_mob || (dev_priv->capabilities2 &SVGA_CAP2_CURSOR_MOB ) ==0 ) -return -ENOSYS ; +u32 i; - mob_max_size =vmw_read (dev_priv,SVGA_REG_MOB_MAX_SIZE ); - cursor_max_dim =vmw_read (dev_priv,SVGA_REG_CURSOR_MAX_DIMENSION ); +if (vps->cursor.bo ==NULL ) +return ; -if (CURSOR_MOB_SIZE (cursor_max_dim) > mob_max_size) - cursor_max_dim =64 ;/* Mandatorily-supported cursor dimension */ +vmw_du_cursor_plane_unmap_cm (vps); -for (i =0 ; i <ARRAY_SIZE (cursor->cursor_mob); i++) { -struct ttm_buffer_object **const bo = &cursor->cursor_mob[i]; +/* Look for a free slot to return this mob to the cache. */ +for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mobs); i++) { +if (vcp->cursor_mobs[i] ==NULL ) { + vcp->cursor_mobs[i] = vps->cursor.bo; + vps->cursor.bo =NULL ; +return ; + } + } - ret =vmw_bo_create_kernel (dev_priv, -CURSOR_MOB_SIZE (cursor_max_dim), - &vmw_mob_placement, bo); +/* Cache is full: See if this mob is bigger than an existing mob. */ +for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mobs); i++) { +if (vcp->cursor_mobs[i]->base.size < + vps->cursor.bo->base.size) { +vmw_du_destroy_cursor_mob (&vcp->cursor_mobs[i]); + vcp->cursor_mobs[i] = vps->cursor.bo; + vps->cursor.bo =NULL ; +return ; + } + } -if (ret !=0 ) - goto teardown; +/* Destroy it if it's not worth caching. */ +vmw_du_destroy_cursor_mob (&vps->cursor.bo); +} -if ((*bo)->resource->mem_type !=VMW_PL_MOB ) { -DRM_ERROR ("Obtained buffer object is not a MOB.\n" ); - ret = -ENOSYS ; - goto teardown; - } +static int vmw_du_get_cursor_mob (struct vmw_cursor_plane *vcp, +struct vmw_plane_state *vps) +{ +struct vmw_private *dev_priv = vcp->base.dev->dev_private; +u32 size =vmw_du_cursor_mob_size (vps->base.crtc_w, vps->base.crtc_h); +u32 i; +u32 cursor_max_dim, mob_max_size; +int ret; -/* Fence the mob creation so we are guarateed to have the mob */ - ret =ttm_bo_reserve (*bo, false, false,NULL ); +if (!dev_priv->has_mob || + (dev_priv->capabilities2 &SVGA_CAP2_CURSOR_MOB ) ==0 ) +return -EINVAL ; -if (ret !=0 ) - goto teardown; + mob_max_size =vmw_read (dev_priv,SVGA_REG_MOB_MAX_SIZE ); + cursor_max_dim =vmw_read (dev_priv,SVGA_REG_CURSOR_MAX_DIMENSION ); -vmw_bo_fence_single (*bo,NULL ); +if (size > mob_max_size || vps->base.crtc_w > cursor_max_dim || + vps->base.crtc_h > cursor_max_dim) +return -EINVAL ; -ttm_bo_unreserve (*bo); +if (vps->cursor.bo !=NULL ) { +if (vps->cursor.bo->base.size >= size) +return 0 ; +vmw_du_put_cursor_mob (vcp, vps); + } -drm_info (&dev_priv->drm,"Using CursorMob mobid %lu, max dimension %u\n" , - (*bo)->resource->start, cursor_max_dim); +/* Look for an unused mob in the cache. */ +for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mobs); i++) { +if (vcp->cursor_mobs[i] !=NULL && + vcp->cursor_mobs[i]->base.size >= size) { + vps->cursor.bo = vcp->cursor_mobs[i]; + vcp->cursor_mobs[i] =NULL ; +return 0 ; + } } +/* Create a new mob if we can't find an existing one. */ + ret =vmw_bo_create_kernel (dev_priv, size, &vmw_mob_placement, + &vps->cursor.bo); + +if (ret !=0 ) +return ret; + +/* Fence the mob creation so we are guarateed to have the mob */ + ret =ttm_bo_reserve (vps->cursor.bo, false, false,NULL ); +if (ret !=0 ) + goto teardown; +vmw_bo_fence_single (vps->cursor.bo,NULL ); +ttm_bo_unreserve (vps->cursor.bo);return 0 ; teardown: -vmw_du_destroy_cursor_mob_array (cursor); - +vmw_du_destroy_cursor_mob (&vps->cursor.bo);return ret; } -#undef CURSOR_MOB_SIZE - -static void vmw_cursor_update_bo (struct vmw_private *dev_priv, -struct ttm_buffer_object *cm_bo, -struct ttm_bo_kmap_obj *cm_map, -struct vmw_buffer_object *bo, -u32 width,u32 height, -u32 hotspotX,u32 hotspotY) -{ -void *virtual; -bool dummy; - - virtual =ttm_kmap_obj_virtual (&bo->map, &dummy); -if (virtual) { -vmw_cursor_update_image (dev_priv, cm_bo, cm_map, virtual, - width, height, - hotspotX, hotspotY); -atomic_dec (&bo->base_mapped_count); - } -} -static void vmw_cursor_update_position (struct vmw_private *dev_priv,bool show,int x,int y)
@@ -391,11 +431,11 @@ void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv)continue ; du->cursor_age = du->cursor_surface->snooper.age; -vmw_cursor_update_image (dev_priv,NULL ,NULL , - du->cursor_surface->snooper.image, -64 ,64 , - du->hotspot_x + du->core_hotspot_x, - du->hotspot_y + du->core_hotspot_y); +vmw_send_define_cursor_cmd (dev_priv, + du->cursor_surface->snooper.image, +64 ,64 , + du->hotspot_x + du->core_hotspot_x, + du->hotspot_y + du->core_hotspot_y); }mutex_unlock (&dev->mode_config.mutex);
@@ -404,8 +444,14 @@ void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv)void vmw_du_cursor_plane_destroy (struct drm_plane *plane) { +struct vmw_cursor_plane *vcp =vmw_plane_to_vcp (plane); +u32 i; +vmw_cursor_update_position (plane->dev->dev_private, false,0 ,0 ); -vmw_du_destroy_cursor_mob_array (vmw_plane_to_vcp (plane)); + +for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mobs); i++) +vmw_du_destroy_cursor_mob (&vcp->cursor_mobs[i]); +drm_plane_cleanup (plane); }
@@ -462,6 +508,87 @@ vmw_du_plane_cleanup_fb(struct drm_plane *plane, } +/** +* vmw_du_cursor_plane_map_cm - Maps the cursor mobs. +* +* @vps: plane_state +* +* Returns 0 on success +*/ + +static int +vmw_du_cursor_plane_map_cm (struct vmw_plane_state *vps) +{ +int ret; +u32 size =vmw_du_cursor_mob_size (vps->base.crtc_w, vps->base.crtc_h); +struct ttm_buffer_object *bo = vps->cursor.bo; + +if (bo ==NULL ) +return -EINVAL ; + +if (bo->base.size < size) +return -EINVAL ; + +if (vps->cursor.mapped) +return 0 ; + + ret =ttm_bo_reserve (bo, false, false,NULL ); + +if (unlikely (ret !=0 )) +return -ENOMEM ; + + ret =ttm_bo_kmap (bo,0 ,PFN_UP (size), &vps->cursor.map); + +/* +* We just want to try to get mob bind to finish +* so that the first write to SVGA_REG_CURSOR_MOBID +* is done with a buffer that the device has already +* seen +*/ + (void )ttm_bo_wait (bo, false, false); + +ttm_bo_unreserve (bo); + +if (unlikely (ret !=0 )) +return -ENOMEM ; + + vps->cursor.mapped = true; + +return 0 ; +} + + +/** +* vmw_du_cursor_plane_unmap_cm - Unmaps the cursor mobs. +* +* @vps: state of the cursor plane +* +* Returns 0 on success +*/ + +static int +vmw_du_cursor_plane_unmap_cm (struct vmw_plane_state *vps) +{ +int ret =0 ; +struct ttm_buffer_object *bo = vps->cursor.bo; + +if (!vps->cursor.mapped) +return 0 ; + +if (bo ==NULL ) +return 0 ; + + ret =ttm_bo_reserve (bo, true, false,NULL ); +if (likely (ret ==0 )) { +ttm_bo_kunmap (&vps->cursor.map); +ttm_bo_unreserve (bo); + vps->cursor.mapped = false; + } + +return ret; +} + +/** * vmw_du_cursor_plane_cleanup_fb - Unpins the plane surface *
@@ -476,6 +603,7 @@ void vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, struct drm_plane_state *old_state) { + struct vmw_cursor_plane *vcp = vmw_plane_to_vcp(plane);struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state);bool dummy;
@@ -489,28 +617,23 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane, } } -if (vps->cm_bo !=NULL &&ttm_kmap_obj_virtual (&vps->cm_map, &dummy) !=NULL ) { -const int ret =ttm_bo_reserve (vps->cm_bo, true, false,NULL ); - -if (likely (ret ==0 )) { -ttm_bo_kunmap (&vps->cm_map); -ttm_bo_unreserve (vps->cm_bo); - } - } +vmw_du_cursor_plane_unmap_cm (vps); +vmw_du_put_cursor_mob (vcp, vps);vmw_du_plane_unpin_surf (vps, false); -if (vps->surf) { +if (vps->surf !=NULL ) {vmw_surface_unreference (&vps->surf); vps->surf =NULL ; } -if (vps->bo) { +if (vps->bo !=NULL ) {vmw_bo_unreference (&vps->bo); vps->bo =NULL ; } } +/** * vmw_du_cursor_plane_prepare_fb - Readies the cursor by referencing it *
@@ -526,8 +649,6 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,struct drm_framebuffer *fb = new_state->fb;struct vmw_cursor_plane *vcp =vmw_plane_to_vcp (plane);struct vmw_plane_state *vps =vmw_plane_state_to_vps (new_state); -struct ttm_buffer_object *cm_bo =NULL ; -bool dummy;int ret =0 ;if (vps->surf) {
@@ -550,13 +671,14 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane, } } - vps->cm_bo =NULL ; -if (vps->surf ==NULL && vps->bo !=NULL ) {const u32 size = new_state->crtc_w * new_state->crtc_h *sizeof (u32); -/* Not using vmw_bo_map_and_cache() helper here as we need to reserve -the ttm_buffer_object first which wmw_bo_map_and_cache() omits. */ +/* +* Not using vmw_bo_map_and_cache() helper here as we need to +* reserve the ttm_buffer_object first which +* vmw_bo_map_and_cache() omits. +*/ ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (unlikely (ret !=0 ))
@@ -573,67 +695,12 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,return -ENOMEM ; } -if (vps->surf || vps->bo) { -unsigned cursor_mob_idx = vps->cursor_mob_idx; - -/* Lazily set up cursor MOBs just once -- no reattempts. */ -if (cursor_mob_idx ==0 && vcp->cursor_mob[0 ] ==NULL ) -if (vmw_du_create_cursor_mob_array (vcp) !=0 ) - vps->cursor_mob_idx = cursor_mob_idx =-1U ; - -if (cursor_mob_idx <ARRAY_SIZE (vcp->cursor_mob)) { -const u32 size =sizeof (SVGAGBCursorHeader) + - new_state->crtc_w * new_state->crtc_h *sizeof (u32); - - cm_bo = vcp->cursor_mob[cursor_mob_idx]; - -if (cm_bo->resource->num_pages *PAGE_SIZE < size) { - ret = -EINVAL ; - goto error_bo_unmap; - } - - ret =ttm_bo_reserve (cm_bo, false, false,NULL ); - -if (unlikely (ret !=0 )) { - ret = -ENOMEM ; - goto error_bo_unmap; - } - - ret =ttm_bo_kmap (cm_bo,0 ,PFN_UP (size), &vps->cm_map); - -/* -* We just want to try to get mob bind to finish -* so that the first write to SVGA_REG_CURSOR_MOBID -* is done with a buffer that the device has already -* seen -*/ - (void )ttm_bo_wait (cm_bo, false, false); - -ttm_bo_unreserve (cm_bo); - -if (unlikely (ret !=0 )) { - ret = -ENOMEM ; - goto error_bo_unmap; - } - - vps->cursor_mob_idx = cursor_mob_idx ^1 ; - vps->cm_bo = cm_bo; - } +if (vps->surf !=NULL || vps->bo !=NULL ) { +vmw_du_get_cursor_mob (vcp, vps); +vmw_du_cursor_plane_map_cm (vps); }return 0 ; - -error_bo_unmap: -if (vps->bo !=NULL &&ttm_kmap_obj_virtual (&vps->bo->map, &dummy) !=NULL ) { -const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL ); -if (likely (ret ==0 )) { -atomic_dec (&vps->bo->base_mapped_count); -ttm_bo_kunmap (&vps->bo->map); -ttm_bo_unreserve (&vps->bo->base); - } - } - -return ret; }
@@ -650,6 +717,8 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,struct vmw_display_unit *du =vmw_crtc_to_du (crtc);struct vmw_plane_state *vps =vmw_plane_state_to_vps (new_state);s32 hotspot_x, hotspot_y; +void *virtual; +bool dummy; hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y;
@@ -662,23 +731,29 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, du->cursor_surface = vps->surf; du->cursor_bo = vps->bo; -if (vps->surf) { +if (vps->surf ==NULL && vps->bo ==NULL ) { +vmw_cursor_update_position (dev_priv, false,0 ,0 ); +return ; + } + +if (vps->surf !=NULL ) { du->cursor_age = du->cursor_surface->snooper.age; -vmw_cursor_update_image (dev_priv, vps->cm_bo, &vps->cm_map, +vmw_cursor_update_image (dev_priv, vps, vps->surf->snooper.image, new_state->crtc_w, new_state->crtc_h, hotspot_x, hotspot_y); - }else if (vps->bo) { -vmw_cursor_update_bo (dev_priv, vps->cm_bo, &vps->cm_map, - vps->bo, - new_state->crtc_w, - new_state->crtc_h, - hotspot_x, hotspot_y); }else { -vmw_cursor_update_position (dev_priv, false,0 ,0 ); -return ; + + virtual =ttm_kmap_obj_virtual (&vps->bo->map, &dummy); +if (virtual) { +vmw_cursor_update_image (dev_priv, vps, virtual, + new_state->crtc_w, + new_state->crtc_h, + hotspot_x, hotspot_y); +atomic_dec (&vps->bo->base_mapped_count); + } } du->cursor_x = new_state->crtc_x + du->set_gui_x;
@@ -943,11 +1018,13 @@ vmw_du_plane_duplicate_state(struct drm_plane *plane) vps->pinned =0 ; vps->cpp =0 ; +memset (&vps->cursor,0 ,sizeof (vps->cursor)); +/* Each ref counted resource needs to be acquired again */ -if (vps->surf) +if (vps->surf !=NULL ) (void )vmw_surface_reference (vps->surf); -if (vps->bo) +if (vps->bo !=NULL ) (void )vmw_bo_reference (vps->bo); state = &vps->base;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +8 -11
@@ -295,13 +295,11 @@ struct vmw_plane_state {/* For CPU Blit */ unsigned int cpp; -/* CursorMob flipping index; -1 if cursor mobs not used */ -unsigned int cursor_mob_idx; -/* Currently-active CursorMob */ -struct ttm_buffer_object *cm_bo; -/* CursorMob kmap_obj; expected valid at cursor_plane_atomic_update -IFF currently-active CursorMob above is valid */ -struct ttm_bo_kmap_obj cm_map; +struct { +struct ttm_buffer_object *bo; +struct ttm_bo_kmap_obj map; +bool mapped; + } cursor; };
@@ -338,11 +336,12 @@ struct vmw_connector_state {* Derived class for cursor plane object * * @base DRM plane object -* @cursor_mob array of two MOBs for CursorMob flipping +* @cursor.cursor_mobs Cursor mobs available for re-use */ struct vmw_cursor_plane {struct drm_plane base; -struct ttm_buffer_object *cursor_mob[2 ]; + +struct ttm_buffer_object *cursor_mobs[3 ]; };/**
@@ -472,8 +471,6 @@ void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv);/* Universal Plane Helpers */ void vmw_du_primary_plane_destroy (struct drm_plane *plane);void vmw_du_cursor_plane_destroy (struct drm_plane *plane); -int vmw_du_create_cursor_mob_array (struct vmw_cursor_plane *vcp); -void vmw_du_destroy_cursor_mob_array (struct vmw_cursor_plane *vcp);/* Atomic Helpers */ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
Signature · 1 line
2.34.1
PATCH v4 7/17 drm/vmwgfx: Start diffing new mob cursors against old ones
In reply to Zack RusinFrom: Michael Banack <[email protected]>
Avoid making the SVGA device do extra work if the new cursor image matches the old one.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 95 ++++++++++++++++++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 12 ++-- 2 files changed, 81 insertions(+), 26 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +74 -21
@@ -52,11 +52,9 @@ void vmw_du_cleanup(struct vmw_display_unit *du)* Display Unit Cursor functions */ -static void vmw_cursor_update_mob (struct vmw_private *dev_priv, -struct vmw_plane_state *vps, -u32 *image,u32 width,u32 height, -u32 hotspotX,u32 hotspotY);static int vmw_du_cursor_plane_unmap_cm (struct vmw_plane_state *vps); +static void vmw_cursor_write_mobid (struct vmw_private *dev_priv, +struct vmw_plane_state *vps);struct vmw_svga_fifo_cmd_define_cursor {u32 cmd;
@@ -120,9 +118,7 @@ static void vmw_cursor_update_image(struct vmw_private *dev_priv, u32 hotspotX, u32 hotspotY) {if (vps->cursor.bo !=NULL ) -vmw_cursor_update_mob (dev_priv, vps, image, - width, height, - hotspotX, hotspotY); +vmw_cursor_write_mobid (dev_priv, vps);else vmw_send_define_cursor_cmd (dev_priv, image, width, height, hotspotX, hotspotY);
@@ -167,6 +163,21 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv, alpha_header->height = height;memcpy (header +1 , image, image_size); +} + + +/** +* vmw_cursor_write_mobid - Update cursor via CursorMob mechanism +* +* Called from inside vmw_du_cursor_plane_atomic_update to actually +* make the cursor-image live. +* +* @dev_priv: device to work with +* @vps: DRM plane_state +*/ +static void vmw_cursor_write_mobid (struct vmw_private *dev_priv, +struct vmw_plane_state *vps) +{vmw_write (dev_priv,SVGA_REG_CURSOR_MOBID , vps->cursor.bo->resource->start); }
@@ -176,6 +187,39 @@ static u32 vmw_du_cursor_mob_size(u32 w, u32 h)return w * h *sizeof (u32) +sizeof (SVGAGBCursorHeader); } + +static bool vmw_du_cursor_plane_mob_has_changed (struct vmw_plane_state *old_vps, +struct vmw_plane_state *new_vps) +{ +void *old_mob; +void *new_mob; +bool dummy; +u32 size; + +// If either of them aren't using CursorMobs, assume changed. +if (old_vps->cursor.bo ==NULL || new_vps->cursor.bo ==NULL ) +return true; + +// If either of them failed to map, assume changed. +if (!old_vps->cursor.mapped || !new_vps->cursor.mapped) +return true; + +if (old_vps->base.crtc_w != new_vps->base.crtc_w || + old_vps->base.crtc_h != new_vps->base.crtc_h) +return true; + + size =vmw_du_cursor_mob_size (new_vps->base.crtc_w, + new_vps->base.crtc_h); + + old_mob =ttm_kmap_obj_virtual (&old_vps->cursor.map, &dummy); + new_mob =ttm_kmap_obj_virtual (&new_vps->cursor.map, &dummy); + +if (memcmp (old_mob, new_mob, size) !=0 ) +return true; + +return false; +} +static void vmw_du_destroy_cursor_mob (struct ttm_buffer_object **bo) {if (*bo ==NULL )
@@ -716,9 +760,10 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,struct vmw_private *dev_priv =vmw_priv (crtc->dev);struct vmw_display_unit *du =vmw_crtc_to_du (crtc);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; -void *virtual;bool dummy; +void *image; hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y;
@@ -738,23 +783,32 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,if (vps->surf !=NULL ) { du->cursor_age = du->cursor_surface->snooper.age; + image = vps->surf->snooper.image; + }else + image =ttm_kmap_obj_virtual (&vps->bo->map, &dummy); -vmw_cursor_update_image (dev_priv, vps, - vps->surf->snooper.image, +if (vps->cursor.bo !=NULL ) +vmw_cursor_update_mob (dev_priv, vps, image, + new_state->crtc_w, + new_state->crtc_h, + hotspot_x, hotspot_y); + +if (!vmw_du_cursor_plane_mob_has_changed (old_vps, vps)) { +/* +* If it hasn't changed, avoid making the device do extra +* work by keeping the old mob active. +*/ +struct vmw_cursor_plane_state tmp = old_vps->cursor; + old_vps->cursor = vps->cursor; + vps->cursor = tmp; + }else if (image !=NULL ) +vmw_cursor_update_image (dev_priv, vps, image, new_state->crtc_w, new_state->crtc_h, hotspot_x, hotspot_y); - }else { - virtual =ttm_kmap_obj_virtual (&vps->bo->map, &dummy); -if (virtual) { -vmw_cursor_update_image (dev_priv, vps, virtual, - new_state->crtc_w, - new_state->crtc_h, - hotspot_x, hotspot_y); -atomic_dec (&vps->bo->base_mapped_count); - } - } +if (image !=NULL && vps->bo !=NULL ) +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;
@@ -1074,7 +1128,6 @@ vmw_du_plane_destroy_state(struct drm_plane *plane, {struct vmw_plane_state *vps =vmw_plane_state_to_vps (state); -/* Should have been freed by cleanup_fb */ if (vps->surf)vmw_surface_unreference (&vps->surf);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +7 -5
@@ -272,6 +272,12 @@ struct vmw_crtc_state {struct drm_crtc_state base; }; +struct vmw_cursor_plane_state { +struct ttm_buffer_object *bo; +struct ttm_bo_kmap_obj map; +bool mapped; +}; +/** * Derived class for plane state object *
@@ -295,11 +301,7 @@ struct vmw_plane_state {/* For CPU Blit */ unsigned int cpp; -struct { -struct ttm_buffer_object *bo; -struct ttm_bo_kmap_obj map; -bool mapped; - } cursor; +struct vmw_cursor_plane_state cursor; };
Signature · 1 line
2.34.1
PATCH v4 8/17 drm/vmwgfx: Support cursor surfaces with mob cursor
In reply to Zack RusinFrom: Michael Banack <[email protected]>
Add support for cursor surfaces when using mob cursors.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 78 ++++++++++++++++++----------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 1 + 2 files changed, 50 insertions(+), 29 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +49 -29
@@ -85,7 +85,7 @@ static void vmw_send_define_cursor_cmd(struct vmw_private *dev_priv,other fallible KMS-atomic resources at prepare_fb */ cmd =VMW_CMD_RESERVE (dev_priv, cmd_size); -if (unlikely (cmd ==NULL )) +if (unlikely (!cmd))return ;memset (cmd,0 ,sizeof (*cmd));
@@ -117,7 +117,7 @@ static void vmw_cursor_update_image(struct vmw_private *dev_priv, u32 *image, u32 width, u32 height, u32 hotspotX, u32 hotspotY) { - if (vps->cursor.bo != NULL) + if (vps->cursor.bo) vmw_cursor_write_mobid(dev_priv, vps); else vmw_send_define_cursor_cmd(dev_priv, image, width, height,
@@ -197,7 +197,7 @@ static bool vmw_du_cursor_plane_mob_has_changed(struct vmw_plane_state *old_vps,u32 size;// If either of them aren't using CursorMobs, assume changed. -if (old_vps->cursor.bo ==NULL || new_vps->cursor.bo ==NULL ) +if (!old_vps->cursor.bo || !new_vps->cursor.bo)return true;// If either of them failed to map, assume changed.
@@ -222,7 +222,7 @@ static bool vmw_du_cursor_plane_mob_has_changed(struct vmw_plane_state *old_vps,static void vmw_du_destroy_cursor_mob (struct ttm_buffer_object **bo) { -if (*bo ==NULL ) +if (!(*bo))return ;ttm_bo_unpin (*bo);
@@ -236,14 +236,14 @@ static void vmw_du_put_cursor_mob(struct vmw_cursor_plane *vcp, {u32 i; -if (vps->cursor.bo ==NULL ) +if (!vps->cursor.bo)return ;vmw_du_cursor_plane_unmap_cm (vps);/* Look for a free slot to return this mob to the cache. */ for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mobs); i++) { -if (vcp->cursor_mobs[i] ==NULL ) { +if (!vcp->cursor_mobs[i]) { vcp->cursor_mobs[i] = vps->cursor.bo; vps->cursor.bo =NULL ;return ;
@@ -285,7 +285,7 @@ static int vmw_du_get_cursor_mob(struct vmw_cursor_plane *vcp, vps->base.crtc_h > cursor_max_dim)return -EINVAL ; -if (vps->cursor.bo !=NULL ) { +if (vps->cursor.bo) {if (vps->cursor.bo->base.size >= size)return 0 ;vmw_du_put_cursor_mob (vcp, vps);
@@ -293,7 +293,7 @@ static int vmw_du_get_cursor_mob(struct vmw_cursor_plane *vcp,/* Look for an unused mob in the cache. */ for (i =0 ; i <ARRAY_SIZE (vcp->cursor_mobs); i++) { -if (vcp->cursor_mobs[i] !=NULL && +if (vcp->cursor_mobs[i] && vcp->cursor_mobs[i]->base.size >= size) { vps->cursor.bo = vcp->cursor_mobs[i]; vcp->cursor_mobs[i] =NULL ;
@@ -371,7 +371,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf, cmd = container_of(header, struct vmw_dma_cmd, header); -/* No snooper installed */ +/* No snooper installed, nothing to copy */ if (!srf->snooper.image)return ;
@@ -471,7 +471,8 @@ void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv)list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { du =vmw_crtc_to_du (crtc);if (!du->cursor_surface || - du->cursor_age == du->cursor_surface->snooper.age) + du->cursor_age == du->cursor_surface->snooper.age || + !du->cursor_surface->snooper.image)continue ; du->cursor_age = du->cursor_surface->snooper.age;
@@ -567,7 +568,7 @@ vmw_du_cursor_plane_map_cm(struct vmw_plane_state *vps)u32 size =vmw_du_cursor_mob_size (vps->base.crtc_w, vps->base.crtc_h);struct ttm_buffer_object *bo = vps->cursor.bo; -if (bo ==NULL ) +if (!bo)return -EINVAL ;if (bo->base.size < size)
@@ -619,7 +620,7 @@ vmw_du_cursor_plane_unmap_cm(struct vmw_plane_state *vps)if (!vps->cursor.mapped)return 0 ; -if (bo ==NULL ) +if (!bo)return 0 ; ret =ttm_bo_reserve (bo, true, false,NULL );
@@ -651,7 +652,12 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane,struct vmw_plane_state *vps =vmw_plane_state_to_vps (old_state);bool dummy; -if (vps->bo !=NULL &&ttm_kmap_obj_virtual (&vps->bo->map, &dummy) !=NULL ) { +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)) {const int ret =ttm_bo_reserve (&vps->bo->base, true, false,NULL );if (likely (ret ==0 )) {
@@ -666,12 +672,12 @@ vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane,vmw_du_plane_unpin_surf (vps, false); -if (vps->surf !=NULL ) { +if (vps->surf) {vmw_surface_unreference (&vps->surf); vps->surf =NULL ; } -if (vps->bo !=NULL ) { +if (vps->bo) {vmw_bo_unreference (&vps->bo); vps->bo =NULL ; }
@@ -715,7 +721,7 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane, } } -if (vps->surf ==NULL && vps->bo !=NULL ) { +if (!vps->surf && vps->bo) {const u32 size = new_state->crtc_w * new_state->crtc_h *sizeof (u32);/*
@@ -737,9 +743,18 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,if (unlikely (ret !=0 ))return -ENOMEM ; + }else if (vps->surf && !vps->bo && vps->surf->res.backup) { + + ret =ttm_bo_reserve (&vps->surf->res.backup->base, true, false, +NULL ); +if (unlikely (ret !=0 )) +return -ENOMEM ; +vmw_bo_map_and_cache (vps->surf->res.backup); +ttm_bo_unreserve (&vps->surf->res.backup->base); + vps->surf_mapped = true; } -if (vps->surf !=NULL || vps->bo !=NULL ) { +if (vps->surf || vps->bo) {vmw_du_get_cursor_mob (vcp, vps);vmw_du_cursor_plane_map_cm (vps); }
@@ -776,18 +791,20 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, du->cursor_surface = vps->surf; du->cursor_bo = vps->bo; -if (vps->surf ==NULL && vps->bo ==NULL ) { +if (!vps->surf && !vps->bo) {vmw_cursor_update_position (dev_priv, false,0 ,0 );return ; } -if (vps->surf !=NULL ) { +if (vps->surf) { du->cursor_age = du->cursor_surface->snooper.age; image = vps->surf->snooper.image; +if (vps->surf_mapped) + image =vmw_bo_map_and_cache (vps->surf->res.backup); }else image =ttm_kmap_obj_virtual (&vps->bo->map, &dummy); -if (vps->cursor.bo !=NULL ) +if (vps->cursor.bo) vmw_cursor_update_mob(dev_priv, vps, image, new_state->crtc_w, new_state->crtc_h,
@@ -801,13 +818,13 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,struct vmw_cursor_plane_state tmp = old_vps->cursor; old_vps->cursor = vps->cursor; vps->cursor = tmp; - }else if (image !=NULL ) + }else if (image)vmw_cursor_update_image (dev_priv, vps, image, new_state->crtc_w, new_state->crtc_h, hotspot_x, hotspot_y); -if (image !=NULL && vps->bo !=NULL ) +if (image && vps->bo)atomic_dec (&vps->bo->base_mapped_count); du->cursor_x = new_state->crtc_x + du->set_gui_x;
@@ -907,12 +924,16 @@ int vmw_du_cursor_plane_atomic_check(struct drm_plane *plane,return -EINVAL ; } -if (!vmw_framebuffer_to_vfb (fb)->bo) +if (!vmw_framebuffer_to_vfb (fb)->bo) { surface =vmw_framebuffer_to_vfbs (fb)->surface; -if (surface && !surface->snooper.image) { -DRM_ERROR ("surface not suitable for cursor\n" ); -return -EINVAL ; +WARN_ON (!surface); + +if (!surface || + (!surface->snooper.image && !surface->res.backup)) { +DRM_ERROR ("surface not suitable for cursor\n" ); +return -EINVAL ; + } }return 0 ;
@@ -1075,10 +1096,10 @@ vmw_du_plane_duplicate_state(struct drm_plane *plane)memset (&vps->cursor,0 ,sizeof (vps->cursor));/* Each ref counted resource needs to be acquired again */ -if (vps->surf !=NULL ) +if (vps->surf) (void )vmw_surface_reference (vps->surf); -if (vps->bo !=NULL ) +if (vps->bo) (void )vmw_bo_reference (vps->bo); state = &vps->base;
@@ -2223,7 +2244,6 @@ int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,struct drm_crtc *crtc;int ret =0 ; -mutex_lock (&dev->mode_config.mutex);if (arg->flags &DRM_VMW_CURSOR_BYPASS_ALL ) {
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +1 -0
@@ -301,6 +301,7 @@ struct vmw_plane_state {/* For CPU Blit */ unsigned int cpp; +bool surf_mapped;struct vmw_cursor_plane_state cursor; };
Signature · 1 line
2.34.1
PATCH v4 9/17 drm/vmwgfx: Diff cursors when using cmds
In reply to Zack RusinFrom: Michael Banack <[email protected]>
Extend the cursor diffing support to support the command-path.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 120 ++++++++++++++-------------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 + 2 files changed, 62 insertions(+), 60 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +60 -60
@@ -53,8 +53,10 @@ void vmw_du_cleanup(struct vmw_display_unit *du)*/ static int vmw_du_cursor_plane_unmap_cm (struct vmw_plane_state *vps); -static void vmw_cursor_write_mobid (struct vmw_private *dev_priv, -struct vmw_plane_state *vps); +static void vmw_cursor_update_mob (struct vmw_private *dev_priv, +struct vmw_plane_state *vps, +u32 *image,u32 width,u32 height, +u32 hotspotX,u32 hotspotY);struct vmw_svga_fifo_cmd_define_cursor {u32 cmd;
@@ -118,7 +120,10 @@ static void vmw_cursor_update_image(struct vmw_private *dev_priv, u32 hotspotX, u32 hotspotY) {if (vps->cursor.bo) -vmw_cursor_write_mobid (dev_priv, vps); +vmw_cursor_update_mob (dev_priv, vps, image, + vps->base.crtc_w, vps->base.crtc_h, + hotspotX, hotspotY); +else vmw_send_define_cursor_cmd (dev_priv, image, width, height, hotspotX, hotspotY);
@@ -163,61 +168,58 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv, alpha_header->height = height;memcpy (header +1 , image, image_size); -} - - -/** -* vmw_cursor_write_mobid - Update cursor via CursorMob mechanism -* -* Called from inside vmw_du_cursor_plane_atomic_update to actually -* make the cursor-image live. -* -* @dev_priv: device to work with -* @vps: DRM plane_state -*/ -static void vmw_cursor_write_mobid (struct vmw_private *dev_priv, -struct vmw_plane_state *vps) -{vmw_write (dev_priv,SVGA_REG_CURSOR_MOBID , vps->cursor.bo->resource->start); } +static u32 vmw_du_cursor_mob_size (u32 w,u32 h) {return w * h *sizeof (u32) +sizeof (SVGAGBCursorHeader); } - -static bool vmw_du_cursor_plane_mob_has_changed (struct vmw_plane_state *old_vps, -struct vmw_plane_state *new_vps) +/** +* vmw_du_cursor_plane_acquire_image -- Acquire the image data +* @vps: cursor plane state +*/ +static u32 *vmw_du_cursor_plane_acquire_image (struct vmw_plane_state *vps) { -void *old_mob; -void *new_mob;bool dummy; -u32 size; - -// If either of them aren't using CursorMobs, assume changed. -if (!old_vps->cursor.bo || !new_vps->cursor.bo) -return true; +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 NULL ; +} -// If either of them failed to map, assume changed. -if (!old_vps->cursor.mapped || !new_vps->cursor.mapped) -return true; +static bool vmw_du_cursor_plane_has_changed (struct vmw_plane_state *old_vps, +struct vmw_plane_state *new_vps) +{ +void *old_image; +void *new_image; +u32 size; +bool changed;if (old_vps->base.crtc_w != new_vps->base.crtc_w || old_vps->base.crtc_h != new_vps->base.crtc_h)return true; - size =vmw_du_cursor_mob_size (new_vps->base.crtc_w, - new_vps->base.crtc_h); +if (old_vps->cursor.hotspot_x != new_vps->cursor.hotspot_x || + old_vps->cursor.hotspot_y != new_vps->cursor.hotspot_y) +return true; - old_mob =ttm_kmap_obj_virtual (&old_vps->cursor.map, &dummy); - new_mob =ttm_kmap_obj_virtual (&new_vps->cursor.map, &dummy); + size = new_vps->base.crtc_w * new_vps->base.crtc_h *sizeof (u32); -if (memcmp (old_mob, new_mob, size) !=0 ) -return true; + old_image =vmw_du_cursor_plane_acquire_image (old_vps); + new_image =vmw_du_cursor_plane_acquire_image (new_vps); -return false; + changed = false; +if (old_image && new_image) + changed =memcmp (old_image, new_image, size) !=0 ; + +return changed; }static void vmw_du_destroy_cursor_mob (struct ttm_buffer_object **bo)
@@ -745,6 +747,7 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,return -ENOMEM ; }else if (vps->surf && !vps->bo && vps->surf->res.backup) { +WARN_ON (vps->surf->snooper.image); ret =ttm_bo_reserve (&vps->surf->res.backup->base, true, false,NULL );if (unlikely (ret !=0 ))
@@ -778,7 +781,6 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,struct vmw_plane_state *old_vps =vmw_plane_state_to_vps (old_state);s32 hotspot_x, hotspot_y;bool dummy; -void *image; hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y;
@@ -796,36 +798,34 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,return ; } + vps->cursor.hotspot_x = hotspot_x; + vps->cursor.hotspot_y = hotspot_y; +if (vps->surf) { du->cursor_age = du->cursor_surface->snooper.age; - image = vps->surf->snooper.image; -if (vps->surf_mapped) - image =vmw_bo_map_and_cache (vps->surf->res.backup); - }else - image =ttm_kmap_obj_virtual (&vps->bo->map, &dummy); - -if (vps->cursor.bo) -vmw_cursor_update_mob (dev_priv, vps, image, - new_state->crtc_w, - new_state->crtc_h, - hotspot_x, hotspot_y); + } -if (!vmw_du_cursor_plane_mob_has_changed (old_vps, vps)) { +if (!vmw_du_cursor_plane_has_changed (old_vps, vps)) {/* * If it hasn't changed, avoid making the device do extra -* work by keeping the old mob active. +* work by keeping the old cursor active. */ struct vmw_cursor_plane_state tmp = old_vps->cursor; old_vps->cursor = vps->cursor; vps->cursor = tmp; - }else if (image) -vmw_cursor_update_image (dev_priv, vps, image, - new_state->crtc_w, - new_state->crtc_h, - hotspot_x, hotspot_y); - -if (image && vps->bo) -atomic_dec (&vps->bo->base_mapped_count); + }else { +void *image =vmw_du_cursor_plane_acquire_image (vps); +if (image) +vmw_cursor_update_image (dev_priv, vps, image, + new_state->crtc_w, + new_state->crtc_h, + 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;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -0
@@ -276,6 +276,8 @@ struct vmw_cursor_plane_state {struct ttm_buffer_object *bo;struct ttm_bo_kmap_obj map;bool mapped; +s32 hotspot_x; +s32 hotspot_y; };/**
Signature · 1 line
2.34.1
PATCH v4 10/17 drm/vmwgfx: Refactor ttm reference object hashtable to use linux/hashtable.
In reply to Zack RusinFrom: Maaz Mombasawala <[email protected]>
This is part of an effort to move from the vmwgfx_open_hash hashtable to linux/hashtable implementation.
Refactor the ref_hash hashtable, used for fast lookup of reference objects associated with a ttm file.
This also exposed a problem related to inconsistently using 32-bit and 64-bit keys with this hashtable. The hash function used changes depending on the size of the type, and results are not consistent across numbers, for example, hash_32(329) = 329, but hash_long(329) = 328. This would cause the lookup to fail for objects already in the hashtable, since keys of different sizes were being passed during adding and lookup. This was not an issue before because vmwgfx_open_hash always used hash_long. Fix this by always using 64-bit keys for this hashtable, which means that hash_long is always used.
--- drivers/gpu/drm/vmwgfx/ttm_object.c | 91 ++++++++++++++++------------- drivers/gpu/drm/vmwgfx/ttm_object.h | 12 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- 3 files changed, 56 insertions(+), 49 deletions(-)
drivers/gpu/drm/vmwgfx/ttm_object.c +50 -41
@@ -52,9 +52,12 @@#include <linux/slab.h> #include <linux/atomic.h> #include <linux/module.h> +#include <linux/hashtable.h> MODULE_IMPORT_NS (DMA_BUF ); +#define VMW_TTM_OBJECT_REF_HT_ORDER 10 +/** * struct ttm_object_file *
@@ -75,7 +78,7 @@ struct ttm_object_file {struct ttm_object_device *tdev;spinlock_t lock;struct list_head ref_list; -struct vmwgfx_open_hash ref_hash; +DECLARE_HASHTABLE (ref_hash,VMW_TTM_OBJECT_REF_HT_ORDER );struct kref refcount; };
@@ -136,6 +139,36 @@ ttm_object_file_ref(struct ttm_object_file *tfile)return tfile; } +static int ttm_tfile_find_ref_rcu (struct ttm_object_file *tfile, +uint64_t key, +struct vmwgfx_hash_item **p_hash) +{ +struct vmwgfx_hash_item *hash; + +hash_for_each_possible_rcu (tfile->ref_hash, hash, head, key) { +if (hash->key == key) { + *p_hash = hash; +return 0 ; + } + } +return -EINVAL ; +} + +static int ttm_tfile_find_ref (struct ttm_object_file *tfile, +uint64_t key, +struct vmwgfx_hash_item **p_hash) +{ +struct vmwgfx_hash_item *hash; + +hash_for_each_possible (tfile->ref_hash, hash, head, key) { +if (hash->key == key) { + *p_hash = hash; +return 0 ; + } + } +return -EINVAL ; +} +static void ttm_object_file_destroy (struct kref *kref) { struct ttm_object_file *tfile =
@@ -238,14 +271,13 @@ void ttm_base_object_unref(struct ttm_base_object **p_base)* Return: A pointer to the object if successful or NULL otherwise. */ struct ttm_base_object * -ttm_base_object_noref_lookup (struct ttm_object_file *tfile,uint32_t key) +ttm_base_object_noref_lookup (struct ttm_object_file *tfile,uint64_t key) {struct vmwgfx_hash_item *hash; -struct vmwgfx_open_hash *ht = &tfile->ref_hash;int ret;rcu_read_lock (); - ret =vmwgfx_ht_find_item_rcu (ht, key, &hash); + ret =ttm_tfile_find_ref_rcu (tfile, key, &hash);if (ret) {rcu_read_unlock ();return NULL ;
@@ -257,15 +289,14 @@ ttm_base_object_noref_lookup(struct ttm_object_file *tfile, uint32_t key)EXPORT_SYMBOL (ttm_base_object_noref_lookup);struct ttm_base_object *ttm_base_object_lookup (struct ttm_object_file *tfile, -uint32_t key) +uint64_t key) {struct ttm_base_object *base =NULL ;struct vmwgfx_hash_item *hash; -struct vmwgfx_open_hash *ht = &tfile->ref_hash;int ret;rcu_read_lock (); - ret =vmwgfx_ht_find_item_rcu (ht, key, &hash); + ret =ttm_tfile_find_ref_rcu (tfile, key, &hash);if (likely (ret ==0 )) { base = drm_hash_entry(hash, struct ttm_ref_object, hash)->obj;
@@ -278,7 +309,7 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, }struct ttm_base_object * -ttm_base_object_lookup_for_ref (struct ttm_object_device *tdev,uint32_t key) +ttm_base_object_lookup_for_ref (struct ttm_object_device *tdev,uint64_t key) {struct ttm_base_object *base;
@@ -297,7 +328,6 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, bool *existed, bool require_existed) { -struct vmwgfx_open_hash *ht = &tfile->ref_hash;struct ttm_ref_object *ref;struct vmwgfx_hash_item *hash;int ret = -EINVAL ;
@@ -310,7 +340,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile,while (ret == -EINVAL ) {rcu_read_lock (); - ret =vmwgfx_ht_find_item_rcu (ht, base->handle, &hash); + ret =ttm_tfile_find_ref_rcu (tfile, base->handle, &hash);if (ret ==0 ) { ref = drm_hash_entry(hash, struct ttm_ref_object, hash);
@@ -335,21 +365,14 @@ int ttm_ref_object_add(struct ttm_object_file *tfile,kref_init (&ref->kref);spin_lock (&tfile->lock); - ret =vmwgfx_ht_insert_item_rcu (ht, &ref->hash); - -if (likely (ret ==0 )) { -list_add_tail (&ref->head, &tfile->ref_list); -kref_get (&base->refcount); -spin_unlock (&tfile->lock); -if (existed !=NULL ) - *existed = false; -break ; - } +hash_add_rcu (tfile->ref_hash, &ref->hash.head, ref->hash.key); + ret =0 ; +list_add_tail (&ref->head, &tfile->ref_list); +kref_get (&base->refcount);spin_unlock (&tfile->lock); -BUG_ON (ret != -EINVAL ); - -kfree (ref); +if (existed !=NULL ) + *existed = false; }return ret;
@@ -361,10 +384,8 @@ ttm_ref_object_release(struct kref *kref)struct ttm_ref_object *ref = container_of(kref, struct ttm_ref_object, kref);struct ttm_object_file *tfile = ref->tfile; -struct vmwgfx_open_hash *ht; - ht = &tfile->ref_hash; - (void )vmwgfx_ht_remove_item_rcu (ht, &ref->hash); +hash_del_rcu (&ref->hash.head);list_del (&ref->head);spin_unlock (&tfile->lock);
@@ -376,13 +397,12 @@ ttm_ref_object_release(struct kref *kref)int ttm_ref_object_base_unref (struct ttm_object_file *tfile,unsigned long key) { -struct vmwgfx_open_hash *ht = &tfile->ref_hash;struct ttm_ref_object *ref;struct vmwgfx_hash_item *hash;int ret;spin_lock (&tfile->lock); - ret =vmwgfx_ht_find_item (ht, key, &hash); + ret =ttm_tfile_find_ref (tfile, key, &hash);if (unlikely (ret !=0 )) {spin_unlock (&tfile->lock);return -EINVAL ;
@@ -414,16 +434,13 @@ void ttm_object_file_release(struct ttm_object_file **p_tfile) }spin_unlock (&tfile->lock); -vmwgfx_ht_remove (&tfile->ref_hash);ttm_object_file_unref (&tfile); } -struct ttm_object_file *ttm_object_file_init (struct ttm_object_device *tdev, -unsigned int hash_order) +struct ttm_object_file *ttm_object_file_init (struct ttm_object_device *tdev) {struct ttm_object_file *tfile =kmalloc (sizeof (*tfile),GFP_KERNEL ); -int ret;if (unlikely (tfile ==NULL ))return NULL ;
@@ -433,17 +450,9 @@ struct ttm_object_file *ttm_object_file_init(struct ttm_object_device *tdev,kref_init (&tfile->refcount);INIT_LIST_HEAD (&tfile->ref_list); - ret =vmwgfx_ht_create (&tfile->ref_hash, hash_order); -if (ret) - goto out_err; +hash_init (tfile->ref_hash);return tfile; -out_err: -vmwgfx_ht_remove (&tfile->ref_hash); - -kfree (tfile); - -return NULL ; } struct ttm_object_device *
drivers/gpu/drm/vmwgfx/ttm_object.h +5 -7
@@ -104,7 +104,7 @@ struct ttm_base_object {struct ttm_object_file *tfile;struct kref refcount;void (*refcount_release) (struct ttm_base_object **base); -u32 handle; +u64 handle;enum ttm_object_type object_type;u32 shareable; };
@@ -164,7 +164,7 @@ extern int ttm_base_object_init(struct ttm_object_file *tfile,*/ extern struct ttm_base_object *ttm_base_object_lookup (struct ttm_object_file - *tfile,uint32_t key); + *tfile,uint64_t key);/** * ttm_base_object_lookup_for_ref
@@ -178,7 +178,7 @@ extern struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file*/ extern struct ttm_base_object * -ttm_base_object_lookup_for_ref (struct ttm_object_device *tdev,uint32_t key); +ttm_base_object_lookup_for_ref (struct ttm_object_device *tdev,uint64_t key);/** * ttm_base_object_unref
@@ -237,14 +237,12 @@ extern int ttm_ref_object_base_unref(struct ttm_object_file *tfile,* ttm_object_file_init - initialize a struct ttm_object file * * @tdev: A struct ttm_object device this file is initialized on. -* @hash_order: Order of the hash table used to hold the reference objects. * * This is typically called by the file_ops::open function. */ extern struct ttm_object_file *ttm_object_file_init (struct ttm_object_device - *tdev, -unsigned int hash_order); + *tdev);/** * ttm_object_file_release - release data held by a ttm_object_file
@@ -312,7 +310,7 @@ extern int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, kfree_rcu(__obj, __prime.base.rhead)struct ttm_base_object * -ttm_base_object_noref_lookup (struct ttm_object_file *tfile,uint32_t key); +ttm_base_object_noref_lookup (struct ttm_object_file *tfile,uint64_t key);/** * ttm_base_object_noref_release - release a base object pointer looked up
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -1
@@ -1242,7 +1242,7 @@ static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)if (unlikely (!vmw_fp))return ret; - vmw_fp->tfile =ttm_object_file_init (dev_priv->tdev,10 ); + vmw_fp->tfile =ttm_object_file_init (dev_priv->tdev);if (unlikely (vmw_fp->tfile ==NULL )) goto out_no_tfile;
Signature · 1 line
2.34.1
PATCH v4 11/17 drm/vmwgfx: Remove vmwgfx_hashtab
In reply to Zack RusinFrom: Maaz Mombasawala <[email protected]>
The vmwgfx driver has migrated from using the hashtable in vmwgfx_hashtab to the linux/hashtable implementation. Remove the vmwgfx_hashtab from the driver.
--- Documentation/gpu/todo.rst | 11 -- drivers/gpu/drm/vmwgfx/Makefile | 2 +- drivers/gpu/drm/vmwgfx/ttm_object.c | 8 +- drivers/gpu/drm/vmwgfx/ttm_object.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.c | 199 --------------------- drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.h | 83 --------- 8 files changed, 12 insertions(+), 303 deletions(-) delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.c delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.h
Documentation/gpu/todo.rst +0 -11
@@ -651,17 +651,6 @@ See drivers/gpu/drm/amd/display/TODO for tasks. Contact: Harry Wentland, Alex Deucher -vmwgfx: Replace hashtable with Linux' implementation ----------------------------------------------------- - -The vmwgfx driver uses its own hashtable implementation. Replace the -code with Linux' implementation and update the callers. It's mostly a -refactoring task, but the interfaces are different. - -Contact: Zack Rusin, Thomas Zimmermann <[email protected]> - -Level: Intermediate - Bootsplash ==========
drivers/gpu/drm/vmwgfx/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_hashtab.o vmwgfx_kms.o vmwgfx_drv.o \ +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_overlay.o vmwgfx_gmrid_manager.o vmwgfx_fence.o \
drivers/gpu/drm/vmwgfx/ttm_object.c +4 -4
@@ -284,7 +284,7 @@ ttm_base_object_noref_lookup(struct ttm_object_file *tfile, uint64_t key) }__release (RCU ); - return drm_hash_entry(hash, struct ttm_ref_object, hash)->obj; + return hlist_entry(hash, struct ttm_ref_object, hash)->obj; }EXPORT_SYMBOL (ttm_base_object_noref_lookup);
@@ -299,7 +299,7 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, ret =ttm_tfile_find_ref_rcu (tfile, key, &hash);if (likely (ret ==0 )) { - base = drm_hash_entry(hash, struct ttm_ref_object, hash)->obj; + base = hlist_entry(hash, struct ttm_ref_object, hash)->obj;if (!kref_get_unless_zero (&base->refcount)) base =NULL ; }
@@ -343,7 +343,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, ret =ttm_tfile_find_ref_rcu (tfile, base->handle, &hash);if (ret ==0 ) { - ref = drm_hash_entry(hash, struct ttm_ref_object, hash); + ref = hlist_entry(hash, struct ttm_ref_object, hash);if (kref_get_unless_zero (&ref->kref)) {rcu_read_unlock ();break ;
@@ -407,7 +407,7 @@ int ttm_ref_object_base_unref(struct ttm_object_file *tfile,spin_unlock (&tfile->lock);return -EINVAL ; } - ref = drm_hash_entry(hash, struct ttm_ref_object, hash); + ref = hlist_entry(hash, struct ttm_ref_object, hash);kref_put (&ref->kref, ttm_ref_object_release);spin_unlock (&tfile->lock);return 0 ;
drivers/gpu/drm/vmwgfx/ttm_object.h +0 -2
@@ -42,8 +42,6 @@#include <linux/list.h> #include <linux/rcupdate.h> -#include "vmwgfx_hashtab.h" -/** * enum ttm_object_type *
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +2 -2
@@ -88,7 +88,7 @@ vmw_cmdbuf_res_lookup(struct vmw_cmdbuf_res_manager *man,hash_for_each_possible_rcu (man->resources, hash, head, key) {if (hash->key == key) - return drm_hash_entry(hash, struct vmw_cmdbuf_res, hash)->res; + return hlist_entry(hash, struct vmw_cmdbuf_res, hash)->res; }return ERR_PTR (-EINVAL ); }
@@ -243,7 +243,7 @@ int vmw_cmdbuf_res_remove(struct vmw_cmdbuf_res_manager *man,hash_for_each_possible_rcu (man->resources, hash, head, key) {if (hash->key == key) { - entry = drm_hash_entry(hash, struct vmw_cmdbuf_res, hash); + entry = hlist_entry(hash, struct vmw_cmdbuf_res, hash);break ; } }
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +5 -1
@@ -43,7 +43,6 @@#include "ttm_object.h" #include "vmwgfx_fence.h" -#include "vmwgfx_hashtab.h" #include "vmwgfx_reg.h" #include "vmwgfx_validation.h"
@@ -104,6 +103,11 @@ struct vmw_fpriv {bool gb_aware;/* user-space is guest-backed aware */ }; +struct vmwgfx_hash_item { +struct hlist_node head; +unsigned long key; +}; +/** * struct vmw_buffer_object - TTM buffer object with vmwgfx additions * @base: The TTM buffer object
drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.c deleted +0 -199
199 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_hashtab.h deleted +0 -83
83 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 12/17 drm/vmwgfx: Do not allow invalid bpp's for dumb buffers
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Dumb buffers allow a very limited set of formats. Basically everything apart from 1, 2 and 4 is expected to return an error. Make vmwgfx follow those guidelines.
This fixes igt's dumb_buffer invalid_bpp test on vmwgfx.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +15 -1
@@ -807,9 +807,23 @@ int vmw_dumb_create(struct drm_file *file_priv, {struct vmw_private *dev_priv =vmw_priv (dev);struct vmw_buffer_object *vbo; +int cpp =DIV_ROUND_UP (args->bpp,8 );int ret; - args->pitch = args->width * ((args->bpp +7 ) /8 ); +switch (cpp) { +case 1 :/* DRM_FORMAT_C8 */ +case 2 :/* DRM_FORMAT_RGB565 */ +case 4 :/* DRM_FORMAT_XRGB8888 */ +break ; +default : +/* +* Dumb buffers don't allow anything else. +* This is tested via IGT's dumb_buffers +*/ +return -EINVAL ; + } + + args->pitch = args->width * cpp; args->size =ALIGN (args->pitch * args->height,PAGE_SIZE ); ret = vmw_gem_object_create_with_handle(dev_priv, file_priv,
Signature · 1 line
2.34.1
PATCH v4 13/17 drm/vmwgfx: Port the framebuffer code to drm fb helpers
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Instead of using vmwgfx specific framebuffer implementation use the drm fb helpers. There's no change in functionality, the only difference is a reduction in the amount of code inside the vmwgfx module.
drm fb helpers do not deal correctly with changes in crtc preferred mode at runtime, but the old fb code wasn't dealing with it either. Same situation applies to high-res fb consoles - the old code was limited to 1176x885 because it was checking for legacy/deprecated memory limites, the drm fb helpers are limited to the initial resolution set on fb due to first problem (drm fb helpers being unable to handle hotplug crtc preferred mode changes).
This also removes the kernel config for disabling fb support which hasn't been used or supported in a very long time.
--- drivers/gpu/drm/vmwgfx/Kconfig | 7 - drivers/gpu/drm/vmwgfx/Makefile | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 58 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 35 +- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 831 ---------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 79 +-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 7 - 7 files changed, 28 insertions(+), 991 deletions(-) delete mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
drivers/gpu/drm/vmwgfx/Kconfig +0 -7
@@ -16,13 +16,6 @@ config DRM_VMWGFX virtual hardware. The compiled module will be called "vmwgfx.ko". -config DRM_VMWGFX_FBCON - depends on DRM_VMWGFX && DRM_FBDEV_EMULATION - bool "Enable framebuffer console under vmwgfx by default" - help - Choose this option if you are shipping a new vmwgfx - userspace driver that supports using the kernel driver. - config DRM_VMWGFX_MKSSTATS bool "Enable mksGuestStats instrumentation of vmwgfx by default" depends on DRM_VMWGFX
drivers/gpu/drm/vmwgfx/Makefile +0 -2
@@ -12,6 +12,4 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ vmwgfx_devcaps.o ttm_object.o vmwgfx_system_manager.o \ vmwgfx_gem.o -vmwgfx-$(CONFIG_DRM_FBDEV_EMULATION) += vmwgfx_fb.o - obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +16 -42
158 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +3 -32
@@ -62,6 +62,9 @@#define VMWGFX_MAX_DISPLAYS 16#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 +#define VMWGFX_MIN_INITIAL_WIDTH 1280 +#define VMWGFX_MIN_INITIAL_HEIGHT 800 +#define VMWGFX_PCI_ID_SVGA2 0x0405#define VMWGFX_PCI_ID_SVGA3 0x0406
@@ -551,7 +554,6 @@ struct vmw_private {* Framebuffer info. */ -void *fb_info;enum vmw_display_unit_type active_display_unit;struct vmw_legacy_display *ldu_priv;struct vmw_overlay *overlay_priv;
@@ -610,8 +612,6 @@ struct vmw_private {struct mutex cmdbuf_mutex;struct mutex binding_mutex; -bool enable_fb; -/** * PM management. */
@@ -1189,35 +1189,6 @@ extern void vmw_generic_waiter_add(struct vmw_private *dev_priv, u32 flag,extern void vmw_generic_waiter_remove (struct vmw_private *dev_priv,u32 flag,int *waiter_count); - -/** -* Kernel framebuffer - vmwgfx_fb.c -*/ - -#ifdef CONFIG_DRM_FBDEV_EMULATION -int vmw_fb_init (struct vmw_private *vmw_priv); -int vmw_fb_close (struct vmw_private *dev_priv); -int vmw_fb_off (struct vmw_private *vmw_priv); -int vmw_fb_on (struct vmw_private *vmw_priv); -#else -static inline int vmw_fb_init (struct vmw_private *vmw_priv) -{ -return 0 ; -} -static inline int vmw_fb_close (struct vmw_private *dev_priv) -{ -return 0 ; -} -static inline int vmw_fb_off (struct vmw_private *vmw_priv) -{ -return 0 ; -} -static inline int vmw_fb_on (struct vmw_private *vmw_priv) -{ -return 0 ; -} -#endif -/** * Kernel modesetting - vmwgfx_kms.c */
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c deleted +0 -831
831 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +9 -70
114 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +0 -7
@@ -462,13 +462,6 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv,struct vmw_surface *surface, bool only_2d, const struct drm_mode_fb_cmd2 *mode_cmd); -int vmw_kms_fbdev_init_data (struct vmw_private *dev_priv, -unsigned unit, -u32 max_width, -u32 max_height, -struct drm_connector **p_con, -struct drm_crtc **p_crtc, -struct drm_display_mode **p_mode);void vmw_guess_mode_timing (struct drm_display_mode *mode);void vmw_kms_update_implicit_fb (struct vmw_private *dev_priv);void vmw_kms_create_implicit_placement_property (struct vmw_private *dev_priv);
Signature · 1 line
2.34.1
PATCH v4 14/17 drm/vmwgfx: Remove explicit and broken vblank handling
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
The explicit vblank handling was never finished. The driver never had the full implementation of vblank and what was there is emulated by DRM when the driver doesn't pretend to be implementing it itself.
Let DRM handle the vblank emulation and stop pretending the driver is doing anything special with vblank. In the future it would make sense to implement helpers for full vblank handling because vkms and amdgpu_vkms already have that code. Exporting it to common helpers and having all three drivers share it would make sense (that would be largely just to allow more of igt to run).
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 3 --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 34 ---------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 8 ------- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 31 +------------------------ drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 26 --------------------- 5 files changed, 1 insertion(+), 101 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0 -3
@@ -1208,9 +1208,6 @@ int vmw_kms_write_svga(struct vmw_private *vmw_priv,bool vmw_kms_validate_mode_vram (struct vmw_private *dev_priv,uint32_t pitch,uint32_t height); -u32 vmw_get_vblank_counter (struct drm_crtc *crtc); -int vmw_enable_vblank (struct drm_crtc *crtc); -void vmw_disable_vblank (struct drm_crtc *crtc); int vmw_kms_present(struct vmw_private *dev_priv, struct drm_file *file_priv, struct vmw_framebuffer *vfb,
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -34
@@ -31,7 +31,6 @@#include <drm/drm_fourcc.h> #include <drm/drm_rect.h> #include <drm/drm_sysfs.h> -#include <drm/drm_vblank.h> #include "vmwgfx_kms.h"
@@ -981,15 +980,6 @@ void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,void vmw_du_crtc_atomic_flush (struct drm_crtc *crtc,struct drm_atomic_state *state) { -struct drm_pending_vblank_event *event = crtc->state->event; - -if (event) { - crtc->state->event =NULL ; - -spin_lock_irq (&crtc->dev->event_lock); -drm_crtc_send_vblank_event (crtc, event); -spin_unlock_irq (&crtc->dev->event_lock); - } }
@@ -2307,30 +2297,6 @@ bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, dev_priv->max_primary_mem : dev_priv->vram_size); } - -/* -* Function called by DRM code called with vbl_lock held. -*/ -u32 vmw_get_vblank_counter (struct drm_crtc *crtc) -{ -return 0 ; -} - -/* -* Function called by DRM code called with vbl_lock held. -*/ -int vmw_enable_vblank (struct drm_crtc *crtc) -{ -return -EINVAL ; -} - -/* -* Function called by DRM code called with vbl_lock held. -*/ -void vmw_disable_vblank (struct drm_crtc *crtc) -{ -} -/** * vmw_du_update_layout - Update the display unit with topology from resolution * plugin and generate DRM uevent
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +0 -8
@@ -28,7 +28,6 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_fourcc.h> -#include <drm/drm_vblank.h> #include "vmwgfx_kms.h"
@@ -235,9 +234,6 @@ static const struct drm_crtc_funcs vmw_legacy_crtc_funcs = { .atomic_duplicate_state = vmw_du_crtc_duplicate_state, .atomic_destroy_state = vmw_du_crtc_destroy_state, .set_config = drm_atomic_helper_set_config, - .get_vblank_counter = vmw_get_vblank_counter, - .enable_vblank = vmw_enable_vblank, - .disable_vblank = vmw_disable_vblank, };
@@ -507,10 +503,6 @@ int vmw_kms_ldu_init_display(struct vmw_private *dev_priv) dev_priv->ldu_priv->last_num_active =0 ; dev_priv->ldu_priv->fb =NULL ; - ret =drm_vblank_init (dev, num_display_units); -if (ret !=0 ) - goto err_free; -vmw_kms_create_implicit_placement_property (dev_priv);for (i =0 ; i < num_display_units; ++i) {
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1 -30
@@ -29,7 +29,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> -#include <drm/drm_vblank.h> #include "vmwgfx_kms.h"
@@ -320,9 +319,6 @@ static const struct drm_crtc_funcs vmw_screen_object_crtc_funcs = { .atomic_destroy_state = vmw_du_crtc_destroy_state, .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip, - .get_vblank_counter = vmw_get_vblank_counter, - .enable_vblank = vmw_enable_vblank, - .disable_vblank = vmw_disable_vblank, };/*
@@ -730,7 +726,6 @@ vmw_sou_primary_plane_atomic_update(struct drm_plane *plane,struct drm_plane_state *old_state =drm_atomic_get_old_plane_state (state, plane);struct drm_plane_state *new_state =drm_atomic_get_new_plane_state (state, plane);struct drm_crtc *crtc = new_state->crtc; -struct drm_pending_vblank_event *event =NULL ;struct vmw_fence_obj *fence =NULL ;int ret;
@@ -754,24 +749,6 @@ vmw_sou_primary_plane_atomic_update(struct drm_plane *plane,return ; } -/* For error case vblank event is send from vmw_du_crtc_atomic_flush */ - event = crtc->state->event; -if (event && fence) { -struct drm_file *file_priv = event->base.file_priv; - - ret =vmw_event_fence_action_queue (file_priv, - fence, - &event->base, - &event->event.vbl.tv_sec, - &event->event.vbl.tv_usec, - true); - -if (unlikely (ret !=0 )) -DRM_ERROR ("Failed to queue event on fence.\n" ); -else - crtc->state->event =NULL ; - } -if (fence)vmw_fence_obj_unreference (&fence); }
@@ -947,18 +924,12 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)int vmw_kms_sou_init_display (struct vmw_private *dev_priv) {struct drm_device *dev = &dev_priv->drm; -int i, ret; +int i;if (!(dev_priv->capabilities &SVGA_CAP_SCREEN_OBJECT_2 )) {return -ENOSYS ; } - ret = -ENOMEM ; - - ret =drm_vblank_init (dev,VMWGFX_NUM_DISPLAY_UNITS ); -if (unlikely (ret !=0 )) -return ret; -for (i =0 ; i <VMWGFX_NUM_DISPLAY_UNITS ; ++i)vmw_sou_init (dev_priv, i);
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +0 -26
@@ -29,7 +29,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> -#include <drm/drm_vblank.h> #include "vmwgfx_kms.h" #include "vmw_surface_cache.h"
@@ -925,9 +924,6 @@ static const struct drm_crtc_funcs vmw_stdu_crtc_funcs = { .atomic_destroy_state = vmw_du_crtc_destroy_state, .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip, - .get_vblank_counter = vmw_get_vblank_counter, - .enable_vblank = vmw_enable_vblank, - .disable_vblank = vmw_disable_vblank, };
@@ -1591,7 +1587,6 @@ vmw_stdu_primary_plane_atomic_update(struct drm_plane *plane,struct vmw_plane_state *vps =vmw_plane_state_to_vps (new_state);struct drm_crtc *crtc = new_state->crtc;struct vmw_screen_target_display_unit *stdu; -struct drm_pending_vblank_event *event;struct vmw_fence_obj *fence =NULL ;struct vmw_private *dev_priv;int ret;
@@ -1640,23 +1635,6 @@ vmw_stdu_primary_plane_atomic_update(struct drm_plane *plane,return ; } -/* In case of error, vblank event is send in vmw_du_crtc_atomic_flush */ - event = crtc->state->event; -if (event && fence) { -struct drm_file *file_priv = event->base.file_priv; - - ret =vmw_event_fence_action_queue (file_priv, - fence, - &event->base, - &event->event.vbl.tv_sec, - &event->event.vbl.tv_usec, - true); -if (ret) -DRM_ERROR ("Failed to queue event on fence.\n" ); -else - crtc->state->event =NULL ; - } -if (fence)vmw_fence_obj_unreference (&fence); }
@@ -1883,10 +1861,6 @@ int vmw_kms_stdu_init_display(struct vmw_private *dev_priv)if (!(dev_priv->capabilities &SVGA_CAP_GBOBJECTS ))return -ENOSYS ; - ret =drm_vblank_init (dev,VMWGFX_NUM_DISPLAY_UNITS ); -if (unlikely (ret !=0 )) -return ret; - dev_priv->active_display_unit = vmw_du_screen_target;for (i =0 ; i <VMWGFX_NUM_DISPLAY_UNITS ; ++i) {
Signature · 1 line
2.34.1
PATCH v4 15/17 drm/vmwgfx: Add a mksstat counter for cotable resizes
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
There's been a lot of cotable resizes on startup which we can track by adding a mks stat to measure both the invocation count and time spent doing cotable resizes.
This is only used if kernel is configured with CONFIG_DRM_VMWGFX_MKSSTATS The stats are collected on the host size inside the vmware-stats.log file.
--- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 13 +++++++++++-- drivers/gpu/drm/vmwgfx/vmwgfx_mksstat.h | 2 ++ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 16 +++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +11 -2
@@ -33,6 +33,7 @@#include <drm/ttm/ttm_placement.h> #include "vmwgfx_drv.h" +#include "vmwgfx_mksstat.h" #include "vmwgfx_resource_priv.h" #include "vmwgfx_so.h"
@@ -395,9 +396,12 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)int ret;size_t i; +MKS_STAT_TIME_DECL (MKSSTAT_KERN_COTABLE_RESIZE ); +MKS_STAT_TIME_PUSH (MKSSTAT_KERN_COTABLE_RESIZE ); + ret =vmw_cotable_readback (res);if (ret) -return ret; + goto out_done; cur_size_read_back = vcotbl->size_read_back; vcotbl->size_read_back = old_size_read_back;
@@ -411,7 +415,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) true, true, vmw_bo_bo_free, &buf);if (ret) {DRM_ERROR ("Failed initializing new cotable MOB.\n" ); -return ret; + goto out_done; } bo = &buf->base;
@@ -485,6 +489,8 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)/* Release the pin acquired in vmw_bo_init */ ttm_bo_unpin (bo); +MKS_STAT_TIME_POP (MKSSTAT_KERN_COTABLE_RESIZE ); +return 0 ; out_map_new:
@@ -494,6 +500,9 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)ttm_bo_unreserve (bo);vmw_bo_unreference (&buf); +out_done: +MKS_STAT_TIME_POP (MKSSTAT_KERN_COTABLE_RESIZE ); +return ret; }
drivers/gpu/drm/vmwgfx/vmwgfx_mksstat.h +2 -0
@@ -29,6 +29,7 @@#define _VMWGFX_MKSSTAT_H_#include <asm/page.h> +#include <linux/kconfig.h> /* Reservation marker for mksstat pid's */ #define MKSSTAT_PID_RESERVED -1
@@ -41,6 +42,7 @@typedef enum {MKSSTAT_KERN_EXECBUF ,/* vmw_execbuf_ioctl */ +MKSSTAT_KERN_COTABLE_RESIZE ,MKSSTAT_KERN_COUNT /* Reserved entry; always last */ }mksstat_kern_stats_t ;
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +9 -7
@@ -85,7 +85,14 @@ struct rpc_channel {u32 cookie_low; }; - +#if IS_ENABLED (CONFIG_DRM_VMWGFX_MKSSTATS ) +/* Kernel mksGuestStats counter names and desciptions; same order as enum mksstat_kern_stats_t */ +static const char *const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT ][2 ] = +{ + {"vmw_execbuf_ioctl" ,"vmw_execbuf_ioctl" }, + {"vmw_cotable_resize" ,"vmw_cotable_resize" }, +}; +#endif /** * vmw_open_channel
@@ -695,12 +702,6 @@ static inline void hypervisor_ppn_remove(PPN64 pfn)/* Header to the text description of mksGuestStat instance descriptor */ #define MKSSTAT_KERNEL_DESCRIPTION "vmwgfx" -/* Kernel mksGuestStats counter names and desciptions; same order as enum mksstat_kern_stats_t */ -static const char *const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT ][2 ] = -{ - {"vmw_execbuf_ioctl" ,"vmw_execbuf_ioctl" }, -}; -/** * mksstat_init_record: Initializes an MKSGuestStatCounter-based record * for the respective mksGuestStat index.
@@ -786,6 +787,7 @@ static int mksstat_init_kern_id(struct page **ppage)/* Set up all kernel-internal counters and corresponding structures */ pstrs_acc = pstrs; pstrs_acc =mksstat_init_record_time (MKSSTAT_KERN_EXECBUF , pstat, pinfo, pstrs_acc); + pstrs_acc =mksstat_init_record_time (MKSSTAT_KERN_COTABLE_RESIZE , pstat, pinfo, pstrs_acc);/* Add new counters above, in their order of appearance in mksstat_kern_stats_t */
Signature · 1 line
2.34.1
PATCH v4 16/17 drm/vmwgfx: Optimize initial sizes of cotables
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
It's important to get the initial size of cotables right because otherwise every app needs to start with a synchronous cotable resize.
This has an measurable impact on system wide performance but is not relevant for long running single full screen apps for which the cotable resizes will happen early in the lifecycle and will continue running just fine.
To eliminate the initial cotable resizes match the initial sizes to what the userspace expects. The actual result of the patch is simply setting the initial size of two of the cotables to a size that will align them to two pages instead of one.
For a piglit run, before:
name | total | per frame | per sec vmw_cotable_resize | 1405 | 0.12 | 1.58 vmw_execbuf_ioctl | 290805 | 25.43 | 326.05
After:
name | total | per frame | per sec vmw_cotable_resize | 4 | 0.00 | 0.00 vmw_execbuf_ioctl | 281673 | 25.10 | 274.68
--- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +14 -2
@@ -73,12 +73,24 @@ struct vmw_cotable_info { bool); }; + +/* +* Getting the initial size right is difficult because it all depends +* on what the userspace is doing. The sizes will be aligned up to +* a PAGE_SIZE so we just want to make sure that for majority of apps +* the initial number of entries doesn't require an immediate resize. +* For all cotables except SVGACOTableDXElementLayoutEntry and +* SVGACOTableDXBlendStateEntry the initial number of entries fits +* within the PAGE_SIZE. For SVGACOTableDXElementLayoutEntry and +* SVGACOTableDXBlendStateEntry we want to reserve two pages, +* because that's what all apps will require initially. +*/ static const struct vmw_cotable_info co_info[] = { {1 ,sizeof (SVGACOTableDXRTViewEntry), &vmw_view_cotable_list_destroy}, {1 ,sizeof (SVGACOTableDXDSViewEntry), &vmw_view_cotable_list_destroy}, {1 ,sizeof (SVGACOTableDXSRViewEntry), &vmw_view_cotable_list_destroy}, - {1 ,sizeof (SVGACOTableDXElementLayoutEntry),NULL }, - {1 ,sizeof (SVGACOTableDXBlendStateEntry),NULL }, + {PAGE_SIZE /sizeof (SVGACOTableDXElementLayoutEntry) +1 ,sizeof (SVGACOTableDXElementLayoutEntry),NULL }, + {PAGE_SIZE /sizeof (SVGACOTableDXBlendStateEntry) +1 ,sizeof (SVGACOTableDXBlendStateEntry),NULL }, {1 ,sizeof (SVGACOTableDXDepthStencilEntry),NULL }, {1 ,sizeof (SVGACOTableDXRasterizerStateEntry),NULL }, {1 ,sizeof (SVGACOTableDXSamplerEntry),NULL },
Signature · 1 line
2.34.1
PATCH v4 17/17 drm/vmwgfx: Fix a sparse warning in kernel docs
In reply to Zack RusinFrom: Zack Rusin <[email protected]>
Fixes a warning about extra docs about a function argument that has been removed a while back:drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:3888: warning: Excess function parameter 'sync_file' description in 'vmw_execbuf_copy_fence_user'
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +0 -1
@@ -3869,7 +3869,6 @@ int vmw_execbuf_fence_commands(struct drm_file *file_priv,* @fence: Pointer to the fenc object. * @fence_handle: User-space fence handle. * @out_fence_fd: exported file descriptor for the fence. -1 if not used -* @sync_file: Only used to clean up in case of an error in this function. * * This function copies fence information to user-space. If copying fails, the * user-space struct drm_vmw_fence_rep::error member is hopefully left
Signature · 1 line
2.34.1