drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c- Extension
.c- Size
- 9733 bytes
- Lines
- 372
- 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.
- 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
linux/bitfield.hlinux/cleanup.hlinux/minmax.hlinux/slab.hlinux/string.hregs/xe_sysctrl_regs.hxe_device.hxe_mmio.hxe_pm.hxe_printk.hxe_sysctrl.hxe_sysctrl_mailbox.hxe_sysctrl_mailbox_types.h
Detected Declarations
struct xe_sysctrl_mailbox_msg_hdrfunction sysctrl_wait_bit_clearfunction sysctrl_wait_bit_setfunction sysctrl_write_framefunction sysctrl_read_framefunction sysctrl_clear_responsefunction sysctrl_prepare_commandfunction sysctrl_send_framesfunction sysctrl_process_framefunction sysctrl_receive_framesfunction sysctrl_send_commandfunction xe_sysctrl_mailbox_initfunction xe_sysctrl_send_command
Annotated Snippet
struct xe_sysctrl_mailbox_msg_hdr {
__le32 data;
} __packed;
#define XE_SYSCTRL_HDR_GROUP_ID(hdr) \
FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, le32_to_cpu((hdr)->data))
#define XE_SYSCTRL_HDR_COMMAND(hdr) \
FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, le32_to_cpu((hdr)->data))
#define XE_SYSCTRL_HDR_IS_RESPONSE(hdr) \
FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, le32_to_cpu((hdr)->data))
#define XE_SYSCTRL_HDR_RESULT(hdr) \
FIELD_GET(SYSCTRL_HDR_RESULT_MASK, le32_to_cpu((hdr)->data))
static bool sysctrl_wait_bit_clear(struct xe_sysctrl *sc, u32 bit_mask,
unsigned int timeout_ms)
{
int ret;
ret = xe_mmio_wait32_not(sc->mmio, SYSCTRL_MB_CTRL, bit_mask, bit_mask,
timeout_ms * 1000, NULL, false);
return ret == 0;
}
static bool sysctrl_wait_bit_set(struct xe_sysctrl *sc, u32 bit_mask,
unsigned int timeout_ms)
{
int ret;
ret = xe_mmio_wait32(sc->mmio, SYSCTRL_MB_CTRL, bit_mask, bit_mask,
timeout_ms * 1000, NULL, false);
return ret == 0;
}
static int sysctrl_write_frame(struct xe_sysctrl *sc, const void *frame,
size_t len)
{
static const struct xe_reg regs[] = {
SYSCTRL_MB_DATA0, SYSCTRL_MB_DATA1, SYSCTRL_MB_DATA2, SYSCTRL_MB_DATA3
};
struct xe_device *xe = sc_to_xe(sc);
u32 val[XE_SYSCTRL_MB_FRAME_SIZE / sizeof(u32)] = {0};
u32 dw = DIV_ROUND_UP(len, sizeof(u32));
u32 i;
xe_assert(xe, len > 0 && len <= XE_SYSCTRL_MB_FRAME_SIZE);
memcpy(val, frame, len);
for (i = 0; i < dw; i++)
xe_mmio_write32(sc->mmio, regs[i], val[i]);
return 0;
}
static int sysctrl_read_frame(struct xe_sysctrl *sc, void *frame,
size_t len)
{
static const struct xe_reg regs[] = {
SYSCTRL_MB_DATA0, SYSCTRL_MB_DATA1, SYSCTRL_MB_DATA2, SYSCTRL_MB_DATA3
};
struct xe_device *xe = sc_to_xe(sc);
u32 val[XE_SYSCTRL_MB_FRAME_SIZE / sizeof(u32)] = {0};
u32 dw = DIV_ROUND_UP(len, sizeof(u32));
u32 i;
xe_assert(xe, len > 0 && len <= XE_SYSCTRL_MB_FRAME_SIZE);
for (i = 0; i < dw; i++)
val[i] = xe_mmio_read32(sc->mmio, regs[i]);
memcpy(frame, val, len);
return 0;
}
static void sysctrl_clear_response(struct xe_sysctrl *sc)
{
xe_mmio_rmw32(sc->mmio, SYSCTRL_MB_CTRL, SYSCTRL_MB_CTRL_RUN_BUSY_OUT, 0);
}
static int sysctrl_prepare_command(struct xe_device *xe,
u8 group_id, u8 command,
const void *data_in, size_t data_in_len,
u8 **mbox_cmd, size_t *cmd_size)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/minmax.h`, `linux/slab.h`, `linux/string.h`, `regs/xe_sysctrl_regs.h`, `xe_device.h`, `xe_mmio.h`.
- Detected declarations: `struct xe_sysctrl_mailbox_msg_hdr`, `function sysctrl_wait_bit_clear`, `function sysctrl_wait_bit_set`, `function sysctrl_write_frame`, `function sysctrl_read_frame`, `function sysctrl_clear_response`, `function sysctrl_prepare_command`, `function sysctrl_send_frames`, `function sysctrl_process_frame`, `function sysctrl_receive_frames`.
- 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.