drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c- Extension
.c- Size
- 25550 bytes
- Lines
- 976
- 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.
- 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
drm/ttm/ttm_placement.hvmwgfx_binding.hvmwgfx_bo.hvmwgfx_drv.hvmwgfx_resource_priv.h
Detected Declarations
struct vmw_shaderstruct vmw_user_shaderstruct vmw_dx_shaderfunction vmw_res_to_shaderfunction vmw_res_to_dx_shaderfunction vmw_hw_shader_destroyfunction vmw_gb_shader_initfunction vmw_gb_shader_createfunction vmw_gb_shader_bindfunction vmw_gb_shader_unbindfunction vmw_gb_shader_destroyfunction vmw_dx_shader_commit_notifyfunction vmw_dx_shader_unscrubfunction vmw_dx_shader_createfunction vmw_dx_shader_bindfunction vmw_dx_shader_scrubfunction vmw_dx_shader_unbindfunction vmw_dx_shader_cotable_list_scrubfunction list_for_each_entry_safefunction vmw_dx_shader_res_freefunction vmw_dx_shader_addfunction vmw_user_shader_base_to_resfunction vmw_user_shader_freefunction vmw_shader_freefunction vmw_user_shader_base_releasefunction vmw_shader_destroy_ioctlfunction vmw_user_shader_allocfunction vmw_shader_definefunction vmw_shader_id_okfunction vmw_shader_keyfunction vmw_shader_removefunction vmw_compat_shader_addfunction vmw_shader_lookupfunction vmw_shader_define_ioctl
Annotated Snippet
struct vmw_shader {
struct vmw_resource res;
SVGA3dShaderType type;
uint32_t size;
uint8_t num_input_sig;
uint8_t num_output_sig;
};
struct vmw_user_shader {
struct ttm_base_object base;
struct vmw_shader shader;
};
struct vmw_dx_shader {
struct vmw_resource res;
struct vmw_resource *ctx;
struct vmw_resource *cotable;
u32 id;
bool committed;
struct list_head cotable_head;
};
static void vmw_user_shader_free(struct vmw_resource *res);
static struct vmw_resource *
vmw_user_shader_base_to_res(struct ttm_base_object *base);
static int vmw_gb_shader_create(struct vmw_resource *res);
static int vmw_gb_shader_bind(struct vmw_resource *res,
struct ttm_validate_buffer *val_buf);
static int vmw_gb_shader_unbind(struct vmw_resource *res,
bool readback,
struct ttm_validate_buffer *val_buf);
static int vmw_gb_shader_destroy(struct vmw_resource *res);
static int vmw_dx_shader_create(struct vmw_resource *res);
static int vmw_dx_shader_bind(struct vmw_resource *res,
struct ttm_validate_buffer *val_buf);
static int vmw_dx_shader_unbind(struct vmw_resource *res,
bool readback,
struct ttm_validate_buffer *val_buf);
static void vmw_dx_shader_commit_notify(struct vmw_resource *res,
enum vmw_cmdbuf_res_state state);
static bool vmw_shader_id_ok(u32 user_key, SVGA3dShaderType shader_type);
static u32 vmw_shader_key(u32 user_key, SVGA3dShaderType shader_type);
static const struct vmw_user_resource_conv user_shader_conv = {
.object_type = VMW_RES_SHADER,
.base_obj_to_res = vmw_user_shader_base_to_res,
.res_free = vmw_user_shader_free
};
const struct vmw_user_resource_conv *user_shader_converter =
&user_shader_conv;
static const struct vmw_res_func vmw_gb_shader_func = {
.res_type = vmw_res_shader,
.needs_guest_memory = true,
.may_evict = true,
.prio = 3,
.dirty_prio = 3,
.type_name = "guest backed shaders",
.domain = VMW_BO_DOMAIN_MOB,
.busy_domain = VMW_BO_DOMAIN_MOB,
.create = vmw_gb_shader_create,
.destroy = vmw_gb_shader_destroy,
.bind = vmw_gb_shader_bind,
.unbind = vmw_gb_shader_unbind
};
static const struct vmw_res_func vmw_dx_shader_func = {
.res_type = vmw_res_shader,
.needs_guest_memory = true,
.may_evict = true,
.prio = 3,
.dirty_prio = 3,
.type_name = "dx shaders",
.domain = VMW_BO_DOMAIN_MOB,
.busy_domain = VMW_BO_DOMAIN_MOB,
.create = vmw_dx_shader_create,
/*
* The destroy callback is only called with a committed resource on
* context destroy, in which case we destroy the cotable anyway,
* so there's no need to destroy DX shaders separately.
*/
.destroy = NULL,
.bind = vmw_dx_shader_bind,
.unbind = vmw_dx_shader_unbind,
.commit_notify = vmw_dx_shader_commit_notify,
};
Annotation
- Immediate include surface: `drm/ttm/ttm_placement.h`, `vmwgfx_binding.h`, `vmwgfx_bo.h`, `vmwgfx_drv.h`, `vmwgfx_resource_priv.h`.
- Detected declarations: `struct vmw_shader`, `struct vmw_user_shader`, `struct vmw_dx_shader`, `function vmw_res_to_shader`, `function vmw_res_to_dx_shader`, `function vmw_hw_shader_destroy`, `function vmw_gb_shader_init`, `function vmw_gb_shader_create`, `function vmw_gb_shader_bind`, `function vmw_gb_shader_unbind`.
- 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.