From patchwork Mon Apr 6 16:32:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11475787 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 7ADD9912 for ; Mon, 6 Apr 2020 16:33:02 +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 62DEF2495E for ; Mon, 6 Apr 2020 16:33:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62DEF2495E 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 B393989DA7; Mon, 6 Apr 2020 16:32:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 440CE89C61; Mon, 6 Apr 2020 16:32:58 +0000 (UTC) IronPort-SDR: kzpvoxjm5vuXXhTt6afnb6BW3foh+SosWv0ThwaIpkx1L2/YB5v6BzQsgXh0UhZDnWYyNS1ET9 NepwroH7uVkA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 09:32:58 -0700 IronPort-SDR: gHufeVnLTk/57VgyoIzSKsxAzxoi7KzLlwPKwFErZJ37r+1PXs2eUjRjHno0MMqU2RvMIJ3Ofm emmsXGZYnfQw== X-IronPort-AV: E=Sophos;i="5.72,351,1580803200"; d="scan'208";a="254163427" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 09:32:56 -0700 From: Janusz Krzysztofik To: Arkadiusz Hiler , Petri Latvala Date: Mon, 6 Apr 2020 18:32:36 +0200 Message-Id: <20200406163237.28293-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200406163237.28293-1-janusz.krzysztofik@linux.intel.com> References: <20200406163237.28293-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/2] tests/gem_userptr_blits: Refresh readonly-mmap-unsync exercise X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Upgrade the subtest to use MMAP_GTT API v4 (aka MMAP_OFFSET), dynamically examine each mapping type supported by i915 driver. Signed-off-by: Janusz Krzysztofik Reviewed-by: Zbigniew Kempczyński --- tests/i915/gem_userptr_blits.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c index beced298a..975cd9dab 100644 --- a/tests/i915/gem_userptr_blits.c +++ b/tests/i915/gem_userptr_blits.c @@ -1277,7 +1277,7 @@ static void sigjmp_handler(int sig) siglongjmp(sigjmp, sig); } -static void test_readonly_mmap(int i915) +static void test_readonly_mmap(int i915, const struct mmap_offset *t) { char *original, *result; uint32_t handle; @@ -1294,6 +1294,14 @@ static void test_readonly_mmap(int i915) * on the GPU as well. */ + handle = gem_create(i915, PAGE_SIZE); + ptr = __gem_mmap_offset(i915, handle, 0, PAGE_SIZE, + PROT_READ | PROT_WRITE, t->type); + gem_close(i915, handle); + igt_require_f(ptr, "HW & kernel support for mmap-offset(%s)\n", + t->name); + munmap(ptr, PAGE_SIZE); + igt_require(igt_setup_clflush()); sz = 16 << 12; @@ -1307,11 +1315,11 @@ static void test_readonly_mmap(int i915) igt_clflush_range(pages, sz); original = g_compute_checksum_for_data(G_CHECKSUM_SHA1, pages, sz); - ptr = __gem_mmap__gtt(i915, handle, sz, PROT_WRITE); + ptr = __gem_mmap_offset(i915, handle, 0, sz, PROT_WRITE, t->type); igt_assert(ptr == NULL); /* Optional kernel support for GTT mmaps of userptr */ - ptr = __gem_mmap__gtt(i915, handle, sz, PROT_READ); + ptr = __gem_mmap_offset(i915, handle, 0, sz, PROT_READ, t->type); gem_close(i915, handle); if (ptr) { /* Check that a write into the GTT readonly map fails */ @@ -2110,8 +2118,11 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL) igt_subtest("readonly-unsync") test_readonly(fd); - igt_subtest("readonly-mmap-unsync") - test_readonly_mmap(fd); + igt_describe("Examine mmap-offset mapping to read-only userptr"); + igt_subtest_with_dynamic("readonly-mmap-unsync") + for_each_mmap_offset_type(fd, t) + igt_dynamic(t->name) + test_readonly_mmap(fd, t); igt_subtest("readonly-pwrite-unsync") test_readonly_pwrite(fd); From patchwork Mon Apr 6 16:32:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11475789 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 CEB67913 for ; Mon, 6 Apr 2020 16:33:03 +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 B77DD2495E for ; Mon, 6 Apr 2020 16:33:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B77DD2495E 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 C96F16E437; Mon, 6 Apr 2020 16:33:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01AE96E434; Mon, 6 Apr 2020 16:32:59 +0000 (UTC) IronPort-SDR: uD5dOg9Yr/qjbCFAovjY51n/KdAexRtzr3MWVZVoMFS8zKqq1cntELvGbgHt8H3UqdJXtN79Ao Bi+jtzReRHCQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 09:32:59 -0700 IronPort-SDR: OnkcOkGlryZo+2dEvWopLYLYQEEmM3K+UOOtswlq3OXtICnYOydCOcF+k6f+k75DJCEHo+CtE0 MT0kUpupavSg== X-IronPort-AV: E=Sophos;i="5.72,351,1580803200"; d="scan'208";a="254163431" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2020 09:32:58 -0700 From: Janusz Krzysztofik To: Arkadiusz Hiler , Petri Latvala Date: Mon, 6 Apr 2020 18:32:37 +0200 Message-Id: <20200406163237.28293-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200406163237.28293-1-janusz.krzysztofik@linux.intel.com> References: <20200406163237.28293-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 2/2] tests/gem_userptr_blits: Refresh other still MMAP_GTT dependent subtests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Extend initial check for support of MMAP_GTT mapping to userptr with equivalent checks for each MMAP_OFFSET mapping type supported by i915 driver. Based on that, extend coverage of process-exit-gtt* subtests over non-GTT mapping types. In case of dmabuf-* subtests, use first supported mapping type if there are any. v2: Clear 'map' before reuse (Zbigniew). Signed-off-by: Janusz Krzysztofik Reviewed-by: Zbigniew Kempczyński --- tests/i915/gem_userptr_blits.c | 111 ++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 30 deletions(-) diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c index 975cd9dab..9b80cf634 100644 --- a/tests/i915/gem_userptr_blits.c +++ b/tests/i915/gem_userptr_blits.c @@ -73,18 +73,31 @@ static uint32_t userptr_flags = LOCAL_I915_USERPTR_UNSYNCHRONIZED; -static bool can_gtt_mmap; +static bool *can_mmap; #define WIDTH 512 #define HEIGHT 512 static uint32_t linear[WIDTH*HEIGHT]; -static bool has_gtt_mmap(int i915) +static bool has_mmap(int i915, const struct mmap_offset *t) { - void *ptr, *map = NULL; + void *ptr, *map; uint32_t handle; + handle = gem_create(i915, PAGE_SIZE); + map = __gem_mmap_offset(i915, handle, 0, PAGE_SIZE, PROT_WRITE, + t->type); + gem_close(i915, handle); + if (map) { + munmap(map, PAGE_SIZE); + } else { + igt_debug("no HW / kernel support for mmap-offset(%s)\n", + t->name); + return false; + } + map = NULL; + igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0); if (__gem_userptr(i915, ptr, 4096, 0, @@ -92,9 +105,12 @@ static bool has_gtt_mmap(int i915) goto out_ptr; igt_assert(handle != 0); - map = __gem_mmap__gtt(i915, handle, 4096, PROT_WRITE); + map = __gem_mmap_offset(i915, handle, 0, 4096, PROT_WRITE, t->type); if (map) munmap(map, 4096); + else if (errno == ENODEV) + igt_debug("mmap-offset(%s) banned, lockdep loop prevention\n", + t->name); gem_close(i915, handle); out_ptr: @@ -642,20 +658,25 @@ static int test_invalid_mapping(int fd, const struct mmap_offset *t) return 0; } -#define PE_GTT_MAP 0x1 -#define PE_BUSY 0x2 -static void test_process_exit(int fd, int flags) +#define PE_BUSY 0x1 +static void test_process_exit(int fd, const struct mmap_offset *mmo, int flags) { - if (flags & PE_GTT_MAP) - igt_require(can_gtt_mmap); + if (mmo) + igt_require_f(can_mmap[mmo->type], + "HW & kernel support for LLC and mmap-offset(%s) over userptr\n", + mmo->name); igt_fork(child, 1) { uint32_t handle; handle = create_userptr_bo(fd, sizeof(linear)); - if (flags & PE_GTT_MAP) { - uint32_t *ptr = __gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE); + if (mmo) { + uint32_t *ptr; + + ptr = __gem_mmap_offset(fd, handle, 0, sizeof(linear), + PROT_READ | PROT_WRITE, + mmo->type); if (ptr) *ptr = 0; } @@ -933,13 +954,14 @@ static void (* volatile orig_sigbus)(int sig, siginfo_t *info, void *param); static volatile unsigned long sigbus_start; static volatile long sigbus_cnt = -1; -static void *umap(int fd, uint32_t handle) +static void *umap(int fd, uint32_t handle, const struct mmap_offset *mmo) { void *ptr; - if (can_gtt_mmap) { - ptr = gem_mmap__gtt(fd, handle, sizeof(linear), - PROT_READ | PROT_WRITE); + if (mmo) { + ptr = __gem_mmap_offset(fd, handle, 0, sizeof(linear), + PROT_READ | PROT_WRITE, mmo->type); + igt_assert(ptr); } else { uint32_t tmp = gem_create(fd, sizeof(linear)); igt_assert_eq(copy(fd, tmp, handle), 0); @@ -951,16 +973,17 @@ static void *umap(int fd, uint32_t handle) } static void -check_bo(int fd1, uint32_t handle1, int is_userptr, int fd2, uint32_t handle2) +check_bo(int fd1, uint32_t handle1, int is_userptr, int fd2, uint32_t handle2, + const struct mmap_offset *mmo) { unsigned char *ptr1, *ptr2; unsigned long size = sizeof(linear); - ptr2 = umap(fd2, handle2); + ptr2 = umap(fd2, handle2, mmo); if (is_userptr) ptr1 = is_userptr > 0 ? get_handle_ptr(handle1) : ptr2; else - ptr1 = umap(fd1, handle1); + ptr1 = umap(fd1, handle1, mmo); igt_assert(ptr1); igt_assert(ptr2); @@ -968,7 +991,7 @@ check_bo(int fd1, uint32_t handle1, int is_userptr, int fd2, uint32_t handle2) sigbus_start = (unsigned long)ptr2; igt_assert(memcmp(ptr1, ptr2, sizeof(linear)) == 0); - if (can_gtt_mmap) { + if (mmo) { counter++; memset(ptr1, counter, size); memset(ptr2, counter, size); @@ -1026,9 +1049,17 @@ static int test_dmabuf(void) uint32_t handle, handle_import; int dma_buf_fd = -1; int ret; + const struct mmap_offset *mmo = NULL; fd1 = drm_open_driver(DRIVER_INTEL); + for_each_mmap_offset_type(fd1, t) + if (can_mmap[t->type]) { + igt_debug("using mmap-offset(%s)\n", t->name); + mmo = t; + break; + } + handle = create_userptr_bo(fd1, sizeof(linear)); memset(get_handle_ptr(handle), counter, sizeof(linear)); @@ -1045,17 +1076,17 @@ static int test_dmabuf(void) fd2 = drm_open_driver(DRIVER_INTEL); handle_import = prime_fd_to_handle(fd2, dma_buf_fd); - check_bo(fd1, handle, 1, fd2, handle_import); + check_bo(fd1, handle, 1, fd2, handle_import, mmo); /* close dma_buf, check whether nothing disappears. */ close(dma_buf_fd); - check_bo(fd1, handle, 1, fd2, handle_import); + check_bo(fd1, handle, 1, fd2, handle_import, mmo); /* destroy userptr object and expect SIGBUS */ free_userptr_bo(fd1, handle); close(fd1); - if (can_gtt_mmap) { + if (mmo) { struct sigaction sigact, orig_sigact; memset(&sigact, 0, sizeof(sigact)); @@ -1067,7 +1098,7 @@ static int test_dmabuf(void) orig_sigbus = orig_sigact.sa_sigaction; sigbus_cnt = 0; - check_bo(fd2, handle_import, -1, fd2, handle_import); + check_bo(fd2, handle_import, -1, fd2, handle_import, mmo); igt_assert(sigbus_cnt > 0); ret = sigaction(SIGBUS, &orig_sigact, NULL); @@ -2030,12 +2061,23 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL) int size = sizeof(linear); igt_fixture { + unsigned int mmo_max = 0; + fd = drm_open_driver(DRIVER_INTEL); igt_assert(fd >= 0); igt_require_gem(fd); gem_require_blitter(fd); - can_gtt_mmap = has_gtt_mmap(fd) && gem_has_llc(fd); + for_each_mmap_offset_type(fd, t) + if (t->type >= mmo_max) + mmo_max = t->type + 1; + igt_assert(mmo_max); + + can_mmap = calloc(mmo_max, sizeof(*can_mmap)); + igt_assert(can_mmap); + + for_each_mmap_offset_type(fd, t) + can_mmap[t->type] = has_mmap(fd, t) && gem_has_llc(fd); size = sizeof(linear); @@ -2193,16 +2235,22 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL) } igt_subtest("process-exit") - test_process_exit(fd, 0); + test_process_exit(fd, NULL, 0); - igt_subtest("process-exit-gtt") - test_process_exit(fd, PE_GTT_MAP); + igt_describe("Test process exit with userptr object mmapped via mmap-offset"); + igt_subtest_with_dynamic("process-exit-mmap") + for_each_mmap_offset_type(fd, t) + igt_dynamic(t->name) + test_process_exit(fd, t, 0); igt_subtest("process-exit-busy") - test_process_exit(fd, PE_BUSY); + test_process_exit(fd, NULL, PE_BUSY); - igt_subtest("process-exit-gtt-busy") - test_process_exit(fd, PE_GTT_MAP | PE_BUSY); + igt_describe("Test process exit with busy userptr object mmapped via mmap-offset"); + igt_subtest_with_dynamic("process-exit-mmap-busy") + for_each_mmap_offset_type(fd, t) + igt_dynamic(t->name) + test_process_exit(fd, t, PE_BUSY); igt_subtest("create-destroy-sync") test_create_destroy(fd, 5); @@ -2325,4 +2373,7 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL) igt_subtest("access-control") test_access_control(fd); + + igt_fixture + free(can_mmap); }