From patchwork Mon Mar 6 23:54:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 9607871 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 C6FC5601D2 for ; Mon, 6 Mar 2017 23:54:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF41028490 for ; Mon, 6 Mar 2017 23:54:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A408928499; Mon, 6 Mar 2017 23:54:43 +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 36C4828490 for ; Mon, 6 Mar 2017 23:54:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A5BD6E59C; Mon, 6 Mar 2017 23:54:34 +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 B46D16E596 for ; Mon, 6 Mar 2017 23:54:31 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 06 Mar 2017 15:54:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,256,1484035200"; d="scan'208";a="233013125" Received: from abahri-mobl.ger.corp.intel.com (HELO mwahaha.ger.corp.intel.com) ([10.252.2.118]) by fmsmga004.fm.intel.com with ESMTP; 06 Mar 2017 15:54:30 -0800 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Mon, 6 Mar 2017 23:54:13 +0000 Message-Id: <20170306235414.23407-15-matthew.auld@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170306235414.23407-1-matthew.auld@intel.com> References: <20170306235414.23407-1-matthew.auld@intel.com> Subject: [Intel-gfx] [PATCH 14/15] drm/i915/selftests: exercise 4K and 64K mm insertion 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 Mock test filling an address space with 4K and 64K objects, in the hope of exercising the page color adjust fun. Signed-off-by: Matthew Auld --- drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c index c7963efe46ba..9b2a7228a78f 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c @@ -31,6 +31,7 @@ #include "mock_context.h" #include "mock_drm.h" #include "mock_gem_device.h" +#include "mock_gtt.h" static void fake_free_pages(struct drm_i915_gem_object *obj, struct sg_table *pages) @@ -1306,6 +1307,72 @@ static int igt_gtt_reserve(void *arg) return err; } +static int igt_ppgtt_page_color(void *arg) +{ + struct drm_mm mm; + struct drm_mm_node *node, *prev, *next; + unsigned long page_colors[] = { + I915_GTT_PAGE_SIZE, + I915_GTT_PAGE_SIZE_64K, + }; + int idx = 0; + u64 count = 0; + u64 size; + + drm_mm_init(&mm, 0, U64_MAX); + mm.color_adjust = i915_page_color_adjust; + + /* Running out of memory is okay. */ + + for_each_prime_number_from(size, 0, U64_MAX) { + node = kzalloc(sizeof(*node), GFP_KERNEL); + if (!node) { + pr_info("finished test early, unable to allocate node, count=%llu\n", count); + break; + } + + size = roundup(size, page_colors[idx]); + + if (drm_mm_insert_node_in_range(&mm, node, size, + page_colors[idx], + page_colors[idx], + 0, U64_MAX, + DRM_MM_INSERT_BEST)) { + pr_info("test finished, unable to insert node: color=%lu, size=%llx, count=%llu\n", + page_colors[idx], size, count); + kfree(node); + break; + } + + GEM_BUG_ON(!IS_ALIGNED(node->start, node->color)); + GEM_BUG_ON(!IS_ALIGNED(node->size, node->color)); + + /* We can't mix 4K and 64K pte's in the same pt. */ + + prev = list_prev_entry(node, node_list); + if (i915_color_differs(prev, node->color)) + GEM_BUG_ON(prev->start >> GEN8_PDE_SHIFT == + node->start >> GEN8_PDE_SHIFT); + + next = list_next_entry(node, node_list); + if (i915_color_differs(next, node->color)) + GEM_BUG_ON(((next->start + next->size) >> GEN8_PDE_SHIFT) == + ((node->start + node->size) >> GEN8_PDE_SHIFT)); + + idx ^= 1; + ++count; + } + + drm_mm_for_each_node_safe(node, next, &mm) { + drm_mm_remove_node(node); + kfree(node); + } + + drm_mm_takedown(&mm); + + return 0; +} + static int igt_gtt_insert(void *arg) { struct drm_i915_private *i915 = arg; @@ -1522,6 +1589,7 @@ int i915_gem_gtt_mock_selftests(void) SUBTEST(igt_mock_fill), SUBTEST(igt_gtt_reserve), SUBTEST(igt_gtt_insert), + SUBTEST(igt_ppgtt_page_color), }; struct drm_i915_private *i915; int err;