drivers/gpu/drm/radeon/radeon_gem.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/radeon/radeon_gem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/radeon/radeon_gem.c- Extension
.c- Size
- 23249 bytes
- Lines
- 920
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/iosys-map.hlinux/overflow.hlinux/pci.hdrm/drm_device.hdrm/drm_file.hdrm/drm_gem_ttm_helper.hdrm/radeon_drm.hradeon.hradeon_prime.h
Detected Declarations
function radeon_gem_faultfunction radeon_gem_object_freefunction radeon_gem_object_createfunction radeon_gem_set_domainfunction radeon_gem_initfunction radeon_gem_finifunction radeon_gem_object_openfunction radeon_gem_object_closefunction radeon_gem_handle_lockupfunction radeon_gem_object_mmapfunction radeon_gem_info_ioctlfunction radeon_gem_create_ioctlfunction radeon_gem_userptr_ioctlfunction radeon_gem_set_domain_ioctlfunction radeon_mode_dumb_mmapfunction radeon_gem_mmap_ioctlfunction radeon_gem_busy_ioctlfunction radeon_gem_wait_idle_ioctlfunction radeon_gem_set_tiling_ioctlfunction radeon_gem_get_tiling_ioctlfunction radeon_gem_va_update_vmfunction list_for_each_entryfunction list_for_each_entryfunction radeon_gem_va_ioctlfunction radeon_gem_op_ioctlfunction radeon_align_pitchfunction radeon_mode_dumb_createfunction radeon_debugfs_gem_info_showfunction radeon_gem_debugfs_init
Annotated Snippet
if (r != -ERESTARTSYS) {
if (initial_domain == RADEON_GEM_DOMAIN_VRAM) {
initial_domain |= RADEON_GEM_DOMAIN_GTT;
goto retry;
}
DRM_ERROR("Failed to allocate GEM object (%ld, %d, %u, %d)\n",
size, initial_domain, alignment, r);
}
return r;
}
*obj = &robj->tbo.base;
robj->pid = task_pid_nr(current);
mutex_lock(&rdev->gem.mutex);
list_add_tail(&robj->list, &rdev->gem.objects);
mutex_unlock(&rdev->gem.mutex);
return 0;
}
static int radeon_gem_set_domain(struct drm_gem_object *gobj,
uint32_t rdomain, uint32_t wdomain)
{
struct radeon_bo *robj;
uint32_t domain;
long r;
/* FIXME: reeimplement */
robj = gem_to_radeon_bo(gobj);
/* work out where to validate the buffer to */
domain = wdomain;
if (!domain) {
domain = rdomain;
}
if (!domain) {
/* Do nothings */
pr_warn("Set domain without domain !\n");
return 0;
}
if (domain == RADEON_GEM_DOMAIN_CPU) {
/* Asking for cpu access wait for object idle */
r = dma_resv_wait_timeout(robj->tbo.base.resv,
DMA_RESV_USAGE_BOOKKEEP,
true, 30 * HZ);
if (!r)
r = -EBUSY;
if (r < 0 && r != -EINTR) {
pr_err("Failed to wait for object: %li\n", r);
return r;
}
}
if (domain == RADEON_GEM_DOMAIN_VRAM && robj->prime_shared_count) {
/* A BO that is associated with a dma-buf cannot be sensibly migrated to VRAM */
return -EINVAL;
}
return 0;
}
int radeon_gem_init(struct radeon_device *rdev)
{
INIT_LIST_HEAD(&rdev->gem.objects);
return 0;
}
void radeon_gem_fini(struct radeon_device *rdev)
{
radeon_bo_force_delete(rdev);
}
/*
* Call from drm_gem_handle_create which appear in both new and open ioctl
* case.
*/
static int radeon_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_priv)
{
struct radeon_bo *rbo = gem_to_radeon_bo(obj);
struct radeon_device *rdev = rbo->rdev;
struct radeon_fpriv *fpriv = file_priv->driver_priv;
struct radeon_vm *vm = &fpriv->vm;
struct radeon_bo_va *bo_va;
int r;
if ((rdev->family < CHIP_CAYMAN) ||
(!rdev->accel_working)) {
return 0;
}
r = radeon_bo_reserve(rbo, false);
if (r) {
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/iosys-map.h`, `linux/overflow.h`, `linux/pci.h`, `drm/drm_device.h`, `drm/drm_file.h`, `drm/drm_gem_ttm_helper.h`, `drm/radeon_drm.h`.
- Detected declarations: `function radeon_gem_fault`, `function radeon_gem_object_free`, `function radeon_gem_object_create`, `function radeon_gem_set_domain`, `function radeon_gem_init`, `function radeon_gem_fini`, `function radeon_gem_object_open`, `function radeon_gem_object_close`, `function radeon_gem_handle_lockup`, `function radeon_gem_object_mmap`.
- 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.