Lines Matching +full:hardware +full:- +full:protected
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
3 * Copyright 2014-2015 VMware, Inc., Palo Alto, CA., USA
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
35 * destroy a hardware surface, all views pointing to it must also be destroyed,
44 * struct vmw_view - view metadata
48 * @ctx: Non-refcounted pointer to the context this view belongs to.
51 * @srf_head: List head for the surface-to-view list.
52 * @cotable_head: List head for the cotable-to_view list.
54 * @view_id: User-space per context view id. Currently used also as per
68 struct list_head srf_head; /* Protected by binding_mutex */
69 struct list_head cotable_head; /* Protected by binding_mutex */
73 bool committed; /* Protected by binding_mutex */
95 * struct vmw_view_define - view define command body stub
109 * vmw_view - Convert a struct vmw_resource to a struct vmw_view
121 * vmw_view_commit_notify - Notify that a view operation has been committed to
122 * hardware from a user-supplied command stream.
132 struct vmw_private *dev_priv = res->dev_priv; in vmw_view_commit_notify()
134 mutex_lock(&dev_priv->binding_mutex); in vmw_view_commit_notify()
136 struct vmw_surface *srf = vmw_res_to_srf(view->srf); in vmw_view_commit_notify()
138 list_add_tail(&view->srf_head, &srf->view_list); in vmw_view_commit_notify()
139 vmw_cotable_add_resource(view->cotable, &view->cotable_head); in vmw_view_commit_notify()
140 view->committed = true; in vmw_view_commit_notify()
141 res->id = view->view_id; in vmw_view_commit_notify()
144 list_del_init(&view->cotable_head); in vmw_view_commit_notify()
145 list_del_init(&view->srf_head); in vmw_view_commit_notify()
146 view->committed = false; in vmw_view_commit_notify()
147 res->id = -1; in vmw_view_commit_notify()
149 mutex_unlock(&dev_priv->binding_mutex); in vmw_view_commit_notify()
153 * vmw_view_create - Create a hardware view.
157 * Create a hardware view. Typically used if that view has previously been
163 struct vmw_surface *srf = vmw_res_to_srf(view->srf); in vmw_view_create()
164 struct vmw_private *dev_priv = res->dev_priv; in vmw_view_create()
170 mutex_lock(&dev_priv->binding_mutex); in vmw_view_create()
171 if (!view->committed) { in vmw_view_create()
172 mutex_unlock(&dev_priv->binding_mutex); in vmw_view_create()
176 cmd = VMW_CMD_CTX_RESERVE(res->dev_priv, view->cmd_size, view->ctx->id); in vmw_view_create()
178 mutex_unlock(&dev_priv->binding_mutex); in vmw_view_create()
179 return -ENOMEM; in vmw_view_create()
182 memcpy(cmd, &view->cmd, view->cmd_size); in vmw_view_create()
183 WARN_ON(cmd->body.view_id != view->view_id); in vmw_view_create()
185 WARN_ON(view->srf->id == SVGA3D_INVALID_ID); in vmw_view_create()
186 cmd->body.sid = view->srf->id; in vmw_view_create()
187 vmw_cmd_commit(res->dev_priv, view->cmd_size); in vmw_view_create()
188 res->id = view->view_id; in vmw_view_create()
189 list_add_tail(&view->srf_head, &srf->view_list); in vmw_view_create()
190 vmw_cotable_add_resource(view->cotable, &view->cotable_head); in vmw_view_create()
191 mutex_unlock(&dev_priv->binding_mutex); in vmw_view_create()
197 * vmw_view_destroy - Destroy a hardware view.
201 * Destroy a hardware view. Typically used on unexpected termination of the
206 struct vmw_private *dev_priv = res->dev_priv; in vmw_view_destroy()
213 lockdep_assert_held_once(&dev_priv->binding_mutex); in vmw_view_destroy()
214 vmw_binding_res_list_scrub(&res->binding_head); in vmw_view_destroy()
216 if (!view->committed || res->id == -1) in vmw_view_destroy()
219 cmd = VMW_CMD_CTX_RESERVE(dev_priv, sizeof(*cmd), view->ctx->id); in vmw_view_destroy()
221 return -ENOMEM; in vmw_view_destroy()
223 cmd->header.id = vmw_view_destroy_cmds[view->view_type]; in vmw_view_destroy()
224 cmd->header.size = sizeof(cmd->body); in vmw_view_destroy()
225 cmd->body.view_id = view->view_id; in vmw_view_destroy()
227 res->id = -1; in vmw_view_destroy()
228 list_del_init(&view->cotable_head); in vmw_view_destroy()
229 list_del_init(&view->srf_head); in vmw_view_destroy()
235 * vmw_hw_view_destroy - Destroy a hardware view as part of resource cleanup.
239 * Destroy a hardware view if it's still present.
243 struct vmw_private *dev_priv = res->dev_priv; in vmw_hw_view_destroy()
245 mutex_lock(&dev_priv->binding_mutex); in vmw_hw_view_destroy()
247 res->id = -1; in vmw_hw_view_destroy()
248 mutex_unlock(&dev_priv->binding_mutex); in vmw_hw_view_destroy()
252 * vmw_view_key - Compute a view key suitable for the cmdbuf resource manager
254 * @user_key: The user-space id used for the view.
257 * Destroy a hardware view if it's still present.
265 * vmw_view_id_ok - Basic view id and type range checks.
267 * @user_key: The user-space id used for the view.
270 * Checks that the view id and type (typically provided by user-space) is
280 * vmw_view_res_free - resource res_free callback for view resources
290 vmw_resource_unreference(&view->cotable); in vmw_view_res_free()
291 vmw_resource_unreference(&view->srf); in vmw_view_res_free()
296 * vmw_view_add - Create a view resource and stage it for addition
326 struct vmw_private *dev_priv = ctx->dev_priv; in vmw_view_add()
335 return -EINVAL; in vmw_view_add()
340 return -EINVAL; in vmw_view_add()
347 return -ENOMEM; in vmw_view_add()
350 res = &view->res; in vmw_view_add()
351 view->ctx = ctx; in vmw_view_add()
352 view->srf = vmw_resource_reference(srf); in vmw_view_add()
353 view->cotable = vmw_resource_reference in vmw_view_add()
355 view->view_type = view_type; in vmw_view_add()
356 view->view_id = user_key; in vmw_view_add()
357 view->cmd_size = cmd_size; in vmw_view_add()
358 view->committed = false; in vmw_view_add()
359 INIT_LIST_HEAD(&view->srf_head); in vmw_view_add()
360 INIT_LIST_HEAD(&view->cotable_head); in vmw_view_add()
361 memcpy(&view->cmd, cmd, cmd_size); in vmw_view_add()
373 res->id = view->view_id; in vmw_view_add()
374 res->hw_destroy = vmw_hw_view_destroy; in vmw_view_add()
383 * vmw_view_remove - Stage a view for removal.
392 * non ref-counted.
401 return -EINVAL; in vmw_view_remove()
410 * vmw_view_cotable_list_destroy - Evict all views belonging to a cotable.
427 lockdep_assert_held_once(&dev_priv->binding_mutex); in vmw_view_cotable_list_destroy()
430 WARN_ON(vmw_view_destroy(&entry->res)); in vmw_view_cotable_list_destroy()
434 * vmw_view_surface_list_destroy - Evict all views pointing to a surface
447 lockdep_assert_held_once(&dev_priv->binding_mutex); in vmw_view_surface_list_destroy()
450 WARN_ON(vmw_view_destroy(&entry->res)); in vmw_view_surface_list_destroy()
454 * vmw_view_srf - Return a non-refcounted pointer to the surface a view is
464 return vmw_view(res)->srf; in vmw_view_srf()
468 * vmw_view_lookup - Look up a view.
485 * vmw_view_dirtying - Return whether a view type is dirtying its resource
491 * GPU operation. Currently only rendertarget-, depth-stencil and unordered
506 return view_is_dirtying[vmw_view(res)->view_type]; in vmw_view_dirtying()
539 * This function is unused at run-time, and only used to dump various build
560 BUILD_BUG_ON(SVGA_COTABLE_MAX_IDS >= ((1 << 20) - 1)); in vmw_so_build_asserts()