Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp711893iog; Wed, 29 Jun 2022 08:42:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLqcUHTyZgVmqXZeR7rZzwVfIVhhKmGEkIqUulZ90S/cNK++fLaXzV3AIi8E6PS4DKikox X-Received: by 2002:a05:6402:ca6:b0:435:8009:aa37 with SMTP id cn6-20020a0564020ca600b004358009aa37mr5172829edb.183.1656517323722; Wed, 29 Jun 2022 08:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656517323; cv=none; d=google.com; s=arc-20160816; b=ZD5yd9zn5dev4FCyMGPLocm6zzSgiPgOpPmRMu/SXE47HORMkOx17tfiu4vYLunPx9 lRuNQXzIvEtEjhiW81co7HRVf05p6+ECA9Gi7tIWB8QI6OqiMratFU2nXobFmI02dGgG eo1DK9dp2goRLpszc6l9fvVF5X4IlYbc1DebFNv9vX2ng80NeodTrRX2hzQKH4Dadnie +KNcs8w7kfh/WbRni0rhJFDTMBzrj8U38Sw8Glz4ZRmavS4PC2aBfkLdr2g8iZc3t/5M o2dk7vyOUEPumNi7rnVoj7OEQC/mErCAx71HM+fcWmJVzEMRnD0gSHoMYTzmZLqHPeds HDNg== 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=f039jZlk7yPHYOacHa3PCqlS2HWOaicqg0x/7OpDMYo=; b=OaR4AROAUYJv8D0hN/DQwJ4hyoP4ABqZZIy+LPqPV6vkKtmr4Hhg62XOilk0nZuMmI d2lN/JeZVkyFbZDkeSW++AlYtmYEJdGrZSs80+uavgQM8GJiyIQ4BG4W2wFsN8DN1MiN QDqY8Z6GXn/iB+pjLxszRUbXhGEXFyidihlsQ1WIuAroAAh+FNJ9bhyjNirKuklwzNkp cz5fweUEUMyF62/sb+KcrOuEnUsEjLV91f+2bg46HHAYlcIEj9ulGqscX6HD0jue0DPk u+zKoMTci1YraVgmiiLuVNWN0auxYksLasULU8yi+DDDp6SDA/1+FvzxzIlc1MpduK01 TVag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b="OkWAWn/A"; 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 e42-20020a056402332a00b00437be2ab51csi1694318eda.199.2022.06.29.08.41.37; Wed, 29 Jun 2022 08:42:03 -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="OkWAWn/A"; 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 S234163AbiF2PZn (ORCPT + 99 others); Wed, 29 Jun 2022 11:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234032AbiF2PZf (ORCPT ); Wed, 29 Jun 2022 11:25:35 -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 1385F2B25D; Wed, 29 Jun 2022 08:25: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 D079EB8254A; Wed, 29 Jun 2022 15:25:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859FDC385A5; Wed, 29 Jun 2022 15:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656516330; bh=vA3TDfCYgbDYTy0RpqmuVlzT3hHqXf/ueg6gMP+LLeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OkWAWn/AWasmoB43WZRoped54kCAWZVtaOLrk99sjBLJ9IREfbBoDMcvhEGPg3QLe SzFj0S99e/mRJHJ2eKCcnY7uTa1D8zuMYeHZYlGRUsERU9m8heYM5PGe83DBsCWyOX DWtE8RVIxotFEHt+LTvaauEa6nToESZpoiDr6JDtvlWffsbG13vL5bWw6CsQWt/k5v bYKNpXn4WmfzCqaXQt4J9a6MqHWDYwIjoV+3MOChOfosE0wnf0A76FsueOuK45nyyx 5nwaOJho8Q4k1v5CbExOVnAZiAaWxx+OzQjS91J1n8sMy8meiPNAm33eHElznhncrg TO/lw41m5bA0Q== Received: from mchehab by mail.kernel.org with local (Exim 4.95) (envelope-from ) id 1o6ZZH-005hFL-Ol; Wed, 29 Jun 2022 16:25:27 +0100 From: Mauro Carvalho Chehab Cc: Chris Wilson , Bruce Chang , Daniel Vetter , David Airlie , Jani Nikula , John Harrison , Joonas Lahtinen , Lucas De Marchi , Matt Roper , Matthew Brost , Rodrigo Vivi , Tejas Upadhyay , Tvrtko Ursulin , Umesh Nerlige Ramappa , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Mika Kuoppala , Chris Wilson , Andi Shyti , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Mauro Carvalho Chehab Subject: [PATCH v2 2/3] drm/i915/gt: Serialize GRDOM access between multiple engine resets Date: Wed, 29 Jun 2022 16:25:25 +0100 Message-Id: <147cf88cd20e8ce75c7849ed5e4e913563657cdf.1656516220.git.mchehab@kernel.org> 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.5 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 Reported-by: Mika Kuoppala Signed-off-by: Chris Wilson Cc: Mika Kuoppala Reviewed-by: Andi Shyti Acked-by: Thomas Hellström Signed-off-by: Mauro Carvalho Chehab --- See [PATCH v2 0/3] at: https://lore.kernel.org/all/cover.1656516220.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