Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3047050imw; Mon, 11 Jul 2022 00:01:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vu9+EnSVKbtIxdxDpZMKbU89tsSbhG8yZ/9zsL2X3iDh8JhWMnq3CqdjTKxM22bk2DAAP+ X-Received: by 2002:a05:6402:1691:b0:43a:db2:a213 with SMTP id a17-20020a056402169100b0043a0db2a213mr22900567edv.100.1657522915125; Mon, 11 Jul 2022 00:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657522915; cv=none; d=google.com; s=arc-20160816; b=EcerZRhIaCi0pTErP7kKMb7EEkv6/f0Z7vhfducytDA4kczs+0t+J/dhvC8l/bz0E8 cZSTT4qKogqwW/CAVdizwEj0oHoGWAIKGyZ/cGvURrOcNewSK08reBHmR55zqSpImILu UKj2ixLxA5pAIicAkA24zjfRd9D+yxD5dV5PA1vzap6zNhx4zbFJPxKsfbqfiio9oTs2 15n2SzlB0psn/PR3sPRNCj2gmxFGVIJzJSogbfXrHcx2SMvEWZn4+SMaW4dJOosHtVZ2 NzS/q39SiBzVp23mWSTQH5pJ8vGQQDQEGrapxzYb4h1G8Pr8xLaJRnpD+qZr4qCDNQNK QxhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=084tPxMAVJltG459DueIjC6IMhcRBogcG0gx7+YVJSs=; b=mjrlr/ViWyY24y+XA3ZBy372SgBdx+Kmi7jGs0bS3Fgdr3N8qFjs02BQQUNN3n2Hxa 3PNAZRvq5uEV3ZeGjZiTTU0Hp1/Bf3cC28UCqWjlqX9yXLm0L2DrC77Q4twirM1JUait gLJd7Ab6HsXpKWy5d/Fn+fsPaTMHY7JTYw2em0PeCnan76gLumdDuTPAp8+3Vw2bXWsq JrtQ5nESt384Sn/l+HQ/GAK1n5Ez53hnFFw1oGMJ473RVTiOCNKncvohwKDMJCk51Gt5 xSrth+LckTSjpyqwIBxMd/DADh3BPDxuSb+t0M1WeiTO9lhgNhWBB/9GGpB0imKdwW1e m2aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=BnTrGNyE; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa36-20020a17090786a400b00722c44f9306si11235395ejc.404.2022.07.11.00.01.28; Mon, 11 Jul 2022 00:01:55 -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=fail header.i=@kernel.org header.s=k20201202 header.b=BnTrGNyE; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbiGKGuu (ORCPT + 99 others); Mon, 11 Jul 2022 02:50:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbiGKGuo (ORCPT ); Mon, 11 Jul 2022 02:50:44 -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 DB5481581F; Sun, 10 Jul 2022 23:50:42 -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 72B9361226; Mon, 11 Jul 2022 06:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C56EFC341C0; Mon, 11 Jul 2022 06:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657522241; bh=gk82hRBUZ3Mn14HV5eJTdUL1I+0tth+4dSD2PfL0rWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnTrGNyEN8TZpU56IIxuNfSNwUae2BY7kfqudFHnJczmA8G6Y8ylGLYc28BWuVL5i YjNMyr9+ItZmd9xOLQRpMaqupSoq4U+lRfCMLAEGv1cf61zlBKpfvL80vh/uzjQ3+O GnZ0ubHczVyqccQgGnfrsNZ1CMDaOe1AHoX/qBlNbyBimL5HBiOS8ECiuYlLYIjEtp c7B+Gi89dPGm7ivmu1DJWtR4+wJ183awgXDrHgQKB+6ki+tRE1H3zMjNcm1LdrOaXE Y7jwrcf8g2nCnkA6OE4XhnGA7QFr5o5mbQCO/A+IviROQU4542J+Lzggs9OYK3I+Ye 4dAOyAEdVhQYA== Received: from mchehab by mail.kernel.org with local (Exim 4.95) (envelope-from ) id 1oAnFe-004a3M-GQ; Mon, 11 Jul 2022 07:50:38 +0100 From: Mauro Carvalho Chehab Cc: Chris Wilson , "Tvrtko Ursulin" , Bruce Chang , Daniel Vetter , David Airlie , Jani Nikula , John Harrison , Joonas Lahtinen , Lucas De Marchi , Matt Roper , Matthew Brost , Rodrigo Vivi , Tejas Upadhyay , Umesh Nerlige Ramappa , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Mika Kuoppala , Andi Shyti , Andrzej Hajda , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Mauro Carvalho Chehab Subject: [PATCH v4 1/2] drm/i915/gt: Serialize GRDOM access between multiple engine resets Date: Mon, 11 Jul 2022 07:50:36 +0100 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson Don't allow two engines to be reset in parallel, as they would both try to select a reset bit (and send requests to common registers) and wait on that register, at the same time. Serialize control of the reset requests/acks using the uncore->lock, which will also ensure that no other GT state changes at the same time as the actual reset. Cc: stable@vger.kernel.org # v4.4 and upper Reported-by: Mika Kuoppala Signed-off-by: Chris Wilson Acked-by: Mika Kuoppala Reviewed-by: Andi Shyti Reviewed-by: Andrzej Hajda Acked-by: Thomas Hellström Signed-off-by: Mauro Carvalho Chehab --- See [PATCH v4 0/2] at: https://lore.kernel.org/all/cover.1657522157.git.mchehab@kernel.org/ drivers/gpu/drm/i915/gt/intel_reset.c | 37 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c b/drivers/gpu/drm/i915/gt/intel_reset.c index a5338c3fde7a..c68d36fb5bbd 100644 --- a/drivers/gpu/drm/i915/gt/intel_reset.c +++ b/drivers/gpu/drm/i915/gt/intel_reset.c @@ -300,9 +300,9 @@ static int gen6_hw_domain_reset(struct intel_gt *gt, u32 hw_domain_mask) return err; } -static int gen6_reset_engines(struct intel_gt *gt, - intel_engine_mask_t engine_mask, - unsigned int retry) +static int __gen6_reset_engines(struct intel_gt *gt, + intel_engine_mask_t engine_mask, + unsigned int retry) { struct intel_engine_cs *engine; u32 hw_mask; @@ -321,6 +321,20 @@ static int gen6_reset_engines(struct intel_gt *gt, return gen6_hw_domain_reset(gt, hw_mask); } +static int gen6_reset_engines(struct intel_gt *gt, + intel_engine_mask_t engine_mask, + unsigned int retry) +{ + unsigned long flags; + int ret; + + spin_lock_irqsave(>->uncore->lock, flags); + ret = __gen6_reset_engines(gt, engine_mask, retry); + spin_unlock_irqrestore(>->uncore->lock, flags); + + return ret; +} + static struct intel_engine_cs *find_sfc_paired_vecs_engine(struct intel_engine_cs *engine) { int vecs_id; @@ -487,9 +501,9 @@ static void gen11_unlock_sfc(struct intel_engine_cs *engine) rmw_clear_fw(uncore, sfc_lock.lock_reg, sfc_lock.lock_bit); } -static int gen11_reset_engines(struct intel_gt *gt, - intel_engine_mask_t engine_mask, - unsigned int retry) +static int __gen11_reset_engines(struct intel_gt *gt, + intel_engine_mask_t engine_mask, + unsigned int retry) { struct intel_engine_cs *engine; intel_engine_mask_t tmp; @@ -583,8 +597,11 @@ static int gen8_reset_engines(struct intel_gt *gt, struct intel_engine_cs *engine; const bool reset_non_ready = retry >= 1; intel_engine_mask_t tmp; + unsigned long flags; int ret; + spin_lock_irqsave(>->uncore->lock, flags); + for_each_engine_masked(engine, gt, engine_mask, tmp) { ret = gen8_engine_reset_prepare(engine); if (ret && !reset_non_ready) @@ -612,17 +629,19 @@ static int gen8_reset_engines(struct intel_gt *gt, * This is best effort, so ignore any error from the initial reset. */ if (IS_DG2(gt->i915) && engine_mask == ALL_ENGINES) - gen11_reset_engines(gt, gt->info.engine_mask, 0); + __gen11_reset_engines(gt, gt->info.engine_mask, 0); if (GRAPHICS_VER(gt->i915) >= 11) - ret = gen11_reset_engines(gt, engine_mask, retry); + ret = __gen11_reset_engines(gt, engine_mask, retry); else - ret = gen6_reset_engines(gt, engine_mask, retry); + ret = __gen6_reset_engines(gt, engine_mask, retry); skip_reset: for_each_engine_masked(engine, gt, engine_mask, tmp) gen8_engine_reset_cancel(engine); + spin_unlock_irqrestore(>->uncore->lock, flags); + return ret; } -- 2.36.1