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

drm/amdgpu/pm_runtime: update usage count in fence handling

Increment the usage count in emit fence, and decrement in
process fence to make sure the GPU is always considered in
use while there are fences outstanding. We always wait for
the engines to drain in runtime suspend, but in practice
that only covers short lived jobs for gfx. This should
cover us for longer lived fences.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+5 -1
+5 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
··· 34 34 #include <linux/kref.h> 35 35 #include <linux/slab.h> 36 36 #include <linux/firmware.h> 37 + #include <linux/pm_runtime.h> 37 38 38 39 #include <drm/drm_debugfs.h> 39 40 ··· 155 154 seq); 156 155 amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr, 157 156 seq, flags | AMDGPU_FENCE_FLAG_INT); 158 - 157 + pm_runtime_get_noresume(adev->ddev->dev); 159 158 ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask]; 160 159 if (unlikely(rcu_dereference_protected(*ptr, 1))) { 161 160 struct dma_fence *old; ··· 235 234 bool amdgpu_fence_process(struct amdgpu_ring *ring) 236 235 { 237 236 struct amdgpu_fence_driver *drv = &ring->fence_drv; 237 + struct amdgpu_device *adev = ring->adev; 238 238 uint32_t seq, last_seq; 239 239 int r; 240 240 ··· 276 274 BUG(); 277 275 278 276 dma_fence_put(fence); 277 + pm_runtime_mark_last_busy(adev->ddev->dev); 278 + pm_runtime_put_autosuspend(adev->ddev->dev); 279 279 } while (last_seq != seq); 280 280 281 281 return true;