drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c- Extension
.c- Size
- 31884 bytes
- Lines
- 1162
- 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
drm/ttm/ttm_placement.hvmwgfx_binding.hvmwgfx_bo.hvmwgfx_drv.hvmwgfx_resource_priv.h
Detected Declarations
function Copyrightfunction vmw_resource_mob_detachfunction vmw_resource_reference_unless_doomedfunction vmw_resource_release_idfunction vmw_resource_releasefunction vmw_resource_unreferencefunction vmw_resource_alloc_idfunction vmw_resource_initfunction vmw_user_resource_lookup_handlefunction vmw_user_object_lookupfunction vmw_resource_buf_allocfunction vmw_resource_do_validatefunction vmw_resource_unreservefunction vmw_resource_check_bufferfunction vmw_resource_reservefunction vmw_resource_backoff_reservationfunction vmw_resource_do_evictfunction vmw_resource_validatefunction vmw_resource_unbind_listfunction vmw_query_readback_allfunction vmw_query_move_notifyfunction vmw_resource_needs_backupfunction vmw_resource_evict_typefunction vmw_resource_evict_allfunction vmw_resource_pinfunction vmw_resource_unpinfunction vmw_res_typefunction vmw_resource_dirty_updatefunction vmw_resource_cleanfunction vmw_resources_clean
Annotated Snippet
if (res->guest_memory_bo->dirty && !res->dirty) {
ret = func->dirty_alloc(res);
if (ret)
return ret;
} else if (!res->guest_memory_bo->dirty && res->dirty) {
func->dirty_free(res);
}
}
/*
* Transfer the dirty regions to the resource and update
* the resource.
*/
if (res->dirty) {
if (dirtying && !res->res_dirty) {
pgoff_t start = res->guest_memory_offset >> PAGE_SHIFT;
pgoff_t end = __KERNEL_DIV_ROUND_UP
(res->guest_memory_offset + res->guest_memory_size,
PAGE_SIZE);
vmw_bo_dirty_unmap(res->guest_memory_bo, start, end);
}
vmw_bo_dirty_transfer_to_res(res);
return func->dirty_sync(res);
}
return 0;
out_bind_failed:
func->destroy(res);
return ret;
}
/**
* vmw_resource_unreserve - Unreserve a resource previously reserved for
* command submission.
*
* @res: Pointer to the struct vmw_resource to unreserve.
* @dirty_set: Change dirty status of the resource.
* @dirty: When changing dirty status indicates the new status.
* @switch_guest_memory: Guest memory buffer has been switched.
* @new_guest_memory_bo: Pointer to new guest memory buffer if command submission
* switched. May be NULL.
* @new_guest_memory_offset: New gbo offset if @switch_guest_memory is true.
*
* Currently unreserving a resource means putting it back on the device's
* resource lru list, so that it can be evicted if necessary.
*/
void vmw_resource_unreserve(struct vmw_resource *res,
bool dirty_set,
bool dirty,
bool switch_guest_memory,
struct vmw_bo *new_guest_memory_bo,
unsigned long new_guest_memory_offset)
{
struct vmw_private *dev_priv = res->dev_priv;
if (!list_empty(&res->lru_head))
return;
if (switch_guest_memory && new_guest_memory_bo != res->guest_memory_bo) {
if (res->guest_memory_bo) {
vmw_resource_mob_detach(res);
if (res->coherent)
vmw_bo_dirty_release(res->guest_memory_bo);
vmw_user_bo_unref(&res->guest_memory_bo);
}
if (new_guest_memory_bo) {
res->guest_memory_bo = vmw_user_bo_ref(new_guest_memory_bo);
/*
* The validation code should already have added a
* dirty tracker here.
*/
WARN_ON(res->coherent && !new_guest_memory_bo->dirty);
vmw_resource_mob_attach(res);
} else {
res->guest_memory_bo = NULL;
}
} else if (switch_guest_memory && res->coherent) {
vmw_bo_dirty_release(res->guest_memory_bo);
}
if (switch_guest_memory)
res->guest_memory_offset = new_guest_memory_offset;
Annotation
- Immediate include surface: `drm/ttm/ttm_placement.h`, `vmwgfx_binding.h`, `vmwgfx_bo.h`, `vmwgfx_drv.h`, `vmwgfx_resource_priv.h`.
- Detected declarations: `function Copyright`, `function vmw_resource_mob_detach`, `function vmw_resource_reference_unless_doomed`, `function vmw_resource_release_id`, `function vmw_resource_release`, `function vmw_resource_unreference`, `function vmw_resource_alloc_id`, `function vmw_resource_init`, `function vmw_user_resource_lookup_handle`, `function vmw_user_object_lookup`.
- 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.