From patchwork Wed Feb 19 16:13:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11391735 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 B0ED5109A for ; Wed, 19 Feb 2020 16:14:25 +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 99B4F2464E for ; Wed, 19 Feb 2020 16:14:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99B4F2464E 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 2B9C76EC40; Wed, 19 Feb 2020 16:14:25 +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 5C7786EC3D; Wed, 19 Feb 2020 16:14:24 +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; 19 Feb 2020 08:14:23 -0800 X-IronPort-AV: E=Sophos;i="5.70,461,1574150400"; d="scan'208";a="229155041" 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; 19 Feb 2020 08:14:21 -0800 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Wed, 19 Feb 2020 17:13:58 +0100 Message-Id: <20200219161358.4726-1-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] tests/gem_userptr_blits: Refresh map-fixed-invalidate* 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: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" map-fixed-invalidate* subtests utilize gem_set_tiling() which may fail, e.g. on hardware with no mappable aperture, due to missing fences. Skip those subtests if fences are not available. Moreover, those subtests use GEM_MMAP_GTT IOCTL which has been replaced by GEM_MMAP_OFFSET that supports other mapping types, not only GTT. Use the new IOCTL and dynamically examine all MMAP_OFFSET types supported by hardware. v2: Examine all supported MMAP_OFFSET types, not only the first one that works, - add subtest description. Signed-off-by: Janusz Krzysztofik Cc: Michał Winiarski --- As advised by Michał, we believe that running those subtests on platforms which do support tiling while skipping them on those which don't is sufficient for detecting potential lockdep loops in scenarios covered by those subtests. tests/i915/gem_userptr_blits.c | 43 +++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c index a8d3783fb..fdfb5853c 100644 --- a/tests/i915/gem_userptr_blits.c +++ b/tests/i915/gem_userptr_blits.c @@ -722,7 +722,8 @@ static void test_forked_access(int fd) MAP_FIXED_INVALIDATE_BUSY | \ MAP_FIXED_INVALIDATE_GET_PAGES) -static int test_map_fixed_invalidate(int fd, uint32_t flags) +static int test_map_fixed_invalidate(int fd, uint32_t flags, + const struct mmap_offset *t) { const size_t ptr_size = sizeof(linear) + 2*PAGE_SIZE; const int num_handles = (flags & MAP_FIXED_INVALIDATE_OVERLAP) ? 2 : 1; @@ -741,7 +742,7 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags) for (char *fixed = (char *)ptr, *end = fixed + ptr_size; fixed + 2*PAGE_SIZE <= end; fixed += PAGE_SIZE) { - struct drm_i915_gem_mmap_gtt mmap_gtt; + struct drm_i915_gem_mmap_offset mmap_offset; uint32_t *map; map = mmap(ptr, ptr_size, PROT_READ | PROT_WRITE, @@ -750,9 +751,13 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags) igt_assert(map != MAP_FAILED); igt_assert(map == ptr); - memset(&mmap_gtt, 0, sizeof(mmap_gtt)); - mmap_gtt.handle = gem_create(fd, 2*PAGE_SIZE); - do_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_gtt); + memset(&mmap_offset, 0, sizeof(mmap_offset)); + mmap_offset.handle = gem_create(fd, 2 * PAGE_SIZE); + mmap_offset.flags = t->type; + igt_skip_on_f(igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &mmap_offset), + "HW & kernel support for mmap_offset(%s)\n", + t->name); if (flags & MAP_FIXED_INVALIDATE_GET_PAGES) igt_assert_eq(__gem_set_domain(fd, handle[0], @@ -766,11 +771,11 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags) map = mmap(fixed, 2*PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - fd, mmap_gtt.offset); + fd, mmap_offset.offset); igt_assert(map != MAP_FAILED); igt_assert(map == (uint32_t *)fixed); - gem_set_tiling(fd, mmap_gtt.handle, I915_TILING_NONE, 0); + gem_set_tiling(fd, mmap_offset.handle, I915_TILING_NONE, 0); *map = 0xdead; if (flags & MAP_FIXED_INVALIDATE_GET_PAGES) { @@ -784,10 +789,10 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags) handle[0] = create_userptr(fd, 0, ptr + PAGE_SIZE/sizeof(*ptr)); } - gem_set_tiling(fd, mmap_gtt.handle, I915_TILING_Y, 512 * 4); + gem_set_tiling(fd, mmap_offset.handle, I915_TILING_Y, 512 * 4); *(uint32_t*)map = 0xbeef; - gem_close(fd, mmap_gtt.handle); + gem_close(fd, mmap_offset.handle); } for (int i = 0; i < num_handles; i++) @@ -2166,11 +2171,21 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL) test_invalidate_close_race(fd, true); for (unsigned flags = 0; flags < ALL_MAP_FIXED_INVALIDATE + 1; flags++) { - igt_subtest_f("map-fixed-invalidate%s%s%s", - flags & MAP_FIXED_INVALIDATE_OVERLAP ? "-overlap" : "", - flags & MAP_FIXED_INVALIDATE_BUSY ? "-busy" : "", - flags & MAP_FIXED_INVALIDATE_GET_PAGES ? "-gup" : "") { - test_map_fixed_invalidate(fd, flags); + igt_describe("Try to anger lockdep with MMU notifier still active after MAP_FIXED remap"); + igt_subtest_with_dynamic_f("map-fixed-invalidate%s%s%s", + flags & MAP_FIXED_INVALIDATE_OVERLAP ? + "-overlap" : "", + flags & MAP_FIXED_INVALIDATE_BUSY ? + "-busy" : "", + flags & MAP_FIXED_INVALIDATE_GET_PAGES ? + "-gup" : "") { + igt_require_f(gem_available_fences(fd), + "HW & kernel support for tiling\n"); + + for_each_mmap_offset_type(t) + igt_dynamic_f("%s", t->name) + test_map_fixed_invalidate(fd, + flags, t); } }