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.

Dependency Surface

Detected Declarations

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

Implementation Notes