1 /* SPDX-License-Identifier: MIT */
2 /*
3 * Copyright © 2022 Intel Corporation
4 */
5
6 #ifndef _XE_GUC_CT_H_
7 #define _XE_GUC_CT_H_
8
9 #include "xe_guc_ct_types.h"
10
11 struct drm_printer;
12
13 int xe_guc_ct_init(struct xe_guc_ct *ct);
14 int xe_guc_ct_enable(struct xe_guc_ct *ct);
15 void xe_guc_ct_disable(struct xe_guc_ct *ct);
16 void xe_guc_ct_fast_path(struct xe_guc_ct *ct);
17
18 struct xe_guc_ct_snapshot *
19 xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct, bool atomic);
20 void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot,
21 struct drm_printer *p);
22 void xe_guc_ct_snapshot_free(struct xe_guc_ct_snapshot *snapshot);
23 void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool atomic);
24
xe_guc_ct_irq_handler(struct xe_guc_ct * ct)25 static inline void xe_guc_ct_irq_handler(struct xe_guc_ct *ct)
26 {
27 wake_up_all(&ct->wq);
28 if (ct->enabled)
29 queue_work(system_unbound_wq, &ct->g2h_worker);
30 xe_guc_ct_fast_path(ct);
31 }
32
33 /* Basic CT send / receives */
34 int xe_guc_ct_send(struct xe_guc_ct *ct, const u32 *action, u32 len,
35 u32 g2h_len, u32 num_g2h);
36 int xe_guc_ct_send_locked(struct xe_guc_ct *ct, const u32 *action, u32 len,
37 u32 g2h_len, u32 num_g2h);
38 int xe_guc_ct_send_recv(struct xe_guc_ct *ct, const u32 *action, u32 len,
39 u32 *response_buffer);
40 static inline int
xe_guc_ct_send_block(struct xe_guc_ct * ct,const u32 * action,u32 len)41 xe_guc_ct_send_block(struct xe_guc_ct *ct, const u32 *action, u32 len)
42 {
43 return xe_guc_ct_send_recv(ct, action, len, NULL);
44 }
45
46 /* This is only version of the send CT you can call from a G2H handler */
47 int xe_guc_ct_send_g2h_handler(struct xe_guc_ct *ct, const u32 *action,
48 u32 len);
49
50 /* Can't fail because a GT reset is in progress */
51 int xe_guc_ct_send_recv_no_fail(struct xe_guc_ct *ct, const u32 *action,
52 u32 len, u32 *response_buffer);
53 static inline int
xe_guc_ct_send_block_no_fail(struct xe_guc_ct * ct,const u32 * action,u32 len)54 xe_guc_ct_send_block_no_fail(struct xe_guc_ct *ct, const u32 *action, u32 len)
55 {
56 return xe_guc_ct_send_recv_no_fail(ct, action, len, NULL);
57 }
58
59 #endif
60