![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 0002 /************************************************************************** 0003 * 0004 * Copyright 2012-2014 VMware, Inc., Palo Alto, CA., USA 0005 * 0006 * Permission is hereby granted, free of charge, to any person obtaining a 0007 * copy of this software and associated documentation files (the 0008 * "Software"), to deal in the Software without restriction, including 0009 * without limitation the rights to use, copy, modify, merge, publish, 0010 * distribute, sub license, and/or sell copies of the Software, and to 0011 * permit persons to whom the Software is furnished to do so, subject to 0012 * the following conditions: 0013 * 0014 * The above copyright notice and this permission notice (including the 0015 * next paragraph) shall be included in all copies or substantial portions 0016 * of the Software. 0017 * 0018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0020 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 0021 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 0022 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 0023 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 0024 * USE OR OTHER DEALINGS IN THE SOFTWARE. 0025 * 0026 **************************************************************************/ 0027 0028 #ifndef _VMWGFX_RESOURCE_PRIV_H_ 0029 #define _VMWGFX_RESOURCE_PRIV_H_ 0030 0031 #include "vmwgfx_drv.h" 0032 0033 /* 0034 * Extra memory required by the resource id's ida storage, which is allocated 0035 * separately from the base object itself. We estimate an on-average 128 bytes 0036 * per ida. 0037 */ 0038 #define VMW_IDA_ACC_SIZE 128 0039 0040 enum vmw_cmdbuf_res_state { 0041 VMW_CMDBUF_RES_COMMITTED, 0042 VMW_CMDBUF_RES_ADD, 0043 VMW_CMDBUF_RES_DEL 0044 }; 0045 0046 /** 0047 * struct vmw_user_resource_conv - Identify a derived user-exported resource 0048 * type and provide a function to convert its ttm_base_object pointer to 0049 * a struct vmw_resource 0050 */ 0051 struct vmw_user_resource_conv { 0052 enum ttm_object_type object_type; 0053 struct vmw_resource *(*base_obj_to_res)(struct ttm_base_object *base); 0054 void (*res_free) (struct vmw_resource *res); 0055 }; 0056 0057 /** 0058 * struct vmw_res_func - members and functions common for a resource type 0059 * 0060 * @res_type: Enum that identifies the lru list to use for eviction. 0061 * @needs_backup: Whether the resource is guest-backed and needs 0062 * persistent buffer storage. 0063 * @type_name: String that identifies the resource type. 0064 * @backup_placement: TTM placement for backup buffers. 0065 * @may_evict Whether the resource may be evicted. 0066 * @create: Create a hardware resource. 0067 * @destroy: Destroy a hardware resource. 0068 * @bind: Bind a hardware resource to persistent buffer storage. 0069 * @unbind: Unbind a hardware resource from persistent 0070 * buffer storage. 0071 * @commit_notify: If the resource is a command buffer managed resource, 0072 * callback to notify that a define or remove command 0073 * has been committed to the device. 0074 * @dirty_alloc: Allocate a dirty tracker. NULL if dirty-tracking is not 0075 * supported. 0076 * @dirty_free: Free the dirty tracker. 0077 * @dirty_sync: Upload the dirty mob contents to the resource. 0078 * @dirty_add_range: Add a sequential dirty range to the resource 0079 * dirty tracker. 0080 * @clean: Clean the resource. 0081 */ 0082 struct vmw_res_func { 0083 enum vmw_res_type res_type; 0084 bool needs_backup; 0085 const char *type_name; 0086 struct ttm_placement *backup_placement; 0087 bool may_evict; 0088 u32 prio; 0089 u32 dirty_prio; 0090 0091 int (*create) (struct vmw_resource *res); 0092 int (*destroy) (struct vmw_resource *res); 0093 int (*bind) (struct vmw_resource *res, 0094 struct ttm_validate_buffer *val_buf); 0095 int (*unbind) (struct vmw_resource *res, 0096 bool readback, 0097 struct ttm_validate_buffer *val_buf); 0098 void (*commit_notify)(struct vmw_resource *res, 0099 enum vmw_cmdbuf_res_state state); 0100 int (*dirty_alloc)(struct vmw_resource *res); 0101 void (*dirty_free)(struct vmw_resource *res); 0102 int (*dirty_sync)(struct vmw_resource *res); 0103 void (*dirty_range_add)(struct vmw_resource *res, size_t start, 0104 size_t end); 0105 int (*clean)(struct vmw_resource *res); 0106 }; 0107 0108 /** 0109 * struct vmw_simple_resource_func - members and functions common for the 0110 * simple resource helpers. 0111 * @res_func: struct vmw_res_func as described above. 0112 * @ttm_res_type: TTM resource type used for handle recognition. 0113 * @size: Size of the simple resource information struct. 0114 * @init: Initialize the simple resource information. 0115 * @hw_destroy: A resource hw_destroy function. 0116 * @set_arg_handle: Set the handle output argument of the ioctl create struct. 0117 */ 0118 struct vmw_simple_resource_func { 0119 const struct vmw_res_func res_func; 0120 int ttm_res_type; 0121 size_t size; 0122 int (*init)(struct vmw_resource *res, void *data); 0123 void (*hw_destroy)(struct vmw_resource *res); 0124 void (*set_arg_handle)(void *data, u32 handle); 0125 }; 0126 0127 /** 0128 * struct vmw_simple_resource - Kernel only side simple resource 0129 * @res: The resource we derive from. 0130 * @func: The method and member virtual table. 0131 */ 0132 struct vmw_simple_resource { 0133 struct vmw_resource res; 0134 const struct vmw_simple_resource_func *func; 0135 }; 0136 0137 int vmw_resource_alloc_id(struct vmw_resource *res); 0138 void vmw_resource_release_id(struct vmw_resource *res); 0139 int vmw_resource_init(struct vmw_private *dev_priv, struct vmw_resource *res, 0140 bool delay_id, 0141 void (*res_free) (struct vmw_resource *res), 0142 const struct vmw_res_func *func); 0143 int 0144 vmw_simple_resource_create_ioctl(struct drm_device *dev, 0145 void *data, 0146 struct drm_file *file_priv, 0147 const struct vmw_simple_resource_func *func); 0148 struct vmw_resource * 0149 vmw_simple_resource_lookup(struct ttm_object_file *tfile, 0150 uint32_t handle, 0151 const struct vmw_simple_resource_func *func); 0152 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |