Skip to content

Commit

Permalink
drm/nouveau: Avoid potential race between nouveau_fence_update() and …
Browse files Browse the repository at this point in the history
…context takedown.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Francisco Jerez committed Dec 8, 2010
1 parent a8b214f commit 937c347
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions drivers/gpu/drm/nouveau/nouveau_fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ nouveau_fence_update(struct nouveau_channel *chan)

spin_lock(&chan->fence.lock);

if (USE_REFCNT(dev))
sequence = nvchan_rd32(chan, 0x48);
else
sequence = atomic_read(&chan->fence.last_sequence_irq);

if (chan->fence.sequence_ack == sequence)
goto out;
chan->fence.sequence_ack = sequence;
/* Fetch the last sequence if the channel is still up and running */
if (likely(!list_empty(&chan->fence.pending))) {
if (USE_REFCNT(dev))
sequence = nvchan_rd32(chan, 0x48);
else
sequence = atomic_read(&chan->fence.last_sequence_irq);

if (chan->fence.sequence_ack == sequence)
goto out;
chan->fence.sequence_ack = sequence;
}

list_for_each_entry_safe(fence, tmp, &chan->fence.pending, entry) {
sequence = fence->sequence;
Expand Down

0 comments on commit 937c347

Please sign in to comment.