From patchwork Wed Dec 2 21:07:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 64350 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB2L7kRR010756 for ; Wed, 2 Dec 2009 21:07:46 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBDF79E7A7; Wed, 2 Dec 2009 13:07:45 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from azsmga102.ch.intel.com (mga12.intel.com [143.182.124.36]) by gabe.freedesktop.org (Postfix) with ESMTP id 831DD9E776 for ; Wed, 2 Dec 2009 13:07:43 -0800 (PST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 02 Dec 2009 13:07:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,316,1257148800"; d="scan'208";a="218098777" Received: from unknown (HELO localhost.localdomain) ([10.255.16.235]) by azsmga001.ch.intel.com with ESMTP; 02 Dec 2009 13:07:39 -0800 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 2 Dec 2009 21:07:37 +0000 Message-Id: <1259788057-10159-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.6.5.3 Cc: stable@kernel.org Subject: [Intel-gfx] [PATCH] drm/i915: Promote invalid buffer alignment. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 214fb18..846f050 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2577,6 +2577,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment) drm_i915_private_t *dev_priv = dev->dev_private; struct drm_i915_gem_object *obj_priv = obj->driver_private; struct drm_mm_node *free_space; + unsigned required_alignment; bool retry_alloc = false; int ret; @@ -2588,11 +2589,17 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment) return -EINVAL; } - if (alignment == 0) - alignment = i915_gem_get_gtt_alignment(obj); - if (alignment & (i915_gem_get_gtt_alignment(obj) - 1)) { - DRM_ERROR("Invalid object alignment requested %u\n", alignment); - return -EINVAL; + required_alignment = i915_gem_get_gtt_alignment(obj); + if (alignment & (required_alignment - 1)) { + WARN(1,"Invalid object alignment requested %x < %x\n", + alignment, required_alignment); + /* Use the smallest possible alignment that honours the + * fencing restrictions and the user request. + */ + if (alignment < required_alignment) + alignment = required_alignment; + else + alignment = (alignment + required_alignment) & -required_alignment; } search_free: