Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4372899imw; Tue, 19 Jul 2022 05:33:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u/6LpK++kYaPxHmADPbJ/zuVEb2xtwEKOSRiK+spe+Kkwo3mbxeHkLEgYsOqEW8nu03Uw/ X-Received: by 2002:a05:6402:899:b0:43b:3b1c:7350 with SMTP id e25-20020a056402089900b0043b3b1c7350mr28415487edy.82.1658234016389; Tue, 19 Jul 2022 05:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234016; cv=none; d=google.com; s=arc-20160816; b=nFFqh+hjJzncl/M9rVRGWFwebUFXFAgfJTzuBVjeWXrqKatYMa/wCBV7hYSTMoxD5k SIb0XzG7ES/RjWZulUg+2FNrubKx98CSqx7una0HOpX8BTm4BI3Df7u4A3Y4EsEitcrX gnNE0h+ks/1hwl0+BdiMm+l4l5YzslGT45eY34OnZ3MAhloSnnECY2fAiGC4buOs8NqT dA3sqVoUFauqnvVEVKVL7ke8sABVGFnyxQ2XeBI0EO3ywEAw0fZBABU5O18brjK6/Dl5 qFrU1aqatpKAz0bfxaQrjyPAIrHB+OI9zkHimqdWWt9b8KwzlvES4sTm+vxE/cL60DgR EPNw== 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=CJqVX4dSTOyB3Lk8f7TGZ2tA3IB+tvYdRrnkoFYPYVk=; b=FQ4AaZ0YqzbHyQ1ofgikPUML+qxABmpGHBOaRp6Wyu2vr78NO+DmjLendnObqYHE3f YkZitsGWvIBrvT5llqGHHEOGP2iKplDc8ein4iPboZogtU4WaKYHd6MDGTPDhXcfcG+2 aJ+L1k7cx6xTvmMm48eEVP1jY5jDXrc1SHcMY97+L7ehvgvvLjDMuCmfltd60cFHN+1p p2HQ0hafn+PW5CWP6q6aHVW+aQg9/dnwxlVhdkpjO/FeRYQCN8/qhw7ViyL0yNT6WNtL gR9R0YuVMiURHVeoeIEcABVOgdFIRD+wQwdFerJ0JZJ18Q1P+jqEiEpdqmosOME02oW3 O9dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wU2gUDZn; 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 y13-20020a056402270d00b0043a8c39f7c4si20322021edd.101.2022.07.19.05.33.11; Tue, 19 Jul 2022 05:33:36 -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=wU2gUDZn; 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 S239017AbiGSMOB (ORCPT + 99 others); Tue, 19 Jul 2022 08:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238921AbiGSMNX (ORCPT ); Tue, 19 Jul 2022 08:13:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 696D7F1C; Tue, 19 Jul 2022 05:04:33 -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 ams.source.kernel.org (Postfix) with ESMTPS id 47580B81A8F; Tue, 19 Jul 2022 12:04:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B61FC341C6; Tue, 19 Jul 2022 12:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232242; bh=lIGn+EkYk/KbpFsuPs7gjDgknOujUHPpafCF3+1seNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wU2gUDZnAHG2ZI32THaKxodgMG3X0B3b9wGpWHSbVvS6dgPg0EEDV0ShbgJXLhE++ 1haEmqGRvaNOocbnZLWw8OUO5c/JLR/eukZsaGuBP3fxb2kiXVJ3lO4Omd557kACX2 fgscFGzFZU4gsCh6OBc4lKJe2RhFcyrkVMFhme6o= 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.4 33/71] drm/i915/gt: Serialize TLB invalidates with GT resets Date: Tue, 19 Jul 2022 13:53:56 +0200 Message-Id: <20220719114555.489104924@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114552.477018590@linuxfoundation.org> References: <20220719114552.477018590@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 c8c070375d29..f6d7f5d307d7 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt.c +++ b/drivers/gpu/drm/i915/gt/intel_gt.c @@ -339,6 +339,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, @@ -353,7 +367,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