1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6 #ifndef _XE_GUC_CT_TYPES_H_ 7 #define _XE_GUC_CT_TYPES_H_ 8 9 #include <linux/interrupt.h> 10 #include <linux/iosys-map.h> 11 #include <linux/spinlock_types.h> 12 #include <linux/wait.h> 13 #include <linux/xarray.h> 14 15 #include "abi/guc_communication_ctb_abi.h" 16 17 struct xe_bo; 18 19 /** 20 * struct guc_ctb_info - GuC command transport buffer (CTB) info 21 */ 22 struct guc_ctb_info { 23 /** @size: size of CTB commands (DW) */ 24 u32 size; 25 /** @resv_space: reserved space of CTB commands (DW) */ 26 u32 resv_space; 27 /** @head: head of CTB commands (DW) */ 28 u32 head; 29 /** @tail: tail of CTB commands (DW) */ 30 u32 tail; 31 /** @space: space in CTB commands (DW) */ 32 u32 space; 33 /** @broken: channel broken */ 34 bool broken; 35 }; 36 37 /** 38 * struct guc_ctb - GuC command transport buffer (CTB) 39 */ 40 struct guc_ctb { 41 /** @desc: dma buffer map for CTB descriptor */ 42 struct iosys_map desc; 43 /** @cmds: dma buffer map for CTB commands */ 44 struct iosys_map cmds; 45 /** @info: CTB info */ 46 struct guc_ctb_info info; 47 }; 48 49 /** 50 * struct guc_ctb_snapshot - GuC command transport buffer (CTB) snapshot 51 */ 52 struct guc_ctb_snapshot { 53 /** @desc: snapshot of the CTB descriptor */ 54 struct guc_ct_buffer_desc desc; 55 /** @cmds: snapshot of the CTB commands */ 56 u32 *cmds; 57 /** @info: snapshot of the CTB info */ 58 struct guc_ctb_info info; 59 }; 60 61 /** 62 * struct xe_guc_ct_snapshot - GuC command transport (CT) snapshot 63 */ 64 struct xe_guc_ct_snapshot { 65 /** @ct_enabled: CT enabled info at capture time. */ 66 bool ct_enabled; 67 /** @g2h_outstanding: G2H outstanding info at the capture time */ 68 u32 g2h_outstanding; 69 /** @g2h: G2H CTB snapshot */ 70 struct guc_ctb_snapshot g2h; 71 /** @h2g: H2G CTB snapshot */ 72 struct guc_ctb_snapshot h2g; 73 }; 74 75 /** 76 * struct xe_guc_ct - GuC command transport (CT) layer 77 * 78 * Includes a pair of CT buffers for bi-directional communication and tracking 79 * for the H2G and G2H requests sent and received through the buffers. 80 */ 81 struct xe_guc_ct { 82 /** @bo: XE BO for CT */ 83 struct xe_bo *bo; 84 /** @lock: protects everything in CT layer */ 85 struct mutex lock; 86 /** @fast_lock: protects G2H channel and credits */ 87 spinlock_t fast_lock; 88 /** @ctbs: buffers for sending and receiving commands */ 89 struct { 90 /** @send: Host to GuC (H2G, send) channel */ 91 struct guc_ctb h2g; 92 /** @recv: GuC to Host (G2H, receive) channel */ 93 struct guc_ctb g2h; 94 } ctbs; 95 /** @g2h_outstanding: number of outstanding G2H */ 96 u32 g2h_outstanding; 97 /** @g2h_worker: worker to process G2H messages */ 98 struct work_struct g2h_worker; 99 /** @enabled: CT enabled */ 100 bool enabled; 101 /** @fence_seqno: G2H fence seqno - 16 bits used by CT */ 102 u32 fence_seqno; 103 /** @fence_lookup: G2H fence lookup */ 104 struct xarray fence_lookup; 105 /** @wq: wait queue used for reliable CT sends and freeing G2H credits */ 106 wait_queue_head_t wq; 107 /** @g2h_fence_wq: wait queue used for G2H fencing */ 108 wait_queue_head_t g2h_fence_wq; 109 /** @msg: Message buffer */ 110 u32 msg[GUC_CTB_MSG_MAX_LEN]; 111 /** @fast_msg: Message buffer */ 112 u32 fast_msg[GUC_CTB_MSG_MAX_LEN]; 113 }; 114 115 #endif 116