drivers/gpu/drm/xe/xe_guc_log.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_guc_log.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_guc_log.c
Extension
.c
Size
19182 bytes
Lines
681
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct guc_log_buffer_entry_list {
	u32 offset;
	u32 rd_ptr;
	u32 wr_ptr;
	u32 wrap_offset;
	u32 buf_size;
};

struct guc_lic_save {
	u32 version;
	/*
	 * Array of init config KLV values.
	 * Range from GUC_LOG_LIC_TYPE_FIRST to GUC_LOG_LIC_TYPE_LAST
	 */
	u32 values[GUC_LIC_TYPE_LAST - GUC_LIC_TYPE_FIRST + 1];
	struct guc_log_buffer_entry_list entry[GUC_LOG_BUFFER_INIT_CONFIG];
};

static struct guc_log_buffer_entry_markers {
	u32 key[2];
} const entry_markers[GUC_LOG_BUFFER_INIT_CONFIG + 1] = {
	{{
		GUC_LFD_LOG_BUFFER_MARKER_1V2,
		GUC_LFD_LOG_BUFFER_MARKER_2
	}},
	{{
		GUC_LFD_LOG_BUFFER_MARKER_1V2,
		GUC_LFD_CRASH_DUMP_BUFFER_MARKER_2
	}},
	{{
		GUC_LFD_STATE_CAPTURE_BUFFER_MARKER_1V2,
		GUC_LFD_STATE_CAPTURE_BUFFER_MARKER_2
	}},
	{{
		GUC_LIC_MAGIC,
		(FIELD_PREP_CONST(GUC_LIC_VERSION_MASK_MAJOR, GUC_LIC_VERSION_MAJOR) |
		 FIELD_PREP_CONST(GUC_LIC_VERSION_MASK_MINOR, GUC_LIC_VERSION_MINOR))
	}}
};

static struct guc_log_lic_lfd_map {
	u32 lic;
	u32 lfd;
} const lic_lfd_type_map[] = {
	{GUC_LIC_TYPE_GUC_SW_VERSION,		GUC_LFD_TYPE_FW_VERSION},
	{GUC_LIC_TYPE_GUC_DEVICE_ID,		GUC_LFD_TYPE_GUC_DEVICE_ID},
	{GUC_LIC_TYPE_TSC_FREQUENCY,		GUC_LFD_TYPE_TSC_FREQUENCY},
	{GUC_LIC_TYPE_GMD_ID,			GUC_LFD_TYPE_GMD_ID},
	{GUC_LIC_TYPE_BUILD_PLATFORM_ID,	GUC_LFD_TYPE_BUILD_PLATFORM_ID}
};

static struct xe_guc *
log_to_guc(struct xe_guc_log *log)
{
	return container_of(log, struct xe_guc, log);
}

static struct xe_gt *
log_to_gt(struct xe_guc_log *log)
{
	return container_of(log, struct xe_gt, uc.guc.log);
}

static struct xe_device *
log_to_xe(struct xe_guc_log *log)
{
	return gt_to_xe(log_to_gt(log));
}

static struct xe_guc_log_snapshot *xe_guc_log_snapshot_alloc(struct xe_guc_log *log, bool atomic)
{
	struct xe_guc_log_snapshot *snapshot;
	size_t remain;
	int i;

	snapshot = kzalloc_obj(*snapshot, atomic ? GFP_ATOMIC : GFP_KERNEL);
	if (!snapshot)
		return NULL;

	/*
	 * NB: kmalloc has a hard limit well below the maximum GuC log buffer size.
	 * Also, can't use vmalloc as might be called from atomic context. So need
	 * to break the buffer up into smaller chunks that can be allocated.
	 */
	snapshot->size = xe_bo_size(log->bo);
	snapshot->num_chunks = DIV_ROUND_UP(snapshot->size, GUC_LOG_CHUNK_SIZE);

	snapshot->copy = kzalloc_objs(*snapshot->copy, snapshot->num_chunks,
				      atomic ? GFP_ATOMIC : GFP_KERNEL);
	if (!snapshot->copy)

Annotation

Implementation Notes