drivers/gpu/drm/xe/xe_guc_ct.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_guc_ct.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_guc_ct.c- Extension
.c- Size
- 65061 bytes
- Lines
- 2286
- 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_guc_ct.hlinux/bitfield.hlinux/circ_buf.hlinux/delay.hlinux/fault-inject.hkunit/static_stub.hdrm/drm_managed.habi/guc_actions_abi.habi/guc_actions_sriov_abi.habi/guc_klvs_abi.hxe_bo.hxe_devcoredump.hxe_device.hxe_gt.hxe_gt_printk.hxe_gt_sriov_pf_control.hxe_gt_sriov_pf_monitor.hxe_guc.hxe_guc_log.hxe_guc_pagefault.hxe_guc_relay.hxe_guc_submit.hxe_guc_tlb_inval.hxe_map.hxe_page_reclaim.hxe_pm.hxe_sleep.hxe_sriov_vf.hxe_trace_guc.h
Detected Declarations
struct g2h_fencefunction ct_dead_finifunction ct_dead_initfunction fast_req_stack_savefunction fast_req_dumpfunction fast_req_reportfunction fast_req_trackfunction ct_dead_finifunction g2h_fence_initfunction g2h_fence_reinitfunction g2h_fence_cancelfunction g2h_fence_needs_allocfunction bufferfunction guc_h2g_sizefunction guc_g2h_sizefunction guc_ct_finifunction primelockdepfunction xe_guc_ct_init_noallocfunction guc_action_disable_ctfunction xe_guc_ct_initfunction memoryfunction guc_ct_ctb_h2g_initfunction guc_ct_ctb_g2h_initfunction guc_ct_ctb_h2g_registerfunction guc_ct_ctb_g2h_registerfunction guc_ct_control_togglefunction guc_ct_change_statefunction ct_needs_safe_modefunction ct_restart_safe_mode_workerfunction safe_mode_worker_funcfunction ct_enter_safe_modefunction ct_exit_safe_modefunction __xe_guc_ct_startfunction xe_guc_ct_restartfunction xe_guc_ct_enablefunction stop_g2h_handlerfunction xe_guc_ct_disablefunction xe_guc_ct_flush_and_stopfunction xe_guc_ct_stopfunction xe_guc_ct_runtime_suspendfunction xe_guc_ct_runtime_resumefunction h2g_has_roomfunction g2h_has_roomfunction has_roomfunction h2g_reserve_spacefunction __g2h_reserve_spacefunction __g2h_release_spacefunction g2h_release_space
Annotated Snippet
struct g2h_fence {
u32 *response_buffer;
u32 seqno;
/* fields below this point are setup based on the response */
u32 response_data;
u16 response_len;
u16 error;
u16 hint;
u16 reason;
u32 counter;
bool cancel;
bool retry;
bool wait;
bool fail;
bool done;
};
static void g2h_fence_init(struct g2h_fence *g2h_fence, u32 *response_buffer)
{
memset(g2h_fence, 0, sizeof(*g2h_fence));
g2h_fence->response_buffer = response_buffer;
g2h_fence->seqno = ~0x0;
}
static void g2h_fence_reinit(struct g2h_fence *g2h_fence)
{
memset_after(g2h_fence, 0, seqno);
}
static void g2h_fence_cancel(struct g2h_fence *g2h_fence)
{
g2h_fence->cancel = true;
g2h_fence->fail = true;
/* WRITE_ONCE pairs with READ_ONCEs in guc_ct_send_recv. */
WRITE_ONCE(g2h_fence->done, true);
}
static bool g2h_fence_needs_alloc(struct g2h_fence *g2h_fence)
{
return g2h_fence->seqno == ~0x0;
}
/**
* DOC: GuC CTB Blob
*
* We allocate single blob to hold both CTB descriptors and buffers:
*
* +--------+-----------------------------------------------+------+
* | offset | contents | size |
* +========+===============================================+======+
* | 0x0000 | H2G CTB Descriptor (send) | |
* +--------+-----------------------------------------------+ 4K |
* | 0x0800 | G2H CTB Descriptor (g2h) | |
* +--------+-----------------------------------------------+------+
* | 0x1000 | H2G CT Buffer (send) | n*4K |
* | | | |
* +--------+-----------------------------------------------+------+
* | 0x1000 | G2H CT Buffer (g2h) | m*4K |
* | + n*4K | | |
* +--------+-----------------------------------------------+------+
*
* Size of each ``CT Buffer`` must be multiple of 4K.
* We don't expect too many messages in flight at any time, unless we are
* using the GuC submission. In that case each request requires a minimum
* 2 dwords which gives us a maximum 256 queue'd requests. Hopefully this
* enough space to avoid backpressure on the driver. We increase the size
* of the receive buffer (relative to the send) to ensure a G2H response
* CTB has a landing spot.
*
* In addition to submissions, the G2H buffer needs to be able to hold
* enough space for recoverable page fault notifications. The number of
* page faults is interrupt driven and can be as much as the number of
* compute resources available. However, most of the actual work for these
* is in a separate page fault worker thread. Therefore we only need to
* make sure the queue has enough space to handle all of the submissions
* and responses and an extra buffer for incoming page faults.
*/
#define CTB_DESC_SIZE ALIGN(sizeof(struct guc_ct_buffer_desc), SZ_2K)
#define CTB_H2G_BUFFER_OFFSET (CTB_DESC_SIZE * 2)
#define CTB_G2H_BUFFER_OFFSET (CTB_DESC_SIZE * 2)
#define CTB_H2G_BUFFER_SIZE (SZ_4K)
#define CTB_H2G_BUFFER_DWORDS (CTB_H2G_BUFFER_SIZE / sizeof(u32))
#define CTB_G2H_BUFFER_SIZE (SZ_128K)
#define CTB_G2H_BUFFER_DWORDS (CTB_G2H_BUFFER_SIZE / sizeof(u32))
#define G2H_ROOM_BUFFER_SIZE (CTB_G2H_BUFFER_SIZE / 2)
#define G2H_ROOM_BUFFER_DWORDS (CTB_G2H_BUFFER_DWORDS / 2)
/**
Annotation
- Immediate include surface: `xe_guc_ct.h`, `linux/bitfield.h`, `linux/circ_buf.h`, `linux/delay.h`, `linux/fault-inject.h`, `kunit/static_stub.h`, `drm/drm_managed.h`, `abi/guc_actions_abi.h`.
- Detected declarations: `struct g2h_fence`, `function ct_dead_fini`, `function ct_dead_init`, `function fast_req_stack_save`, `function fast_req_dump`, `function fast_req_report`, `function fast_req_track`, `function ct_dead_fini`, `function g2h_fence_init`, `function g2h_fence_reinit`.
- 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.