panfrost: propagate errors from panfrost_batch_create_bo

Without this, we just assert and/or crash because the allocation fails.
This should allow us to survive a bit longer.

Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32724>
This commit is contained in:
Erik Faye-Lund 2024-12-19 16:39:03 +01:00 committed by Marge Bot
parent 76760ce610
commit b60ee4251e
3 changed files with 25 additions and 10 deletions

View file

@ -1574,6 +1574,9 @@ panfrost_emit_shared_memory(struct panfrost_batch *batch,
struct panfrost_bo *bo = panfrost_batch_get_shared_memory(batch, size, 1);
if (!bo)
return 0;
info.wls.ptr = bo->ptr.gpu;
}
@ -4001,6 +4004,12 @@ batch_get_polygon_list(struct panfrost_batch *batch)
batch->polygon_list_bo = panfrost_batch_create_bo(
batch, size, init_polygon_list ? 0 : PAN_BO_INVISIBLE,
PIPE_SHADER_VERTEX, "Polygon list");
if (!batch->polygon_list_bo) {
mesa_loge("failed to allocate memory for polygon-list");
return 0;
}
batch->tiler_ctx.midgard.polygon_list = batch->polygon_list_bo->ptr.gpu;
panfrost_batch_add_bo(batch, batch->polygon_list_bo,
PIPE_SHADER_FRAGMENT);
@ -4035,8 +4044,9 @@ init_polygon_list(struct panfrost_batch *batch)
{
#if PAN_ARCH <= 5
uint64_t polygon_list = batch_get_polygon_list(batch);
pan_jc_initialize_tiler(&batch->pool.base, &batch->jm.jobs.vtc_jc,
polygon_list);
if (polygon_list)
pan_jc_initialize_tiler(&batch->pool.base, &batch->jm.jobs.vtc_jc,
polygon_list);
#endif
}

View file

@ -209,6 +209,10 @@ panfrost_get_blend(struct panfrost_batch *batch, unsigned rti,
if (!(*bo)) {
*bo = panfrost_batch_create_bo(batch, 4096, PAN_BO_EXECUTE,
PIPE_SHADER_FRAGMENT, "Blend shader");
if (!(*bo)) {
mesa_loge("failed to allocate blend-shader");
return 0;
}
}
struct panfrost_compiled_shader *ss = ctx->prog[PIPE_SHADER_FRAGMENT];

View file

@ -409,15 +409,16 @@ panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
bo = panfrost_bo_create(pan_device(batch->ctx->base.screen), size,
create_flags, label);
assert(bo);
panfrost_batch_add_bo(batch, bo, stage);
if (bo) {
panfrost_batch_add_bo(batch, bo, stage);
/* panfrost_batch_add_bo() has retained a reference and
* panfrost_bo_create() initialize the refcnt to 1, so let's
* unreference the BO here so it gets released when the batch is
* destroyed (unless it's retained by someone else in the meantime).
*/
panfrost_bo_unreference(bo);
/* panfrost_batch_add_bo() has retained a reference and
* panfrost_bo_create() initialize the refcnt to 1, so let's
* unreference the BO here so it gets released when the batch is
* destroyed (unless it's retained by someone else in the meantime).
*/
panfrost_bo_unreference(bo);
}
return bo;
}