This source file includes following definitions.
- radeon_semaphore_create
- radeon_semaphore_emit_signal
- radeon_semaphore_emit_wait
- radeon_semaphore_free
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include "radeon.h"
32 #include "radeon_trace.h"
33
34 int radeon_semaphore_create(struct radeon_device *rdev,
35 struct radeon_semaphore **semaphore)
36 {
37 int r;
38
39 *semaphore = kmalloc(sizeof(struct radeon_semaphore), GFP_KERNEL);
40 if (*semaphore == NULL) {
41 return -ENOMEM;
42 }
43 r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo,
44 &(*semaphore)->sa_bo, 8, 8);
45 if (r) {
46 kfree(*semaphore);
47 *semaphore = NULL;
48 return r;
49 }
50 (*semaphore)->waiters = 0;
51 (*semaphore)->gpu_addr = radeon_sa_bo_gpu_addr((*semaphore)->sa_bo);
52
53 *((uint64_t *)radeon_sa_bo_cpu_addr((*semaphore)->sa_bo)) = 0;
54
55 return 0;
56 }
57
58 bool radeon_semaphore_emit_signal(struct radeon_device *rdev, int ridx,
59 struct radeon_semaphore *semaphore)
60 {
61 struct radeon_ring *ring = &rdev->ring[ridx];
62
63 trace_radeon_semaphore_signale(ridx, semaphore);
64
65 if (radeon_semaphore_ring_emit(rdev, ridx, ring, semaphore, false)) {
66 --semaphore->waiters;
67
68
69 ring->last_semaphore_signal_addr = semaphore->gpu_addr;
70 return true;
71 }
72 return false;
73 }
74
75 bool radeon_semaphore_emit_wait(struct radeon_device *rdev, int ridx,
76 struct radeon_semaphore *semaphore)
77 {
78 struct radeon_ring *ring = &rdev->ring[ridx];
79
80 trace_radeon_semaphore_wait(ridx, semaphore);
81
82 if (radeon_semaphore_ring_emit(rdev, ridx, ring, semaphore, true)) {
83 ++semaphore->waiters;
84
85
86 ring->last_semaphore_wait_addr = semaphore->gpu_addr;
87 return true;
88 }
89 return false;
90 }
91
92 void radeon_semaphore_free(struct radeon_device *rdev,
93 struct radeon_semaphore **semaphore,
94 struct radeon_fence *fence)
95 {
96 if (semaphore == NULL || *semaphore == NULL) {
97 return;
98 }
99 if ((*semaphore)->waiters > 0) {
100 dev_err(rdev->dev, "semaphore %p has more waiters than signalers,"
101 " hardware lockup imminent!\n", *semaphore);
102 }
103 radeon_sa_bo_free(rdev, &(*semaphore)->sa_bo, fence);
104 kfree(*semaphore);
105 *semaphore = NULL;
106 }