OSDN Git Service

nouveau: add asserts to make sure krefs are there
[android-x86/external-libdrm.git] / nouveau / pushbuf.c
index ff8e125..8e7dcdf 100644 (file)
@@ -234,6 +234,8 @@ pushbuf_krel(struct nouveau_pushbuf *push, struct nouveau_bo *bo,
        bkref = cli_kref_get(push->client, bo);
        krel  = &krec->reloc[krec->nr_reloc++];
 
+       assert(pkref);
+       assert(bkref);
        krel->reloc_bo_index = pkref - krec->buffer;
        krel->reloc_bo_offset = (push->cur - nvpb->ptr) * 4;
        krel->bo_index = bkref - krec->buffer;
@@ -347,8 +349,10 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct nouveau_object *chan)
                                          &req, sizeof(req));
                nvpb->suffix0 = req.suffix0;
                nvpb->suffix1 = req.suffix1;
-               dev->vram_limit = (req.vram_available * 80) / 100;
-               dev->gart_limit = (req.gart_available * 80) / 100;
+               dev->vram_limit = (req.vram_available *
+                               nouveau_device(dev)->vram_limit_percent) / 100;
+               dev->gart_limit = (req.gart_available *
+                               nouveau_device(dev)->gart_limit_percent) / 100;
 #else
                if (dbg_on(31))
                        ret = -EINVAL;
@@ -524,7 +528,7 @@ pushbuf_validate(struct nouveau_pushbuf *push, bool retry)
                }
        }
 
-       return 0;
+       return ret;
 }
 
 int
@@ -719,6 +723,7 @@ nouveau_pushbuf_data(struct nouveau_pushbuf *push, struct nouveau_bo *bo,
 
        if (bo) {
                kref = cli_kref_get(push->client, bo);
+               assert(kref);
                kpsh = &krec->push[krec->nr_push++];
                kpsh->bo_index = kref - krec->buffer;
                kpsh->offset   = offset;
@@ -737,7 +742,8 @@ void
 nouveau_pushbuf_reloc(struct nouveau_pushbuf *push, struct nouveau_bo *bo,
                      uint32_t data, uint32_t flags, uint32_t vor, uint32_t tor)
 {
-       *push->cur++ = pushbuf_krel(push, bo, data, flags, vor, tor);
+       *push->cur = pushbuf_krel(push, bo, data, flags, vor, tor);
+       push->cur++;
 }
 
 int
@@ -754,6 +760,7 @@ nouveau_pushbuf_refd(struct nouveau_pushbuf *push, struct nouveau_bo *bo)
 
        if (cli_push_get(push->client, bo) == push) {
                kref = cli_kref_get(push->client, bo);
+               assert(kref);
                if (kref->read_domains)
                        flags |= NOUVEAU_BO_RD;
                if (kref->write_domains)