From patchwork Tue Apr 4 22:11:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 9662669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 596C76032D for ; Tue, 4 Apr 2017 22:11:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BDDF22B39 for ; Tue, 4 Apr 2017 22:11:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40FEC28583; Tue, 4 Apr 2017 22:11:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 03A1A22B39 for ; Tue, 4 Apr 2017 22:11:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99AB989B0B; Tue, 4 Apr 2017 22:11:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FF1B6E6E0 for ; Tue, 4 Apr 2017 22:11:39 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 04 Apr 2017 15:11:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,276,1486454400"; d="scan'208";a="83060586" Received: from cmachale-mobl1.ger.corp.intel.com (HELO mwahaha.ger.corp.intel.com) ([10.252.25.9]) by orsmga005.jf.intel.com with ESMTP; 04 Apr 2017 15:11:38 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Tue, 4 Apr 2017 23:11:18 +0100 Message-Id: <20170404221128.3943-9-matthew.auld@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404221128.3943-1-matthew.auld@intel.com> References: <20170404221128.3943-1-matthew.auld@intel.com> Subject: [Intel-gfx] [PATCH 08/18] drm/i915: handle evict-for-node with page coloring 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-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem_evict.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index 0c9c51be0f6a..817acff2fb6c 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c @@ -276,6 +276,30 @@ int i915_gem_evict_for_node(struct i915_address_space *vm, /* Always look at the page afterwards to avoid the end-of-GTT */ end += I915_GTT_PAGE_SIZE; + } else if (i915_vm_has_page_coloring(vm)) { + u64 pt_start, pt_end; + + GEM_BUG_ON(!is_valid_gtt_page_size(target->color)); + GEM_BUG_ON(!IS_ALIGNED(start, target->color)); + GEM_BUG_ON(!IS_ALIGNED(end, target->color)); + + /* We need to consider the page table coloring on both sides of + * the range, where a mismatch would require extending our + * range to evict nodes up to the page table boundry for each + * side to ensure the underlying page table(s) for the range + * match the target color. + */ + pt_start = rounddown(start, 1 << GEN8_PDE_SHIFT); + node = __drm_mm_interval_first(&vm->mm, pt_start, start); + if (i915_node_color_differs(node, target->color)) { + start = pt_start; + } + + pt_end = roundup(start, 1 << GEN8_PDE_SHIFT); + node = __drm_mm_interval_first(&vm->mm, end, pt_end); + if (i915_node_color_differs(node, target->color)) { + end = pt_end; + } } GEM_BUG_ON(start >= end);