drivers/gpu/drm/xe/xe_drm_client.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_drm_client.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_drm_client.c- Extension
.c- Size
- 10004 bytes
- Lines
- 402
- 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
xe_drm_client.hdrm/drm_print.huapi/drm/xe_drm.hlinux/kernel.hlinux/slab.hlinux/types.hxe_assert.hxe_bo.hxe_bo_types.hxe_device_types.hxe_exec_queue.hxe_force_wake.hxe_gt.hxe_hw_engine.hxe_pm.hxe_trace.h
Detected Declarations
function xe_drm_client_allocfunction __xe_drm_client_freefunction xe_drm_client_add_bofunction xe_drm_client_remove_bofunction bo_meminfofunction show_meminfofunction for_each_gtfunction force_wake_get_any_enginefunction show_run_ticksfunction scoped_guardfunction xa_for_eachfunction xe_drm_client_fdinfo
Annotated Snippet
if (dma_resv_trylock(bo->ttm.base.resv)) {
bo_meminfo(bo, stats);
xe_bo_unlock(bo);
} else {
xe_bo_get(bo);
spin_unlock(&file->table_lock);
xe_bo_lock(bo, false);
bo_meminfo(bo, stats);
xe_bo_unlock(bo);
xe_bo_put(bo);
spin_lock(&file->table_lock);
}
}
spin_unlock(&file->table_lock);
/* Internal objects. */
spin_lock(&client->bos_lock);
list_for_each_entry(bo, &client->bos_list, client_link) {
if (!kref_get_unless_zero(&bo->ttm.base.refcount))
continue;
if (dma_resv_trylock(bo->ttm.base.resv)) {
bo_meminfo(bo, stats);
xe_bo_unlock(bo);
} else {
spin_unlock(&client->bos_lock);
xe_bo_lock(bo, false);
bo_meminfo(bo, stats);
xe_bo_unlock(bo);
spin_lock(&client->bos_lock);
/* The bo ref will prevent this bo from being removed from the list */
xe_assert(xef->xe, !list_empty(&bo->client_link));
}
xe_bo_put_deferred(bo, &deferred);
}
spin_unlock(&client->bos_lock);
xe_bo_put_commit(&deferred);
for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
if (!xe_mem_type_to_name[mem_type])
continue;
man = ttm_manager_type(bdev, mem_type);
if (man) {
drm_print_memory_stats(p,
&stats[mem_type],
DRM_GEM_OBJECT_ACTIVE |
DRM_GEM_OBJECT_RESIDENT |
(mem_type != XE_PL_SYSTEM ? 0 :
DRM_GEM_OBJECT_PURGEABLE),
xe_mem_type_to_name[mem_type]);
}
}
}
static struct xe_hw_engine *any_engine(struct xe_device *xe)
{
struct xe_gt *gt;
unsigned long gt_id;
for_each_gt(gt, xe, gt_id) {
struct xe_hw_engine *hwe = xe_gt_any_hw_engine(gt);
if (hwe)
return hwe;
}
return NULL;
}
/*
* Pick any engine and grab its forcewake. On error phwe will be NULL and
* the returned forcewake reference will be invalid. Callers should check
* phwe against NULL.
*/
static struct xe_force_wake_ref force_wake_get_any_engine(struct xe_device *xe,
struct xe_hw_engine **phwe)
{
enum xe_force_wake_domains domain;
struct xe_force_wake_ref fw_ref = {};
struct xe_hw_engine *hwe;
*phwe = NULL;
Annotation
- Immediate include surface: `xe_drm_client.h`, `drm/drm_print.h`, `uapi/drm/xe_drm.h`, `linux/kernel.h`, `linux/slab.h`, `linux/types.h`, `xe_assert.h`, `xe_bo.h`.
- Detected declarations: `function xe_drm_client_alloc`, `function __xe_drm_client_free`, `function xe_drm_client_add_bo`, `function xe_drm_client_remove_bo`, `function bo_meminfo`, `function show_meminfo`, `function for_each_gt`, `function force_wake_get_any_engine`, `function show_run_ticks`, `function scoped_guard`.
- 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.