From patchwork Wed May 6 12:31:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonas Lahtinen X-Patchwork-Id: 6349271 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B04FCBEEE1 for ; Wed, 6 May 2015 12:31:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E296A202DD for ; Wed, 6 May 2015 12:31:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E955320122 for ; Wed, 6 May 2015 12:31:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDD856E668; Wed, 6 May 2015 05:31:14 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F0C76E668 for ; Wed, 6 May 2015 05:31:13 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 06 May 2015 05:31:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,379,1427785200"; d="scan'208";a="490059889" Received: from unknown (HELO [10.252.11.83]) ([10.252.11.83]) by FMSMGA003.fm.intel.com with ESMTP; 06 May 2015 05:31:11 -0700 Message-ID: <1430915470.6667.0.camel@jlahtine-mobl1> From: Joonas Lahtinen To: intel-gfx Date: Wed, 06 May 2015 15:31:10 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Cc: Thomas Wood Subject: [Intel-gfx] [PATCH i-g-t] tests/gem_mmap_gtt(huge_bo): Use pread more to verify domain transfer. 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Use pread right after moving out of CPU domain to verify all writes flushed correctly. Due to extended usage, add own buffer. Signed-off-by: Joonas Lahtinen --- tests/gem_mmap_gtt.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c index 92fa644..e53ab13 100644 --- a/tests/gem_mmap_gtt.c +++ b/tests/gem_mmap_gtt.c @@ -291,6 +291,7 @@ test_huge_bo(int fd) char *ptr_gtt; char *cpu_pattern; char *gtt_pattern; + char *pread_buffer; uint64_t mappable_aperture_pages = gem_mappable_aperture_size() / PAGE_SIZE; uint64_t huge_object_size = (mappable_aperture_pages + 1) * PAGE_SIZE; @@ -298,7 +299,8 @@ test_huge_bo(int fd) cpu_pattern = malloc(PAGE_SIZE); gtt_pattern = malloc(PAGE_SIZE); - igt_assert(cpu_pattern && gtt_pattern); + pread_buffer = malloc(PAGE_SIZE); + igt_assert(cpu_pattern && gtt_pattern && pread_buffer); memset(cpu_pattern, 0xaa, PAGE_SIZE); memset(gtt_pattern, ~0xaa, PAGE_SIZE); @@ -334,6 +336,17 @@ test_huge_bo(int fd) set_domain_gtt(fd, bo); + /* Verify the page contents via pread after domain transfer. + * This is to make sure the transfer actually flushed everything. + */ + memset(pread_buffer, 0, PAGE_SIZE); + pread_bo(fd, bo, pread_buffer, 0, PAGE_SIZE); + igt_assert(memcmp(pread_buffer, cpu_pattern, PAGE_SIZE) == 0); + + memset(pread_buffer, 0, PAGE_SIZE); + pread_bo(fd, bo, pread_buffer, last_offset, PAGE_SIZE); + igt_assert(memcmp(pread_buffer, cpu_pattern, PAGE_SIZE) == 0); + /* Access through GTT should still provide the CPU written values. */ igt_assert(memcmp(ptr_gtt , cpu_pattern, PAGE_SIZE) == 0); igt_assert(memcmp(ptr_gtt + last_offset, cpu_pattern, PAGE_SIZE) == 0); @@ -356,17 +369,18 @@ test_huge_bo(int fd) /* Verify the page contents after GTT writes by reading without mapping. * Mapping to CPU domain is avoided not to cause a huge flush. */ - pread_bo(fd, bo, cpu_pattern, 0, PAGE_SIZE); - igt_assert(memcmp(cpu_pattern, gtt_pattern, PAGE_SIZE) == 0); - - memset(cpu_pattern, 0x00, PAGE_SIZE); + memset(pread_buffer, 0x00, PAGE_SIZE); + pread_bo(fd, bo, pread_buffer, 0, PAGE_SIZE); + igt_assert(memcmp(pread_buffer, gtt_pattern, PAGE_SIZE) == 0); - pread_bo(fd, bo, cpu_pattern, last_offset, PAGE_SIZE); - igt_assert(memcmp(cpu_pattern, gtt_pattern, PAGE_SIZE) == 0); + memset(pread_buffer, 0x00, PAGE_SIZE); + pread_bo(fd, bo, pread_buffer, last_offset, PAGE_SIZE); + igt_assert(memcmp(pread_buffer, gtt_pattern, PAGE_SIZE) == 0); gem_close(fd, bo); free(cpu_pattern); free(gtt_pattern); + free(pread_buffer); } static void