drivers/gpu/drm/virtio/virtgpu_plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/virtio/virtgpu_plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/virtio/virtgpu_plane.c- Extension
.c- Size
- 17535 bytes
- Lines
- 615
- 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/drm_atomic_helper.hdrm/drm_damage_helper.hdrm/drm_fourcc.hdrm/drm_gem_atomic_helper.hlinux/virtio_dma_buf.hdrm/drm_managed.hdrm/drm_panic.hdrm/drm_print.hvirtgpu_drv.h
Detected Declarations
function virtio_gpu_translate_formatfunction virtio_gpu_plane_atomic_checkfunction virtio_gpu_panic_update_dumb_bofunction virtio_gpu_update_dumb_bofunction virtio_gpu_panic_resource_flushfunction virtio_gpu_resource_flushfunction virtio_gpu_primary_plane_updatefunction virtio_gpu_prepare_imported_objfunction virtio_gpu_plane_prepare_fbfunction virtio_gpu_cleanup_imported_objfunction virtio_gpu_plane_cleanup_fbfunction virtio_gpu_cursor_plane_updatefunction virtio_drm_get_scanout_bufferfunction virtio_panic_flush
Annotated Snippet
if (virtio_gpu_lock_one_resv_uninterruptible(objs)) {
virtio_gpu_array_put_free(objs);
return;
}
virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle, x, y,
width, height, objs,
vgplane_st->fence);
virtio_gpu_notify(vgdev);
dma_fence_wait_timeout(&vgplane_st->fence->f, true,
msecs_to_jiffies(50));
} else {
virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle, x, y,
width, height, NULL, NULL);
virtio_gpu_notify(vgdev);
}
}
static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
struct drm_atomic_commit *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_device *dev = plane->dev;
struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_output *output = NULL;
struct virtio_gpu_object *bo;
struct drm_rect rect;
if (plane->state->crtc)
output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
if (old_state->crtc)
output = drm_crtc_to_virtio_gpu_output(old_state->crtc);
if (WARN_ON(!output))
return;
if (!plane->state->fb || !output->crtc.state->active) {
DRM_DEBUG("nofb\n");
virtio_gpu_cmd_set_scanout(vgdev, output->index, 0,
plane->state->src_w >> 16,
plane->state->src_h >> 16,
0, 0);
virtio_gpu_notify(vgdev);
return;
}
if (!drm_atomic_helper_damage_merged(old_state, plane->state, &rect))
return;
bo = gem_to_virtio_gpu_obj(plane->state->fb->obj[0]);
if (bo->dumb)
virtio_gpu_update_dumb_bo(vgdev, plane->state, &rect);
if (plane->state->fb != old_state->fb ||
plane->state->src_w != old_state->src_w ||
plane->state->src_h != old_state->src_h ||
plane->state->src_x != old_state->src_x ||
plane->state->src_y != old_state->src_y ||
output->needs_modeset) {
output->needs_modeset = false;
DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
bo->hw_res_handle,
plane->state->crtc_w, plane->state->crtc_h,
plane->state->crtc_x, plane->state->crtc_y,
plane->state->src_w >> 16,
plane->state->src_h >> 16,
plane->state->src_x >> 16,
plane->state->src_y >> 16);
if (bo->host3d_blob || bo->guest_blob) {
virtio_gpu_cmd_set_scanout_blob
(vgdev, output->index, bo,
plane->state->fb,
plane->state->src_w >> 16,
plane->state->src_h >> 16,
plane->state->src_x >> 16,
plane->state->src_y >> 16);
} else {
virtio_gpu_cmd_set_scanout(vgdev, output->index,
bo->hw_res_handle,
plane->state->src_w >> 16,
plane->state->src_h >> 16,
plane->state->src_x >> 16,
plane->state->src_y >> 16);
}
}
virtio_gpu_resource_flush(plane,
rect.x1,
rect.y1,
rect.x2 - rect.x1,
Annotation
- Immediate include surface: `drm/drm_atomic_helper.h`, `drm/drm_damage_helper.h`, `drm/drm_fourcc.h`, `drm/drm_gem_atomic_helper.h`, `linux/virtio_dma_buf.h`, `drm/drm_managed.h`, `drm/drm_panic.h`, `drm/drm_print.h`.
- Detected declarations: `function virtio_gpu_translate_format`, `function virtio_gpu_plane_atomic_check`, `function virtio_gpu_panic_update_dumb_bo`, `function virtio_gpu_update_dumb_bo`, `function virtio_gpu_panic_resource_flush`, `function virtio_gpu_resource_flush`, `function virtio_gpu_primary_plane_update`, `function virtio_gpu_prepare_imported_obj`, `function virtio_gpu_plane_prepare_fb`, `function virtio_gpu_cleanup_imported_obj`.
- 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.