drivers/gpu/drm/xe/xe_dma_buf.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_dma_buf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_dma_buf.c- Extension
.c- Size
- 9697 bytes
- Lines
- 399
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xe_dma_buf.hkunit/test.hlinux/dma-buf.hlinux/pci-p2pdma.hdrm/drm_device.hdrm/drm_prime.hdrm/ttm/ttm_tt.htests/xe_test.hxe_bo.hxe_device.hxe_pm.hxe_ttm_vram_mgr.hxe_vm.htests/xe_dma_buf.c
Detected Declarations
struct dma_buf_test_paramsfunction xe_dma_buf_attachfunction xe_dma_buf_detachfunction xe_dma_buf_pinfunction list_for_each_entryfunction xe_dma_buf_unpinfunction xe_dma_buf_unmapfunction xe_dma_buf_begin_cpu_accessfunction xe_dma_buf_releasefunction xe_dma_buf_create_objfunction xe_dma_buf_move_notify
Annotated Snippet
struct dma_buf_test_params {
struct xe_test_priv base;
const struct dma_buf_attach_ops *attach_ops;
bool force_different_devices;
u32 mem_mask;
};
#define to_dma_buf_test_params(_priv) \
container_of(_priv, struct dma_buf_test_params, base)
#endif
struct drm_gem_object *xe_gem_prime_import(struct drm_device *dev,
struct dma_buf *dma_buf)
{
XE_TEST_DECLARE(struct dma_buf_test_params *test =
to_dma_buf_test_params
(xe_cur_kunit_priv(XE_TEST_LIVE_DMA_BUF));)
const struct dma_buf_attach_ops *attach_ops;
struct dma_buf_attachment *attach;
struct drm_gem_object *obj;
if (dma_buf->ops == &xe_dmabuf_ops) {
obj = dma_buf->priv;
if (obj->dev == dev &&
!XE_TEST_ONLY(test && test->force_different_devices)) {
/*
* Importing dmabuf exported from out own gem increases
* refcount on gem itself instead of f_count of dmabuf.
*/
drm_gem_object_get(obj);
return obj;
}
}
/*
* This needs to happen before the attach, since it will create a new
* attachment for this, and add it to the list of attachments, at which
* point it is globally visible, and at any point the export side can
* call into on invalidate_mappings callback, which require a working
* object.
*/
obj = xe_dma_buf_create_obj(dev, dma_buf);
if (IS_ERR(obj))
return obj;
attach_ops = &xe_dma_buf_attach_ops;
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
if (test)
attach_ops = test->attach_ops;
#endif
attach = dma_buf_dynamic_attach(dma_buf, dev->dev, attach_ops, obj);
if (IS_ERR(attach)) {
xe_bo_put(gem_to_xe_bo(obj));
return ERR_CAST(attach);
}
get_dma_buf(dma_buf);
obj->import_attach = attach;
return obj;
}
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
#include "tests/xe_dma_buf.c"
#endif
Annotation
- Immediate include surface: `xe_dma_buf.h`, `kunit/test.h`, `linux/dma-buf.h`, `linux/pci-p2pdma.h`, `drm/drm_device.h`, `drm/drm_prime.h`, `drm/ttm/ttm_tt.h`, `tests/xe_test.h`.
- Detected declarations: `struct dma_buf_test_params`, `function xe_dma_buf_attach`, `function xe_dma_buf_detach`, `function xe_dma_buf_pin`, `function list_for_each_entry`, `function xe_dma_buf_unpin`, `function xe_dma_buf_unmap`, `function xe_dma_buf_begin_cpu_access`, `function xe_dma_buf_release`, `function xe_dma_buf_create_obj`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- 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.