From patchwork Thu Mar 27 10:18:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 3897241 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D73929F334 for ; Thu, 27 Mar 2014 10:19:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABEDE20171 for ; Thu, 27 Mar 2014 10:19:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 484CE20148 for ; Thu, 27 Mar 2014 10:19:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 164596E888; Thu, 27 Mar 2014 03:19:13 -0700 (PDT) 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 1057B6E888 for ; Thu, 27 Mar 2014 03:19:12 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 27 Mar 2014 03:19:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,741,1389772800"; d="scan'208";a="508077186" Received: from tursulin-linux.iwi.intel.com ([172.28.253.34]) by fmsmga002.fm.intel.com with ESMTP; 27 Mar 2014 03:19:08 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 27 Mar 2014 10:18:57 +0000 Message-Id: <1395915537-11086-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395852527-6048-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1395852527-6048-1-git-send-email-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [RFC] drm/i915: Simplify page allocation loop a bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.6 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 From: Tvrtko Ursulin Looks like there are some redundant lines in the main loop of i915_gem_object_get_pages_gtt. v2: Put CONFIG_SWIOTLB back in. I haven't tested this so just RFC please. Not sure that seven lines net less is worth this. It just made it clerer to a newby to sg building to think of it in terms of "merge entries always except when...". Signed-off-by: Tvrtko Ursulin Cc: Imre Deak Cc: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 00c8361..b435db1 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1912,15 +1912,11 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD; gfp &= ~(__GFP_IO | __GFP_WAIT); } + if (!i || page_to_pfn(page) != last_pfn + 1 #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { - st->nents++; - sg_set_page(sg, page, PAGE_SIZE, 0); - sg = sg_next(sg); - continue; - } + || swiotlb_nr_tbl() #endif - if (!i || page_to_pfn(page) != last_pfn + 1) { + ) { if (i) sg = sg_next(sg); st->nents++; @@ -1933,10 +1929,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) /* Check that the i965g/gm workaround works. */ WARN_ON((gfp & __GFP_DMA32) && (last_pfn >= 0x00100000UL)); } -#ifdef CONFIG_SWIOTLB - if (!swiotlb_nr_tbl()) -#endif - sg_mark_end(sg); + sg_mark_end(sg); obj->pages = st; if (i915_gem_object_needs_bit17_swizzle(obj))