{
struct nouveau_screen *screen = fence->screen;
- fence->sequence = ++screen->fence.sequence;
-
assert(fence->state == NOUVEAU_FENCE_STATE_AVAILABLE);
/* set this now, so that if fence.emit triggers a flush we don't recurse */
- fence->state = NOUVEAU_FENCE_STATE_EMITTED;
+ fence->state = NOUVEAU_FENCE_STATE_EMITTING;
++fence->ref;
screen->fence.tail = fence;
- screen->fence.emit(&screen->base, fence->sequence);
+ screen->fence.emit(&screen->base, &fence->sequence);
+
+ assert(fence->state == NOUVEAU_FENCE_STATE_EMITTING);
+ fence->state = NOUVEAU_FENCE_STATE_EMITTED;
}
void
if (flushed) {
for (fence = next; fence; fence = fence->next)
- fence->state = NOUVEAU_FENCE_STATE_FLUSHED;
+ if (fence->state == NOUVEAU_FENCE_STATE_EMITTED)
+ fence->state = NOUVEAU_FENCE_STATE_FLUSHED;
}
}
struct nouveau_screen *screen = fence->screen;
uint32_t spins = 0;
+ /* wtf, someone is waiting on a fence in flush_notify handler? */
+ assert(fence->state != NOUVEAU_FENCE_STATE_EMITTING);
+
if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) {
nouveau_fence_emit(fence);
void
nouveau_fence_next(struct nouveau_screen *screen)
{
- if (screen->fence.current->state < NOUVEAU_FENCE_STATE_EMITTED)
+ if (screen->fence.current->state < NOUVEAU_FENCE_STATE_EMITTING)
nouveau_fence_emit(screen->fence.current);
nouveau_fence_ref(NULL, &screen->fence.current);
#include "util/u_double_list.h"
#define NOUVEAU_FENCE_STATE_AVAILABLE 0
-#define NOUVEAU_FENCE_STATE_EMITTED 1
-#define NOUVEAU_FENCE_STATE_FLUSHED 2
-#define NOUVEAU_FENCE_STATE_SIGNALLED 3
+#define NOUVEAU_FENCE_STATE_EMITTING 1
+#define NOUVEAU_FENCE_STATE_EMITTED 2
+#define NOUVEAU_FENCE_STATE_FLUSHED 3
+#define NOUVEAU_FENCE_STATE_SIGNALLED 4
struct nouveau_fence_work {
struct list_head list;
struct nouveau_fence *current;
u32 sequence;
u32 sequence_ack;
- void (*emit)(struct pipe_screen *, u32 sequence);
+ void (*emit)(struct pipe_screen *, u32 *sequence);
u32 (*update)(struct pipe_screen *);
} fence;
}
static void
-nv50_screen_fence_emit(struct pipe_screen *pscreen, u32 sequence)
+nv50_screen_fence_emit(struct pipe_screen *pscreen, u32 *sequence)
{
struct nv50_screen *screen = nv50_screen(pscreen);
struct nouveau_channel *chan = screen->base.channel;
MARK_RING (chan, 5, 2);
+
+ /* we need to do it after possible flush in MARK_RING */
+ *sequence = ++screen->base.fence.sequence;
+
BEGIN_RING(chan, RING_3D(QUERY_ADDRESS_HIGH), 4);
OUT_RELOCh(chan, screen->fence.bo, 0, NOUVEAU_BO_WR);
OUT_RELOCl(chan, screen->fence.bo, 0, NOUVEAU_BO_WR);
- OUT_RING (chan, sequence);
+ OUT_RING (chan, *sequence);
OUT_RING (chan, NV50_3D_QUERY_GET_MODE_WRITE_UNK0 |
NV50_3D_QUERY_GET_UNK4 |
NV50_3D_QUERY_GET_UNIT_CROP |
}
static void
-nvc0_screen_fence_emit(struct pipe_screen *pscreen, u32 sequence)
+nvc0_screen_fence_emit(struct pipe_screen *pscreen, u32 *sequence)
{
struct nvc0_screen *screen = nvc0_screen(pscreen);
struct nouveau_channel *chan = screen->base.channel;
MARK_RING (chan, 5, 2);
+
+ /* we need to do it after possible flush in MARK_RING */
+ *sequence = ++screen->base.fence.sequence;
+
BEGIN_RING(chan, RING_3D(QUERY_ADDRESS_HIGH), 4);
OUT_RELOCh(chan, screen->fence.bo, 0, NOUVEAU_BO_WR);
OUT_RELOCl(chan, screen->fence.bo, 0, NOUVEAU_BO_WR);
- OUT_RING (chan, sequence);
+ OUT_RING (chan, *sequence);
OUT_RING (chan, NVC0_3D_QUERY_GET_FENCE | NVC0_3D_QUERY_GET_SHORT |
(0xf << NVC0_3D_QUERY_GET_UNIT__SHIFT));
}