From patchwork Mon Oct 28 15:53:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11215797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5081314DB for ; Mon, 28 Oct 2019 15:53:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38A8220830 for ; Mon, 28 Oct 2019 15:53:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38A8220830 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D22506E970; Mon, 28 Oct 2019 15:53:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id A38D26E96C; Mon, 28 Oct 2019 15:53:30 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:30 -0700 X-IronPort-AV: E=Sophos;i="5.68,240,1569308400"; d="scan'208";a="193299010" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.17]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:27 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Mon, 28 Oct 2019 16:53:15 +0100 Message-Id: <20191028155318.23416-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> References: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t v3 1/4] lib: Move redundant local helpers to lib/ X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Two tests - gem_exec_reloc and gem_softpin - define local helpers for calculation of softpin offset canonical addresses. As more users are expected, replace those local instances with a single shared one under lib/. Signed-off-by: Janusz Krzysztofik Cc: Chris Wilson --- lib/igt_x86.c | 13 +++++++++++++ lib/igt_x86.h | 5 +++++ tests/i915/gem_exec_reloc.c | 16 +++------------- tests/i915/gem_softpin.c | 13 +------------ 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/lib/igt_x86.c b/lib/igt_x86.c index 6ac700df..13d7c6e5 100644 --- a/lib/igt_x86.c +++ b/lib/igt_x86.c @@ -190,6 +190,19 @@ char *igt_x86_features_to_string(unsigned features, char *line) } #endif +/** + * gen8_canonical_addr + * Used to convert any address into canonical form, i.e. [63:48] == [47]. + * Based on kernel's sign_extend64 implementation. + * @address - a virtual address + */ +uint64_t gen8_canonical_addr(uint64_t address) +{ + int shift = 63 - GEN8_HIGH_ADDRESS_BIT; + + return (int64_t)(address << shift) >> shift; +} + #if defined(__x86_64__) && !defined(__clang__) #pragma GCC push_options #pragma GCC target("sse4.1") diff --git a/lib/igt_x86.h b/lib/igt_x86.h index c7b84dec..8c7eb5e8 100644 --- a/lib/igt_x86.h +++ b/lib/igt_x86.h @@ -30,6 +30,8 @@ #ifndef IGT_X86_H #define IGT_X86_H +#include + #define MMX 0x1 #define SSE 0x2 #define SSE2 0x4 @@ -56,6 +58,9 @@ static inline char *igt_x86_features_to_string(unsigned features, char *line) } #endif +#define GEN8_HIGH_ADDRESS_BIT 47 +uint64_t gen8_canonical_addr(uint64_t address); + void igt_memcpy_from_wc(void *dst, const void *src, unsigned long len); #endif /* IGT_X86_H */ diff --git a/tests/i915/gem_exec_reloc.c b/tests/i915/gem_exec_reloc.c index fdd9661d..61f8b755 100644 --- a/tests/i915/gem_exec_reloc.c +++ b/tests/i915/gem_exec_reloc.c @@ -23,6 +23,7 @@ #include "igt.h" #include "igt_dummyload.h" +#include "igt_x86.h" IGT_TEST_DESCRIPTION("Basic sanity check of execbuf-ioctl relocations."); @@ -500,17 +501,6 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags) gem_close(fd, obj.handle); } -static inline uint64_t sign_extend(uint64_t x, int index) -{ - int shift = 63 - index; - return (int64_t)(x << shift) >> shift; -} - -static uint64_t gen8_canonical_address(uint64_t address) -{ - return sign_extend(address, 47); -} - static void basic_range(int fd, unsigned flags) { struct drm_i915_gem_relocation_entry reloc[128]; @@ -537,7 +527,7 @@ static void basic_range(int fd, unsigned flags) for (int i = 0; i <= count; i++) { obj[n].handle = gem_create(fd, 4096); obj[n].offset = (1ull << (i + 12)) - 4096; - obj[n].offset = gen8_canonical_address(obj[n].offset); + obj[n].offset = gen8_canonical_addr(obj[n].offset); obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS; gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe)); execbuf.buffers_ptr = to_user_pointer(&obj[n]); @@ -557,7 +547,7 @@ static void basic_range(int fd, unsigned flags) for (int i = 1; i < count; i++) { obj[n].handle = gem_create(fd, 4096); obj[n].offset = 1ull << (i + 12); - obj[n].offset = gen8_canonical_address(obj[n].offset); + obj[n].offset = gen8_canonical_addr(obj[n].offset); obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS; gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe)); execbuf.buffers_ptr = to_user_pointer(&obj[n]); diff --git a/tests/i915/gem_softpin.c b/tests/i915/gem_softpin.c index b9ff532e..17bd40a4 100644 --- a/tests/i915/gem_softpin.c +++ b/tests/i915/gem_softpin.c @@ -27,22 +27,11 @@ */ #include "igt.h" +#include "igt_x86.h" #define EXEC_OBJECT_PINNED (1<<4) #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3) -/* gen8_canonical_addr - * Used to convert any address into canonical form, i.e. [63:48] == [47]. - * Based on kernel's sign_extend64 implementation. - * @address - a virtual address -*/ -#define GEN8_HIGH_ADDRESS_BIT 47 -static uint64_t gen8_canonical_addr(uint64_t address) -{ - __u8 shift = 63 - GEN8_HIGH_ADDRESS_BIT; - return (__s64)(address << shift) >> shift; -} - static void test_invalid(int fd) { const uint32_t bbe = MI_BATCH_BUFFER_END; From patchwork Mon Oct 28 15:53:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11215793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8D7C1390 for ; Mon, 28 Oct 2019 15:53:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 917F6208C0 for ; Mon, 28 Oct 2019 15:53:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 917F6208C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 03B1F6E95C; Mon, 28 Oct 2019 15:53:35 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B24446E96C; Mon, 28 Oct 2019 15:53:33 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:33 -0700 X-IronPort-AV: E=Sophos;i="5.68,240,1569308400"; d="scan'208";a="193299017" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.17]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:30 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Mon, 28 Oct 2019 16:53:16 +0100 Message-Id: <20191028155318.23416-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> References: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t v3 2/4] lib: Add GEM minimum page size helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some tests assume 4kB page size while using softpin. That assumption may be wrong on future GEM backends with possibly larger minimum page sizes. As a result, those tests may either fail on softpin at offsets which are incorrectly aligned, may silently skip such incorrectly aligned addresses assuming them occupied by other users, or may always succeed when examining invalid use patterns. Provide a helper function that detects minimum page size and returns the size order. Tests may use it to calculate softpin offsets suitable for actually used backing store. Signed-off-by: Janusz Krzysztofik Cc: Chris Wilson Cc: Daniele Ceraolo Spurio Cc: Stuart Summers --- lib/ioctl_wrappers.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ lib/ioctl_wrappers.h | 1 + 2 files changed, 83 insertions(+) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 280fdd62..a4313832 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -54,6 +54,7 @@ #include "intel_io.h" #include "igt_debugfs.h" #include "igt_sysfs.h" +#include "igt_x86.h" #include "config.h" #ifdef HAVE_VALGRIND @@ -1157,6 +1158,87 @@ bool gem_has_softpin(int fd) return has_softpin; } +static int __min_page_size_order(int fd, struct drm_i915_gem_exec_object2 *obj, + struct drm_i915_gem_execbuffer2 *eb, + uint64_t offset, int min_order, int max_order) +{ + static const uint32_t bbe = MI_BATCH_BUFFER_END; + uint64_t page_size = 1ull << max_order; + int order; + + if (max_order > min_order) { + /* explore upper half of the max_order@offset area */ + order = __min_page_size_order(fd, obj, eb, offset, min_order, + max_order - 1); + if (order < max_order) + return order; + } + + obj->offset = gen8_canonical_addr(offset - page_size); + gem_write(fd, obj->handle, 0, &bbe, sizeof(bbe)); + if (!__gem_execbuf(fd, eb)) { + /* upper half not occupied, must be the minimum */ + igt_debug("found min page size=%#llx, size order=%d\n", + (long long)page_size, max_order); + return max_order; + } + + if (max_order > min_order) { + /* explore lower half of in case the upper half was occupied */ + page_size >>= 1; + order = __min_page_size_order(fd, obj, eb, offset - page_size, + min_order, max_order - 1); + if (order < max_order) + return order; + } + + return max_order + 1; +} + +/** + * gem_min_page_size_order: + * @fd: open i915 drm file descriptor + * + * This function detects the minimum size of a gem object allocated from + * a default backing store. It is useful for calculating correctly aligned + * softpin offsets. + * Since size order to size conversion (size = 1 << order) is less trivial + * than the opposite, the function returns the size order as more handy. + * + * Returns: + * Size order of the minimum page size + */ +int gem_min_page_size_order(int fd) +{ + struct drm_i915_gem_exec_object2 obj; + struct drm_i915_gem_execbuffer2 eb; + uint64_t gtt_size = gem_aperture_size(fd); + int min_order = 12; /* current I915_GTT_PAGE_SIZE equivalent */ + uint64_t page_size = 1ull << min_order; + int max_order = 21; /* current I915_GTT_MAX_PAGE_SIZE equivalent */ + + /* no softpin => 4kB page size */ + if (!gem_has_softpin(fd)) + return min_order; + + memset(&obj, 0, sizeof(obj)); + memset(&eb, 0, sizeof(eb)); + + obj.handle = gem_create(fd, page_size); + obj.flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS; + eb.buffers_ptr = to_user_pointer(&obj); + eb.buffer_count = 1; + + min_order = __min_page_size_order(fd, &obj, &eb, gtt_size, min_order, + max_order); + + gem_close(fd, obj.handle); + + igt_require(min_order <= max_order); + + return min_order; +} + /** * gem_has_exec_fence: * @fd: open i915 drm file descriptor diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 03211c97..91690847 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -138,6 +138,7 @@ uint64_t gem_aperture_size(int fd); uint64_t gem_global_aperture_size(int fd); uint64_t gem_mappable_aperture_size(void); bool gem_has_softpin(int fd); +int gem_min_page_size_order(int fd); bool gem_has_exec_fence(int fd); /* check functions which auto-skip tests by calling igt_skip() */ From patchwork Mon Oct 28 15:53:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11215795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 045181390 for ; Mon, 28 Oct 2019 15:53:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E108A208C0 for ; Mon, 28 Oct 2019 15:53:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E108A208C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6AF986E966; Mon, 28 Oct 2019 15:53:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2735A6E966; Mon, 28 Oct 2019 15:53:37 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:37 -0700 X-IronPort-AV: E=Sophos;i="5.68,240,1569308400"; d="scan'208";a="193299025" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.17]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:33 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Mon, 28 Oct 2019 16:53:17 +0100 Message-Id: <20191028155318.23416-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> References: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t v3 3/4] tests/gem_exec_reloc: Calculate softpin offsets from actual page size X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Janusz Krzysztofik , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Janusz Krzysztofik The basic-range subtest assumes 4kB page size while calculating softpin offsets. On future backends with possibly larger minimum page sizes a half of calculated offsets to be tested may be incorrectly detected as occupied by other users and skiped, significantly distoring the intended test pattern. Replace hardcoded constants corresponding to the assumed 4kB page size with variables initialized with actual minimum page size and order. v2: Simplify the code by reversing the size->order conversion, - drop irrelevant modifications of requested object sizes. v3: Initialize page size order with an actual minimum returned by a new helper (inspired by Chris). Signed-off-by: Janusz Krzysztofik Cc: Katarzyna Dec Cc: Stuart Summers Cc: Chris Wilson --- tests/i915/gem_exec_reloc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/i915/gem_exec_reloc.c b/tests/i915/gem_exec_reloc.c index 61f8b755..5e7df8ed 100644 --- a/tests/i915/gem_exec_reloc.c +++ b/tests/i915/gem_exec_reloc.c @@ -510,14 +510,16 @@ static void basic_range(int fd, unsigned flags) uint64_t gtt_size = gem_aperture_size(fd); const uint32_t bbe = MI_BATCH_BUFFER_END; igt_spin_t *spin = NULL; + int page_order = gem_min_page_size_order(fd); + uint64_t page_size = 1ull << page_order; int count, n; igt_require(gem_has_softpin(fd)); - for (count = 12; gtt_size >> (count + 1); count++) + for (count = page_order; gtt_size >> (count + 1); count++) ; - count -= 12; + count -= page_order; memset(obj, 0, sizeof(obj)); memset(reloc, 0, sizeof(reloc)); @@ -526,7 +528,7 @@ static void basic_range(int fd, unsigned flags) n = 0; for (int i = 0; i <= count; i++) { obj[n].handle = gem_create(fd, 4096); - obj[n].offset = (1ull << (i + 12)) - 4096; + obj[n].offset = (1ull << (i + page_order)) - page_size; obj[n].offset = gen8_canonical_addr(obj[n].offset); obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS; gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe)); @@ -546,7 +548,7 @@ static void basic_range(int fd, unsigned flags) } for (int i = 1; i < count; i++) { obj[n].handle = gem_create(fd, 4096); - obj[n].offset = 1ull << (i + 12); + obj[n].offset = 1ull << (i + page_order); obj[n].offset = gen8_canonical_addr(obj[n].offset); obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS; gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe)); From patchwork Mon Oct 28 15:53:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11215799 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8886214DB for ; Mon, 28 Oct 2019 15:53:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7058D208C0 for ; Mon, 28 Oct 2019 15:53:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7058D208C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D59796E973; Mon, 28 Oct 2019 15:53:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A0B86E96C; Mon, 28 Oct 2019 15:53:40 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:40 -0700 X-IronPort-AV: E=Sophos;i="5.68,240,1569308400"; d="scan'208";a="193299043" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.17]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 08:53:37 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Mon, 28 Oct 2019 16:53:18 +0100 Message-Id: <20191028155318.23416-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> References: <20191028155318.23416-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t v3 4/4] tests/gem_ctx_shared: Calculate object attributs from actual page size X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" exec-shared-gtt-* subtests use hardcoded values for object size and softpin offset, based on 4kB page size assumption. That may result in those subtests failing when run on future backing stores with possibly larger minimum page sizes. Replace hardcoded constants with values derived from minimum page size of actual backing store the test is running on. Signed-off-by: Janusz Krzysztofik Cc: Chris Wilson --- tests/i915/gem_ctx_shared.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c index f7852482..d386de65 100644 --- a/tests/i915/gem_ctx_shared.c +++ b/tests/i915/gem_ctx_shared.c @@ -195,6 +195,7 @@ static void exec_shared_gtt(int i915, unsigned int ring) uint32_t scratch, *s; uint32_t batch, cs[16]; uint64_t offset; + uint64_t page_size; int i; gem_require_ring(i915, ring); @@ -203,7 +204,8 @@ static void exec_shared_gtt(int i915, unsigned int ring) clone = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0); /* Find a hole big enough for both objects later */ - scratch = gem_create(i915, 16384); + page_size = 1ull << gem_min_page_size_order(i915); + scratch = gem_create(i915, 4 * page_size); gem_write(i915, scratch, 0, &bbe, sizeof(bbe)); obj.handle = scratch; gem_execbuf(i915, &execbuf); @@ -246,7 +248,7 @@ static void exec_shared_gtt(int i915, unsigned int ring) gem_write(i915, batch, 0, cs, sizeof(cs)); obj.handle = batch; - obj.offset += 8192; /* make sure we don't cause an eviction! */ + obj.offset += 2 * page_size; /* make sure we don't cause an eviction! */ execbuf.rsvd1 = clone; if (gen > 3 && gen < 6) execbuf.flags |= I915_EXEC_SECURE;