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
11struct drm_printer;
12struct xe_device;
13
14int xe_guc_ct_init_noalloc(struct xe_guc_ct *ct);
15int xe_guc_ct_init(struct xe_guc_ct *ct);
16int xe_guc_ct_init_post_hwconfig(struct xe_guc_ct *ct);
17int xe_guc_ct_enable(struct xe_guc_ct *ct);
18int xe_guc_ct_restart(struct xe_guc_ct *ct);
19void xe_guc_ct_disable(struct xe_guc_ct *ct);
20void xe_guc_ct_stop(struct xe_guc_ct *ct);
21void xe_guc_ct_flush_and_stop(struct xe_guc_ct *ct);
22void xe_guc_ct_fast_path(struct xe_guc_ct *ct);
23
24struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct);
25void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot, struct drm_printer *p);
26void xe_guc_ct_snapshot_free(struct xe_guc_ct_snapshot *snapshot);
27void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool want_ctb);
28
29static inline bool xe_guc_ct_initialized(struct xe_guc_ct *ct)
30{
31 return ct->state != XE_GUC_CT_STATE_NOT_INITIALIZED;
32}
33
34static inline bool xe_guc_ct_enabled(struct xe_guc_ct *ct)
35{
36 return ct->state == XE_GUC_CT_STATE_ENABLED;
37}
38
39static inline void xe_guc_ct_irq_handler(struct xe_guc_ct *ct)
40{
41 if (!xe_guc_ct_enabled(ct))
42 return;
43
44 wake_up_all(&ct->wq);
45 queue_work(wq: ct->g2h_wq, work: &ct->g2h_worker);
46 xe_guc_ct_fast_path(ct);
47}
48
49/* Basic CT send / receives */
50int xe_guc_ct_send(struct xe_guc_ct *ct, const u32 *action, u32 len,
51 u32 g2h_len, u32 num_g2h);
52int xe_guc_ct_send_locked(struct xe_guc_ct *ct, const u32 *action, u32 len,
53 u32 g2h_len, u32 num_g2h);
54int xe_guc_ct_send_recv(struct xe_guc_ct *ct, const u32 *action, u32 len,
55 u32 *response_buffer);
56static inline int
57xe_guc_ct_send_block(struct xe_guc_ct *ct, const u32 *action, u32 len)
58{
59 return xe_guc_ct_send_recv(ct, action, len, NULL);
60}
61
62/* This is only version of the send CT you can call from a G2H handler */
63int xe_guc_ct_send_g2h_handler(struct xe_guc_ct *ct, const u32 *action,
64 u32 len);
65
66/* Can't fail because a GT reset is in progress */
67int xe_guc_ct_send_recv_no_fail(struct xe_guc_ct *ct, const u32 *action,
68 u32 len, u32 *response_buffer);
69static inline int
70xe_guc_ct_send_block_no_fail(struct xe_guc_ct *ct, const u32 *action, u32 len)
71{
72 return xe_guc_ct_send_recv_no_fail(ct, action, len, NULL);
73}
74
75long xe_guc_ct_queue_proc_time_jiffies(struct xe_guc_ct *ct);
76
77/**
78 * xe_guc_ct_wake_waiters() - GuC CT wake up waiters
79 * @ct: GuC CT object
80 */
81static inline void xe_guc_ct_wake_waiters(struct xe_guc_ct *ct)
82{
83 wake_up_all(&ct->wq);
84}
85
86#endif
87

source code of linux/drivers/gpu/drm/xe/xe_guc_ct.h