Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7150589ybi; Mon, 8 Jul 2019 15:39:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0QAAQ5ulqjH05WTyILNy2eB+jocPVxBhDYY8k8c/cyyf4m8WQg38VDFgRxkYbuhnypf2h X-Received: by 2002:a17:902:8489:: with SMTP id c9mr28118124plo.327.1562625589730; Mon, 08 Jul 2019 15:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625589; cv=none; d=google.com; s=arc-20160816; b=SJ+FUC0br6G6X6KNs45zsOoGp5g7fE+20j6WwnvrraBycS9QTQPEmcRX9Hsdlt+T/8 9wEL1zqdToN420RoMx3qDNw04R/SJtvALcyeX+rFIHkUJX72uppM8rD8i8tlg3CBzodK yf4dLWDLpnskZk9MHM8mIzMz/VJk14xw4BABZjud9VHPTzEKnBPdMnMnbSWfQ9jq8qVv lgE7LqK+zwc0N4N8KcWD3rxR6ZW73V2J+IyYgQyIQ+KvA4CBxOB1EMaHxdfMEhdfCq7E SWMPVJ238C+PCtgXC+mGk7PlUA99QAwfvRLTIN5ctavwJfikmmevzLUTwCp/QUerAJPy k9ew== 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=pzE2tEvaBkXiAqe1Rt7xQDUMpZOP9UkkBlltTyXph2Q=; b=dJ4MfhEvIQ+JAKSyPbn0xOCH3cWNG484/DiEtxnz8berOBGjM5/6I1hFswPA1Vqgqv A+Bqvs/nyQY73wRtri4EPSxyN0Hi/6KS9Fg5qzFAI3d+KDCUllkWpFc/UZ/D+LtaEiEx 8hKo6mj4i9Obhx9QxFXnlPT1XaVRpiN6w9IyyvvXO1U/WI2Yk5xJ4vB4I90heXSAPYNe weBx9UTur+WZAWu1ltcvWycm5BjFF0Mb119yUJRirxJghzN7tZvR2/OEEqxxIXel+GCB NBWfXJbSYQzf/yBkiQ/2QoGF3qvlEhpITT0VEcYjNecI3yGiZlH2aE8qmN7iNUVlgOo1 egAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wkLuIvsB; 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 q4si19992780pfh.12.2019.07.08.15.39.35; Mon, 08 Jul 2019 15:39:49 -0700 (PDT) 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=wkLuIvsB; 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 S2389560AbfGHPeI (ORCPT + 99 others); Mon, 8 Jul 2019 11:34:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:36114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390460AbfGHPd5 (ORCPT ); Mon, 8 Jul 2019 11:33:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 E5ECE204EC; Mon, 8 Jul 2019 15:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562600036; bh=QWEh1KWjRkuEdqk4cC4/ckIcIZMQz4gyuaWKf67BMWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wkLuIvsBz28gVY+kq8k4/geuNvGCtJ0/ipPczI5FOdObKYSXiuCqek4HDfbefL2QO K7jFth+CGi5TME8Ncn6fTif5ks1LPlSOEvW388MZRwZYPHdYeBHqJ0Z5UwY36gtLLv /L1HFjuCKup9lsJaSAM/dgA1mlDB/RE5nJg0+XKw= 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?= , Daniel Vetter Subject: [PATCH 5.1 72/96] drm/i915/ringbuffer: EMIT_INVALIDATE *before* switch context Date: Mon, 8 Jul 2019 17:13:44 +0200 Message-Id: <20190708150530.343722818@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150526.234572443@linuxfoundation.org> References: <20190708150526.234572443@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Chris Wilson commit c84c9029d782a3a0d2a7f0522ecb907314d43e2c upstream. Despite what I think the prm recommends, commit f2253bd9859b ("drm/i915/ringbuffer: EMIT_INVALIDATE after switch context") turned out to be a huge mistake when enabling Ironlake contexts as the GPU would hang on either a MI_FLUSH or PIPE_CONTROL immediately following the MI_SET_CONTEXT of an active mesa context (more vanilla contexts, e.g. simple rendercopies with igt, do not suffer). Ville found the following clue, "[DevCTG+]: For the invalidate operation of the pipe control, the following pointers are affected. The invalidate operation affects the restore of these packets. If the pipe control invalidate operation is completed before the context save, the indirect pointers will not be restored from memory. 1. Pipeline State Pointer 2. Media State Pointer 3. Constant Buffer Packet" which suggests by us emitting the INVALIDATE prior to the MI_SET_CONTEXT, we prevent the context-restore from chasing the dangling pointers within the image, and explains why this likely prevents the GPU hang. Signed-off-by: Chris Wilson Reviewed-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20190419111749.3910-1-chris@chris-wilson.co.uk (cherry picked from commit 928f8f42310f244501a7c70daac82c196112c190 in drm-intel-next) Cc: stable@vger.kernel.org Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111014 Fixes: f2253bd9859b ("drm/i915/ringbuffer: EMIT_INVALIDATE after switch context") Signed-off-by: Daniel Vetter Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/intel_ringbuffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -1957,12 +1957,12 @@ static int ring_request_alloc(struct i91 */ request->reserved_space += LEGACY_REQUEST_SIZE; - ret = switch_context(request); + /* Unconditionally invalidate GPU caches and TLBs. */ + ret = request->engine->emit_flush(request, EMIT_INVALIDATE); if (ret) return ret; - /* Unconditionally invalidate GPU caches and TLBs. */ - ret = request->engine->emit_flush(request, EMIT_INVALIDATE); + ret = switch_context(request); if (ret) return ret;