From patchwork Tue Aug 7 15:57:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10558845 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 2F66A13AC for ; Tue, 7 Aug 2018 15:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D5D92A4CF for ; Tue, 7 Aug 2018 15:58:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10DEB2A4DD; Tue, 7 Aug 2018 15:58:07 +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 AE34C2A4CF for ; Tue, 7 Aug 2018 15:58:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE45789CD5; Tue, 7 Aug 2018 15:58:05 +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 394DA6E186; Tue, 7 Aug 2018 15:58:04 +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 12685445-1500050 for multiple; Tue, 07 Aug 2018 16:57:52 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 7 Aug 2018 16:57:51 +0100 Message-Id: <20180807155751.30698-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/amd_prime: Link an amdgpu bo into i915 and try to shrink it 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 Create and export an amdgpu bo into i915 so that we can try and invalidate the i915_bo->pages from inside the shrinker, teaching lockdep about that linkage. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Cc: Daniel Vetter Acked-by: Tvrtko Ursulin --- tests/amdgpu/amd_prime.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/amdgpu/amd_prime.c b/tests/amdgpu/amd_prime.c index 9bf298a41..bda0ce83d 100644 --- a/tests/amdgpu/amd_prime.c +++ b/tests/amdgpu/amd_prime.c @@ -392,6 +392,35 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device) ib_result_mc_address, 4096); } +static void shrink(int i915, int amd, amdgpu_device_handle device) +{ + struct amdgpu_bo_alloc_request request = { + .alloc_size = 1024 * 1024 * 4, + .phys_alignment = 4096, + .preferred_heap = AMDGPU_GEM_DOMAIN_GTT, + }; + amdgpu_bo_handle bo; + uint32_t handle; + int dmabuf; + + igt_assert_eq(amdgpu_bo_alloc(device, &request, &bo), 0); + amdgpu_bo_export(bo, + amdgpu_bo_handle_type_dma_buf_fd, + (uint32_t *)&dmabuf); + amdgpu_bo_free(bo); + + handle = prime_fd_to_handle(i915, dmabuf); + close(dmabuf); + + /* Populate the i915_bo->pages. */ + gem_set_domain(i915, handle, I915_GEM_DOMAIN_GTT, 0); + + /* Now evict them, establishing the link from i915:shrinker to amd. */ + igt_drop_caches_set(i915, DROP_SHRINK_ALL); + + gem_close(i915, handle); +} + igt_main { amdgpu_device_handle device; @@ -420,6 +449,9 @@ igt_main igt_subtest("amd-to-i915") amd_to_i915(i915, amd, device); + igt_subtest("shrink") + shrink(i915, amd, device); + igt_fixture { amdgpu_device_deinitialize(device); close(amd);