drivers/gpu/drm/xe/xe_gsc_submit.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gsc_submit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gsc_submit.c- Extension
.c- Size
- 6684 bytes
- Lines
- 219
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xe_gsc_submit.hlinux/poison.habi/gsc_command_header_abi.hxe_assert.hxe_bb.hxe_exec_queue.hxe_gt_types.hxe_map.hxe_sched_job.hinstructions/xe_gsc_commands.h
Detected Declarations
function gsc_to_gtfunction xe_gsc_create_host_session_idfunction xe_gsc_emit_headerfunction xe_gsc_poison_headerfunction xe_gsc_check_and_update_pendingfunction xe_gsc_read_out_headerfunction xe_gsc_pkt_submit_kernel
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023 Intel Corporation
*/
#include "xe_gsc_submit.h"
#include <linux/poison.h>
#include "abi/gsc_command_header_abi.h"
#include "xe_assert.h"
#include "xe_bb.h"
#include "xe_exec_queue.h"
#include "xe_gt_types.h"
#include "xe_map.h"
#include "xe_sched_job.h"
#include "instructions/xe_gsc_commands.h"
#define GSC_HDR_SIZE (sizeof(struct intel_gsc_mtl_header)) /* shorthand define */
#define mtl_gsc_header_wr(xe_, map_, offset_, field_, val_) \
xe_map_wr_field(xe_, map_, offset_, struct intel_gsc_mtl_header, field_, val_)
#define mtl_gsc_header_rd(xe_, map_, offset_, field_) \
xe_map_rd_field(xe_, map_, offset_, struct intel_gsc_mtl_header, field_)
/*
* GSC FW allows us to define the host_session_handle as we see fit, as long
* as we use unique identifier for each user, with handle 0 being reserved for
* kernel usage.
* To be able to differentiate which client subsystem owns the given session, we
* include the client id in the top 8 bits of the handle.
*/
#define HOST_SESSION_CLIENT_MASK GENMASK_ULL(63, 56)
static struct xe_gt *
gsc_to_gt(struct xe_gsc *gsc)
{
return container_of(gsc, struct xe_gt, uc.gsc);
}
/**
* xe_gsc_create_host_session_id - Creates a random 64 bit host_session id with
* bits 56-63 masked.
*
* Returns: random host_session_id which can be used to send messages to gsc cs
*/
u64 xe_gsc_create_host_session_id(void)
{
u64 host_session_id;
get_random_bytes(&host_session_id, sizeof(u64));
host_session_id &= ~HOST_SESSION_CLIENT_MASK;
return host_session_id;
}
/**
* xe_gsc_emit_header - write the MTL GSC header in memory
* @xe: the Xe device
* @map: the iosys map to write to
* @offset: offset from the start of the map at which to write the header
* @heci_client_id: client id identifying the type of command (see abi for values)
* @host_session_id: host session ID of the caller
* @payload_size: size of the payload that follows the header
*
* Returns: offset memory location following the header
*/
u32 xe_gsc_emit_header(struct xe_device *xe, struct iosys_map *map, u32 offset,
u8 heci_client_id, u64 host_session_id, u32 payload_size)
{
xe_assert(xe, !(host_session_id & HOST_SESSION_CLIENT_MASK));
if (host_session_id)
host_session_id |= FIELD_PREP(HOST_SESSION_CLIENT_MASK, heci_client_id);
xe_map_memset(xe, map, offset, 0, GSC_HDR_SIZE);
mtl_gsc_header_wr(xe, map, offset, validity_marker, GSC_HECI_VALIDITY_MARKER);
mtl_gsc_header_wr(xe, map, offset, heci_client_id, heci_client_id);
mtl_gsc_header_wr(xe, map, offset, host_session_handle, host_session_id);
mtl_gsc_header_wr(xe, map, offset, header_version, MTL_GSC_HEADER_VERSION);
mtl_gsc_header_wr(xe, map, offset, message_size, payload_size + GSC_HDR_SIZE);
return offset + GSC_HDR_SIZE;
};
/**
* xe_gsc_poison_header - poison the MTL GSC header in memory
* @xe: the Xe device
* @map: the iosys map to write to
Annotation
- Immediate include surface: `xe_gsc_submit.h`, `linux/poison.h`, `abi/gsc_command_header_abi.h`, `xe_assert.h`, `xe_bb.h`, `xe_exec_queue.h`, `xe_gt_types.h`, `xe_map.h`.
- Detected declarations: `function gsc_to_gt`, `function xe_gsc_create_host_session_id`, `function xe_gsc_emit_header`, `function xe_gsc_poison_header`, `function xe_gsc_check_and_update_pending`, `function xe_gsc_read_out_header`, `function xe_gsc_pkt_submit_kernel`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.