Lines Matching refs:ring
48 static void radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring);
61 struct radeon_ring *ring) in radeon_ring_supports_scratch_reg() argument
63 switch (ring->idx) { in radeon_ring_supports_scratch_reg()
81 void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *ring) in radeon_ring_free_size() argument
83 uint32_t rptr = radeon_ring_get_rptr(rdev, ring); in radeon_ring_free_size()
86 ring->ring_free_dw = rptr + (ring->ring_size / 4); in radeon_ring_free_size()
87 ring->ring_free_dw -= ring->wptr; in radeon_ring_free_size()
88 ring->ring_free_dw &= ring->ptr_mask; in radeon_ring_free_size()
89 if (!ring->ring_free_dw) { in radeon_ring_free_size()
91 ring->ring_free_dw = ring->ring_size / 4; in radeon_ring_free_size()
93 radeon_ring_lockup_update(rdev, ring); in radeon_ring_free_size()
107 int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw) in radeon_ring_alloc() argument
112 if (ndw > (ring->ring_size / 4)) in radeon_ring_alloc()
116 radeon_ring_free_size(rdev, ring); in radeon_ring_alloc()
117 ndw = (ndw + ring->align_mask) & ~ring->align_mask; in radeon_ring_alloc()
118 while (ndw > (ring->ring_free_dw - 1)) { in radeon_ring_alloc()
119 radeon_ring_free_size(rdev, ring); in radeon_ring_alloc()
120 if (ndw < ring->ring_free_dw) { in radeon_ring_alloc()
123 r = radeon_fence_wait_next(rdev, ring->idx); in radeon_ring_alloc()
127 ring->count_dw = ndw; in radeon_ring_alloc()
128 ring->wptr_old = ring->wptr; in radeon_ring_alloc()
143 int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw) in radeon_ring_lock() argument
148 r = radeon_ring_alloc(rdev, ring, ndw); in radeon_ring_lock()
167 void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *ring, in radeon_ring_commit() argument
173 if (hdp_flush && rdev->asic->ring[ring->idx]->hdp_flush) in radeon_ring_commit()
174 rdev->asic->ring[ring->idx]->hdp_flush(rdev, ring); in radeon_ring_commit()
176 while (ring->wptr & ring->align_mask) { in radeon_ring_commit()
177 radeon_ring_write(ring, ring->nop); in radeon_ring_commit()
185 radeon_ring_set_wptr(rdev, ring); in radeon_ring_commit()
198 void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *ring, in radeon_ring_unlock_commit() argument
201 radeon_ring_commit(rdev, ring, hdp_flush); in radeon_ring_unlock_commit()
212 void radeon_ring_undo(struct radeon_ring *ring) in radeon_ring_undo() argument
214 ring->wptr = ring->wptr_old; in radeon_ring_undo()
225 void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *ring) in radeon_ring_unlock_undo() argument
227 radeon_ring_undo(ring); in radeon_ring_unlock_undo()
240 struct radeon_ring *ring) in radeon_ring_lockup_update() argument
242 atomic_set(&ring->last_rptr, radeon_ring_get_rptr(rdev, ring)); in radeon_ring_lockup_update()
243 atomic64_set(&ring->last_activity, jiffies_64); in radeon_ring_lockup_update()
252 bool radeon_ring_test_lockup(struct radeon_device *rdev, struct radeon_ring *ring) in radeon_ring_test_lockup() argument
254 uint32_t rptr = radeon_ring_get_rptr(rdev, ring); in radeon_ring_test_lockup()
255 uint64_t last = atomic64_read(&ring->last_activity); in radeon_ring_test_lockup()
258 if (rptr != atomic_read(&ring->last_rptr)) { in radeon_ring_test_lockup()
260 radeon_ring_lockup_update(rdev, ring); in radeon_ring_test_lockup()
267 ring->idx, elapsed); in radeon_ring_test_lockup()
283 unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring, in radeon_ring_backup() argument
292 if (ring->ring_obj == NULL) { in radeon_ring_backup()
298 if (!radeon_fence_count_emitted(rdev, ring->idx)) { in radeon_ring_backup()
304 if (ring->rptr_save_reg) in radeon_ring_backup()
305 ptr = RREG32(ring->rptr_save_reg); in radeon_ring_backup()
307 ptr = le32_to_cpu(*ring->next_rptr_cpu_addr); in radeon_ring_backup()
314 size = ring->wptr + (ring->ring_size / 4); in radeon_ring_backup()
316 size &= ring->ptr_mask; in radeon_ring_backup()
329 (*data)[i] = ring->ring[ptr++]; in radeon_ring_backup()
330 ptr &= ring->ptr_mask; in radeon_ring_backup()
347 int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring, in radeon_ring_restore() argument
356 r = radeon_ring_lock(rdev, ring, size); in radeon_ring_restore()
361 radeon_ring_write(ring, data[i]); in radeon_ring_restore()
364 radeon_ring_unlock_commit(rdev, ring, false); in radeon_ring_restore()
381 int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ring_size, in radeon_ring_init() argument
386 ring->ring_size = ring_size; in radeon_ring_init()
387 ring->rptr_offs = rptr_offs; in radeon_ring_init()
388 ring->nop = nop; in radeon_ring_init()
389 ring->rdev = rdev; in radeon_ring_init()
391 if (ring->ring_obj == NULL) { in radeon_ring_init()
392 r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true, in radeon_ring_init()
394 NULL, &ring->ring_obj); in radeon_ring_init()
399 r = radeon_bo_reserve(ring->ring_obj, false); in radeon_ring_init()
402 r = radeon_bo_pin(ring->ring_obj, RADEON_GEM_DOMAIN_GTT, in radeon_ring_init()
403 &ring->gpu_addr); in radeon_ring_init()
405 radeon_bo_unreserve(ring->ring_obj); in radeon_ring_init()
409 r = radeon_bo_kmap(ring->ring_obj, in radeon_ring_init()
410 (void **)&ring->ring); in radeon_ring_init()
411 radeon_bo_unreserve(ring->ring_obj); in radeon_ring_init()
417 ring->ptr_mask = (ring->ring_size / 4) - 1; in radeon_ring_init()
418 ring->ring_free_dw = ring->ring_size / 4; in radeon_ring_init()
420 u32 index = RADEON_WB_RING0_NEXT_RPTR + (ring->idx * 4); in radeon_ring_init()
421 ring->next_rptr_gpu_addr = rdev->wb.gpu_addr + index; in radeon_ring_init()
422 ring->next_rptr_cpu_addr = &rdev->wb.wb[index/4]; in radeon_ring_init()
424 radeon_debugfs_ring_init(rdev, ring); in radeon_ring_init()
425 radeon_ring_lockup_update(rdev, ring); in radeon_ring_init()
437 void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *ring) in radeon_ring_fini() argument
443 ring_obj = ring->ring_obj; in radeon_ring_fini()
444 ring->ready = false; in radeon_ring_fini()
445 ring->ring = NULL; in radeon_ring_fini()
446 ring->ring_obj = NULL; in radeon_ring_fini()
467 struct radeon_ring *ring = (struct radeon_ring *) m->private; in radeon_debugfs_ring_info_show() local
468 struct radeon_device *rdev = ring->rdev; in radeon_debugfs_ring_info_show()
473 radeon_ring_free_size(rdev, ring); in radeon_debugfs_ring_info_show()
474 count = (ring->ring_size / 4) - ring->ring_free_dw; in radeon_debugfs_ring_info_show()
476 wptr = radeon_ring_get_wptr(rdev, ring); in radeon_debugfs_ring_info_show()
480 rptr = radeon_ring_get_rptr(rdev, ring); in radeon_debugfs_ring_info_show()
484 if (ring->rptr_save_reg) { in radeon_debugfs_ring_info_show()
485 rptr_next = RREG32(ring->rptr_save_reg); in radeon_debugfs_ring_info_show()
487 ring->rptr_save_reg, rptr_next, rptr_next); in radeon_debugfs_ring_info_show()
492 ring->wptr, ring->wptr); in radeon_debugfs_ring_info_show()
494 ring->last_semaphore_signal_addr); in radeon_debugfs_ring_info_show()
496 ring->last_semaphore_wait_addr); in radeon_debugfs_ring_info_show()
497 seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw); in radeon_debugfs_ring_info_show()
500 if (!ring->ring) in radeon_debugfs_ring_info_show()
506 i = (rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask; in radeon_debugfs_ring_info_show()
508 seq_printf(m, "r[%5d]=0x%08x", i, ring->ring[i]); in radeon_debugfs_ring_info_show()
514 i = (i + 1) & ring->ptr_mask; in radeon_debugfs_ring_info_show()
547 static void radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring) in radeon_debugfs_ring_init() argument
550 const char *ring_name = radeon_debugfs_ring_idx_to_name(ring->idx); in radeon_debugfs_ring_init()
554 debugfs_create_file(ring_name, 0444, root, ring, in radeon_debugfs_ring_init()