drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c- Extension
.c- Size
- 6845 bytes
- Lines
- 232
- 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.h
Detected Declarations
struct vmw_user_simple_resourcefunction vmw_simple_resource_initfunction vmw_simple_resource_freefunction vmw_simple_resource_base_releasefunction vmw_simple_resource_create_ioctlfunction vmw_simple_resource_lookup
Annotated Snippet
struct vmw_user_simple_resource {
struct ttm_base_object base;
struct vmw_simple_resource simple;
/*
* Nothing to be placed after @simple, since size of @simple is
* unknown.
*/
};
/**
* vmw_simple_resource_init - Initialize a simple resource object.
*
* @dev_priv: Pointer to a struct device private.
* @simple: The struct vmw_simple_resource to initialize.
* @data: Data passed to the information initialization function.
* @res_free: Function pointer to destroy the simple resource.
*
* Returns:
* 0 if succeeded.
* Negative error value if error, in which case the resource will have been
* freed.
*/
static int vmw_simple_resource_init(struct vmw_private *dev_priv,
struct vmw_simple_resource *simple,
void *data,
void (*res_free)(struct vmw_resource *res))
{
struct vmw_resource *res = &simple->res;
int ret;
ret = vmw_resource_init(dev_priv, res, false, res_free,
&simple->func->res_func);
if (ret) {
res_free(res);
return ret;
}
ret = simple->func->init(res, data);
if (ret) {
vmw_resource_unreference(&res);
return ret;
}
simple->res.hw_destroy = simple->func->hw_destroy;
return 0;
}
/**
* vmw_simple_resource_free - Free a simple resource object.
*
* @res: The struct vmw_resource member of the simple resource object.
*
* Frees memory for the object.
*/
static void vmw_simple_resource_free(struct vmw_resource *res)
{
struct vmw_user_simple_resource *usimple =
container_of(res, struct vmw_user_simple_resource,
simple.res);
ttm_base_object_kfree(usimple, base);
}
/**
* vmw_simple_resource_base_release - TTM object release callback
*
* @p_base: The struct ttm_base_object member of the simple resource object.
*
* Called when the last reference to the embedded struct ttm_base_object is
* gone. Typically results in an object free, unless there are other
* references to the embedded struct vmw_resource.
*/
static void vmw_simple_resource_base_release(struct ttm_base_object **p_base)
{
struct ttm_base_object *base = *p_base;
struct vmw_user_simple_resource *usimple =
container_of(base, struct vmw_user_simple_resource, base);
struct vmw_resource *res = &usimple->simple.res;
*p_base = NULL;
vmw_resource_unreference(&res);
}
/**
* vmw_simple_resource_create_ioctl - Helper to set up an ioctl function to
* create a struct vmw_simple_resource.
*
Annotation
- Immediate include surface: `vmwgfx_drv.h`, `vmwgfx_resource_priv.h`.
- Detected declarations: `struct vmw_user_simple_resource`, `function vmw_simple_resource_init`, `function vmw_simple_resource_free`, `function vmw_simple_resource_base_release`, `function vmw_simple_resource_create_ioctl`, `function vmw_simple_resource_lookup`.
- 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.