Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add the trailing fence per ring

The trailing fence for ring is used to track the
completion of preemption.

Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Jack Xiao and committed by
Alex Deucher
ef3e1323 dfc98479

+27 -5
+13 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
··· 707 707 amdgpu_fence_process(ring); 708 708 709 709 seq_printf(m, "--- ring %d (%s) ---\n", i, ring->name); 710 - seq_printf(m, "Last signaled fence 0x%08x\n", 710 + seq_printf(m, "Last signaled fence 0x%08x\n", 711 711 atomic_read(&ring->fence_drv.last_seq)); 712 - seq_printf(m, "Last emitted 0x%08x\n", 712 + seq_printf(m, "Last emitted 0x%08x\n", 713 713 ring->fence_drv.sync_seq); 714 + 715 + if (ring->funcs->type == AMDGPU_RING_TYPE_GFX || 716 + ring->funcs->type == AMDGPU_RING_TYPE_SDMA) { 717 + seq_printf(m, "Last signaled trailing fence 0x%08x\n", 718 + le32_to_cpu(*ring->trail_fence_cpu_addr)); 719 + seq_printf(m, "Last emitted 0x%08x\n", 720 + ring->trail_seq); 721 + } 714 722 715 723 if (ring->funcs->type != AMDGPU_RING_TYPE_GFX) 716 724 continue; 717 725 718 726 /* set in CP_VMID_PREEMPT and preemption occurred */ 719 - seq_printf(m, "Last preempted 0x%08x\n", 727 + seq_printf(m, "Last preempted 0x%08x\n", 720 728 le32_to_cpu(*(ring->fence_drv.cpu_addr + 2))); 721 729 /* set in CP_VMID_RESET and reset occurred */ 722 - seq_printf(m, "Last reset 0x%08x\n", 730 + seq_printf(m, "Last reset 0x%08x\n", 723 731 le32_to_cpu(*(ring->fence_drv.cpu_addr + 4))); 724 732 /* Both preemption and reset occurred */ 725 - seq_printf(m, "Last both 0x%08x\n", 733 + seq_printf(m, "Last both 0x%08x\n", 726 734 le32_to_cpu(*(ring->fence_drv.cpu_addr + 6))); 727 735 } 728 736 return 0;
+10
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
··· 281 281 return r; 282 282 } 283 283 284 + r = amdgpu_device_wb_get(adev, &ring->trail_fence_offs); 285 + if (r) { 286 + dev_err(adev->dev, 287 + "(%d) ring trail_fence_offs wb alloc failed\n", r); 288 + return r; 289 + } 290 + ring->trail_fence_gpu_addr = 291 + adev->wb.gpu_addr + (ring->trail_fence_offs * 4); 292 + ring->trail_fence_cpu_addr = &adev->wb.wb[ring->trail_fence_offs]; 293 + 284 294 r = amdgpu_device_wb_get(adev, &ring->cond_exe_offs); 285 295 if (r) { 286 296 dev_err(adev->dev, "(%d) ring cond_exec_polling wb alloc failed\n", r);
+4
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
··· 206 206 unsigned fence_offs; 207 207 uint64_t current_ctx; 208 208 char name[16]; 209 + u32 trail_seq; 210 + unsigned trail_fence_offs; 211 + u64 trail_fence_gpu_addr; 212 + volatile u32 *trail_fence_cpu_addr; 209 213 unsigned cond_exe_offs; 210 214 u64 cond_exe_gpu_addr; 211 215 volatile u32 *cond_exe_cpu_addr;