Skip to contentSkip to conversation

nvc0: switch mechanism for shader eviction to be a while loop

PATCH In review Ilia Mirkin 2 participants 2 messages May 10, 2015 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvc0: switch mechanism for shader eviction to be a while loop

This aligns it to work similarly to nv50. However there's no library code there, so the whole thing can be freed. Here we end up with an allocated node that's not attached to a specific program.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86792

---
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/nvc0/nvc0_program.c +6 -5
index c156e91..5589695 100644
@@ -683,11 +683,12 @@ nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog)
    ret = nouveau_heap_alloc(screen->text_heap, size, prog, &prog->mem);
    if (ret) {
       struct nouveau_heap *heap = screen->text_heap;
-      struct nouveau_heap *iter;
-      for (iter = heap; iter && iter->next != heap; iter = iter->next) {
-         struct nvc0_program *evict = iter->priv;
-         if (evict)
-            nouveau_heap_free(&evict->mem);
+      /* Note that the code library, which is allocated before anything else,
+       * does not have a priv pointer. We can stop once we hit it.
+       */
+      while (heap->next && heap->next->priv) {
+         struct nvc0_program *evict = heap->next->priv;
+         nouveau_heap_free(&evict->mem);
       }
       debug_printf("WARNING: out of code space, evicting all shaders.\n");
       ret = nouveau_heap_alloc(heap, size, prog, &prog->mem);
Signature · 6 lines
2.3.6

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): 1431237476-912-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]

#2 lore raw
Quoted 23 lines · Ilia Mirkin

This aligns it to work similarly to nv50. However there's no library code there, so the whole thing can be freed. Here we end up with an allocated node that's not attached to a specific program.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86792

---
  src/gallium/drivers/nouveau/nvc0/nvc0_program.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/nvc0/nvc0_program.c +0 -4
index c156e91..5589695 100644
@@ -683,11 +683,12 @@ nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog)
     ret = nouveau_heap_alloc(screen->text_heap, size, prog, &prog->mem);
     if (ret) {
        struct nouveau_heap *heap = screen->text_heap;
-      struct nouveau_heap *iter;
-      for (iter = heap; iter && iter->next != heap; iter = iter->next) {
-         struct nvc0_program *evict = iter->priv;
-         if (evict)

src/gallium/drivers/nouveau/nvc0/nvc0_program.c nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog) · line 694

Quoted 10 lines
src/gallium/drivers/nouveau/nvc0/nvc0_program.c +6 -1
-            nouveau_heap_free(&evict->mem);
+      /* Note that the code library, which is allocated before anything else,
+       * does not have a priv pointer. We can stop once we hit it.
+       */
+      while (heap->next && heap->next->priv) {
+         struct nvc0_program *evict = heap->next->priv;
+         nouveau_heap_free(&evict->mem);
        }
        debug_printf("WARNING: out of code space, evicting all shaders.\n");
        ret = nouveau_heap_alloc(heap, size, prog, &prog->mem);

The new comment is a bit upside down, but thats not really a problem

R-b here as well
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau