From patchwork Wed Mar 16 17:07:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 8602711 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38F4B9F44D for ; Wed, 16 Mar 2016 17:09:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 606052025A for ; Wed, 16 Mar 2016 17:09:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 322F420259 for ; Wed, 16 Mar 2016 17:09:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00BA96E2BA; Wed, 16 Mar 2016 17:09:27 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id DFB876E2BA for ; Wed, 16 Mar 2016 17:09:24 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 16 Mar 2016 10:07:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,345,1455004800"; d="scan'208";a="67597604" Received: from unknown (HELO localhost.isw.intel.com) ([10.237.224.39]) by fmsmga004.fm.intel.com with ESMTP; 16 Mar 2016 10:07:11 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Wed, 16 Mar 2016 17:07:06 +0000 Message-Id: <1458148026-3057-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. Signed-off-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index b854af2..5a8d69d 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3470,46 +3470,27 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj, u32 fence_alignment, unfenced_alignment; u32 search_flag, alloc_flag; u64 start, end; - u64 size, fence_size; + u64 size, obj_size, fence_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; + obj_size = i915_ggtt_view_size(obj, ggtt_view); } 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, - obj->tiling_mode, - false); - size = flags & PIN_MAPPABLE ? fence_size : obj->base.size; + obj_size = obj->base.size; } + fence_size = i915_gem_get_gtt_size(dev, obj_size, obj->tiling_mode); + fence_alignment = i915_gem_get_gtt_alignment(dev, obj_size, + obj->tiling_mode, true); + unfenced_alignment = i915_gem_get_gtt_alignment(dev, obj_size, + obj->tiling_mode, + false); + size = flags & PIN_MAPPABLE ? fence_size : obj_size; + start = flags & PIN_OFFSET_BIAS ? flags & PIN_OFFSET_MASK : 0; end = vm->total; if (flags & PIN_MAPPABLE)