aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 333bad749067..fb9f88ef6059 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -169,6 +169,32 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
169} 169}
170 170
171/** 171/**
172 * amdgpu_fence_emit_polling - emit a fence on the requeste ring
173 *
174 * @ring: ring the fence is associated with
175 * @s: resulting sequence number
176 *
177 * Emits a fence command on the requested ring (all asics).
178 * Used For polling fence.
179 * Returns 0 on success, -ENOMEM on failure.
180 */
181int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s)
182{
183 uint32_t seq;
184
185 if (!s)
186 return -EINVAL;
187
188 seq = ++ring->fence_drv.sync_seq;
189 amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
190 seq, AMDGPU_FENCE_FLAG_INT);
191
192 *s = seq;
193
194 return 0;
195}
196
197/**
172 * amdgpu_fence_schedule_fallback - schedule fallback check 198 * amdgpu_fence_schedule_fallback - schedule fallback check
173 * 199 *
174 * @ring: pointer to struct amdgpu_ring 200 * @ring: pointer to struct amdgpu_ring
@@ -282,6 +308,30 @@ int amdgpu_fence_wait_empty(struct amdgpu_ring *ring)
282} 308}
283 309
284/** 310/**
311 * amdgpu_fence_wait_polling - busy wait for givn sequence number
312 *
313 * @ring: ring index the fence is associated with
314 * @wait_seq: sequence number to wait
315 * @timeout: the timeout for waiting in usecs
316 *
317 * Wait for all fences on the requested ring to signal (all asics).
318 * Returns left time if no timeout, 0 or minus if timeout.
319 */
320signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
321 uint32_t wait_seq,
322 signed long timeout)
323{
324 uint32_t seq;
325
326 do {
327 seq = amdgpu_fence_read(ring);
328 udelay(5);
329 timeout -= 5;
330 } while ((int32_t)(wait_seq - seq) > 0 && timeout > 0);
331
332 return timeout > 0 ? timeout : 0;
333}
334/**
285 * amdgpu_fence_count_emitted - get the count of emitted fences 335 * amdgpu_fence_count_emitted - get the count of emitted fences
286 * 336 *
287 * @ring: ring the fence is associated with 337 * @ring: ring the fence is associated with
@@ -641,6 +691,19 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
641 atomic_read(&ring->fence_drv.last_seq)); 691 atomic_read(&ring->fence_drv.last_seq));
642 seq_printf(m, "Last emitted 0x%08x\n", 692 seq_printf(m, "Last emitted 0x%08x\n",
643 ring->fence_drv.sync_seq); 693 ring->fence_drv.sync_seq);
694
695 if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
696 continue;
697
698 /* set in CP_VMID_PREEMPT and preemption occurred */
699 seq_printf(m, "Last preempted 0x%08x\n",
700 le32_to_cpu(*(ring->fence_drv.cpu_addr + 2)));
701 /* set in CP_VMID_RESET and reset occurred */
702 seq_printf(m, "Last reset 0x%08x\n",
703 le32_to_cpu(*(ring->fence_drv.cpu_addr + 4)));
704 /* Both preemption and reset occurred */
705 seq_printf(m, "Last both 0x%08x\n",
706 le32_to_cpu(*(ring->fence_drv.cpu_addr + 6)));
644 } 707 }
645 return 0; 708 return 0;
646} 709}