diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-03-08 23:36:02 +0000 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-03-12 02:37:41 +0000 |
commit | 9f25a4e65c025364df0b52cbb3e9aa2e525b1a74 (patch) | |
tree | c63d14b06ecfee1883c817cd8bb32dc73ca3fe07 /src/gallium/drivers/panfrost | |
parent | f9dc1ebc0d5cc475b8729f2dc4f6dac8c83e52a1 (diff) |
panfrost: Allocate dedicated slab for linear BOs
Previously, linear BOs shared memory with each other to minimize kernel
round-trips / latency, as well as to work around a bug in the free_slab
function. These concerns are invalid now, but continuing to use the slab
allocator for BOs resulted in memory allocation errors. This issue was
aggravated, though not introduced (so not a real regression) in the
previous commit.
v2 (unreviewed): Fix bug in v1 preventing munmaps from working
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Tomeu Vizoso <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_resource.c | 33 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_resource.h | 4 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 0b97d9c3461..d647f618ee7 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -223,17 +223,20 @@ panfrost_create_bo(struct panfrost_screen *screen, const struct pipe_resource *t for (int l = 0; l < (template->last_level + 1); ++l) { bo->cpu[l] = malloc(sz); + bo->size[l] = sz; sz >>= 2; } } else { - /* But for linear, we can! */ + /* For a linear resource, allocate a block of memory from + * kernel space */ - struct pb_slab_entry *entry = pb_slab_alloc(&screen->slabs, sz, HEAP_TEXTURE); - struct panfrost_memory_entry *p_entry = (struct panfrost_memory_entry *) entry; - struct panfrost_memory *backing = (struct panfrost_memory *) entry->slab; - bo->entry[0] = p_entry; - bo->cpu[0] = backing->cpu + p_entry->offset; - bo->gpu[0] = backing->gpu + p_entry->offset; + struct panfrost_memory mem; + + bo->size[0] = ALIGN(sz, 4096); + screen->driver->allocate_slab(screen, &mem, bo->size[0] / 4096, true, 0, 0, 0); + + bo->cpu[0] = mem.cpu; + bo->gpu[0] = mem.gpu; /* TODO: Mipmap */ } @@ -303,12 +306,16 @@ panfrost_destroy_bo(struct panfrost_screen *screen, struct panfrost_bo *pbo) { struct panfrost_bo *bo = (struct panfrost_bo *)pbo; - 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->layout == PAN_LINEAR && !bo->imported) { + /* Construct a memory object for all mip levels */ + + struct panfrost_memory mem = { + .cpu = bo->cpu[0], + .gpu = bo->gpu[0], + .size = bo->size[0] + }; + + screen->driver->free_slab(screen, &mem); } if (bo->layout == PAN_TILED) { diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index 6114fe75779..2e3d72babe6 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -56,8 +56,8 @@ struct panfrost_bo { /* Set if this bo was imported rather than allocated */ bool imported; - /* Number of bytes of the imported allocation */ - size_t imported_size; + /* Number of bytes of allocation */ + size_t size[MAX_MIP_LEVELS]; /* Internal layout (tiled?) */ enum panfrost_memory_layout layout; |