From patchwork Wed Nov 6 18:12:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rafael.barbalho@intel.com X-Patchwork-Id: 3148661 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5DC83BEEB2 for ; Wed, 6 Nov 2013 18:14:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B11E72050B for ; Wed, 6 Nov 2013 18:14:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2C04820503 for ; Wed, 6 Nov 2013 18:13:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CEA7F0743 for ; Wed, 6 Nov 2013 10:13:58 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 505AD1023CB for ; Wed, 6 Nov 2013 10:12:33 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 06 Nov 2013 10:12:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,647,1378882800"; d="scan'208";a="428946900" Received: from rbarbalh-linux.isw.intel.com ([10.102.226.47]) by fmsmga002.fm.intel.com with ESMTP; 06 Nov 2013 10:12:31 -0800 From: rafael.barbalho@intel.com To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Nov 2013 18:12:12 +0000 Message-Id: <1383761532-30805-1-git-send-email-rafael.barbalho@intel.com> X-Mailer: git-send-email 1.8.4 Subject: [Intel-gfx] [PATCH] tests/gem_reloc_overflow: Add gen8+ specifc tests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael Barbalho Broadwell introduces 64-bit relocation addresses which add extra corner cases. The test was refactored slightly with some tests that were in the source offset tests were moved to the more generic reloc test area. The source offset tests are now gen aware and called twice to test both cpu & gtt relocation paths. In addition 2 new gen8+ test were added to the test: * Relocation straddling page a page * Insufficient space for a relocation at the end of the buffer. Signed-off-by: Rafael Barbalho Conflicts: tests/gem_reloc_overflow.c --- tests/gem_reloc_overflow.c | 148 +++++++++++++++++++++++++++++++-------------- 1 file changed, 103 insertions(+), 45 deletions(-) diff --git a/tests/gem_reloc_overflow.c b/tests/gem_reloc_overflow.c index f7ba1d7..38ad2a5 100644 --- a/tests/gem_reloc_overflow.c +++ b/tests/gem_reloc_overflow.c @@ -24,6 +24,7 @@ * Authors: * Kees Cook * Daniel Vetter + * Rafael Barbalho * */ @@ -60,13 +61,14 @@ struct drm_i915_gem_relocation_entry *reloc; uint32_t handle; uint32_t batch_handle; - -static void source_offset_tests(void) +static void source_offset_tests(int devid, bool reloc_gtt) { struct drm_i915_gem_relocation_entry single_reloc; + char *dst_gtt; + char *relocation_type; igt_fixture { - handle = gem_create(fd, 4096); + handle = gem_create(fd, 8192); execobjs[1].handle = batch_handle; execobjs[1].relocation_count = 0; @@ -76,21 +78,70 @@ static void source_offset_tests(void) execobjs[0].relocation_count = 1; execobjs[0].relocs_ptr = (uintptr_t) &single_reloc; execbuf.buffer_count = 2; + + if (reloc_gtt) { + dst_gtt = gem_mmap(fd, handle, 8192, PROT_READ | PROT_WRITE); + igt_assert(dst_gtt != MAP_FAILED); + gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + memset(dst_gtt, 0, 8192); + munmap(dst_gtt, 8192); + relocation_type = "reloc-gtt"; + } else { + relocation_type = "reloc-cpu"; + } } - igt_subtest("source-offset-end") { - single_reloc.offset = 4096 - 4; - single_reloc.delta = 0; - single_reloc.target_handle = handle; - single_reloc.read_domains = I915_GEM_DOMAIN_RENDER; - single_reloc.write_domain = I915_GEM_DOMAIN_RENDER; - single_reloc.presumed_offset = 0; + if (intel_gen(devid) >= 8) { + igt_subtest_f("source-offset-page-stradle-gen8+-%s", relocation_type) { + single_reloc.offset = 4096 - 4; + single_reloc.delta = 0; + single_reloc.target_handle = handle; + single_reloc.read_domains = I915_GEM_DOMAIN_RENDER; + single_reloc.write_domain = I915_GEM_DOMAIN_RENDER; + single_reloc.presumed_offset = 0; + + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0); + single_reloc.delta = 1024; + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0); + } - igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0); + igt_subtest_f("source-offset-end-gen8+-%s", relocation_type) { + single_reloc.offset = 8192 - 8; + single_reloc.delta = 0; + single_reloc.target_handle = handle; + single_reloc.read_domains = I915_GEM_DOMAIN_RENDER; + single_reloc.write_domain = I915_GEM_DOMAIN_RENDER; + single_reloc.presumed_offset = 0; + + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0); + } + + igt_subtest_f("source-offset-overflow-gen8+-%s", relocation_type) { + single_reloc.offset = 8192 - 4; + single_reloc.delta = 0; + single_reloc.target_handle = handle; + single_reloc.read_domains = I915_GEM_DOMAIN_RENDER; + single_reloc.write_domain = I915_GEM_DOMAIN_RENDER; + single_reloc.presumed_offset = 0; + + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) != 0); + igt_assert(errno == EINVAL); + } + } else { + igt_subtest_f("source-offset-end-%s", relocation_type) { + single_reloc.offset = 8192 - 4; + single_reloc.delta = 0; + single_reloc.target_handle = handle; + single_reloc.read_domains = I915_GEM_DOMAIN_RENDER; + single_reloc.write_domain = I915_GEM_DOMAIN_RENDER; + single_reloc.presumed_offset = 0; + + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0); + } } - igt_subtest("source-offset-big") { - single_reloc.offset = 4096; + igt_subtest_f("source-offset-big-%s", relocation_type) { + single_reloc.offset = 8192; single_reloc.delta = 0; single_reloc.target_handle = handle; single_reloc.read_domains = I915_GEM_DOMAIN_RENDER; @@ -101,7 +152,7 @@ static void source_offset_tests(void) igt_assert(errno == EINVAL); } - igt_subtest("source-offset-negative") { + igt_subtest_f("source-offset-negative-%s", relocation_type) { single_reloc.offset = (int64_t) -4; single_reloc.delta = 0; single_reloc.target_handle = handle; @@ -113,7 +164,7 @@ static void source_offset_tests(void) igt_assert(errno == EINVAL); } - igt_subtest("source-offset-unaligned") { + igt_subtest_f("source-offset-unaligned-%s", relocation_type) { single_reloc.offset = 1; single_reloc.delta = 0; single_reloc.target_handle = handle; @@ -126,34 +177,6 @@ static void source_offset_tests(void) } igt_fixture { - execobjs[0].handle = batch_handle; - execobjs[0].relocation_count = 0; - execobjs[0].relocs_ptr = 0; - - execbuf.buffer_count = 1; - } - - igt_subtest("batch-start-unaligend") { - execbuf.batch_start_offset = 1; - execbuf.batch_len = 8; - - igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) != 0); - igt_assert(errno == EINVAL); - } - - igt_subtest("batch-end-unaligend") { - execbuf.batch_start_offset = 0; - execbuf.batch_len = 7; - - igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) != 0); - igt_assert(errno == EINVAL); - } - - igt_fixture { - /* Undo damage for next tests. */ - execbuf.batch_start_offset = 0; - execbuf.batch_len = 8; - gem_close(fd, handle); } } @@ -185,6 +208,36 @@ static void reloc_tests(void) igt_assert(errno == EINVAL); } + igt_fixture { + execobjs[0].handle = batch_handle; + execobjs[0].relocation_count = 0; + execobjs[0].relocs_ptr = 0; + + execbuf.buffer_count = 1; + } + + igt_subtest("batch-start-unaligned") { + execbuf.batch_start_offset = 1; + execbuf.batch_len = 8; + + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) != 0); + igt_assert(errno == EINVAL); + } + + igt_subtest("batch-end-unaligned") { + execbuf.batch_start_offset = 0; + execbuf.batch_len = 7; + + igt_assert(ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) != 0); + igt_assert(errno == EINVAL); + } + + igt_fixture { + /* Undo damage for next tests. */ + execbuf.batch_start_offset = 0; + execbuf.batch_len = 8; + } + igt_subtest("wrapped-overflow") { /* Attempt wrapped overflow entries. */ for (i = 0; i < num; i++) { @@ -252,12 +305,16 @@ static void buffer_count_tests(void) igt_main { + int devid = 0; + igt_fixture { int ring; uint32_t batch_data [2] = { MI_NOOP, MI_BATCH_BUFFER_END }; fd = drm_open_any(); + devid = intel_get_drm_devid(fd); + /* Create giant reloc buffer area. */ num = 257; entries = ((1ULL << 32) / (num - 1)); @@ -271,7 +328,7 @@ igt_main for (int i = 0; i < num; i++) handles[i] = gem_create(fd, 4096); - if (intel_gen(intel_get_drm_devid(fd)) >= 6) + if (intel_gen(devid) >= 6) ring = I915_EXEC_BLT; else ring = 0; @@ -296,7 +353,8 @@ igt_main reloc_tests(); - source_offset_tests(); + source_offset_tests(devid, false); + source_offset_tests(devid, true); buffer_count_tests();