From patchwork Fri Aug 23 15:03:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11111981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D9F01398 for ; Fri, 23 Aug 2019 15:03:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05B5D20870 for ; Fri, 23 Aug 2019 15:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05B5D20870 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D92C6ECBD; Fri, 23 Aug 2019 15:03:19 +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 12EDE6ECBC for ; Fri, 23 Aug 2019 15:03:17 +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 18241843-1500050 for multiple; Fri, 23 Aug 2019 16:03:06 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 23 Aug 2019 16:03:02 +0100 Message-Id: <20190823150302.5719-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Flush the existing fence before GGTT read/write 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: Matthew Auld Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Our fence management is lazy, very lazy. If the user marks an object as untiled, we do not immediately flush the fence but merely mark it as dirty. On the use we have to remember to check and remove the fence, by which time we hope it is idle and we do not have to wait. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111468 Fixes: 1f7fd484fff1 ("drm/i915: Replace i915_vma_put_fence()") Signed-off-by: Chris Wilson Cc: Matthew Auld Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index eb31b69a316a..41b28f6d8620 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -324,6 +324,26 @@ gtt_user_read(struct io_mapping *mapping, return unwritten; } +static int linear_ggtt_offset(struct i915_vma *vma, u64 *offset) +{ + int ret; + + GEM_BUG_ON(!i915_vma_is_map_and_fenceable(vma)); + + /* Open-coded i915_vma_pin_iomap() */ + + if (vma->fence) { + mutex_lock(&vma->vm->mutex); + ret = i915_vma_revoke_fence(vma); + mutex_unlock(&vma->vm->mutex); + if (ret) + return ret; + } + + *offset = i915_ggtt_offset(vma); + return 0; +} + static int i915_gem_gtt_pread(struct drm_i915_gem_object *obj, const struct drm_i915_gem_pread *args) @@ -350,7 +370,10 @@ i915_gem_gtt_pread(struct drm_i915_gem_object *obj, PIN_NONBLOCK /* NOWARN */ | PIN_NOEVICT); if (!IS_ERR(vma)) { - node.start = i915_ggtt_offset(vma); + ret = linear_ggtt_offset(vma, &node.start); + if (ret) + goto out_unpin; + node.allocated = false; } else { ret = insert_mappable_node(ggtt, &node, PAGE_SIZE); @@ -560,7 +583,10 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_gem_object *obj, PIN_NONBLOCK /* NOWARN */ | PIN_NOEVICT); if (!IS_ERR(vma)) { - node.start = i915_ggtt_offset(vma); + ret = linear_ggtt_offset(vma, &node.start); + if (ret) + goto out_unpin; + node.allocated = false; } else { ret = insert_mappable_node(ggtt, &node, PAGE_SIZE);