drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c- Extension
.c- Size
- 9390 bytes
- Lines
- 317
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmwgfx_drv.hvmwgfx_resource_priv.hlinux/hashtable.h
Detected Declarations
struct vmw_cmdbuf_resstruct vmw_cmdbuf_res_managerfunction vmw_cmdbuf_res_lookupfunction hash_for_each_possible_rcufunction vmw_cmdbuf_res_freefunction vmw_cmdbuf_res_commitfunction list_for_each_entry_safefunction vmw_cmdbuf_res_revertfunction list_for_each_entry_safefunction vmw_cmdbuf_res_addfunction vmw_cmdbuf_res_removefunction hash_for_each_possible_rcufunction vmw_cmdbuf_res_man_createfunction vmw_cmdbuf_res_man_destroy
Annotated Snippet
struct vmw_cmdbuf_res {
struct vmw_resource *res;
struct vmwgfx_hash_item hash;
struct list_head head;
enum vmw_cmdbuf_res_state state;
struct vmw_cmdbuf_res_manager *man;
};
/**
* struct vmw_cmdbuf_res_manager - Command buffer resource manager.
*
* @resources: Hash table containing staged and committed command buffer
* resources
* @list: List of committed command buffer resources.
* @dev_priv: Pointer to a device private structure.
*
* @resources and @list are protected by the cmdbuf mutex for now.
*/
struct vmw_cmdbuf_res_manager {
DECLARE_HASHTABLE(resources, VMW_CMDBUF_RES_MAN_HT_ORDER);
struct list_head list;
struct vmw_private *dev_priv;
};
/**
* vmw_cmdbuf_res_lookup - Look up a command buffer resource
*
* @man: Pointer to the command buffer resource manager
* @res_type: The resource type, that combined with the user key
* identifies the resource.
* @user_key: The user key.
*
* Returns a valid refcounted struct vmw_resource pointer on success,
* an error pointer on failure.
*/
struct vmw_resource *
vmw_cmdbuf_res_lookup(struct vmw_cmdbuf_res_manager *man,
enum vmw_cmdbuf_res_type res_type,
u32 user_key)
{
struct vmwgfx_hash_item *hash;
unsigned long key = user_key | (res_type << 24);
hash_for_each_possible_rcu(man->resources, hash, head, key) {
if (hash->key == key)
return hlist_entry(hash, struct vmw_cmdbuf_res, hash)->res;
}
return ERR_PTR(-EINVAL);
}
/**
* vmw_cmdbuf_res_free - Free a command buffer resource.
*
* @man: Pointer to the command buffer resource manager
* @entry: Pointer to a struct vmw_cmdbuf_res.
*
* Frees a struct vmw_cmdbuf_res entry and drops its reference to the
* struct vmw_resource.
*/
static void vmw_cmdbuf_res_free(struct vmw_cmdbuf_res_manager *man,
struct vmw_cmdbuf_res *entry)
{
list_del(&entry->head);
hash_del_rcu(&entry->hash.head);
vmw_resource_unreference(&entry->res);
kfree(entry);
}
/**
* vmw_cmdbuf_res_commit - Commit a list of command buffer resource actions
*
* @list: Caller's list of command buffer resource actions.
*
* This function commits a list of command buffer resource
* additions or removals.
* It is typically called when the execbuf ioctl call triggering these
* actions has committed the fifo contents to the device.
*/
void vmw_cmdbuf_res_commit(struct list_head *list)
{
struct vmw_cmdbuf_res *entry, *next;
list_for_each_entry_safe(entry, next, list, head) {
list_del(&entry->head);
if (entry->res->func->commit_notify)
entry->res->func->commit_notify(entry->res,
entry->state);
switch (entry->state) {
case VMW_CMDBUF_RES_ADD:
Annotation
- Immediate include surface: `vmwgfx_drv.h`, `vmwgfx_resource_priv.h`, `linux/hashtable.h`.
- Detected declarations: `struct vmw_cmdbuf_res`, `struct vmw_cmdbuf_res_manager`, `function vmw_cmdbuf_res_lookup`, `function hash_for_each_possible_rcu`, `function vmw_cmdbuf_res_free`, `function vmw_cmdbuf_res_commit`, `function list_for_each_entry_safe`, `function vmw_cmdbuf_res_revert`, `function list_for_each_entry_safe`, `function vmw_cmdbuf_res_add`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.