From patchwork Mon Jan 16 19:23:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1727229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=vH0y4KAy; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nwhmx13fyz23fk for ; Tue, 17 Jan 2023 06:25:05 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pHV6H-0000dj-EX; Mon, 16 Jan 2023 19:24:57 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pHV6F-0000d8-BL for kernel-team@lists.ubuntu.com; Mon, 16 Jan 2023 19:24:55 +0000 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1C6B03F473 for ; Mon, 16 Jan 2023 19:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1673897095; bh=P/QU1y9G5ONwZeQoNYwn+ZaKSxLeQDj2ePDAVmm2zeQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=vH0y4KAyIdJq2CU3n69K8cwB75CVbnc5RCln3h6Bp+cZ9+YIxU0LJfy2UdEr40JQr yr+QaI9TgRN0aemTSuWbbiUQTyhxX9y5KllFdQXcNEmX6e66r7YqgmcInYfTa5lAE2 dmEPnWy6Ysy2vEBpEdWb44S76jla049NvXJovvC2apOnZNHoZFOCR/m7WkyLPKEmNY FLD3uiqbaSFXrp3VyRjf2ja44e+h/Cp9omR/chPQMyOc1UKUboOsc6VCCfzqPENO5U rkQmtL29zq3RiSyXFljBTQFBDYxdQQLiwLZr3m+fFFhLPwNHwbRafhVgCbwM3cOBi+ /Ovdcgyp4J3fQ== Received: by mail-ed1-f71.google.com with SMTP id w3-20020a056402268300b00487e0d9b53fso19733102edd.10 for ; Mon, 16 Jan 2023 11:24:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/QU1y9G5ONwZeQoNYwn+ZaKSxLeQDj2ePDAVmm2zeQ=; b=phB/Ziv9sfWDCUCrSCcGgyGySF2d3k7tyaKfV8JYopjXu0sQtuG4Boy0I+qsJ9E3A0 LDXitSMaUWEF+yJW7BHcLZQch0qjz1AWxCxCr+1nx5DcrtcQ6KYca+zm5012HXzLmIE9 1E48IANlaomHvs+hOg8wF5KS1u1Q0ao4ze0VlQjM/xKSVcXpwihzsB9m86B9ZF+ArsUK cpZrFEHbOzBS5sJARR+w2xSO0qvcRUBVOo9exwOr+YqnjqS48sFAVq+RP2cCFFLIrVou bv46KvH7sHYS6tFvxSpRKJm8t3MdAtGRYi2YsDnZq1LDrgT80THsEAq45c909zYo9O3q GWjg== X-Gm-Message-State: AFqh2korOQRTqUcNAzjyEwC4JYTuKWh41+GrJyxIMwcBe34DuwisW0Et mIFW0RgY8NSCx6Xj/A7dNu7ap1RfGJYnDN3r7tc0l5AON9DKyU9wWJ7t90gimQVpcCz0a6r96W2 6fXb4N1fVFBrAVkeR9zg7lPboxYE/HX+WGrr59NVnXg== X-Received: by 2002:a17:906:1417:b0:86d:f880:5193 with SMTP id p23-20020a170906141700b0086df8805193mr101583ejc.38.1673897094582; Mon, 16 Jan 2023 11:24:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuCxE7VBcGwTgEANBMuxM93Vqc5O8bu0gX/1VH2CnOxN6YgUgYn9PgbU43rQgD1Vw7/NSvd4Q== X-Received: by 2002:a17:906:1417:b0:86d:f880:5193 with SMTP id p23-20020a170906141700b0086df8805193mr101575ejc.38.1673897094340; Mon, 16 Jan 2023 11:24:54 -0800 (PST) Received: from localhost ([176.234.90.170]) by smtp.gmail.com with ESMTPSA id 22-20020a170906311600b0082535e2da13sm12178700ejx.6.2023.01.16.11.24.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 11:24:54 -0800 (PST) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU OEM-5.14 1/2] drm/i915/gt: Serialize TLB invalidates with GT resets Date: Mon, 16 Jan 2023 22:23:50 +0300 Message-Id: <20230116192349.89358-3-cengiz.can@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116192349.89358-1-cengiz.can@canonical.com> References: <20230116192349.89358-1-cengiz.can@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Chris Wilson [ Upstream commit a1c5a7bf79c1faa5633b918b5c0666545e84c4d1 ] Avoid trying to invalidate the TLB in the middle of performing an engine reset, as this may result in the reset timing out. Currently, the TLB invalidate is only serialised by its own mutex, forgoing the uncore lock, but we can take the uncore->lock as well to serialise the mmio access, thereby serialising with the GDRST. Tested on a NUC5i7RYB, BIOS RYBDWi35.86A.0380.2019.0517.1530 with i915 selftest/hangcheck. Cc: stable@vger.kernel.org # v4.4 and upper Fixes: 7938d61591d3 ("drm/i915: Flush TLBs before releasing backing store") Reported-by: Mauro Carvalho Chehab Tested-by: Mauro Carvalho Chehab Reviewed-by: Mauro Carvalho Chehab Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Reviewed-by: Andi Shyti Acked-by: Thomas Hellström Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Rodrigo Vivi Link: https://patchwork.freedesktop.org/patch/msgid/1e59a7c45dd919a530256b9ac721ac6ea86c0677.1657639152.git.mchehab@kernel.org (cherry picked from commit 33da97894758737895e90c909f16786052680ef4) Signed-off-by: Rodrigo Vivi Signed-off-by: Sasha Levin CVE-2022-4139 (cherry picked from commit 2744e302e752fe3538dfefa406f382cd90681963 linux-5.10.y) Signed-off-by: Cengiz Can --- drivers/gpu/drm/i915/gt/intel_gt.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c index ddcdb327c885..59d36fff08ab 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt.c +++ b/drivers/gpu/drm/i915/gt/intel_gt.c @@ -779,6 +779,20 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt) mutex_lock(>->tlb_invalidate_lock); intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL); + spin_lock_irq(&uncore->lock); /* serialise invalidate with GT reset */ + + for_each_engine(engine, gt, id) { + struct reg_and_bit rb; + + rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num); + if (!i915_mmio_reg_offset(rb.reg)) + continue; + + intel_uncore_write_fw(uncore, rb.reg, rb.bit); + } + + spin_unlock_irq(&uncore->lock); + for_each_engine(engine, gt, id) { /* * HW architecture suggest typical invalidation time at 40us, @@ -793,7 +807,6 @@ void intel_gt_invalidate_tlbs(struct intel_gt *gt) if (!i915_mmio_reg_offset(rb.reg)) continue; - intel_uncore_write_fw(uncore, rb.reg, rb.bit); if (__intel_wait_for_register_fw(uncore, rb.reg, rb.bit, 0, timeout_us, timeout_ms,