Home | History | Annotate | Download | only in radeon

Lines Matching refs:ring

43  * Most engines on the GPU are fed via ring buffers.  Ring
49 * pointers are equal, the ring is idle. When the host
50 * writes commands to the ring buffer, it increments the
54 static int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring);
57 * radeon_ring_supports_scratch_reg - check if the ring supports
61 * @ring: radeon_ring structure holding ring information
63 * Check if a specific ring supports writing to scratch registers (all asics).
64 * Returns true if the ring supports writing to scratch regs, false if not.
67 struct radeon_ring *ring)
69 switch (ring->idx) {
83 * @ring: radeon_ring structure holding ring information
85 * Update the free dw slots in the ring buffer (all asics).
87 void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *ring)
89 uint32_t rptr = radeon_ring_get_rptr(rdev, ring);
92 ring->ring_free_dw = rptr + (ring->ring_size / 4);
93 ring->ring_free_dw -= ring->wptr;
94 ring->ring_free_dw &= ring->ptr_mask;
95 if (!ring->ring_free_dw) {
96 /* this is an empty ring */
97 ring->ring_free_dw = ring->ring_size / 4;
99 radeon_ring_lockup_update(rdev, ring);
104 * radeon_ring_alloc - allocate space on the ring buffer
107 * @ring: radeon_ring structure holding ring information
108 * @ndw: number of dwords to allocate in the ring buffer
110 * Allocate @ndw dwords in the ring buffer (all asics).
113 int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw)
117 /* make sure we aren't trying to allocate more space than there is on the ring */
118 if (ndw > (ring->ring_size / 4))
122 radeon_ring_free_size(rdev, ring);
123 ndw = (ndw + ring->align_mask) & ~ring->align_mask;
124 while (ndw > (ring->ring_free_dw - 1)) {
125 radeon_ring_free_size(rdev, ring);
126 if (ndw < ring->ring_free_dw) {
129 r = radeon_fence_wait_next(rdev, ring->idx);
133 ring->count_dw = ndw;
134 ring->wptr_old = ring->wptr;
139 * radeon_ring_lock - lock the ring and allocate space on it
142 * @ring: radeon_ring structure holding ring information
143 * @ndw: number of dwords to allocate in the ring buffer
145 * Lock the ring and allocate @ndw dwords in the ring buffer
149 int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw)
154 r = radeon_ring_alloc(rdev, ring, ndw);
164 * commands on the ring buffer
167 * @ring: radeon_ring structure holding ring information
171 * execute new commands on the ring buffer (all asics).
173 void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *ring,
176 /* If we are emitting the HDP flush via the ring buffer, we need to
179 if (hdp_flush && rdev->asic->ring[ring->idx]->hdp_flush)
180 rdev->asic->ring[ring->idx]->hdp_flush(rdev, ring);
182 while (ring->wptr & ring->align_mask) {
183 radeon_ring_write(ring, ring->nop);
191 radeon_ring_set_wptr(rdev, ring);
196 * commands on the ring buffer and unlock it
199 * @ring: radeon_ring structure holding ring information
202 * Call radeon_ring_commit() then unlock the ring (all asics).
204 void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *ring,
207 radeon_ring_commit(rdev, ring, hdp_flush);
214 * @ring: radeon_ring structure holding ring information
218 void radeon_ring_undo(struct radeon_ring *ring)
220 ring->wptr = ring->wptr_old;
224 * radeon_ring_unlock_undo - reset the wptr and unlock the ring
226 * @ring: radeon_ring structure holding ring information
228 * Call radeon_ring_undo() then unlock the ring (all asics).
230 void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *ring)
232 radeon_ring_undo(ring);
239 * @ring: radeon_ring structure holding ring information
244 struct radeon_ring *ring)
246 atomic_set(&ring->last_rptr, radeon_ring_get_rptr(rdev, ring));
247 atomic64_set(&ring->last_activity, jiffies_64);
251 * radeon_ring_test_lockup() - check if ring is lockedup by recording information
253 * @ring: radeon_ring structure holding ring information
256 bool radeon_ring_test_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
258 uint32_t rptr = radeon_ring_get_rptr(rdev, ring);
259 uint64_t last = atomic64_read(&ring->last_activity);
262 if (rptr != atomic_read(&ring->last_rptr)) {
263 /* ring is still working, no lockup */
264 radeon_ring_lockup_update(rdev, ring);
270 dev_err(rdev->dev, "ring %d stalled for more than %"PRIu64"msec\n",
271 ring->idx, elapsed);
279 * radeon_ring_backup - Back up the content of a ring
282 * @ring: the ring we want to back up
284 * Saves all unprocessed commits from a ring, returns the number of dwords saved.
286 unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring,
291 /* just in case lock the ring */
295 if (ring->ring_obj == NULL) {
301 if (!radeon_fence_count_emitted(rdev, ring->idx)) {
306 /* calculate the number of dw on the ring */
307 if (ring->rptr_save_reg)
308 ptr = RREG32(ring->rptr_save_reg);
310 ptr = le32_to_cpu(*ring->next_rptr_cpu_addr);
317 size = ring->wptr + (ring->ring_size / 4);
319 size &= ring->ptr_mask;
325 /* and then save the content of the ring */
332 (*data)[i] = ring->ring[ptr++];
333 ptr &= ring->ptr_mask;
341 * radeon_ring_restore - append saved commands to the ring again
344 * @ring: ring to append commands to
348 * Allocates space on the ring and restore the previously saved commands.
350 int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
358 /* restore the saved ring content */
359 r = radeon_ring_lock(rdev, ring, size);
364 radeon_ring_write(ring, data[i]);
367 radeon_ring_unlock_commit(rdev, ring, false);
373 * radeon_ring_init - init driver ring struct.
376 * @ring: radeon_ring structure holding ring information
377 * @ring_size: size of the ring
379 * @nop: nop packet for this ring
381 * Initialize the driver information for the selected ring (all asics).
384 int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ring_size,
389 ring->ring_size = ring_size;
390 ring->rptr_offs = rptr_offs;
391 ring->nop = nop;
392 /* Allocate ring buffer */
393 if (ring->ring_obj == NULL) {
394 r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true,
396 NULL, &ring->ring_obj);
398 dev_err(rdev->dev, "(%d) ring create failed\n", r);
401 r = radeon_bo_reserve(ring->ring_obj, false);
404 r = radeon_bo_pin(ring->ring_obj, RADEON_GEM_DOMAIN_GTT,
405 &ring->gpu_addr);
407 radeon_bo_unreserve(ring->ring_obj);
408 dev_err(rdev->dev, "(%d) ring pin failed\n", r);
411 r = radeon_bo_kmap(ring->ring_obj,
412 (void **)__UNVOLATILE(&ring->ring));
413 radeon_bo_unreserve(ring->ring_obj);
415 dev_err(rdev->dev, "(%d) ring map failed\n", r);
419 ring->ptr_mask = (ring->ring_size / 4) - 1;
420 ring->ring_free_dw = ring->ring_size / 4;
422 u32 index = RADEON_WB_RING0_NEXT_RPTR + (ring->idx * 4);
423 ring->next_rptr_gpu_addr = rdev->wb.gpu_addr + index;
424 ring->next_rptr_cpu_addr = &rdev->wb.wb[index/4];
426 if (radeon_debugfs_ring_init(rdev, ring)) {
429 radeon_ring_lockup_update(rdev, ring);
434 * radeon_ring_fini - tear down the driver ring struct.
437 * @ring: radeon_ring structure holding ring information
439 * Tear down the driver information for the selected ring (all asics).
441 void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *ring)
447 ring_obj = ring->ring_obj;
448 ring->ready = false;
449 ring->ring = NULL;
450 ring->ring_obj = NULL;
475 struct radeon_ring *ring = &rdev->ring[ridx];
480 radeon_ring_free_size(rdev, ring);
481 count = (ring->ring_size / 4) - ring->ring_free_dw;
483 wptr = radeon_ring_get_wptr(rdev, ring);
487 rptr = radeon_ring_get_rptr(rdev, ring);
491 if (ring->rptr_save_reg) {
492 rptr_next = RREG32(ring->rptr_save_reg);
494 ring->rptr_save_reg, rptr_next, rptr_next);
499 ring->wptr, ring->wptr);
501 ring->last_semaphore_signal_addr);
503 ring->last_semaphore_wait_addr);
504 seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
505 seq_printf(m, "%u dwords in ring\n", count);
507 if (!ring->ring)
513 i = (rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask;
515 seq_printf(m, "r[%5d]=0x%08x", i, ring->ring[i]);
521 i = (i + 1) & ring->ptr_mask;
548 static int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring)
557 if (&rdev->ring[ridx] != ring)