From patchwork Fri Aug 12 13:46:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9276989 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 12A8A600CB for ; Fri, 12 Aug 2016 13:47:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04B9B28A04 for ; Fri, 12 Aug 2016 13:47:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDDD428A08; Fri, 12 Aug 2016 13:47:40 +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, 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 E0C9628A04 for ; Fri, 12 Aug 2016 13:47:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 521E76EB98; Fri, 12 Aug 2016 13:47:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id C9B4A6EB96 for ; Fri, 12 Aug 2016 13:47:33 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id i138so2941408wmf.3 for ; Fri, 12 Aug 2016 06:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=h8RN0trxapCcRgQArgdTSvot2S/PHTrBlWk5ivSYMB8=; b=I0lZU9OUhJ3R7tEV2Yd2acTxy2CMbhbeUtONcjWrSCx49Veh3wt2xOioWGzSMQSo5H BOS4em6qr/b4JnE39D/AvMBh18CkoJ7T2yf6+MA7Zldu0wdEPmZ9GbM8uk7C6qI0ZTcX XGIVIuXZBZriE7EOBd2kf1LPag/6QWL33oOpGYGOeiUyY7DigkS3MD2qAlzCsqH0wc9W dllKlfIfBTU/E7oAekfiRs1B8CPEIXvMRk4hLBA3AV81+lF30NlrA3lQNVAmfELEgJky frPjIi4fhp/7E3q1yHg4LBlBJLnEljDh/vayVYDbCLnwz8KTpN3EbdvwTOGgfYOoGlmq vgsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=h8RN0trxapCcRgQArgdTSvot2S/PHTrBlWk5ivSYMB8=; b=ka3RnL6gqRBCbk3AyOgYgfq6vANAYIDS4QUXxTpXtf8OJBdyTHQ88aCTTqYOwdJOq+ SJf0Dmj+2SP6GameUwYSiMaGruANLBFziCEMR5ciPIQPD//6sSQ1QfL/EUGP0ahLuNup zefFcmlm60vMBDx3PopJ4rCZqUOx7jkMfbQiGUghOALopu/s2G1QMrFZmNF1RDAmwwlO vczOmEPGTLJZ0R0p20fKnXF5HLsj831JOx6PZl33+VJnOpUJ0Su52GekM7AMSqjTFPWg 8dQpl15qAMaJYFGF9EyLl0zKPXKabXDPqz4t34T9i5JIFPR0sUVigclc89ElGQoWigDc PYCA== X-Gm-Message-State: AEkoouu3DVnOg6h7b7ml/DzxtuUI9vHKYk1AaWQFCig609Dmpwe/bUhAIHwKyom28hfb1Q== X-Received: by 10.28.61.11 with SMTP id k11mr3373293wma.34.1471009652241; Fri, 12 Aug 2016 06:47:32 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id v134sm2676423wmf.10.2016.08.12.06.47.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Aug 2016 06:47:31 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 12 Aug 2016 14:46:55 +0100 Message-Id: <1471009630-24370-16-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1471009630-24370-1-git-send-email-chris@chris-wilson.co.uk> References: <1471009630-24370-1-git-send-email-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [CI 16/31] drm/i915: Only change the context object's domain when binding X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We know that the only access to the context object is via the GPU, and the only time when it can be out of the GPU domain is when it is swapped out and unbound. Therefore we only need to clflush the object when binding, thus avoiding any potential stall on touching the domain on an active context. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_gem_context.c | 19 +++++++------------ drivers/gpu/drm/i915/intel_ringbuffer.c | 4 ++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 3857ce097c84..824dfe14bcd0 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -772,6 +772,13 @@ static int do_rcs_switch(struct drm_i915_gem_request *req) if (skip_rcs_switch(ppgtt, engine, to)) return 0; + /* Clear this page out of any CPU caches for coherent swap-in/out. */ + if (!(vma->flags & I915_VMA_GLOBAL_BIND)) { + ret = i915_gem_object_set_to_gtt_domain(vma->obj, false); + if (ret) + return ret; + } + /* Trying to pin first makes error handling easier. */ ret = i915_vma_pin(vma, 0, to->ggtt_alignment, PIN_GLOBAL); if (ret) @@ -786,18 +793,6 @@ static int do_rcs_switch(struct drm_i915_gem_request *req) */ from = engine->last_context; - /* - * Clear this page out of any CPU caches for coherent swap-in/out. Note - * that thanks to write = false in this call and us not setting any gpu - * write domains when putting a context object onto the active list - * (when switching away from it), this won't block. - * - * XXX: We need a real interface to do this instead of trickery. - */ - ret = i915_gem_object_set_to_gtt_domain(vma->obj, false); - if (ret) - goto err; - if (needs_pd_load_pre(ppgtt, engine, to)) { /* Older GENs and non render rings still want the load first, * "PP_DCLV followed by PP_DIR_BASE register through Load diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 2318a27341c8..81dc69d1ff05 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -2092,6 +2092,10 @@ static int intel_ring_context_pin(struct i915_gem_context *ctx, return 0; if (ce->state) { + ret = i915_gem_object_set_to_gtt_domain(ce->state->obj, false); + if (ret) + goto error; + ret = i915_vma_pin(ce->state, 0, ctx->ggtt_alignment, PIN_GLOBAL | PIN_HIGH); if (ret)