Skip to content

Commit

Permalink
drm/amdgpu: hold reference to fences in amdgpu_sa_bo_new (v2)
Browse files Browse the repository at this point in the history
An arbitrary amount of time can pass between spin_unlock and
fence_wait_any_timeout, so we need to ensure that nobody frees the
fences from under us.

A stress test (rapidly starting and killing hundreds of glxgears
instances) ran into a deadlock in fence_wait_any_timeout after
about an hour, and this race condition appears to be a plausible
cause.

v2: agd: rebase on upstream

Signed-off-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
Reviewed-by: Christian König <[email protected]>
Cc: [email protected]
  • Loading branch information
nhaehnle authored and alexdeucher committed Feb 10, 2016
1 parent ca19852 commit a8d81b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,15 @@ int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager,

for (i = 0, count = 0; i < AMDGPU_MAX_RINGS; ++i)
if (fences[i])
fences[count++] = fences[i];
fences[count++] = fence_get(fences[i]);

if (count) {
spin_unlock(&sa_manager->wq.lock);
t = fence_wait_any_timeout(fences, count, false,
MAX_SCHEDULE_TIMEOUT);
for (i = 0; i < count; ++i)
fence_put(fences[i]);

r = (t > 0) ? 0 : t;
spin_lock(&sa_manager->wq.lock);
} else {
Expand Down

0 comments on commit a8d81b3

Please sign in to comment.