drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c- Extension
.c- Size
- 39699 bytes
- Lines
- 1411
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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_drv.hdrm/ttm/ttm_bo.hlinux/dmapool.hlinux/pci.h
Detected Declarations
struct vmw_cmdbuf_contextstruct vmw_cmdbuf_manstruct vmw_cmdbuf_headerstruct vmw_cmdbuf_dheaderstruct vmw_cmdbuf_alloc_infofunction vmw_cmdbuf_cur_lockfunction vmw_cmdbuf_cur_unlockfunction vmw_cmdbuf_header_inline_freefunction __vmw_cmdbuf_header_freefunction vmw_cmdbuf_header_freefunction vmw_cmdbuf_header_submitfunction vmw_cmdbuf_ctx_initfunction vmw_cmdbuf_ctx_submitfunction vmw_cmdbuf_ctx_processfunction list_for_each_entry_safefunction vmw_cmdbuf_ctx_processfunction vmw_cmdbuf_ctx_addfunction vmw_cmdbuf_irqthreadfunction vmw_cmdbuf_work_funcfunction vmw_cmdbuf_man_idlefunction __vmw_cmdbuf_cur_flushfunction vmw_cmdbuf_cur_flushfunction vmw_cmdbuf_idlefunction vmw_cmdbuf_try_allocfunction vmw_cmdbuf_alloc_spacefunction vmw_cmdbuf_space_poolfunction vmw_cmdbuf_space_inlinefunction vmw_cmdbuf_reservefunction vmw_cmdbuf_commit_curfunction vmw_cmdbuf_commitfunction vmw_cmdbuf_send_device_commandfunction vmw_cmdbuf_preemptfunction vmw_cmdbuf_startstopfunction vmw_cmdbuf_set_pool_sizefunction vmw_cmdbuf_remove_poolfunction vmw_cmdbuf_man_destroy
Annotated Snippet
struct vmw_cmdbuf_context {
struct list_head submitted;
struct list_head hw_submitted;
struct list_head preempted;
unsigned num_hw_submitted;
bool block_submission;
};
/**
* struct vmw_cmdbuf_man - Command buffer manager
*
* @cur_mutex: Mutex protecting the command buffer used for incremental small
* kernel command submissions, @cur.
* @space_mutex: Mutex to protect against starvation when we allocate
* main pool buffer space.
* @error_mutex: Mutex to serialize the work queue error handling.
* Note this is not needed if the same workqueue handler
* can't race with itself...
* @work: A struct work_struct implementeing command buffer error handling.
* Immutable.
* @dev_priv: Pointer to the device private struct. Immutable.
* @ctx: Array of command buffer context queues. The queues and the context
* data is protected by @lock.
* @error: List of command buffers that have caused device errors.
* Protected by @lock.
* @mm: Range manager for the command buffer space. Manager allocations and
* frees are protected by @lock.
* @cmd_space: Buffer object for the command buffer space, unless we were
* able to make a contigous coherent DMA memory allocation, @handle. Immutable.
* @map: Pointer to command buffer space. May be a mapped buffer object or
* a contigous coherent DMA memory allocation. Immutable.
* @cur: Command buffer for small kernel command submissions. Protected by
* the @cur_mutex.
* @cur_pos: Space already used in @cur. Protected by @cur_mutex.
* @default_size: Default size for the @cur command buffer. Immutable.
* @max_hw_submitted: Max number of in-flight command buffers the device can
* handle. Immutable.
* @lock: Spinlock protecting command submission queues.
* @headers: Pool of DMA memory for device command buffer headers.
* Internal protection.
* @dheaders: Pool of DMA memory for device command buffer headers with trailing
* space for inline data. Internal protection.
* @alloc_queue: Wait queue for processes waiting to allocate command buffer
* space.
* @idle_queue: Wait queue for processes waiting for command buffer idle.
* @irq_on: Whether the process function has requested irq to be turned on.
* Protected by @lock.
* @using_mob: Whether the command buffer space is a MOB or a contigous DMA
* allocation. Immutable.
* @has_pool: Has a large pool of DMA memory which allows larger allocations.
* Typically this is false only during bootstrap.
* @handle: DMA address handle for the command buffer space if @using_mob is
* false. Immutable.
* @size: The size of the command buffer space. Immutable.
* @id: Monotonically increasing ID of the last cmdbuf submitted.
* @num_contexts: Number of contexts actually enabled.
*/
struct vmw_cmdbuf_man {
struct mutex cur_mutex;
struct mutex space_mutex;
struct mutex error_mutex;
struct work_struct work;
struct vmw_private *dev_priv;
struct vmw_cmdbuf_context ctx[SVGA_CB_CONTEXT_MAX];
struct list_head error;
struct drm_mm mm;
struct vmw_bo *cmd_space;
u8 *map;
struct vmw_cmdbuf_header *cur;
size_t cur_pos;
size_t default_size;
unsigned max_hw_submitted;
spinlock_t lock;
struct dma_pool *headers;
struct dma_pool *dheaders;
wait_queue_head_t alloc_queue;
wait_queue_head_t idle_queue;
bool irq_on;
bool using_mob;
bool has_pool;
dma_addr_t handle;
size_t size;
u64 id;
u32 num_contexts;
};
/**
* struct vmw_cmdbuf_header - Command buffer metadata
*
* @man: The command buffer manager.
Annotation
- Immediate include surface: `vmwgfx_bo.h`, `vmwgfx_drv.h`, `drm/ttm/ttm_bo.h`, `linux/dmapool.h`, `linux/pci.h`.
- Detected declarations: `struct vmw_cmdbuf_context`, `struct vmw_cmdbuf_man`, `struct vmw_cmdbuf_header`, `struct vmw_cmdbuf_dheader`, `struct vmw_cmdbuf_alloc_info`, `function vmw_cmdbuf_cur_lock`, `function vmw_cmdbuf_cur_unlock`, `function vmw_cmdbuf_header_inline_free`, `function __vmw_cmdbuf_header_free`, `function vmw_cmdbuf_header_free`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.