From patchwork Fri Mar 4 14:39:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 8504071 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6A0AA9F7CA for ; Fri, 4 Mar 2016 14:39:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90DD4201CD for ; Fri, 4 Mar 2016 14:39:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C8A7720172 for ; Fri, 4 Mar 2016 14:39:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F3FE6E327; Fri, 4 Mar 2016 14:39:11 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id D02BB6E327 for ; Fri, 4 Mar 2016 14:39:09 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 04 Mar 2016 06:39:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,536,1449561600"; d="scan'208";a="663837984" Received: from tursulin-linux.isw.intel.com ([10.102.226.196]) by FMSMGA003.fm.intel.com with ESMTP; 04 Mar 2016 06:39:08 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Fri, 4 Mar 2016 14:39:06 +0000 Message-Id: <1457102346-25721-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH i-g-t] gem_ppgtt: Fix flink-and-exit-vma-leak for engine->last_context 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, 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: Tvrtko Ursulin Now that engines keep references on the last executed contexts, to fix this test we need to execute an unrelated context last to ensure the one we are interested in is free to be cleaned up when we expect it to be. Signed-off-by: Tvrtko Ursulin --- tests/gem_ppgtt.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c index 78d5b48fae35..1a620ad8e46b 100644 --- a/tests/gem_ppgtt.c +++ b/tests/gem_ppgtt.c @@ -252,8 +252,8 @@ static void flink_and_close(void) static void flink_and_exit(void) { - uint32_t fd, fd2; - uint32_t bo, flinked_bo, name; + uint32_t fd, fd2, fd3; + uint32_t bo, bo2, flinked_bo, name; char match[100]; int to_match; bool matched; @@ -270,12 +270,19 @@ static void flink_and_exit(void) igt_assert(to_match < sizeof(match)); fd2 = drm_open_driver(DRIVER_INTEL); - flinked_bo = gem_open(fd2, name); + + fd3 = drm_open_driver(DRIVER_INTEL); + bo2 = gem_create(fd3, 4096); + + /* Verify VMA is not there yet. */ + matched = igt_debugfs_search("i915_gem_gtt", match); + igt_assert_eq(matched, false); + exec_and_get_offset(fd2, flinked_bo); gem_sync(fd2, flinked_bo); - /* Verify looking for string works OK. */ + /* Verify VMA has been created. */ matched = igt_debugfs_search("i915_gem_gtt", match); igt_assert_eq(matched, true); @@ -284,6 +291,11 @@ static void flink_and_exit(void) /* Close the context. */ close(fd2); + /* Execute a different and unrelated (wrt object sharing) context to + * ensure engine drops its last context reference. + */ + exec_and_get_offset(fd3, bo2); + retry: /* Give cleanup some time to run. */ usleep(100000); @@ -297,6 +309,9 @@ retry: igt_assert_eq(matched, false); + gem_close(fd3, bo2); + close(fd3); + gem_close(fd, bo); close(fd); }