drivers/gpu/drm/i915/gvt/dmabuf.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gvt/dmabuf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gvt/dmabuf.c- Extension
.c- Size
- 15669 bytes
- Lines
- 594
- 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/dma-buf.hlinux/mdev.hdrm/drm_fourcc.hdrm/drm_plane.hdrm/drm_print.hdisplay/skl_universal_plane_regs.hgem/i915_gem_dmabuf.hgvt.hi915_drv.h
Detected Declarations
function filesfunction for_each_sgfunction vgpu_gem_put_pagesfunction dmabuf_gem_object_freefunction dmabuf_obj_getfunction dmabuf_obj_putfunction vgpu_gem_releasefunction validate_hotspotfunction vgpu_get_plane_infofunction pick_dmabuf_by_infofunction list_for_eachfunction pick_dmabuf_by_numfunction list_for_eachfunction update_fb_infofunction intel_vgpu_query_planefunction intel_vgpu_get_dmabuffunction intel_vgpu_dmabuf_cleanup
Annotated Snippet
if (intel_gvt_dma_pin_guest_page(vgpu, dma_addr)) {
ret = -EINVAL;
goto out;
}
sg->offset = 0;
sg->length = PAGE_SIZE;
sg_dma_len(sg) = PAGE_SIZE;
sg_dma_address(sg) = dma_addr;
}
__i915_gem_object_set_pages(obj, st);
out:
if (ret) {
dma_addr_t dma_addr;
for_each_sg(st->sgl, sg, i, j) {
dma_addr = sg_dma_address(sg);
if (dma_addr)
intel_gvt_dma_unmap_guest_page(vgpu, dma_addr);
}
sg_free_table(st);
kfree(st);
}
return ret;
}
static void vgpu_gem_put_pages(struct drm_i915_gem_object *obj,
struct sg_table *pages)
{
struct scatterlist *sg;
if (obj->base.dma_buf) {
struct intel_vgpu_fb_info *fb_info = obj->gvt_info;
struct intel_vgpu_dmabuf_obj *obj = fb_info->obj;
struct intel_vgpu *vgpu = obj->vgpu;
int i;
for_each_sg(pages->sgl, sg, fb_info->size, i)
intel_gvt_dma_unmap_guest_page(vgpu,
sg_dma_address(sg));
}
sg_free_table(pages);
kfree(pages);
}
static void dmabuf_gem_object_free(struct kref *kref)
{
struct intel_vgpu_dmabuf_obj *obj =
container_of(kref, struct intel_vgpu_dmabuf_obj, kref);
struct intel_vgpu *vgpu = obj->vgpu;
struct list_head *pos;
struct intel_vgpu_dmabuf_obj *dmabuf_obj;
if (vgpu && test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status) &&
!list_empty(&vgpu->dmabuf_obj_list_head)) {
list_for_each(pos, &vgpu->dmabuf_obj_list_head) {
dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list);
if (dmabuf_obj == obj) {
list_del(pos);
idr_remove(&vgpu->object_idr,
dmabuf_obj->dmabuf_id);
kfree(dmabuf_obj->info);
kfree(dmabuf_obj);
break;
}
}
} else {
/* Free the orphan dmabuf_objs here */
kfree(obj->info);
kfree(obj);
}
}
static inline void dmabuf_obj_get(struct intel_vgpu_dmabuf_obj *obj)
{
kref_get(&obj->kref);
}
static inline void dmabuf_obj_put(struct intel_vgpu_dmabuf_obj *obj)
{
kref_put(&obj->kref, dmabuf_gem_object_free);
}
static void vgpu_gem_release(struct drm_i915_gem_object *gem_obj)
{
Annotation
- Immediate include surface: `linux/dma-buf.h`, `linux/mdev.h`, `drm/drm_fourcc.h`, `drm/drm_plane.h`, `drm/drm_print.h`, `display/skl_universal_plane_regs.h`, `gem/i915_gem_dmabuf.h`, `gvt.h`.
- Detected declarations: `function files`, `function for_each_sg`, `function vgpu_gem_put_pages`, `function dmabuf_gem_object_free`, `function dmabuf_obj_get`, `function dmabuf_obj_put`, `function vgpu_gem_release`, `function validate_hotspot`, `function vgpu_get_plane_info`, `function pick_dmabuf_by_info`.
- 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.