From patchwork Tue Aug 7 15:44:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10558837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B8D514E5 for ; Tue, 7 Aug 2018 15:44:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FCDA28E6C for ; Tue, 7 Aug 2018 15:44:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D7E029492; Tue, 7 Aug 2018 15:44:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EEC428FAE for ; Tue, 7 Aug 2018 15:44:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A66E56E1A3; Tue, 7 Aug 2018 15:44:34 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9979E6E186; Tue, 7 Aug 2018 15:44:32 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12685120-1500050 for multiple; Tue, 07 Aug 2018 16:44:15 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 7 Aug 2018 16:44:14 +0100 Message-Id: <20180807154414.25773-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/prime_vgem: Ask the shrinker to purge a vgem bo from inside i915 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Link a vgem dmabuf into an i915 bo and then ask the i915 shrinker to purge/invalidate its pages. This should establish the lockdep link from the fs_reclaim shrinker section to whatever locks are used to acquire/release dmabuf mappings; if any are required ofc. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Cc: Daniel Vetter Reviewed-by: Tvrtko Ursulin --- tests/prime_vgem.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c index d886044a4..3b3dcc910 100644 --- a/tests/prime_vgem.c +++ b/tests/prime_vgem.c @@ -237,6 +237,32 @@ static void test_gtt(int vgem, int i915) gem_close(vgem, scratch.handle); } +static void test_shrink(int vgem, int i915) +{ + struct vgem_bo scratch = { + .width = 1024, + .height = 1024, + .bpp = 32 + }; + int dmabuf; + + vgem_create(vgem, &scratch); + + dmabuf = prime_handle_to_fd(vgem, scratch.handle); + gem_close(vgem, scratch.handle); + + scratch.handle = prime_fd_to_handle(i915, dmabuf); + close(dmabuf); + + /* Populate the i915_bo->pages. */ + gem_set_domain(i915, scratch.handle, I915_GEM_DOMAIN_GTT, 0); + + /* Now evict them, establising the link from i915:shrinker to vgem. */ + igt_drop_caches_set(i915, DROP_SHRINK_ALL); + + gem_close(i915, scratch.handle); +} + static bool is_coherent(int i915) { int val = 1; /* by default, we assume GTT is coherent, hence the test */ @@ -794,6 +820,9 @@ igt_main igt_subtest("basic-gtt") test_gtt(vgem, i915); + igt_subtest("shrink") + test_shrink(vgem, i915); + igt_subtest("coherency-gtt") test_gtt_interleaved(vgem, i915);