Skip to content

Commit

Permalink
gdev: bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
iwata-axe committed Aug 8, 2013
1 parent 3d6c5d1 commit 17c8f19
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
12 changes: 11 additions & 1 deletion common/gdev_nvidia.h
Expand Up @@ -153,7 +153,9 @@ struct gdev_ctx {
uint32_t pb_pos;
uint32_t pb_put;
uint32_t pb_get;
void (*space)(struct gdev_ctx *, uint32_t);
void (*push)(struct gdev_ctx *, uint64_t, uint32_t, int);
void (*kick)(struct gdev_ctx *);
void (*update_get)(struct gdev_ctx *);
} fifo; /* command FIFO queue struct. */
struct gdev_fence { /* fence objects (for compute and dma). */
Expand Down Expand Up @@ -265,14 +267,16 @@ static inline void __gdev_fire_ring(struct gdev_ctx *ctx)
if (len > 0)
ctx->fifo.push(ctx, base, len, 0);
ctx->fifo.pb_put = ctx->fifo.pb_pos;
if (ctx->fifo.kick)
ctx->fifo.kick(ctx);
}
}

static inline void __gdev_out_ring(struct gdev_ctx *ctx, uint32_t word)
{
while (((ctx->fifo.pb_pos + 4) & ctx->fifo.pb_mask) == ctx->fifo.pb_get) {
uint32_t old = ctx->fifo.pb_get;
__gdev_fire_ring(ctx);
//__gdev_fire_ring(ctx);
ctx->fifo.update_get(ctx);
if (old == ctx->fifo.pb_get) {
SCHED_YIELD();
Expand All @@ -283,6 +287,12 @@ static inline void __gdev_out_ring(struct gdev_ctx *ctx, uint32_t word)
ctx->fifo.pb_pos &= ctx->fifo.pb_mask;
}

static inline void __gdev_ring_space(struct gdev_ctx *ctx, uint32_t word)
{
if (ctx->fifo.space)
ctx->fifo.space(ctx, word);
}

static inline void __gdev_begin_ring_nv50(struct gdev_ctx *ctx, int subc, int mthd, int len)
{
__gdev_out_ring(ctx, mthd | (subc<<13) | (len<<18));
Expand Down
23 changes: 19 additions & 4 deletions lib/user/nouveau/nouveau_gdev.c
Expand Up @@ -42,27 +42,40 @@ struct gdev_nouveau_ctx_objects {
struct nouveau_object *m2mf;
};

void __nouveau_fifo_push(struct gdev_ctx *ctx, uint64_t base, uint32_t len, int flags)
void __nouveau_fifo_space(struct gdev_ctx *ctx, uint32_t len)
{
struct nouveau_pushbuf *push = (struct nouveau_pushbuf *)ctx->pctx;
nouveau_pushbuf_space(push, len, 0, 0);
}

void __nouveau_fifo_push(struct gdev_ctx *ctx, uint64_t base, uint32_t len, int flags)
{
struct nouveau_pushbuf *push = (struct nouveau_pushbuf *)ctx->pctx;
int dwords = len / 4;
int p = ctx->fifo.pb_put / 4;
int max = ctx->fifo.pb_size / 4;
nouveau_pushbuf_space(push, dwords, 1, 0);

nouveau_pushbuf_space(push, dwords, 0, 0);
for (;dwords > 0; dwords--) {
*push->cur++ = ctx->fifo.pb_map[p++];
if (p >= max) p = 0;
}
ctx->fifo.pb_put += len;
ctx->fifo.pb_put &= ctx->fifo.pb_mask;
//nouveau_pushbuf_kick(push, push->channel);
}

void __nouveau_fifo_kick(struct gdev_ctx *ctx)
{
struct nouveau_pushbuf *push = (struct nouveau_pushbuf *)ctx->pctx;
nouveau_pushbuf_kick(push, push->channel);
}

void __nouveau_fifo_update_get(struct gdev_ctx *ctx)
{
printf("FIXME: need to update FIFO GET in a safe manner.");
ctx->fifo.pb_get = 0; /* FIXME */
//printf("FIXME: need to update FIFO GET in a safe manner.");
//ctx->fifo.pb_get = 0; /* FIXME */
ctx->fifo.pb_get = ctx->fifo.pb_put;
}

/* query a piece of the device-specific information. */
Expand Down Expand Up @@ -297,7 +310,9 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
ctx->fifo.pb_mask = (1 << ctx->fifo.pb_order) - 1;
ctx->fifo.pb_size = (1 << ctx->fifo.pb_order);
ctx->fifo.pb_pos = ctx->fifo.pb_put = ctx->fifo.pb_get = 0;
ctx->fifo.space = __nouveau_fifo_space;
ctx->fifo.push = __nouveau_fifo_push;
ctx->fifo.kick = __nouveau_fifo_kick;
ctx->fifo.update_get = __nouveau_fifo_update_get;

/* FIFO index buffer setup. */
Expand Down
1 change: 1 addition & 0 deletions lib/user/nvrm/nvrm_gdev.c
Expand Up @@ -195,6 +195,7 @@ struct gdev_ctx *gdev_raw_ctx_new

if (!(ctx = malloc(sizeof(*ctx))))
goto fail_ctx;
memset(ctx, 0, sizeof(*ctx));

/* FIFO indirect buffer setup. */
ctx->fifo.ib_order = 10;
Expand Down
1 change: 1 addition & 0 deletions lib/user/pscnv/pscnv_gdev.c
Expand Up @@ -173,6 +173,7 @@ struct gdev_ctx *gdev_raw_ctx_new

if (!(ctx = malloc(sizeof(*ctx))))
goto fail_ctx;
memset(ctx, 0, sizeof(*ctx));

/* FIFO indirect buffer setup. */
ctx->fifo.ib_order = chan->ib_order;
Expand Down

0 comments on commit 17c8f19

Please sign in to comment.