From patchwork Fri Oct 28 17:37:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 9402495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F7F560588 for ; Fri, 28 Oct 2016 17:37:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 031842A7C8 for ; Fri, 28 Oct 2016 17:37:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E91602A8B8; Fri, 28 Oct 2016 17:37:35 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 44D8F2A7C8 for ; Fri, 28 Oct 2016 17:37:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C7366EBE7; Fri, 28 Oct 2016 17:37:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id D53C26EBE7; Fri, 28 Oct 2016 17:37:32 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id 68so1579366wmz.2; Fri, 28 Oct 2016 10:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=/Rz1+5+MwIosACMm5zLAGksT77gRbdaC86S/jQF2UoA=; b=B9GJXdtTfQMmgvAz/cSrpsf+xdBvCsIh1a+KSaR+Xp1COwgDS5Mtw5nUiJ1EIQqV3W cYUltr0yoWxIcM5ICkfhfElibJrFKyrk8ik5Ot2t7ze5dgi7r+JrsgEB1UOdCCp2rki7 0J7i5/yphZpQFK1mNU418LzjTAbe4t0X1afyAS/nqu/nbVtWtq/KKSY+jXfO3/3Xp+Qp jpalPNPdcdgFd1o+ZjlSmTPpa9dqZ/ZFpwf/wTMQbzkabpgxS4qNujO7dpHxEfXCrYOH Uble0pAZeiJLE+z5jwOJg6Dka+wsRsSOaQOZNr2R8RmcOtXklOwaPRq3QQ6lqcN/kyXO QbcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=/Rz1+5+MwIosACMm5zLAGksT77gRbdaC86S/jQF2UoA=; b=jTY3pE50t2uPrv74PgT+6zF449bBDaSlUTS7qxl8lQfUuFcJc/JrqOgcXxLbSxC54z e7v5CEPgxg4QsQm4dqV52OCERQHEkFslRLuAd14OFt3kZNzmjEUVba2N8Hmgurl/QhAQ UU622kDJtd929ILEpP4HiqJuenck7sCbud/LMNi3L+9IE5s9MhldJOyJPw5qknS0Ebaj QR2gzOWgkKK7zwrRb0VH44vGOqkBdCNY6loKGBniBTSIda2zR2cGJIGRU60ch95G5xiU pNuZ4xx6b6anukLAXUr99mzwy36XxqwPmEfrtGpZPjeDCnqZYPfEFvAc/DljTtYX4fmJ 4srg== X-Gm-Message-State: ABUngvcaEauYrx4KHdGBq3DOKEMi5WDvEQvmAyIMWlk9IOdgdOjY81TTjRdGNa5cPeRYZQ== X-Received: by 10.194.55.65 with SMTP id q1mr12296802wjp.45.1477676251391; Fri, 28 Oct 2016 10:37:31 -0700 (PDT) Received: from [192.168.178.26] (x5f703c2a.dyn.telefonica.de. [95.112.60.42]) by smtp.gmail.com with ESMTPSA id ux6sm15158002wjb.18.2016.10.28.10.37.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 10:37:30 -0700 (PDT) Subject: Re: [PATCH] drm/i915: Before pageflip, also wait for shared dmabuf fences. To: =?UTF-8?Q?Michel_D=c3=a4nzer?= , Mike Lothian , =?UTF-8?Q?Christian_K=c3=b6nig?= , Daniel Vetter References: <3f4643cb-52a9-d7ae-439b-5f6fc6e718cc@vodafone.de> <20160922063625.GD22164@dvetter-linux.ger.corp.intel.com> <20160923120954.GH22164@dvetter-linux.ger.corp.intel.com> <8c21f70a-7f96-480e-9784-93f2d48f52bb@daenzer.net> <20160926080419.GV20761@phenom.ffwll.local> <720351a2-7597-aee3-58ce-9d65cad5762f@daenzer.net> From: Mario Kleiner Message-ID: <7eb19a73-a558-d2e6-bd8d-34fe95045dfd@gmail.com> Date: Fri, 28 Oct 2016 19:37:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <720351a2-7597-aee3-58ce-9d65cad5762f@daenzer.net> Cc: Nayan Deshmukh , amd-gfx list , dri-devel X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 10/28/2016 03:34 AM, Michel Dänzer wrote: > On 27/10/16 10:33 PM, Mike Lothian wrote: >> >> Just another gentle ping to see where you are with this? > > I haven't got a chance to look into this any further. > > Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime. ftrace confirms the i915 driver's pageflip function is waiting on the fence in reservation_object_wait_timeout_rcu() as it should. That entry->tv.shared needs to be set false for such buffers in amdgpu_bo_list_set() makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far. I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients? All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems. -mario From 2a8d7fcd36da30305fa675df311c697162792597 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Wed, 26 Oct 2016 10:58:00 +0200 Subject: [PATCH] drm/amdgpu: Attach exclusive fence to prime exported bo's. External clients which import our bo's wait only for exclusive dmabuf-fences, not on shared ones, so attach fences on such exported buffers as exclusive ones, not shared ones. -> Backup commit. Work in progress. Signed-off-by: Mario Kleiner --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 039b57e..a337d56 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -459,6 +459,7 @@ struct amdgpu_bo { u64 metadata_flags; void *metadata; u32 metadata_size; + bool prime_exported; /* list of all virtual address to which this bo * is associated to */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index 651115d..6e1d7b3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -132,7 +132,10 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev, entry->priority = min(info[i].bo_priority, AMDGPU_BO_LIST_MAX_PRIORITY); entry->tv.bo = &entry->robj->tbo; - entry->tv.shared = true; + entry->tv.shared = !entry->robj->prime_exported; + + if (entry->robj->prime_exported) + DRM_DEBUG_PRIME("Exclusive fence for exported prime bo %p\n", entry->robj); if (entry->robj->prefered_domains == AMDGPU_GEM_DOMAIN_GDS) gds_obj = entry->robj; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index a7ea9a3..730a68e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -494,6 +494,12 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, tv.bo = &bo_va->bo->tbo; tv.shared = true; + + if (bo_va->bo->prime_exported) { + DRM_DEBUG_PRIME("Update for exported prime bo %p\n", bo_va->bo); + /* tv.shared = false; */ + } + list_add(&tv.head, &list); amdgpu_vm_get_pd_bo(bo_va->vm, &list, &vm_pd); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c index 7700dc2..bfbfeb9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c @@ -121,5 +121,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm)) return ERR_PTR(-EPERM); + bo->prime_exported = true; + DRM_DEBUG_PRIME("Exporting prime bo %p\n", bo); + return drm_gem_prime_export(dev, gobj, flags); } -- 2.7.4