Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4374319imw; Tue, 19 Jul 2022 05:35:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tod4bb19VCmfq2nqsmE4ojww1vko2Bz1zrLomX6xm6rh3smUvoT2kvbpaTVjV1IZOq9kNs X-Received: by 2002:a63:5f56:0:b0:412:9907:ec0d with SMTP id t83-20020a635f56000000b004129907ec0dmr29035750pgb.18.1658234123333; Tue, 19 Jul 2022 05:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234123; cv=none; d=google.com; s=arc-20160816; b=I0vRSGv/3EMQwGrmik8apkYL5nlLW88bst9VHC568LQhwfaWPDjs3y31WlvNu1D3LD JjBBRwTe96FS55hVmL83yL121qTweMqET3DSqqSPqx5oVTk3wJdVOaD8gXfC+nSfHLub QLEModIc4fsUHyAnOpby3+deBJDeKdnAAg7eoSLZeCi0ag9pgZIQhglIT3HE7lIRa2Qr 1fX3EygKdSoJujklQ5u/M1ACrHYGQ/fON6qD6Q9Pb4yzIkyuNYc9B2zKb+nrgUQ4A7HD oobSLpL6QJ+MXC0j+6HNV+O43bKaFuyJb1ZtOsA19dWDlLaIdaWMZnOHWwUBZ5LKKoo9 j3Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JN2Z/npW322QmSQTvJKRgZByNI/eH0ZOuCnOSPbiYJw=; b=yw4WPPZTLSgydpicF9lGj4ilNq5GOlk+W1rFM2rFZppmcij7daN6s6bPchx3AsnDTE DqwdTeOaPaTxnJ2XXD0RqZ/KOQ/mMIajpgdg94wkpJh6zVdL3wcFbTMPamZOOkZ1yeDH UG+PUmFm20tu2bWH2y4pMNRG48WA7nEwJQn7T4D/fGxKslu6mrWZKdaxgOSZPtSrcHBn Pj3SdYGsaa6ksVZXR+U+PV94IxBSvK6YZaLd9tJDnLN1aUiCHVTxvedYvsIJiHeEg2hD /8HVaS77seQ4NNwn2PyHHMTNe4iq8iz6iHyuIr/1jqKdNhHXZsICy3XkcqrYLEjYIpY7 S72g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lzUb9svM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x186-20020a6386c3000000b00411f3d72b41si3620212pgd.506.2022.07.19.05.35.07; Tue, 19 Jul 2022 05:35:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lzUb9svM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239335AbiGSMWe (ORCPT + 99 others); Tue, 19 Jul 2022 08:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237779AbiGSMWN (ORCPT ); Tue, 19 Jul 2022 08:22:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A1A75B7B1; Tue, 19 Jul 2022 05:07:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 273CE616DB; Tue, 19 Jul 2022 12:07:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D8D0C341CB; Tue, 19 Jul 2022 12:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232458; bh=MGRxvlQdazFCHl7kA+lOHazR0cm1kX0uE8dBjTkcp+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzUb9svMzyCViLY1g/DpVp2A2gagtpJGuXeEtqcf9qAxPX3mTWRbhv0PAD+nhzVED AwaaEfaA+SUdvpBs1IbwgVZAjG1I2Uiw8ge0KhLKxw6RDQbnbjlNcTpZQ86dnYwrEt MiQf1/xN6G8/Tz1bJ1kiUlmvCNMCxcyLIFhnG+qA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauro Carvalho Chehab , Chris Wilson , Tvrtko Ursulin , Andi Shyti , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi , Sasha Levin Subject: [PATCH 5.10 057/112] drm/i915/gt: Serialize TLB invalidates with GT resets Date: Tue, 19 Jul 2022 13:53:50 +0200 Message-Id: <20220719114631.953939070@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 6615eb5147e2..a33887f2464f 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt.c +++ b/drivers/gpu/drm/i915/gt/intel_gt.c @@ -736,6 +736,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, @@ -750,7 +764,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, -- 2.35.1