Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4480170imw; Tue, 19 Jul 2022 07:23:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8s0aAG/TaYD0JKMgZbBSjCGe/QuRnW5Eha4JnHcayLiIv4OEZ1Zxrb973OHChswD3kFt+ X-Received: by 2002:a05:6870:608f:b0:fe:340d:df8e with SMTP id t15-20020a056870608f00b000fe340ddf8emr20362108oae.15.1658240620455; Tue, 19 Jul 2022 07:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658240620; cv=none; d=google.com; s=arc-20160816; b=MqQML8MIC752NVr2nSnZE3fP7sPgBSEqwdas9O4w1zmU0siGIvNOcBp/p5y4cDLlnM FBvNGIynOMFcj1/qnqKUyxXWU5NOR9zUMcMe3bNXf3P2TX9HNvEPRxP22RBAMiY/6ESe AzkAGBKDLDFz38YG/Gmgcry9vMjLfCryYGbFyHk1nEmzrtTOfyuYMT4l3mBlO19fEy7X +Je/5T+IFc8SZl8vx4N3C6QFSregNTeetOVd8WnMeTaH4Bi7a1czmMLvF0hHBSVfjre0 ilVncNtvE3QO0XcTITLsKbDgMM8UL5jUjTnkJMZ7wQbiEBohIv4cid0n+1x4uQOBTIfQ czXQ== 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=tD/EIh3k8zBl8Rqso6lwXxbm9VzZkWs/gMnETqS+G4U=; b=nZAK3o1oSAeTkRdCCTnZwPSyg53hywoSVTvp+gIyI1v5JurAilm0uFqzdOcH2yyK0i G3F8eMUH+2w+B4fa4HfOYH1KjnhbaYdWE6uzU4a7ItQ32fdWW09LoWgF8QwKRy1SqQsO JO3CsFE9cRG7eOfRSf0FlY/xQQt641+aHjvPcDxLWrx60FSP8M2lH4nOgn1S+2JuGbSJ sTF4FQrTIV7orfSpzZrtfRS0dzkI+fmhuAVFzBDtgUybmCaUSOktGcBLMHK2pKM5mWT6 gBv90md5eU1HqGjPddj9zAA/pzkzoH0HZcdVS+1BKL4i/9lRaILSVW10lWfLctm5jPu1 I2qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f3DP9dqa; 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 c36-20020a05687047a400b0010c688f0d25si12623857oaq.270.2022.07.19.07.23.27; Tue, 19 Jul 2022 07:23:40 -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=f3DP9dqa; 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 S240790AbiGSMhI (ORCPT + 99 others); Tue, 19 Jul 2022 08:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240767AbiGSMgX (ORCPT ); Tue, 19 Jul 2022 08:36:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BEC721247; Tue, 19 Jul 2022 05:14:11 -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 BAA506182C; Tue, 19 Jul 2022 12:13:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E276C341C6; Tue, 19 Jul 2022 12:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232817; bh=zB7fBImbL6S5dCvk5R6aCJWY4IS24Bb5+S+GtUzM51w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3DP9dqa0Ua/M+zdcmEQhx0EDmPQ0BTDZvova+sjipMBhBykAflwE56X1UF2t6H2O uGbw6Q31wmkuL5U62jTnUTgaY9gZIs7Vi7ZyJhUcbPjb+o8xBL0o5OQoz30o2iaBbe fzbAjObYlMT1/qFSLavKOMWg5g8cbD+DP8i9vjuA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Kuoppala , Chris Wilson , Andi Shyti , Andrzej Hajda , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Mauro Carvalho Chehab , Rodrigo Vivi , Sasha Levin Subject: [PATCH 5.15 076/167] drm/i915/gt: Serialize GRDOM access between multiple engine resets Date: Tue, 19 Jul 2022 13:53:28 +0200 Message-Id: <20220719114703.894354538@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@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 b24dcf1dc507f69ed3b5c66c2b6a0209ae80d4d4 ] 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 Signed-off-by: Rodrigo Vivi Link: https://patchwork.freedesktop.org/patch/msgid/e0a2d894e77aed7c2e36b0d1abdc7dbac3011729.1657639152.git.mchehab@kernel.org (cherry picked from commit 336561a914fc0c6f1218228718f633b31b7af1c3) Signed-off-by: Rodrigo Vivi Signed-off-by: Sasha Levin --- 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 b6697c1d260a..18b0e57c58c1 100644 --- a/drivers/gpu/drm/i915/gt/intel_reset.c +++ b/drivers/gpu/drm/i915/gt/intel_reset.c @@ -293,9 +293,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) { static const u32 hw_engine_mask[] = { [RCS0] = GEN6_GRDOM_RENDER, @@ -322,6 +322,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; @@ -488,9 +502,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) { static const u32 hw_engine_mask[] = { [RCS0] = GEN11_GRDOM_RENDER, @@ -601,8 +615,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) @@ -630,17 +647,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.35.1