From patchwork Fri Oct 28 18:37:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Lothian X-Patchwork-Id: 9402565 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 C8D41605EE for ; Fri, 28 Oct 2016 18:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A844F2A8A8 for ; Fri, 28 Oct 2016 18:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B19A2A8D6; Fri, 28 Oct 2016 18:37:43 +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_SIGNED, HTML_MESSAGE, 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 B13F22A8A8 for ; Fri, 28 Oct 2016 18:37:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5C386EBDC; Fri, 28 Oct 2016 18:37:41 +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 7575B6EBB0 for ; Fri, 28 Oct 2016 18:37:39 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id m83so8562609wmc.0 for ; Fri, 28 Oct 2016 11:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fireburn-co-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KH8GI9BJ9ZbH52rndQxkiOH05pYUw18zeEMtf8uOhK0=; b=Ht1dAJx/pSXB5C2Bb1ueHLzNfT7FS6rFOfEHpNt0zf9RvBXDtxb+qnmE8Y8Nwi/zUJ Jl2l2a/7I2ED99gVg2ScBQ+hNF5ZElm9x/D3te19khxqDZ4Pml8yrfHaW+eN+B20gWKa xnmYfYfJQw7+qLyXtVL7PRqj9lN2srvLwbG8exlLy3cwx8ghWhY7cuoyqh65V7WkCEub WckJmnHrCRG9RRlQCLlZ3TP+gz/Wb9BhDgDiJQUiL+o8gZSPO6p74JnkOdo8aiL15rUg XL9BUsgN0+B+EPMkUmEkSZj6PA1zADxAtDUV15/rN0c3o37JSANxoP+mRDnJEZvkiLT/ RMlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KH8GI9BJ9ZbH52rndQxkiOH05pYUw18zeEMtf8uOhK0=; b=IlMjo3ZHWSWHnBilipOf4tqlbkDh9ToNJInjK18b2AX1l0T+IsEV0fzfVRUC7d86CH 9V3vv0qA3pO9P86X5A0cDnEFykoPGmrldIqdtq5LAmDXXw2Jsn/2WeoNAtLSfQZkG+86 0QSUnAvlWDuQFpyQ8eEy1eun6cGBZ0CKlHIAQDuU9zgN1CG61h33q3HxlMPDyP158dvI 9JoSEeXq2t+lwSPWUksl0kyFE1J0B6WxyaBWnqFikx0Eg1CH9Bh2Xje6kPj1K80fKhy4 kRjcD4Xkip5YV2vfJAIgrz5nGlMWhfdgcIdOjQKkKxWGDY4YbgoHGXvmvfmC/utB0Gdx xXog== X-Gm-Message-State: ABUngvfw+Z1aaZynUgDlfpOkM697lEvq4eReg4/H96muY9CfPpW2d2Oc7OYQa1l8gDjOtVgTjMcwmnWPCmWUAA== X-Received: by 10.28.215.6 with SMTP id o6mr85906wmg.124.1477679857982; Fri, 28 Oct 2016 11:37:37 -0700 (PDT) MIME-Version: 1.0 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> <7eb19a73-a558-d2e6-bd8d-34fe95045dfd@gmail.com> In-Reply-To: <7eb19a73-a558-d2e6-bd8d-34fe95045dfd@gmail.com> From: Mike Lothian Date: Fri, 28 Oct 2016 18:37:26 +0000 Message-ID: Subject: Re: [PATCH] drm/i915: Before pageflip, also wait for shared dmabuf fences. To: Mario Kleiner , =?UTF-8?Q?Michel_D=C3=A4nzer?= , =?UTF-8?Q?Christian_K=C3=B6nig?= , Daniel Vetter 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 Hi Mario That fixes the tearing, it's been replaced with a strange stutter, like it's only showing half the number of frames being reported - it's really noticeable in tomb raider Thanks for your work on this, the stutter is much more manageable than the tearing was I've attached the patch that applies cleanly to 4.10-wip On Fri, 28 Oct 2016 at 18:37 Mario Kleiner wrote: > > > 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 > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 217df24..6757b99 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -391,6 +391,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 cd62f6f..54099a5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -504,6 +504,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); }