summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
diff options
context:
space:
mode:
authorChunming Zhou <david1.zhou@amd.com>2015-07-24 10:49:47 +0800
committerAlex Deucher <alexander.deucher@amd.com>2015-08-17 16:50:38 -0400
commit176e1ab1b534368d0cd338a010aaea99067c3c6e (patch)
tree4a30358b9d603cf62eded5032665816ec3d2de97 /drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
parente0d8f3c34e54b7f7563360131e89be0d9405d436 (diff)
drm/amdgpu: protect fence_process from multiple context
fence_process may be called from kthread, user thread and interrupt context. it is possible to called concurrently, then will wake up fence queue multiple times. Signed-off-by: Chunming Zhou <david1.zhou@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 1580d8d7a3bf..b0e15b574606 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -295,6 +295,7 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
uint64_t seq, last_seq, last_emitted;
unsigned count_loop = 0;
bool wake = false;
+ unsigned long irqflags;
/* Note there is a scenario here for an infinite loop but it's
* very unlikely to happen. For it to happen, the current polling
@@ -317,6 +318,7 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
* have temporarly set the last_seq not to the true real last
* seq but to an older one.
*/
+ spin_lock_irqsave(&ring->fence_lock, irqflags);
last_seq = atomic64_read(&ring->fence_drv.last_seq);
do {
last_emitted = ring->fence_drv.sync_seq[ring->idx];
@@ -355,7 +357,7 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
if (handled_seq == latest_seq) {
DRM_ERROR("ring %d, EOP without seq update (lastest_seq=%llu)\n",
ring->idx, latest_seq);
- return;
+ goto exit;
}
do {
amd_sched_isr(ring->scheduler);
@@ -364,6 +366,8 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
wake_up_all(&ring->adev->fence_queue);
}
+exit:
+ spin_unlock_irqrestore(&ring->fence_lock, irqflags);
}
/**