drivers/gpu/drm/qxl/qxl_cmd.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/qxl/qxl_cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/qxl/qxl_cmd.c- Extension
.c- Size
- 16666 bytes
- Lines
- 663
- 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
linux/delay.hdrm/drm_print.hdrm/drm_util.hqxl_drv.hqxl_object.h
Detected Declarations
struct ringstruct qxl_ringfunction qxl_ring_freefunction qxl_ring_createfunction qxl_check_headerfunction qxl_check_idlefunction qxl_ring_pushfunction qxl_ring_popfunction qxl_push_command_ring_releasefunction qxl_push_cursor_ring_releasefunction qxl_queue_garbage_collectfunction qxl_garbage_collectfunction qxl_alloc_bo_reservedfunction wait_for_io_cmd_userfunction wait_for_io_cmdfunction qxl_io_update_areafunction qxl_io_notify_oomfunction qxl_io_flush_releasefunction qxl_io_flush_surfacesfunction qxl_io_destroy_primaryfunction qxl_io_create_primaryfunction qxl_io_memslot_addfunction qxl_io_resetfunction qxl_io_monitors_configfunction qxl_surface_id_allocfunction qxl_surface_id_deallocfunction qxl_hw_surface_allocfunction qxl_hw_surface_deallocfunction qxl_update_surfacefunction qxl_surface_evict_lockedfunction qxl_surface_evictfunction qxl_reap_surffunction qxl_reap_surface_id
Annotated Snippet
struct ring {
struct qxl_ring_header header;
uint8_t elements[];
};
struct qxl_ring {
struct ring *ring;
int element_size;
int n_elements;
int prod_notify;
wait_queue_head_t *push_event;
spinlock_t lock;
};
void qxl_ring_free(struct qxl_ring *ring)
{
kfree(ring);
}
struct qxl_ring *
qxl_ring_create(struct qxl_ring_header *header,
int element_size,
int n_elements,
int prod_notify,
wait_queue_head_t *push_event)
{
struct qxl_ring *ring;
ring = kmalloc_obj(*ring);
if (!ring)
return NULL;
ring->ring = (struct ring *)header;
ring->element_size = element_size;
ring->n_elements = n_elements;
ring->prod_notify = prod_notify;
ring->push_event = push_event;
spin_lock_init(&ring->lock);
return ring;
}
static int qxl_check_header(struct qxl_ring *ring)
{
int ret;
struct qxl_ring_header *header = &(ring->ring->header);
unsigned long flags;
spin_lock_irqsave(&ring->lock, flags);
ret = header->prod - header->cons < header->num_items;
if (ret == 0)
header->notify_on_cons = header->cons + 1;
spin_unlock_irqrestore(&ring->lock, flags);
return ret;
}
int qxl_check_idle(struct qxl_ring *ring)
{
int ret;
struct qxl_ring_header *header = &(ring->ring->header);
unsigned long flags;
spin_lock_irqsave(&ring->lock, flags);
ret = header->prod == header->cons;
spin_unlock_irqrestore(&ring->lock, flags);
return ret;
}
int qxl_ring_push(struct qxl_ring *ring,
const void *new_elt, bool interruptible)
{
struct qxl_ring_header *header = &(ring->ring->header);
uint8_t *elt;
int idx, ret;
unsigned long flags;
spin_lock_irqsave(&ring->lock, flags);
if (header->prod - header->cons == header->num_items) {
header->notify_on_cons = header->cons + 1;
mb();
spin_unlock_irqrestore(&ring->lock, flags);
if (!drm_can_sleep()) {
while (!qxl_check_header(ring))
udelay(1);
} else {
if (interruptible) {
ret = wait_event_interruptible(*ring->push_event,
qxl_check_header(ring));
if (ret)
return ret;
} else {
Annotation
- Immediate include surface: `linux/delay.h`, `drm/drm_print.h`, `drm/drm_util.h`, `qxl_drv.h`, `qxl_object.h`.
- Detected declarations: `struct ring`, `struct qxl_ring`, `function qxl_ring_free`, `function qxl_ring_create`, `function qxl_check_header`, `function qxl_check_idle`, `function qxl_ring_push`, `function qxl_ring_pop`, `function qxl_push_command_ring_release`, `function qxl_push_cursor_ring_release`.
- 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.