From 62335e7879aa90e665cc7f7f6166bbce81c17d96 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 17 Dec 2018 10:22:44 +0000 Subject: [PATCH] i965: limit texture total size Mesa has MaxTextureMbytes variable the driver can set to avoid allocating a texture above a certain size. When applying the check on the size, Mesa only checks for a given level. But the way i965 allocates BOs for mipmap is by taking into account all the levels, meaning that we can if an application allocates a BO by starting by the smaller LOD, it'll pass Mesa's check and i965 will attempt to allocate a massive BOs for all the included levels. i915 appears to lock up the system if we allocate a massive BO (on my system ~12Gb with 16Gb of available RAM). This changes works around the i915 lock up by applying a size check on the size of the BO against MaxTextureMbytes. Signed-off-by: Lionel Landwerlin Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104760 --- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index a679ddf3e48..39aa412be23 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -623,6 +623,11 @@ make_surface(struct brw_context *brw, GLenum target, mesa_format format, assert(mt->surf.size_B % mt->surf.row_pitch_B == 0); if (!bo) { + if (mt->surf.size_B > ((uint64_t)brw->ctx.Const.MaxTextureMbytes * 1024 * 1024)) { + DBG("%s texture too large %"PRIu64"\n", __func__, mt->surf.size_B); + goto fail; + } + mt->bo = brw_bo_alloc_tiled(brw->bufmgr, "isl-miptree", mt->surf.size_B, BRW_MEMZONE_OTHER, -- 2.20.0