Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1346397ybp; Thu, 17 Oct 2019 11:23:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX9JHkhCvDVx0t4jgvaDy5hrW6Wl8Yx3IU675JFAwgsr0lfWRm0C1rvxBFztyLbTN1zvB7 X-Received: by 2002:a50:9a46:: with SMTP id o64mr5343499edb.191.1571336597482; Thu, 17 Oct 2019 11:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336597; cv=none; d=google.com; s=arc-20160816; b=Hzrz0YWao2o3WGjxVkj4qZ63Ueu2VbdOvCIGvDPgLXhBPMJVQTnaWfyJvQ33DVnd6W o4noVTLZ3yDp2pq6ju+VFJm2q4Il/nWxaA4R7qbW3t0SJ5nnYCe4FZOh4g/cuQty/EhO n62vLCGtIf+PNwtk2v4mtHvF9ShYAkrF//N+O2aBknPsgKtH3YVqwJpdaMq4ImFUQhfh rsZh0FkTcifC9evNgCKP5LZ9IETFfjwhQFrj3Fl/KpsWQH5BAXq6Ee1dSaaxhW/lmb0u bjjkAeHTH79ZHAoY2nKrkSngjX3sXnlDzQyRjfjY4HEnsEXmj07ZYsGLKfLkPxex976n xE0g== 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=pB8ADiXTGeJaiEpnoEIRZdvCcOM7KbqCOJKMRnAQ4Mg=; b=dx8ZWSb6puIq2fdiH265x01Z4RwCU+ju189OuBUN7EB3M2pODKyapWklHJqXUdlXHg L3rBFP9/Nt2pCtpNCzLqK8/Yi08/+KDz5U6XLUIcSGl39WSuosqCRs+XEps7C9msGWFG 7ElHZ4o49m/gJYtl93A02z64kmQYExqvYqNOmt99wRlS7DUKw18wNLQpsaulYA2Sksvc /nnt3WG0a0EXi2YDrAu+6I9JS6Af2Vig0/xc2yTJ3iyblWjqJbm+jzAWvKPwizwHtwbI DzR2jYA2vTiV2cJXQqlVY0AWk/Ai6PiYDYtiPSFoZGSp41mFFeMBSpAOqgAMqE8JGl0R sywA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cFjIW8mL; 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 v18si1836641ejd.115.2019.10.17.11.22.54; Thu, 17 Oct 2019 11:23:17 -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=cFjIW8mL; 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 S2391943AbfJPWCJ (ORCPT + 99 others); Wed, 16 Oct 2019 18:02:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:55138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438649AbfJPV7v (ORCPT ); Wed, 16 Oct 2019 17:59:51 -0400 Received: from localhost (unknown [192.55.54.58]) (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 5E71D222C2; Wed, 16 Oct 2019 21:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263190; bh=pcGHmEd7rKiz0AWG27Jsh94bX116U0ITyp0UnfLY9nI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cFjIW8mL4jfoxbnHMvuDZwD7b+k5sU+vktn6LzGkhBvTxPdFeFgDqUO5Y8GX5K8cK JfeerTouzRf7jJnea4LRnYJsTEN07+xKCJNN4sGFYRFmqPyvA0DUqyCJ7ddzqjnAgf jZFrlH3oW5kOsjsMXvz0u3g2Tq2aoGGXznNSRuqM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Mika Kuoppala , Martin Peres , Joonas Lahtinen , Rodrigo Vivi Subject: [PATCH 5.3 068/112] drm/i915: Perform GGTT restore much earlier during resume Date: Wed, 16 Oct 2019 14:51:00 -0700 Message-Id: <20191016214902.978070580@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@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 6c76a93c453643e11a1063906c7c39168dd8d163 upstream. As soon as we re-enable the various functions within the HW, they may go off and read data via a GGTT offset. Hence, if we have not yet restored the GGTT PTE before then, they may read and even *write* random locations in memory. Detected by DMAR faults during resume. Signed-off-by: Chris Wilson Cc: Mika Kuoppala Cc: Martin Peres Cc: Joonas Lahtinen Cc: stable@vger.kernel.org Reviewed-by: Mika Kuoppala Link: https://patchwork.freedesktop.org/patch/msgid/20190909110011.8958-4-chris@chris-wilson.co.uk (cherry picked from commit cec5ca08e36fd18d2939b98055346b3b06f56c6c) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gem/i915_gem_pm.c | 3 --- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/selftests/i915_gem.c | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/i915/gem/i915_gem_pm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_pm.c @@ -250,9 +250,6 @@ void i915_gem_resume(struct drm_i915_pri mutex_lock(&i915->drm.struct_mutex); intel_uncore_forcewake_get(&i915->uncore, FORCEWAKE_ALL); - i915_gem_restore_gtt_mappings(i915); - i915_gem_restore_fences(i915); - if (i915_gem_init_hw(i915)) goto err_wedged; --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -2238,6 +2238,11 @@ static int i915_drm_resume(struct drm_de if (ret) DRM_ERROR("failed to re-enable GGTT\n"); + mutex_lock(&dev_priv->drm.struct_mutex); + i915_gem_restore_gtt_mappings(dev_priv); + i915_gem_restore_fences(dev_priv); + mutex_unlock(&dev_priv->drm.struct_mutex); + intel_csr_ucode_resume(dev_priv); i915_restore_state(dev_priv); --- a/drivers/gpu/drm/i915/selftests/i915_gem.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem.c @@ -117,6 +117,12 @@ static void pm_resume(struct drm_i915_pr with_intel_runtime_pm(&i915->runtime_pm, wakeref) { intel_gt_sanitize(i915, false); i915_gem_sanitize(i915); + + mutex_lock(&i915->drm.struct_mutex); + i915_gem_restore_gtt_mappings(i915); + i915_gem_restore_fences(i915); + mutex_unlock(&i915->drm.struct_mutex); + i915_gem_resume(i915); } }