Lines Matching +full:resource +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * Copyright © 2018-2023 VMware, Inc., Palo Alto, CA., USA
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
37 * struct vmw_dx_streamoutput - Streamoutput resource metadata.
38 * @res: Base resource struct.
39 * @ctx: Non-refcounted context to which @res belong.
41 * @cotable_head: List head for cotable-so_res list.
42 * @id: User-space provided identifier.
43 * @size: User-space provided mob size.
51 u32 id; member
72 .destroy = NULL, /* Command buffer managed resource. */
85 * vmw_dx_streamoutput_unscrub - Reattach the MOB to streamoutput.
86 * @res: The streamoutput resource.
93 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_streamoutput_unscrub()
99 if (!list_empty(&so->cotable_head) || !so->committed ) in vmw_dx_streamoutput_unscrub()
102 cmd = VMW_CMD_CTX_RESERVE(dev_priv, sizeof(*cmd), so->ctx->id); in vmw_dx_streamoutput_unscrub()
104 return -ENOMEM; in vmw_dx_streamoutput_unscrub()
106 cmd->header.id = SVGA_3D_CMD_DX_BIND_STREAMOUTPUT; in vmw_dx_streamoutput_unscrub()
107 cmd->header.size = sizeof(cmd->body); in vmw_dx_streamoutput_unscrub()
108 cmd->body.soid = so->id; in vmw_dx_streamoutput_unscrub()
109 cmd->body.mobid = res->guest_memory_bo->tbo.resource->start; in vmw_dx_streamoutput_unscrub()
110 cmd->body.offsetInBytes = res->guest_memory_offset; in vmw_dx_streamoutput_unscrub()
111 cmd->body.sizeInBytes = so->size; in vmw_dx_streamoutput_unscrub()
114 vmw_cotable_add_resource(so->cotable, &so->cotable_head); in vmw_dx_streamoutput_unscrub()
121 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_streamoutput_create()
125 WARN_ON_ONCE(!so->committed); in vmw_dx_streamoutput_create()
128 mutex_lock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_create()
130 mutex_unlock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_create()
133 res->id = so->id; in vmw_dx_streamoutput_create()
141 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_streamoutput_bind()
142 struct ttm_buffer_object *bo = val_buf->bo; in vmw_dx_streamoutput_bind()
145 if (WARN_ON(bo->resource->mem_type != VMW_PL_MOB)) in vmw_dx_streamoutput_bind()
146 return -EINVAL; in vmw_dx_streamoutput_bind()
148 mutex_lock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_bind()
150 mutex_unlock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_bind()
156 * vmw_dx_streamoutput_scrub - Unbind the MOB from streamoutput.
157 * @res: The streamoutput resource.
163 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_streamoutput_scrub()
170 if (list_empty(&so->cotable_head)) in vmw_dx_streamoutput_scrub()
173 WARN_ON_ONCE(!so->committed); in vmw_dx_streamoutput_scrub()
175 cmd = VMW_CMD_CTX_RESERVE(dev_priv, sizeof(*cmd), so->ctx->id); in vmw_dx_streamoutput_scrub()
177 return -ENOMEM; in vmw_dx_streamoutput_scrub()
179 cmd->header.id = SVGA_3D_CMD_DX_BIND_STREAMOUTPUT; in vmw_dx_streamoutput_scrub()
180 cmd->header.size = sizeof(cmd->body); in vmw_dx_streamoutput_scrub()
181 cmd->body.soid = res->id; in vmw_dx_streamoutput_scrub()
182 cmd->body.mobid = SVGA3D_INVALID_ID; in vmw_dx_streamoutput_scrub()
183 cmd->body.offsetInBytes = 0; in vmw_dx_streamoutput_scrub()
184 cmd->body.sizeInBytes = so->size; in vmw_dx_streamoutput_scrub()
187 res->id = -1; in vmw_dx_streamoutput_scrub()
188 list_del_init(&so->cotable_head); in vmw_dx_streamoutput_scrub()
196 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_streamoutput_unbind()
200 if (WARN_ON(res->guest_memory_bo->tbo.resource->mem_type != VMW_PL_MOB)) in vmw_dx_streamoutput_unbind()
201 return -EINVAL; in vmw_dx_streamoutput_unbind()
203 mutex_lock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_unbind()
205 mutex_unlock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_unbind()
211 vmw_bo_fence_single(val_buf->bo, fence); in vmw_dx_streamoutput_unbind()
222 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_streamoutput_commit_notify()
226 mutex_lock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_commit_notify()
227 vmw_cotable_add_resource(so->cotable, &so->cotable_head); in vmw_dx_streamoutput_commit_notify()
228 so->committed = true; in vmw_dx_streamoutput_commit_notify()
229 res->id = so->id; in vmw_dx_streamoutput_commit_notify()
230 mutex_unlock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_commit_notify()
232 mutex_lock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_commit_notify()
233 list_del_init(&so->cotable_head); in vmw_dx_streamoutput_commit_notify()
234 so->committed = false; in vmw_dx_streamoutput_commit_notify()
235 res->id = -1; in vmw_dx_streamoutput_commit_notify()
236 mutex_unlock(&dev_priv->binding_mutex); in vmw_dx_streamoutput_commit_notify()
241 * vmw_dx_streamoutput_lookup - Do a streamoutput resource lookup by user key.
242 * @man: Command buffer managed resource manager for current context.
243 * @user_key: User-space identifier for lookup.
259 vmw_resource_unreference(&so->cotable); in vmw_dx_streamoutput_res_free()
265 /* Destroyed by user-space cmd buf or as part of context takedown. */ in vmw_dx_streamoutput_hw_destroy()
266 res->id = -1; in vmw_dx_streamoutput_hw_destroy()
270 * vmw_dx_streamoutput_add - Add a streamoutput as a cmd buf managed resource.
271 * @man: Command buffer managed resource manager for current context.
272 * @ctx: Pointer to context resource.
284 struct vmw_private *dev_priv = ctx->dev_priv; in vmw_dx_streamoutput_add()
289 return -ENOMEM; in vmw_dx_streamoutput_add()
292 res = &so->res; in vmw_dx_streamoutput_add()
293 so->ctx = ctx; in vmw_dx_streamoutput_add()
294 so->cotable = vmw_resource_reference in vmw_dx_streamoutput_add()
296 so->id = user_key; in vmw_dx_streamoutput_add()
297 so->committed = false; in vmw_dx_streamoutput_add()
298 INIT_LIST_HEAD(&so->cotable_head); in vmw_dx_streamoutput_add()
310 res->id = so->id; in vmw_dx_streamoutput_add()
311 res->hw_destroy = vmw_dx_streamoutput_hw_destroy; in vmw_dx_streamoutput_add()
320 * vmw_dx_streamoutput_set_size - Sets streamoutput mob size in res struct.
322 * @size: The size provided by user-space to set.
328 so->size = size; in vmw_dx_streamoutput_set_size()
332 * vmw_dx_streamoutput_remove - Stage streamoutput for removal.
333 * @man: Command buffer managed resource manager for current context.
350 * vmw_dx_streamoutput_cotable_list_scrub - cotable unbind_func callback.
361 lockdep_assert_held_once(&dev_priv->binding_mutex); in vmw_dx_streamoutput_cotable_list_scrub()
364 WARN_ON(vmw_dx_streamoutput_scrub(&entry->res)); in vmw_dx_streamoutput_cotable_list_scrub()
366 entry->committed =false; in vmw_dx_streamoutput_cotable_list_scrub()