From patchwork Mon Aug 6 12:43:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10557041 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 D7B9113B4 for ; Mon, 6 Aug 2018 12:43:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4E62290E0 for ; Mon, 6 Aug 2018 12:43:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B74D829199; Mon, 6 Aug 2018 12:43:45 +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 6F6B7290E0 for ; Mon, 6 Aug 2018 12:43:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5D8F6E2CB; Mon, 6 Aug 2018 12:43:44 +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 736816E2CB; Mon, 6 Aug 2018 12:43:43 +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 12652013-1500050 for multiple; Mon, 06 Aug 2018 13:43:37 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 6 Aug 2018 13:43:36 +0100 Message-Id: <20180806124336.32225-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] amdgpu: Exporting a dmabuf from amdgpu waits for outstanding fences 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 Since amdgpu is synchronous for exporting a dmabuf, exercise both paths to highlight the issue. References: https://bugs.freedesktop.org/show_bug.cgi?id=107341 Signed-off-by: Chris Wilson --- tests/amdgpu/amd_prime.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/amdgpu/amd_prime.c b/tests/amdgpu/amd_prime.c index 9bf298a41..7be7a04ac 100644 --- a/tests/amdgpu/amd_prime.c +++ b/tests/amdgpu/amd_prime.c @@ -286,7 +286,9 @@ static void i915_to_amd(int i915, int amd, amdgpu_device_handle device) gem_close(i915, obj[1].handle); } -static void amd_to_i915(int i915, int amd, amdgpu_device_handle device) +static void amd_to_i915(int i915, int amd, amdgpu_device_handle device, + unsigned int flags) +#define EXPORT_BEFORE 0x1 { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_exec_object2 obj[2]; @@ -300,7 +302,7 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device) struct amdgpu_cs_ib_info ib_info; uint32_t *ptr; amdgpu_context_handle *contexts; - int i, r, dmabuf; + int i, r, dmabuf = -1; amdgpu_bo_list_handle bo_list; amdgpu_va_handle va_handle; unsigned long count, size; @@ -320,6 +322,13 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device) &ib_result_mc_address, &va_handle); igt_assert_eq(r, 0); + if (flags & EXPORT_BEFORE) { + amdgpu_bo_export(ib_result_handle, + amdgpu_bo_handle_type_dma_buf_fd, + (uint32_t *)&dmabuf); + igt_assert(dmabuf != -1); + } + ptr = ib_result_cpu; for (i = 0; i < 16; ++i) ptr[i] = GFX_COMPUTE_NOP; @@ -365,9 +374,12 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device) igt_info("Reservation width = %ld\n", count); - amdgpu_bo_export(ib_result_handle, - amdgpu_bo_handle_type_dma_buf_fd, - (uint32_t *)&dmabuf); + if (dmabuf == -1) { + amdgpu_bo_export(ib_result_handle, + amdgpu_bo_handle_type_dma_buf_fd, + (uint32_t *)&dmabuf); + igt_assert(dmabuf != -1); + } igt_assert_eq(poll(&(struct pollfd){dmabuf, POLLOUT}, 1, 0), 0); obj[0].handle = prime_fd_to_handle(i915, dmabuf); obj[0].flags = EXEC_OBJECT_WRITE; @@ -418,7 +430,10 @@ igt_main } igt_subtest("amd-to-i915") - amd_to_i915(i915, amd, device); + amd_to_i915(i915, amd, device, EXPORT_BEFORE); + + igt_subtest("inflight-amd-to-i915") + amd_to_i915(i915, amd, device, 0); igt_fixture { amdgpu_device_deinitialize(device);