panfrost: Fix various leaks unmapping resources
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 14 Feb 2019 06:17:19 +0000 (06:17 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 18 Feb 2019 05:09:41 +0000 (05:09 +0000)
v2: Don't check for NULL before free()

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_screen.h

index f2cff7c80dfe26f86568fd7fb787844e4c4e1988..1287193c0e90d7e6f3e8f7cdd81232a21b45136b 100644 (file)
@@ -287,16 +287,18 @@ panfrost_destroy_bo(struct panfrost_screen *screen, struct panfrost_bo *pbo)
 {
        struct panfrost_bo *bo = (struct panfrost_bo *)pbo;
 
-        if (bo->entry[0] != NULL) {
-                /* Most allocations have an entry to free */
-                bo->entry[0]->freed = true;
-                pb_slab_free(&screen->slabs, &bo->entry[0]->base);
+        for (int l = 0; l < MAX_MIP_LEVELS; ++l) {
+                if (bo->entry[l] != NULL) {
+                        /* Most allocations have an entry to free */
+                        bo->entry[l]->freed = true;
+                        pb_slab_free(&screen->slabs, &bo->entry[l]->base);
+                }
         }
 
         if (bo->tiled) {
                 /* Tiled has a malloc'd CPU, so just plain ol' free needed */
 
-                for (int l = 0; bo->cpu[l]; l++) {
+                for (int l = 0; l < MAX_MIP_LEVELS; ++l) {
                         free(bo->cpu[l]);
                 }
         }
@@ -509,9 +511,10 @@ panfrost_slab_can_reclaim(void *priv, struct pb_slab_entry *entry)
 static void
 panfrost_slab_free(void *priv, struct pb_slab *slab)
 {
-        /* STUB */
-        //struct panfrost_memory *mem = (struct panfrost_memory *) slab;
-        printf("stub: Tried to free slab\n");
+        struct panfrost_memory *mem = (struct panfrost_memory *) slab;
+        struct panfrost_screen *screen = (struct panfrost_screen *) priv;
+
+        screen->driver->free_slab(screen, mem);
 }
 
 static void
index b89d921c71f4a64f0ea4260e89c2b892c1036986..afb3d34b5b13c1b9521ca140d2ba3101597b9839 100644 (file)
@@ -58,7 +58,9 @@ struct panfrost_driver {
                               int extra_flags,
                               int commit_count,
                               int extent);
-       void (*enable_counters) (struct panfrost_screen *screen);
+        void (*free_slab) (struct panfrost_screen *screen,
+                           struct panfrost_memory *mem);
+        void (*enable_counters) (struct panfrost_screen *screen);
 };
 
 struct panfrost_screen {