From patchwork Fri Mar 18 13:54:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 8619201 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3012DC0553 for ; Fri, 18 Mar 2016 13:55:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 516D220382 for ; Fri, 18 Mar 2016 13:55:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 630E820377 for ; Fri, 18 Mar 2016 13:55:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A4B6E6E0C2; Fri, 18 Mar 2016 13:55:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C07C6E0C2 for ; Fri, 18 Mar 2016 13:55:01 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 18 Mar 2016 06:55:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,355,1455004800"; d="scan'208";a="766808566" Received: from unknown (HELO localhost.isw.intel.com) ([10.237.224.39]) by orsmga003.jf.intel.com with ESMTP; 18 Mar 2016 06:55:00 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Fri, 18 Mar 2016 13:54:50 +0000 Message-Id: <1458309290-15188-1-git-send-email-matthew.auld@intel.com> X-Mailer: git-send-email 2.4.3 Subject: [Intel-gfx] [PATCH] drm/i915: simplify bind_to_vm init code X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No functional change, just makes the code easier to follow. v2: - Remove local fence_size variable (Tvrtko Ursulin) - Remove redundant NULL ggtt_view check - Reuse size variable v3: (Chris Wilson) - Keep start, end computation separate - Simplify alignment Signed-off-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem.c | 52 +++++++++++------------------------------ 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index f45856d..ffb802e 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3465,48 +3465,23 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj, { struct drm_device *dev = obj->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; - u32 fence_alignment, unfenced_alignment; + u32 min_alignment; u32 search_flag, alloc_flag; u64 start, end; - u64 size, fence_size; + u64 size; struct i915_vma *vma; int ret; - if (i915_is_ggtt(vm)) { - u32 view_size; - - if (WARN_ON(!ggtt_view)) - return ERR_PTR(-EINVAL); - - view_size = i915_ggtt_view_size(obj, ggtt_view); - - fence_size = i915_gem_get_gtt_size(dev, - view_size, - obj->tiling_mode); - fence_alignment = i915_gem_get_gtt_alignment(dev, - view_size, - obj->tiling_mode, - true); - unfenced_alignment = i915_gem_get_gtt_alignment(dev, - view_size, - obj->tiling_mode, - false); - size = flags & PIN_MAPPABLE ? fence_size : view_size; - } else { - fence_size = i915_gem_get_gtt_size(dev, - obj->base.size, - obj->tiling_mode); - fence_alignment = i915_gem_get_gtt_alignment(dev, - obj->base.size, - obj->tiling_mode, - true); - unfenced_alignment = - i915_gem_get_gtt_alignment(dev, - obj->base.size, + if (i915_is_ggtt(vm)) + size = i915_ggtt_view_size(obj, ggtt_view); + else + size = obj->base.size; + + min_alignment = i915_gem_get_gtt_alignment(dev, size, obj->tiling_mode, - false); - size = flags & PIN_MAPPABLE ? fence_size : obj->base.size; - } + flags & PIN_MAPPABLE); + if (flags & PIN_MAPPABLE) + size = i915_gem_get_gtt_size(dev, size, obj->tiling_mode); start = flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0; end = vm->total; @@ -3516,9 +3491,8 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj, end = min_t(u64, end, (1ULL << 32) - PAGE_SIZE); if (alignment == 0) - alignment = flags & PIN_MAPPABLE ? fence_alignment : - unfenced_alignment; - if (flags & PIN_MAPPABLE && alignment & (fence_alignment - 1)) { + alignment = min_alignment; + if (flags & PIN_MAPPABLE && alignment & (min_alignment - 1)) { DRM_DEBUG("Invalid object (view type=%u) alignment requested %u\n", ggtt_view ? ggtt_view->type : 0, alignment);