1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #ifndef __AMDGPU_CTX_H__
24 #define __AMDGPU_CTX_H__
25
26 #include "amdgpu_ring.h"
27
28 struct drm_device;
29 struct drm_file;
30 struct amdgpu_fpriv;
31
32 struct amdgpu_ctx_entity {
33 uint64_t sequence;
34 struct dma_fence **fences;
35 struct drm_sched_entity entity;
36 };
37
38 struct amdgpu_ctx {
39 struct kref refcount;
40 struct amdgpu_device *adev;
41 unsigned reset_counter;
42 unsigned reset_counter_query;
43 uint32_t vram_lost_counter;
44 spinlock_t ring_lock;
45 struct dma_fence **fences;
46 struct amdgpu_ctx_entity *entities[AMDGPU_HW_IP_NUM];
47 bool preamble_presented;
48 enum drm_sched_priority init_priority;
49 enum drm_sched_priority override_priority;
50 struct mutex lock;
51 atomic_t guilty;
52 unsigned long ras_counter_ce;
53 unsigned long ras_counter_ue;
54 };
55
56 struct amdgpu_ctx_mgr {
57 struct amdgpu_device *adev;
58 struct mutex lock;
59
60 struct idr ctx_handles;
61 };
62
63 extern const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM];
64
65 struct amdgpu_ctx *amdgpu_ctx_get(struct amdgpu_fpriv *fpriv, uint32_t id);
66 int amdgpu_ctx_put(struct amdgpu_ctx *ctx);
67
68 int amdgpu_ctx_get_entity(struct amdgpu_ctx *ctx, u32 hw_ip, u32 instance,
69 u32 ring, struct drm_sched_entity **entity);
70 void amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx,
71 struct drm_sched_entity *entity,
72 struct dma_fence *fence, uint64_t *seq);
73 struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
74 struct drm_sched_entity *entity,
75 uint64_t seq);
76 void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx,
77 enum drm_sched_priority priority);
78
79 int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
80 struct drm_file *filp);
81
82 int amdgpu_ctx_wait_prev_fence(struct amdgpu_ctx *ctx,
83 struct drm_sched_entity *entity);
84
85 void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr);
86 void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr);
87 long amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr, long timeout);
88 void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr);
89
90 #endif