This patch sets an upper limit on the size of buffer object which can be mapped safely. Following bugs reported segmentation fault / assertion failure with large textures: https://bugs.freedesktop.org/show_bug.cgi?id=44970 https://bugs.freedesktop.org/show_bug.cgi?id=46303 This patch along with another patch which I posted on mesa-dev (intel: Fix a case when mapping large texture fails) resolve above mentioned bugs. Recently posted piglit test case (large-textures) also passes with these patches. Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com> --- This fix doesn't limit developers to create very large texture but it restricts them to map it. I am not very confident about this patch and setting 128 MB as the upper limit on size of buffer object. So, please provide your views. Chris Wilson's views on this issue: http://www.mail-archive.com/intel-gfx at lists.freedesktop.org/msg08585.html intel/intel_bufmgr_gem.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 0f33b71..8b05de9 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -1191,6 +1191,17 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo) pthread_mutex_lock(&bufmgr_gem->lock); + /* Set am upper limit on the size of buffer which can be mapped + safely + */ + if (bo->size > 128 * 1024 * 1024) { + DBG("%s:%d: Reached buffer map limit.\n", + __FILE__, __LINE__); + bo->virtual = NULL; + pthread_mutex_unlock(&bufmgr_gem->lock); + return -1; + } + if (bo_gem->map_count++ == 0) drm_intel_gem_bo_open_vma(bufmgr_gem, bo_gem); -- 1.7.7.6