drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c- Extension
.c- Size
- 67204 bytes
- Lines
- 2339
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
vmwgfx_bo.hvmwgfx_cursor_plane.hvmwgfx_drv.hvmwgfx_resource_priv.hvmwgfx_so.hvmwgfx_binding.hvmw_surface_cache.hdevice_include/svga3d_surfacedefs.hdrm/drm_dumb_buffers.hdrm/ttm/ttm_placement.h
Detected Declarations
struct vmw_user_surfacestruct vmw_surface_offsetstruct vmw_surface_dirtystruct vmw_surface_dmastruct vmw_surface_definestruct vmw_surface_destroyfunction vmw_surface_dma_sizefunction vmw_surface_define_sizefunction vmw_surface_destroy_sizefunction vmw_surface_destroy_encodefunction vmw_surface_define_encodefunction vmw_surface_dma_encodefunction vmw_hw_surface_destroyfunction vmw_legacy_srf_createfunction vmw_legacy_srf_dmafunction vmw_legacy_srf_bindfunction vmw_legacy_srf_unbindfunction vmw_legacy_srf_destroyfunction vmw_surface_initfunction vmw_user_surface_base_to_resfunction vmw_user_surface_freefunction vmw_user_surface_base_releasefunction vmw_surface_destroy_ioctlfunction vmw_surface_define_ioctlfunction vmw_lookup_user_surface_for_bufferfunction vmw_lookup_surface_handle_for_bufferfunction vmw_buffer_prime_to_surface_basefunction vmw_surface_handle_referencefunction vmw_surface_reference_ioctlfunction vmw_gb_surface_createfunction vmw_gb_surface_bindfunction vmw_gb_surface_unbindfunction vmw_gb_surface_destroyfunction vmw_gb_surface_define_ioctlfunction vmw_gb_surface_reference_ioctlfunction vmw_gb_surface_define_ext_ioctlfunction vmw_gb_surface_reference_ext_ioctlfunction vmw_gb_surface_define_internalfunction vmw_gb_surface_reference_internalfunction vmw_subres_dirty_addfunction vmw_subres_dirty_fullfunction vmw_surface_tex_dirty_range_addfunction vmw_surface_buf_dirty_range_addfunction vmw_surface_dirty_range_addfunction vmw_surface_dirty_syncfunction vmw_surface_dirty_allocfunction vmw_surface_dirty_freefunction vmw_surface_clean
Annotated Snippet
struct vmw_user_surface {
struct ttm_prime_object prime;
struct vmw_surface srf;
struct drm_master *master;
};
/**
* struct vmw_surface_offset - Backing store mip level offset info
*
* @face: Surface face.
* @mip: Mip level.
* @bo_offset: Offset into backing store of this mip level.
*
*/
struct vmw_surface_offset {
uint32_t face;
uint32_t mip;
uint32_t bo_offset;
};
/**
* struct vmw_surface_dirty - Surface dirty-tracker
* @cache: Cached layout information of the surface.
* @num_subres: Number of subresources.
* @boxes: Array of SVGA3dBoxes indicating dirty regions. One per subresource.
*/
struct vmw_surface_dirty {
struct vmw_surface_cache cache;
u32 num_subres;
SVGA3dBox boxes[] __counted_by(num_subres);
};
static void vmw_user_surface_free(struct vmw_resource *res);
static struct vmw_resource *
vmw_user_surface_base_to_res(struct ttm_base_object *base);
static int vmw_legacy_srf_bind(struct vmw_resource *res,
struct ttm_validate_buffer *val_buf);
static int vmw_legacy_srf_unbind(struct vmw_resource *res,
bool readback,
struct ttm_validate_buffer *val_buf);
static int vmw_legacy_srf_create(struct vmw_resource *res);
static int vmw_legacy_srf_destroy(struct vmw_resource *res);
static int vmw_gb_surface_create(struct vmw_resource *res);
static int vmw_gb_surface_bind(struct vmw_resource *res,
struct ttm_validate_buffer *val_buf);
static int vmw_gb_surface_unbind(struct vmw_resource *res,
bool readback,
struct ttm_validate_buffer *val_buf);
static int vmw_gb_surface_destroy(struct vmw_resource *res);
static int
vmw_gb_surface_define_internal(struct drm_device *dev,
struct drm_vmw_gb_surface_create_ext_req *req,
struct drm_vmw_gb_surface_create_rep *rep,
struct drm_file *file_priv);
static int
vmw_gb_surface_reference_internal(struct drm_device *dev,
struct drm_vmw_surface_arg *req,
struct drm_vmw_gb_surface_ref_ext_rep *rep,
struct drm_file *file_priv);
static void vmw_surface_dirty_free(struct vmw_resource *res);
static int vmw_surface_dirty_alloc(struct vmw_resource *res);
static int vmw_surface_dirty_sync(struct vmw_resource *res);
static void vmw_surface_dirty_range_add(struct vmw_resource *res, size_t start,
size_t end);
static int vmw_surface_clean(struct vmw_resource *res);
static const struct vmw_user_resource_conv user_surface_conv = {
.object_type = VMW_RES_SURFACE,
.base_obj_to_res = vmw_user_surface_base_to_res,
.res_free = vmw_user_surface_free
};
const struct vmw_user_resource_conv *user_surface_converter =
&user_surface_conv;
static const struct vmw_res_func vmw_legacy_surface_func = {
.res_type = vmw_res_surface,
.needs_guest_memory = false,
.may_evict = true,
.prio = 1,
.dirty_prio = 1,
.type_name = "legacy surfaces",
.domain = VMW_BO_DOMAIN_GMR,
.busy_domain = VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM,
.create = &vmw_legacy_srf_create,
.destroy = &vmw_legacy_srf_destroy,
.bind = &vmw_legacy_srf_bind,
.unbind = &vmw_legacy_srf_unbind
};
Annotation
- Immediate include surface: `vmwgfx_bo.h`, `vmwgfx_cursor_plane.h`, `vmwgfx_drv.h`, `vmwgfx_resource_priv.h`, `vmwgfx_so.h`, `vmwgfx_binding.h`, `vmw_surface_cache.h`, `device_include/svga3d_surfacedefs.h`.
- Detected declarations: `struct vmw_user_surface`, `struct vmw_surface_offset`, `struct vmw_surface_dirty`, `struct vmw_surface_dma`, `struct vmw_surface_define`, `struct vmw_surface_destroy`, `function vmw_surface_dma_size`, `function vmw_surface_define_size`, `function vmw_surface_destroy_size`, `function vmw_surface_destroy_encode`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.