Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 218242
b: refs/heads/master
c: 8ac3891
h: refs/heads/master
v: v3
  • Loading branch information
Francisco Jerez authored and Ben Skeggs committed Oct 4, 2010
1 parent 497a941 commit 06ff4e5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2730723bbc4a8b289fa536fc3555e15947da09c1
refs/heads/master: 8ac3891b48906b38db4b153c2d0d55db2ef81aee
3 changes: 3 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,9 @@ extern void nouveau_fence_update(struct nouveau_channel *);
extern int nouveau_fence_new(struct nouveau_channel *, struct nouveau_fence **,
bool emit);
extern int nouveau_fence_emit(struct nouveau_fence *);
extern void nouveau_fence_work(struct nouveau_fence *fence,
void (*work)(void *priv, bool signalled),
void *priv);
struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *);
extern bool nouveau_fence_signalled(void *obj, void *arg);
extern int nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr);
Expand Down
30 changes: 30 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ struct nouveau_fence {

uint32_t sequence;
bool signalled;

void (*work)(void *priv, bool signalled);
void *priv;
};

static inline struct nouveau_fence *
Expand Down Expand Up @@ -78,6 +81,10 @@ nouveau_fence_update(struct nouveau_channel *chan)
sequence = fence->sequence;
fence->signalled = true;
list_del(&fence->entry);

if (unlikely(fence->work))
fence->work(fence->priv, true);

kref_put(&fence->refcount, nouveau_fence_del);

if (sequence == chan->fence.sequence_ack)
Expand Down Expand Up @@ -147,6 +154,25 @@ nouveau_fence_emit(struct nouveau_fence *fence)
return 0;
}

void
nouveau_fence_work(struct nouveau_fence *fence,
void (*work)(void *priv, bool signalled),
void *priv)
{
BUG_ON(fence->work);

spin_lock(&fence->channel->fence.lock);

if (fence->signalled) {
work(priv, true);
} else {
fence->work = work;
fence->priv = priv;
}

spin_unlock(&fence->channel->fence.lock);
}

void
nouveau_fence_unref(void **sync_obj)
{
Expand Down Expand Up @@ -268,6 +294,10 @@ nouveau_fence_channel_fini(struct nouveau_channel *chan)
list_for_each_entry_safe(fence, tmp, &chan->fence.pending, entry) {
fence->signalled = true;
list_del(&fence->entry);

if (unlikely(fence->work))
fence->work(fence->priv, false);

kref_put(&fence->refcount, nouveau_fence_del);
}
}
Expand Down

0 comments on commit 06ff4e5

Please sign in to comment.