drivers/gpu/drm/vmwgfx/vmwgfx_validation.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c- Extension
.c- Size
- 24170 bytes
- Lines
- 849
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmwgfx_bo.hvmwgfx_drv.hvmwgfx_resource_priv.hvmwgfx_validation.hlinux/slab.h
Detected Declarations
struct vmw_validation_bo_nodestruct vmw_validation_res_nodefunction vmw_validation_mem_allocfunction list_for_each_entry_safefunction vmw_validation_find_bo_dupfunction hash_for_each_possible_rcufunction list_for_each_entryfunction vmw_validation_find_res_dupfunction hash_for_each_possible_rcufunction list_for_each_entryfunction list_for_each_entryfunction vmw_validation_add_bofunction vmw_validation_add_resourcefunction vmw_validation_res_set_dirtyfunction vmw_validation_res_switch_backupfunction vmw_validation_res_reservefunction list_for_each_entryfunction vmw_validation_res_unreservefunction list_for_each_entryfunction list_for_each_entryfunction vmw_validation_bo_validate_singlefunction vmw_validation_bo_validatefunction list_for_each_entryfunction resource_unreservefunction vmw_validation_res_validatefunction list_for_each_entryfunction vmw_validation_drop_htfunction vmw_validation_unref_listsfunction list_for_each_entryfunction vmw_validation_preparefunction vmw_validation_revertfunction vmw_validation_donefunction vmw_validation_add_bofunction vmw_validation_add_resfunction vmw_validation_bo_backoff
Annotated Snippet
struct vmw_validation_bo_node {
struct ttm_validate_buffer base;
struct vmwgfx_hash_item hash;
unsigned int coherent_count;
};
/**
* struct vmw_validation_res_node - Resource validation metadata.
* @head: List head for the resource validation list.
* @hash: A hash entry used for the duplicate detection hash table.
* @res: Reference counted resource pointer.
* @new_guest_memory_bo: Non ref-counted pointer to new guest memory buffer
* to be assigned to a resource.
* @new_guest_memory_offset: Offset into the new backup mob for resources
* that can share MOBs.
* @no_buffer_needed: Kernel does not need to allocate a MOB during validation,
* the command stream provides a mob bind operation.
* @switching_guest_memory_bo: The validation process is switching backup MOB.
* @first_usage: True iff the resource has been seen only once in the current
* validation batch.
* @reserved: Whether the resource is currently reserved by this process.
* @dirty_set: Change dirty status of the resource.
* @dirty: Dirty information VMW_RES_DIRTY_XX.
* @private: Optionally additional memory for caller-private data.
*
* Bit fields are used since these structures are allocated and freed in
* large numbers and space conservation is desired.
*/
struct vmw_validation_res_node {
struct list_head head;
struct vmwgfx_hash_item hash;
struct vmw_resource *res;
struct vmw_bo *new_guest_memory_bo;
unsigned long new_guest_memory_offset;
u32 no_buffer_needed : 1;
u32 switching_guest_memory_bo : 1;
u32 first_usage : 1;
u32 reserved : 1;
u32 dirty : 1;
u32 dirty_set : 1;
unsigned long private[];
};
/**
* vmw_validation_mem_alloc - Allocate kernel memory from the validation
* context based allocator
* @ctx: The validation context
* @size: The number of bytes to allocated.
*
* The memory allocated may not exceed PAGE_SIZE, and the returned
* address is aligned to sizeof(long). All memory allocated this way is
* reclaimed after validation when calling any of the exported functions:
* vmw_validation_unref_lists()
* vmw_validation_revert()
* vmw_validation_done()
*
* Return: Pointer to the allocated memory on success. NULL on failure.
*/
void *vmw_validation_mem_alloc(struct vmw_validation_context *ctx,
unsigned int size)
{
void *addr;
size = vmw_validation_align(size);
if (size > PAGE_SIZE)
return NULL;
if (ctx->mem_size_left < size) {
struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (!page)
return NULL;
list_add_tail(&page->lru, &ctx->page_list);
ctx->page_address = page_address(page);
ctx->mem_size_left = PAGE_SIZE;
}
addr = (void *) (ctx->page_address + (PAGE_SIZE - ctx->mem_size_left));
ctx->mem_size_left -= size;
return addr;
}
/**
* vmw_validation_mem_free - Free all memory allocated using
* vmw_validation_mem_alloc()
* @ctx: The validation context
*
* All memory previously allocated for this context using
* vmw_validation_mem_alloc() is freed.
*/
Annotation
- Immediate include surface: `vmwgfx_bo.h`, `vmwgfx_drv.h`, `vmwgfx_resource_priv.h`, `vmwgfx_validation.h`, `linux/slab.h`.
- Detected declarations: `struct vmw_validation_bo_node`, `struct vmw_validation_res_node`, `function vmw_validation_mem_alloc`, `function list_for_each_entry_safe`, `function vmw_validation_find_bo_dup`, `function hash_for_each_possible_rcu`, `function list_for_each_entry`, `function vmw_validation_find_res_dup`, `function hash_for_each_possible_rcu`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.