xref: /linux/drivers/gpu/drm/xe/abi/guc_capture_abi.h (revision 2c1ed907520c50326b8f604907a8478b27881a2e)
19c8c7a7eSZhanjun Dong /* SPDX-License-Identifier: MIT */
29c8c7a7eSZhanjun Dong /*
39c8c7a7eSZhanjun Dong  * Copyright © 2024 Intel Corporation
49c8c7a7eSZhanjun Dong  */
59c8c7a7eSZhanjun Dong 
69c8c7a7eSZhanjun Dong #ifndef _ABI_GUC_CAPTURE_ABI_H
79c8c7a7eSZhanjun Dong #define _ABI_GUC_CAPTURE_ABI_H
89c8c7a7eSZhanjun Dong 
99c8c7a7eSZhanjun Dong #include <linux/types.h>
109c8c7a7eSZhanjun Dong 
119c8c7a7eSZhanjun Dong /* Capture List Index */
129c8c7a7eSZhanjun Dong enum guc_capture_list_index_type {
139c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_INDEX_PF = 0,
149c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_INDEX_VF = 1,
159c8c7a7eSZhanjun Dong };
169c8c7a7eSZhanjun Dong 
179c8c7a7eSZhanjun Dong #define GUC_CAPTURE_LIST_INDEX_MAX	(GUC_CAPTURE_LIST_INDEX_VF + 1)
189c8c7a7eSZhanjun Dong 
199c8c7a7eSZhanjun Dong /* Register-types of GuC capture register lists */
209c8c7a7eSZhanjun Dong enum guc_state_capture_type {
219c8c7a7eSZhanjun Dong 	GUC_STATE_CAPTURE_TYPE_GLOBAL = 0,
229c8c7a7eSZhanjun Dong 	GUC_STATE_CAPTURE_TYPE_ENGINE_CLASS,
239c8c7a7eSZhanjun Dong 	GUC_STATE_CAPTURE_TYPE_ENGINE_INSTANCE
249c8c7a7eSZhanjun Dong };
259c8c7a7eSZhanjun Dong 
269c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_TYPE_MAX	(GUC_STATE_CAPTURE_TYPE_ENGINE_INSTANCE + 1)
279c8c7a7eSZhanjun Dong 
28*75fd04f2SNitin Gote /* Class indices for capture_class and capture_instance arrays */
299c8c7a7eSZhanjun Dong enum guc_capture_list_class_type {
309c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE = 0,
319c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_CLASS_VIDEO = 1,
329c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE = 2,
339c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_CLASS_BLITTER = 3,
349c8c7a7eSZhanjun Dong 	GUC_CAPTURE_LIST_CLASS_GSC_OTHER = 4,
359c8c7a7eSZhanjun Dong };
369c8c7a7eSZhanjun Dong 
379c8c7a7eSZhanjun Dong #define GUC_CAPTURE_LIST_CLASS_MAX	(GUC_CAPTURE_LIST_CLASS_GSC_OTHER + 1)
389c8c7a7eSZhanjun Dong 
399c8c7a7eSZhanjun Dong /**
409c8c7a7eSZhanjun Dong  * struct guc_mmio_reg - GuC MMIO reg state struct
419c8c7a7eSZhanjun Dong  *
429c8c7a7eSZhanjun Dong  * GuC MMIO reg state struct
439c8c7a7eSZhanjun Dong  */
449c8c7a7eSZhanjun Dong struct guc_mmio_reg {
459c8c7a7eSZhanjun Dong 	/** @offset: MMIO Offset - filled in by Host */
469c8c7a7eSZhanjun Dong 	u32 offset;
479c8c7a7eSZhanjun Dong 	/** @value: MMIO Value - Used by Firmware to store value */
489c8c7a7eSZhanjun Dong 	u32 value;
499c8c7a7eSZhanjun Dong 	/** @flags: Flags for accessing the MMIO */
509c8c7a7eSZhanjun Dong 	u32 flags;
519c8c7a7eSZhanjun Dong 	/** @mask: Value of a mask to apply if mask with value is set */
529c8c7a7eSZhanjun Dong 	u32 mask;
539c8c7a7eSZhanjun Dong #define GUC_REGSET_MASKED		BIT(0)
549c8c7a7eSZhanjun Dong #define GUC_REGSET_STEERING_NEEDED	BIT(1)
559c8c7a7eSZhanjun Dong #define GUC_REGSET_MASKED_WITH_VALUE	BIT(2)
569c8c7a7eSZhanjun Dong #define GUC_REGSET_RESTORE_ONLY		BIT(3)
579c8c7a7eSZhanjun Dong #define GUC_REGSET_STEERING_GROUP       GENMASK(16, 12)
589c8c7a7eSZhanjun Dong #define GUC_REGSET_STEERING_INSTANCE    GENMASK(23, 20)
599c8c7a7eSZhanjun Dong } __packed;
609c8c7a7eSZhanjun Dong 
619c8c7a7eSZhanjun Dong /**
629c8c7a7eSZhanjun Dong  * struct guc_mmio_reg_set - GuC register sets
639c8c7a7eSZhanjun Dong  *
649c8c7a7eSZhanjun Dong  * GuC register sets
659c8c7a7eSZhanjun Dong  */
669c8c7a7eSZhanjun Dong struct guc_mmio_reg_set {
679c8c7a7eSZhanjun Dong 	/** @address: register address */
689c8c7a7eSZhanjun Dong 	u32 address;
699c8c7a7eSZhanjun Dong 	/** @count: register count */
709c8c7a7eSZhanjun Dong 	u16 count;
719c8c7a7eSZhanjun Dong 	/** @reserved: reserved */
729c8c7a7eSZhanjun Dong 	u16 reserved;
739c8c7a7eSZhanjun Dong } __packed;
749c8c7a7eSZhanjun Dong 
759c8c7a7eSZhanjun Dong /**
769c8c7a7eSZhanjun Dong  * struct guc_debug_capture_list_header - Debug capture list header.
779c8c7a7eSZhanjun Dong  *
789c8c7a7eSZhanjun Dong  * Debug capture list header.
799c8c7a7eSZhanjun Dong  */
809c8c7a7eSZhanjun Dong struct guc_debug_capture_list_header {
819c8c7a7eSZhanjun Dong 	/** @info: contains number of MMIO descriptors in the capture list. */
829c8c7a7eSZhanjun Dong 	u32 info;
839c8c7a7eSZhanjun Dong #define GUC_CAPTURELISTHDR_NUMDESCR GENMASK(15, 0)
849c8c7a7eSZhanjun Dong } __packed;
859c8c7a7eSZhanjun Dong 
869c8c7a7eSZhanjun Dong /**
879c8c7a7eSZhanjun Dong  * struct guc_debug_capture_list - Debug capture list
889c8c7a7eSZhanjun Dong  *
899c8c7a7eSZhanjun Dong  * As part of ADS registration, these header structures (followed by
909c8c7a7eSZhanjun Dong  * an array of 'struct guc_mmio_reg' entries) are used to register with
919c8c7a7eSZhanjun Dong  * GuC microkernel the list of registers we want it to dump out prior
929c8c7a7eSZhanjun Dong  * to a engine reset.
939c8c7a7eSZhanjun Dong  */
949c8c7a7eSZhanjun Dong struct guc_debug_capture_list {
959c8c7a7eSZhanjun Dong 	/** @header: Debug capture list header. */
969c8c7a7eSZhanjun Dong 	struct guc_debug_capture_list_header header;
979c8c7a7eSZhanjun Dong 	/** @regs: MMIO descriptors in the capture list. */
989c8c7a7eSZhanjun Dong 	struct guc_mmio_reg regs[];
999c8c7a7eSZhanjun Dong } __packed;
1009c8c7a7eSZhanjun Dong 
1019c8c7a7eSZhanjun Dong /**
1029c8c7a7eSZhanjun Dong  * struct guc_state_capture_header_t - State capture header.
1039c8c7a7eSZhanjun Dong  *
1049c8c7a7eSZhanjun Dong  * Prior to resetting engines that have hung or faulted, GuC microkernel
1059c8c7a7eSZhanjun Dong  * reports the engine error-state (register values that was read) by
1069c8c7a7eSZhanjun Dong  * logging them into the shared GuC log buffer using these hierarchy
1079c8c7a7eSZhanjun Dong  * of structures.
1089c8c7a7eSZhanjun Dong  */
1099c8c7a7eSZhanjun Dong struct guc_state_capture_header_t {
1109c8c7a7eSZhanjun Dong 	/**
1119c8c7a7eSZhanjun Dong 	 * @owner: VFID
1129c8c7a7eSZhanjun Dong 	 * BR[ 7: 0] MBZ when SRIOV is disabled. When SRIOV is enabled
1139c8c7a7eSZhanjun Dong 	 * VFID is an integer in range [0, 63] where 0 means the state capture
1149c8c7a7eSZhanjun Dong 	 * is corresponding to the PF and an integer N in range [1, 63] means
1159c8c7a7eSZhanjun Dong 	 * the state capture is for VF N.
1169c8c7a7eSZhanjun Dong 	 */
1179c8c7a7eSZhanjun Dong 	u32 owner;
1189c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_HEADER_VFID GENMASK(7, 0)
1199c8c7a7eSZhanjun Dong 	/** @info: Engine class/instance and capture type info */
1209c8c7a7eSZhanjun Dong 	u32 info;
1219c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_HEADER_CAPTURE_TYPE GENMASK(3, 0) /* see guc_state_capture_type */
1229c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_HEADER_ENGINE_CLASS GENMASK(7, 4) /* see guc_capture_list_class_type */
1239c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_HEADER_ENGINE_INSTANCE GENMASK(11, 8)
1249c8c7a7eSZhanjun Dong 	/**
1259c8c7a7eSZhanjun Dong 	 * @lrca: logical ring context address.
1269c8c7a7eSZhanjun Dong 	 * if type-instance, LRCA (address) that hung, else set to ~0
1279c8c7a7eSZhanjun Dong 	 */
1289c8c7a7eSZhanjun Dong 	u32 lrca;
1299c8c7a7eSZhanjun Dong 	/**
1309c8c7a7eSZhanjun Dong 	 * @guc_id: context_index.
1319c8c7a7eSZhanjun Dong 	 * if type-instance, context index of hung context, else set to ~0
1329c8c7a7eSZhanjun Dong 	 */
1339c8c7a7eSZhanjun Dong 	u32 guc_id;
1349c8c7a7eSZhanjun Dong 	/** @num_mmio_entries: Number of captured MMIO entries. */
1359c8c7a7eSZhanjun Dong 	u32 num_mmio_entries;
1369c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_HEADER_NUM_MMIO_ENTRIES GENMASK(9, 0)
1379c8c7a7eSZhanjun Dong } __packed;
1389c8c7a7eSZhanjun Dong 
1399c8c7a7eSZhanjun Dong /**
1409c8c7a7eSZhanjun Dong  * struct guc_state_capture_t - State capture.
1419c8c7a7eSZhanjun Dong  *
1429c8c7a7eSZhanjun Dong  * State capture
1439c8c7a7eSZhanjun Dong  */
1449c8c7a7eSZhanjun Dong struct guc_state_capture_t {
1459c8c7a7eSZhanjun Dong 	/** @header: State capture header. */
1469c8c7a7eSZhanjun Dong 	struct guc_state_capture_header_t header;
1479c8c7a7eSZhanjun Dong 	/** @mmio_entries: Array of captured guc_mmio_reg entries. */
1489c8c7a7eSZhanjun Dong 	struct guc_mmio_reg mmio_entries[];
1499c8c7a7eSZhanjun Dong } __packed;
1509c8c7a7eSZhanjun Dong 
1519c8c7a7eSZhanjun Dong /* State Capture Group Type */
1529c8c7a7eSZhanjun Dong enum guc_state_capture_group_type {
1539c8c7a7eSZhanjun Dong 	GUC_STATE_CAPTURE_GROUP_TYPE_FULL = 0,
1549c8c7a7eSZhanjun Dong 	GUC_STATE_CAPTURE_GROUP_TYPE_PARTIAL
1559c8c7a7eSZhanjun Dong };
1569c8c7a7eSZhanjun Dong 
1579c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_GROUP_TYPE_MAX (GUC_STATE_CAPTURE_GROUP_TYPE_PARTIAL + 1)
1589c8c7a7eSZhanjun Dong 
1599c8c7a7eSZhanjun Dong /**
1609c8c7a7eSZhanjun Dong  * struct guc_state_capture_group_header_t - State capture group header
1619c8c7a7eSZhanjun Dong  *
1629c8c7a7eSZhanjun Dong  * State capture group header.
1639c8c7a7eSZhanjun Dong  */
1649c8c7a7eSZhanjun Dong struct guc_state_capture_group_header_t {
1659c8c7a7eSZhanjun Dong 	/** @owner: VFID */
1669c8c7a7eSZhanjun Dong 	u32 owner;
1679c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_GROUP_HEADER_VFID GENMASK(7, 0)
1689c8c7a7eSZhanjun Dong 	/** @info: Engine class/instance and capture type info */
1699c8c7a7eSZhanjun Dong 	u32 info;
1709c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_GROUP_HEADER_NUM_CAPTURES GENMASK(7, 0)
1719c8c7a7eSZhanjun Dong #define GUC_STATE_CAPTURE_GROUP_HEADER_CAPTURE_GROUP_TYPE GENMASK(15, 8)
1729c8c7a7eSZhanjun Dong } __packed;
1739c8c7a7eSZhanjun Dong 
1749c8c7a7eSZhanjun Dong /**
1759c8c7a7eSZhanjun Dong  * struct guc_state_capture_group_t - State capture group.
1769c8c7a7eSZhanjun Dong  *
1779c8c7a7eSZhanjun Dong  * this is the top level structure where an error-capture dump starts
1789c8c7a7eSZhanjun Dong  */
1799c8c7a7eSZhanjun Dong struct guc_state_capture_group_t {
1809c8c7a7eSZhanjun Dong 	/** @grp_header: State capture group header. */
1819c8c7a7eSZhanjun Dong 	struct guc_state_capture_group_header_t grp_header;
1829c8c7a7eSZhanjun Dong 	/** @capture_entries: Array of state captures */
1839c8c7a7eSZhanjun Dong 	struct guc_state_capture_t capture_entries[];
1849c8c7a7eSZhanjun Dong } __packed;
1859c8c7a7eSZhanjun Dong 
1869c8c7a7eSZhanjun Dong #endif
187