Lines Matching +full:resource +full:- +full:files
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * Copyright 2014-2022 VMware, Inc., Palo Alto, CA., USA
7 * copy of this software and associated documentation files (the
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
36 * struct vmw_cmdbuf_res - Command buffer managed resource entry.
42 * @state: Staging state of this resource entry.
43 * @man: Pointer to a resource manager for this entry.
54 * struct vmw_cmdbuf_res_manager - Command buffer resource manager.
71 * vmw_cmdbuf_res_lookup - Look up a command buffer resource
73 * @man: Pointer to the command buffer resource manager
74 * @res_type: The resource type, that combined with the user key
75 * identifies the resource.
89 hash_for_each_possible_rcu(man->resources, hash, head, key) { in vmw_cmdbuf_res_lookup()
90 if (hash->key == key) in vmw_cmdbuf_res_lookup()
91 return hlist_entry(hash, struct vmw_cmdbuf_res, hash)->res; in vmw_cmdbuf_res_lookup()
93 return ERR_PTR(-EINVAL); in vmw_cmdbuf_res_lookup()
97 * vmw_cmdbuf_res_free - Free a command buffer resource.
99 * @man: Pointer to the command buffer resource manager
108 list_del(&entry->head); in vmw_cmdbuf_res_free()
109 hash_del_rcu(&entry->hash.head); in vmw_cmdbuf_res_free()
110 vmw_resource_unreference(&entry->res); in vmw_cmdbuf_res_free()
115 * vmw_cmdbuf_res_commit - Commit a list of command buffer resource actions
117 * @list: Caller's list of command buffer resource actions.
119 * This function commits a list of command buffer resource
129 list_del(&entry->head); in vmw_cmdbuf_res_commit()
130 if (entry->res->func->commit_notify) in vmw_cmdbuf_res_commit()
131 entry->res->func->commit_notify(entry->res, in vmw_cmdbuf_res_commit()
132 entry->state); in vmw_cmdbuf_res_commit()
133 switch (entry->state) { in vmw_cmdbuf_res_commit()
135 entry->state = VMW_CMDBUF_RES_COMMITTED; in vmw_cmdbuf_res_commit()
136 list_add_tail(&entry->head, &entry->man->list); in vmw_cmdbuf_res_commit()
139 vmw_resource_unreference(&entry->res); in vmw_cmdbuf_res_commit()
150 * vmw_cmdbuf_res_revert - Revert a list of command buffer resource actions
152 * @list: Caller's list of command buffer resource action
154 * This function reverts a list of command buffer resource
165 switch (entry->state) { in vmw_cmdbuf_res_revert()
167 vmw_cmdbuf_res_free(entry->man, entry); in vmw_cmdbuf_res_revert()
170 hash_add_rcu(entry->man->resources, &entry->hash.head, in vmw_cmdbuf_res_revert()
171 entry->hash.key); in vmw_cmdbuf_res_revert()
172 list_move_tail(&entry->head, &entry->man->list); in vmw_cmdbuf_res_revert()
173 entry->state = VMW_CMDBUF_RES_COMMITTED; in vmw_cmdbuf_res_revert()
183 * vmw_cmdbuf_res_add - Stage a command buffer managed resource for addition.
185 * @man: Pointer to the command buffer resource manager.
186 * @res_type: The resource type.
187 * @user_key: The user-space id of the resource.
192 * resource to the hash table of the manager identified by @man. The
205 return -ENOMEM; in vmw_cmdbuf_res_add()
207 cres->hash.key = user_key | (res_type << 24); in vmw_cmdbuf_res_add()
208 hash_add_rcu(man->resources, &cres->hash.head, cres->hash.key); in vmw_cmdbuf_res_add()
210 cres->state = VMW_CMDBUF_RES_ADD; in vmw_cmdbuf_res_add()
211 cres->res = vmw_resource_reference(res); in vmw_cmdbuf_res_add()
212 cres->man = man; in vmw_cmdbuf_res_add()
213 list_add_tail(&cres->head, list); in vmw_cmdbuf_res_add()
219 * vmw_cmdbuf_res_remove - Stage a command buffer managed resource for removal.
221 * @man: Pointer to the command buffer resource manager.
222 * @res_type: The resource type.
223 * @user_key: The user-space id of the resource.
225 * @res_p: If the resource is in an already committed state, points to the
227 * non ref-counted.
244 hash_for_each_possible_rcu(man->resources, hash, head, key) { in vmw_cmdbuf_res_remove()
245 if (hash->key == key) { in vmw_cmdbuf_res_remove()
251 return -EINVAL; in vmw_cmdbuf_res_remove()
253 switch (entry->state) { in vmw_cmdbuf_res_remove()
259 hash_del_rcu(&entry->hash.head); in vmw_cmdbuf_res_remove()
260 list_del(&entry->head); in vmw_cmdbuf_res_remove()
261 entry->state = VMW_CMDBUF_RES_DEL; in vmw_cmdbuf_res_remove()
262 list_add_tail(&entry->head, list); in vmw_cmdbuf_res_remove()
263 *res_p = entry->res; in vmw_cmdbuf_res_remove()
274 * vmw_cmdbuf_res_man_create - Allocate a command buffer managed resource
279 * Allocates and initializes a command buffer managed resource manager. Returns
289 return ERR_PTR(-ENOMEM); in vmw_cmdbuf_res_man_create()
291 man->dev_priv = dev_priv; in vmw_cmdbuf_res_man_create()
292 INIT_LIST_HEAD(&man->list); in vmw_cmdbuf_res_man_create()
293 hash_init(man->resources); in vmw_cmdbuf_res_man_create()
298 * vmw_cmdbuf_res_man_destroy - Destroy a command buffer managed resource
303 * This function destroys a command buffer managed resource manager and
304 * unreferences / frees all command buffer managed resources and -entries
311 list_for_each_entry_safe(entry, next, &man->list, head) in vmw_cmdbuf_res_man_destroy()