From: Anuj Phogat Subject: [PATCH] drm/i915: Handle request to map a very large buffer object Date: Mon, 27 Feb 2012 12:28:58 -0800 Message-ID: <1330374538-8138-1-git-send-email-anuj.phogat@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-pz0-f49.google.com (mail-pz0-f49.google.com [209.85.210.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 043299E9A3 for ; Mon, 27 Feb 2012 12:30:49 -0800 (PST) Received: by dakp5 with SMTP id p5so3988401dak.36 for ; Mon, 27 Feb 2012 12:30:49 -0800 (PST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org 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 --- 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@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