drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c- Extension
.c- Size
- 13032 bytes
- Lines
- 561
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
i915_drv.hi915_selftest.hgem/i915_gem_context.hgt/intel_gt.hmock_context.hmock_dmabuf.higt_gem_utils.hselftests/mock_drm.hselftests/mock_gem_device.h
Detected Declarations
function igt_dmabuf_exportfunction igt_dmabuf_import_selffunction igt_dmabuf_import_same_driver_lmemfunction verify_accessfunction for_each_gem_enginefunction igt_dmabuf_import_same_driverfunction igt_dmabuf_import_same_driver_smemfunction igt_dmabuf_import_same_driver_lmem_smemfunction igt_dmabuf_importfunction igt_dmabuf_import_ownershipfunction igt_dmabuf_export_vmapfunction i915_gem_dmabuf_mock_selftestsfunction i915_gem_dmabuf_live_selftests
Annotated Snippet
if (vaddr[i] != 0xdeadbeaf) {
pr_err("Data mismatch [%d]=%u\n", i, vaddr[i]);
err = -EINVAL;
goto out_file;
}
}
out_file:
fput(file);
return err;
}
static int igt_dmabuf_import_same_driver(struct drm_i915_private *i915,
struct intel_memory_region **regions,
unsigned int num_regions)
{
struct drm_i915_gem_object *obj, *import_obj;
struct drm_gem_object *import;
struct dma_buf *dmabuf;
struct dma_buf_attachment *import_attach;
struct sg_table *st;
long timeout;
int err;
force_different_devices = true;
obj = __i915_gem_object_create_user(i915, SZ_8M,
regions, num_regions);
if (IS_ERR(obj)) {
pr_err("__i915_gem_object_create_user failed with err=%ld\n",
PTR_ERR(obj));
err = PTR_ERR(obj);
goto out_ret;
}
dmabuf = i915_gem_prime_export(&obj->base, 0);
if (IS_ERR(dmabuf)) {
pr_err("i915_gem_prime_export failed with err=%ld\n",
PTR_ERR(dmabuf));
err = PTR_ERR(dmabuf);
goto out;
}
import = i915_gem_prime_import(&i915->drm, dmabuf);
if (IS_ERR(import)) {
pr_err("i915_gem_prime_import failed with err=%ld\n",
PTR_ERR(import));
err = PTR_ERR(import);
goto out_dmabuf;
}
import_obj = to_intel_bo(import);
if (import == &obj->base) {
pr_err("i915_gem_prime_import reused gem object!\n");
err = -EINVAL;
goto out_import;
}
i915_gem_object_lock(import_obj, NULL);
err = __i915_gem_object_get_pages(import_obj);
if (err) {
pr_err("Different objects dma-buf get_pages failed!\n");
i915_gem_object_unlock(import_obj);
goto out_import;
}
/*
* If the exported object is not in system memory, something
* weird is going on. TODO: When p2p is supported, this is no
* longer considered weird.
*/
if (obj->mm.region != i915->mm.regions[INTEL_REGION_SMEM]) {
pr_err("Exported dma-buf is not in system memory\n");
err = -EINVAL;
}
i915_gem_object_unlock(import_obj);
err = verify_access(i915, obj, import_obj);
if (err)
goto out_import;
/* Now try a fake an importer */
import_attach = dma_buf_attach(dmabuf, obj->base.dev->dev);
if (IS_ERR(import_attach)) {
err = PTR_ERR(import_attach);
goto out_import;
}
st = dma_buf_map_attachment_unlocked(import_attach, DMA_BIDIRECTIONAL);
Annotation
- Immediate include surface: `i915_drv.h`, `i915_selftest.h`, `gem/i915_gem_context.h`, `gt/intel_gt.h`, `mock_context.h`, `mock_dmabuf.h`, `igt_gem_utils.h`, `selftests/mock_drm.h`.
- Detected declarations: `function igt_dmabuf_export`, `function igt_dmabuf_import_self`, `function igt_dmabuf_import_same_driver_lmem`, `function verify_access`, `function for_each_gem_engine`, `function igt_dmabuf_import_same_driver`, `function igt_dmabuf_import_same_driver_smem`, `function igt_dmabuf_import_same_driver_lmem_smem`, `function igt_dmabuf_import`, `function igt_dmabuf_import_ownership`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.