Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2961011imu; Mon, 19 Nov 2018 08:39:50 -0800 (PST) X-Google-Smtp-Source: AJdET5dSAQwphi85NZAhaUDgXIsd5TX2YKcjn1NAfFx8LjkHTAye8FYqI71ZVmyOuDj0YjRB2Xrn X-Received: by 2002:a63:680a:: with SMTP id d10mr20858483pgc.396.1542645590038; Mon, 19 Nov 2018 08:39:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645590; cv=none; d=google.com; s=arc-20160816; b=Rm7xa4gWPG5jTpcKvqYQ+V/1Qdg8SDMttpvzlK3iMti8jYOz0/OJLlulYW6Bxm8Zyy 1OrS0CuuX3KHiae64qC7q3I4zmUFkx9cDqgFcWtFvFU/8CzRz6wU6WRAr9kXbTrH2yY9 YfPJojCtkDSiayntwpLa7ivd8bTWr3BuRcRynXRDzlP7BHX2CZrwydL508Xor0o9PE9V IORFdXDk18Sfu3cT4+aFhkJzpUG/UxoMJckqVKQ3RlYs8t8XVdi4YOCkMDTUvkY+pCa9 OGHGXIZJEwweAZZbxNSXKEyZw7zq1H+yAtvnDIum+mDPfMSXm41HU/SQDBbHxjeeoFHT 8G1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jSIobCCuq7K+BN2zk40U6sAq4XmdAQGwATtrki069e8=; b=cgrWGg7gA96Cpfyc73FrPSXVC1/wKVY+84+nzjNnkzkoubpqrEb37zP4VFOx1epfZl w7cwtFD7dk5EtG52+O10yV8VD9RkR40INY/1t+j6cEGZ+iZakeK1dBwMAoR9DKvyUZNZ hEiXD/C2x0v8J00I+RY3nzQwHLQiFBQOmp23+eN9B1i9mSKeaSRx9+bGUf51Z0RnlWjx bK8tc3/J/qEaEnzwyszmtS/VSzRP98vbKkukDyGNnWsGfG/CAK+Lj0+XhSfema/2Eqsn fSSs12HYmoHNyAjQvqt2LwX4tCZoQJUvJe/a0r7dxM+KQRMOMCSXfRYHq3CO3bhjYwn/ BZEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GL02f9RC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si731886pfm.85.2018.11.19.08.39.34; Mon, 19 Nov 2018 08:39:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GL02f9RC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732605AbeKTDDF (ORCPT + 99 others); Mon, 19 Nov 2018 22:03:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:35556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731637AbeKTDDF (ORCPT ); Mon, 19 Nov 2018 22:03:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB1C5208E4; Mon, 19 Nov 2018 16:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645535; bh=++4ejMa4O5954C1Zh1rfSK6YWCNAKlhNqK6IidztQjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GL02f9RC0WlYIezXuozyjBnm6ZKM+RjTFzL4/M5Q3KzgpLrjL24lJd0H80r3b3ZHS rr0cqv0+Dikh+m4UtUMlalsP4EOaGZrUQ4UzE506BTZcGIH2niieQ7jhvsIV1ry3FH NnRpSA4hOINFlqZgJf/PSz8zXxaPWK3wsOzeW7RE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Joonas Lahtinen Subject: [PATCH 4.19 200/205] drm/i915/ringbuffer: Delay after EMIT_INVALIDATE for gen4/gen5 Date: Mon, 19 Nov 2018 17:28:27 +0100 Message-Id: <20181119162642.641785207@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Wilson commit fb5bbae9b1333d44023713946fdd28db0cd85751 upstream. Exercising the gpu reloc path strenuously revealed an issue where the updated relocations (from MI_STORE_DWORD_IMM) were not being observed upon execution. After some experiments with adding pipecontrols (a lot of pipecontrols (32) as gen4/5 do not have a bit to wait on earlier pipe controls or even the current on), it was discovered that we merely needed to delay the EMIT_INVALIDATE by several flushes. It is important to note that it is the EMIT_INVALIDATE as opposed to the EMIT_FLUSH that needs the delay as opposed to what one might first expect -- that the delay is required for the TLB invalidation to take effect (one presumes to purge any CS buffers) as opposed to a delay after flushing to ensure the writes have landed before triggering invalidation. Testcase: igt/gem_tiled_fence_blits Signed-off-by: Chris Wilson Cc: stable@vger.kernel.org Reviewed-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20181105094305.5767-1-chris@chris-wilson.co.uk (cherry picked from commit 55f99bf2a9c331838c981694bc872cd1ec4070b2) Signed-off-by: Joonas Lahtinen Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/intel_ringbuffer.c | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -91,6 +91,7 @@ static int gen4_render_ring_flush(struct i915_request *rq, u32 mode) { u32 cmd, *cs; + int i; /* * read/write caches: @@ -127,12 +128,45 @@ gen4_render_ring_flush(struct i915_reque cmd |= MI_INVALIDATE_ISP; } - cs = intel_ring_begin(rq, 2); + i = 2; + if (mode & EMIT_INVALIDATE) + i += 20; + + cs = intel_ring_begin(rq, i); if (IS_ERR(cs)) return PTR_ERR(cs); *cs++ = cmd; - *cs++ = MI_NOOP; + + /* + * A random delay to let the CS invalidate take effect? Without this + * delay, the GPU relocation path fails as the CS does not see + * the updated contents. Just as important, if we apply the flushes + * to the EMIT_FLUSH branch (i.e. immediately after the relocation + * write and before the invalidate on the next batch), the relocations + * still fail. This implies that is a delay following invalidation + * that is required to reset the caches as opposed to a delay to + * ensure the memory is written. + */ + if (mode & EMIT_INVALIDATE) { + *cs++ = GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE; + *cs++ = i915_ggtt_offset(rq->engine->scratch) | + PIPE_CONTROL_GLOBAL_GTT; + *cs++ = 0; + *cs++ = 0; + + for (i = 0; i < 12; i++) + *cs++ = MI_FLUSH; + + *cs++ = GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE; + *cs++ = i915_ggtt_offset(rq->engine->scratch) | + PIPE_CONTROL_GLOBAL_GTT; + *cs++ = 0; + *cs++ = 0; + } + + *cs++ = cmd; + intel_ring_advance(rq, cs); return 0;