drivers/gpu/drm/xe/xe_gt.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gt.c- Extension
.c- Size
- 26580 bytes
- Lines
- 1187
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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_gt.hlinux/minmax.hkunit/visibility.hdrm/drm_managed.huapi/drm/xe_drm.hgenerated/xe_device_wa_oob.hgenerated/xe_wa_oob.hinstructions/xe_alu_commands.hinstructions/xe_mi_commands.hregs/xe_engine_regs.hregs/xe_gt_regs.hxe_assert.hxe_bb.hxe_device.hxe_eu_stall.hxe_exec_queue.hxe_execlist.hxe_force_wake.hxe_ggtt.hxe_gsc.hxe_gt_ccs_mode.hxe_gt_clock.hxe_gt_freq.hxe_gt_idle.hxe_gt_mcr.hxe_gt_printk.hxe_gt_sriov_pf.hxe_gt_sriov_vf.hxe_gt_stats.hxe_gt_sysfs.hxe_gt_topology.hxe_guc_exec_queue_types.h
Detected Declarations
function xe_gt_sanitizefunction xe_gt_enable_host_l2_vramfunction xe_gt_disable_host_l2_vramfunction xe_gt_enable_comp_1wcohfunction emit_job_syncfunction emit_nop_jobfunction emit_wa_jobfunction xa_for_eachfunction xe_gt_record_default_lrcsfunction for_each_hw_enginefunction wa_14026539277function xe_gt_init_earlyfunction dump_pat_on_errorfunction gt_init_with_gt_forcewakefunction gt_init_with_all_forcewakefunction xe_gt_finifunction xe_gt_initfunction xe_gt_mmio_initfunction xe_gt_record_user_enginesfunction for_each_hw_enginefunction do_gt_resetfunction vf_gt_restartfunction do_gt_restartfunction gt_reset_workerfunction xe_gt_reset_asyncfunction xe_gt_suspend_preparefunction xe_gt_suspendfunction xe_gt_shutdownfunction xe_gt_sanitize_freqfunction xe_gt_resumefunction xe_gt_runtime_suspendfunction xe_gt_runtime_resumefunction for_each_hw_enginefunction xe_gt_declare_wedged
Annotated Snippet
if (xe_gt_is_media_type(gt)) {
xe_mmio_rmw32(>->mmio, XE2_GAMWALK_CTRL_MEDIA, 0, EN_CMP_1WCOH_GW);
} else {
reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMWALK_CTRL_3D);
reg |= EN_CMP_1WCOH_GW;
xe_gt_mcr_multicast_write(gt, XE2_GAMWALK_CTRL_3D, reg);
}
}
}
static void gt_reset_worker(struct work_struct *w);
static int emit_job_sync(struct xe_exec_queue *q, struct xe_bb *bb,
long timeout_jiffies, bool force_reset)
{
struct xe_sched_job *job;
struct dma_fence *fence;
long timeout;
job = xe_bb_create_job(q, bb);
if (IS_ERR(job))
return PTR_ERR(job);
job->ring_ops_force_reset = force_reset;
xe_sched_job_arm(job);
fence = dma_fence_get(&job->drm.s_fence->finished);
xe_sched_job_push(job);
timeout = dma_fence_wait_timeout(fence, false, timeout_jiffies);
dma_fence_put(fence);
if (timeout < 0)
return timeout;
else if (!timeout)
return -ETIME;
return 0;
}
static int emit_nop_job(struct xe_gt *gt, struct xe_exec_queue *q)
{
struct xe_bb *bb;
int ret;
bb = xe_bb_new(gt, 4, false);
if (IS_ERR(bb))
return PTR_ERR(bb);
ret = emit_job_sync(q, bb, HZ, false);
xe_bb_free(bb, NULL);
return ret;
}
/* Dwords required to emit a RMW of a register */
#define EMIT_RMW_DW 20
static int emit_wa_job(struct xe_gt *gt, struct xe_exec_queue *q)
{
struct xe_hw_engine *hwe = q->hwe;
struct xe_reg_sr *sr = &hwe->reg_lrc;
struct xe_reg_sr_entry *entry;
int count_rmw = 0, count_rmw_mcr = 0, count = 0, ret;
unsigned long idx;
struct xe_bb *bb;
size_t bb_len = 0;
u32 *cs;
/* count RMW registers as those will be handled separately */
xa_for_each(&sr->xa, idx, entry) {
if (entry->reg.masked || entry->clr_bits == ~0)
++count;
else if (entry->reg.mcr)
++count_rmw_mcr;
else
++count_rmw;
}
if (count)
bb_len += count * 2 + 1;
/*
* RMW of MCR registers is the same as a normal RMW, except an
* additional LRI (3 dwords) is required per register to steer the read
* to a nom-terminated instance.
*
* We could probably shorten the batch slightly by eliding the
* steering for consecutive MCR registers that have the same
* group/instance target, but it's not worth the extra complexity to do
* so.
Annotation
- Immediate include surface: `xe_gt.h`, `linux/minmax.h`, `kunit/visibility.h`, `drm/drm_managed.h`, `uapi/drm/xe_drm.h`, `generated/xe_device_wa_oob.h`, `generated/xe_wa_oob.h`, `instructions/xe_alu_commands.h`.
- Detected declarations: `function xe_gt_sanitize`, `function xe_gt_enable_host_l2_vram`, `function xe_gt_disable_host_l2_vram`, `function xe_gt_enable_comp_1wcoh`, `function emit_job_sync`, `function emit_nop_job`, `function emit_wa_job`, `function xa_for_each`, `function xe_gt_record_default_lrcs`, `function for_each_hw_engine`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.