Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2135785lqb; Mon, 27 May 2024 08:59:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFPmjSSY4dys/JCWRg6bbnFkh3Q/CVEdhck2OyppY0SUrAZzGmGCY9+4dm/LgUXNarRu0tqK/P373VHR1dE8l7KbojDjddBwpY4UEB1Q== X-Google-Smtp-Source: AGHT+IG3ihdyFgjs7Qxb1AhmvI7LzewrnIsxnxzGRxL6KGo1wd9DZ/9+A4YgFaolwlnzOHcE5xpQ X-Received: by 2002:a05:6a21:3417:b0:1af:d1f0:b350 with SMTP id adf61e73a8af0-1b212dc14d2mr9464066637.22.1716825546746; Mon, 27 May 2024 08:59:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716825546; cv=pass; d=google.com; s=arc-20160816; b=OIsBk0XlfhE+Xfcm+g/JyhNja2dVmwHgGprhVNEoM2FO3Z4CfqA5s5FI2nZj1xRJsA +xqPTx/CR23kTsBjYxLJkCy+kEgqGfGFibpWnZjGC0yseu70p13yuzd9Y4qJjlrbRZA+ S6mi0w9erfE/weoijIppEczBmCnoSs381jp8YC95MYKwLbf3W+lxcvcd79yTaVtDRf08 wp85vTr4QmqJkrHAxBP/blkU1JVvuqZUqAfvE0epaH1Zz9QFB6x176yc9KEzYnWF1RYy IV7XF1U3ac1Y2UgaqTv13Al5wdbf3ECQwuFxc/XgHKCdvQu+SDIhUcSmpRq8z9zCga68 /JAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=akuzXHmY/MBiU9vRjZTDdQOHettslnWmmTqmiMvQn28=; fh=WhD81fWBaFAG5U2HvSXuLo5kTBRNwCB0qBSmUcS+MBE=; b=LlgWL3Q4V5aESY+b/diE+CPJwIBqA0FBIuT5amei2X/dKoomomkZtSYotd7KupTOHR +YhJdHDkudBkv33CxjgkZfKVhRkaVIvRWuuZg5G3Ta7nwxQewR6watTaBsZt7bwatJ0d 7nsEuvs6bsnSSoxv696a16ceYHqto93rLFdfFkKxNsbsOLFzVmUP1DSXHfUFOxEsFyeh htw/9Ez2i4IDz+HmOyKT7mePHqUjbRHf1dm56hRE/mJhyJ6mAvnMGgMq3Qy+F7/bxmyQ FIVNuyfO31YSA3o//hgW+OVTSxwGa1G8Hcv7bQPz3XpKfUphuFw9T7Ok1T/VDbZtufRH 1/gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=owC2v79c; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c7856c6si63439625ad.90.2024.05.27.08.59.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=owC2v79c; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AA69B288022 for ; Mon, 27 May 2024 15:51:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2471F73463; Mon, 27 May 2024 15:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="owC2v79c" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47DC17344F; Mon, 27 May 2024 15:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825103; cv=none; b=pcmhRjQDjGMAu59NnF09SrZTvt0+uberoG1He4uw1KlI3OyJ1kdkHgvXt3POHz4Issv3Jaz4TIE/wD+SCfG3+AtBwiutJFTsQdjnZLlnFnQcNV6s/0MUf2HIwWaQLwTuA5voyiHOtJ623UiQiqVCYIF6MakUYLFw3rypR/V3SEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825103; c=relaxed/simple; bh=FlBZCzmT0a6aZg1CQ2btL1d7i3NzplDFKuGezfER560=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GOjdtFrXn7Yu2a6l3qmhtrSqzrcE08o2H2TWr+W6jwFhY1T4OjOCoyG5lOiGdJN7snMMFl+vdDS1YMRzSajoqjhb2y18KHKPYOXeixE5gyEF3e5eGg6ATMN3qcr7F000RkwWI+J4Zwa/kHWzUsWybiV3S395K2j3ifJLkkLyx4I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=owC2v79c; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57D10C4AF07; Mon, 27 May 2024 15:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716825102; bh=FlBZCzmT0a6aZg1CQ2btL1d7i3NzplDFKuGezfER560=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owC2v79ce3AwK8Jqpu75DyIMdP8wI0HAWP49jlHdAtHthPHjltVrZOJDS1CtCRFUU OvI01Wsmh7wjkrpfx9QMkAvuaaTP6gEUtoMpC+ujZKrEvVM5Ta+H4gZSxb1Hy1TkDZ fkVpYz+JhmPZmnMuXBJOctVlvJ+u4YkuUsaL/oFlOJykhp3imluZmQoSWkE8AMtG/R iboP6sYf1yCwNX5KISBDgiqBFxIKG4rdR5/KltS2pKuPdQBf6hu1LQYkKXDPFT5LNj Wq3ie7XrfFnMKEy1gKj7CubjWGZND3DxRBcNws+oyGofyP+3SMizFdBb3MlePSflZp +mNoDjSp8Tbgg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Kazlauskas , Duncan Ma , Wayne Lin , Daniel Wheeler , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, chiahsuan.chung@amd.com, samson.tam@amd.com, dillon.varone@amd.com, alvin.lee2@amd.com, jinze.xu@amd.com, Qingqing.Zhuo@amd.com, cruise.hung@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.9 02/23] drm/amd/display: Workaround register access in idle race with cursor Date: Mon, 27 May 2024 11:50:03 -0400 Message-ID: <20240527155123.3863983-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527155123.3863983-1-sashal@kernel.org> References: <20240527155123.3863983-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.2 Content-Transfer-Encoding: 8bit From: Nicholas Kazlauskas [ Upstream commit b5b6d6251579a29dafdad25f4bc7f3ff7bfd2c86 ] [Why] Cursor update can be pre-empted by a request for setting target flip submission. This causes an issue where we're in the middle of the exit sequence trying to log to DM, but the pre-emption starts another DMCUB command submission that requires being out of idle. The DC lock aqusition can fail, and depending on the DM/OS interface it's possible that the function inserted into this thread must not fail. This means that lock aqusition must be skipped and exit *must* occur. [How] Modify when we consider idle as active. Consider it exited only once the exit has fully finished. Consider it as entered prior to actual notification. Since we're on the same core/thread the cached values are coherent and we'll see that we still need to exit. Once the cursor update resumes it'll continue doing the double exit but this won't cause a functional issue, just a (potential) redundant operation. Reviewed-by: Duncan Ma Acked-by: Wayne Lin Signed-off-by: Nicholas Kazlauskas Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c index 6083b1dcf050a..a72e849eced3f 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c +++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c @@ -1340,16 +1340,27 @@ void dc_dmub_srv_apply_idle_power_optimizations(const struct dc *dc, bool allow_ * Powering up the hardware requires notifying PMFW and DMCUB. * Clearing the driver idle allow requires a DMCUB command. * DMCUB commands requires the DMCUB to be powered up and restored. - * - * Exit out early to prevent an infinite loop of DMCUB commands - * triggering exit low power - use software state to track this. */ - dc_dmub_srv->idle_allowed = allow_idle; - if (!allow_idle) + if (!allow_idle) { dc_dmub_srv_exit_low_power_state(dc); - else + /* + * Idle is considered fully exited only after the sequence above + * fully completes. If we have a race of two threads exiting + * at the same time then it's safe to perform the sequence + * twice as long as we're not re-entering. + * + * Infinite command submission is avoided by using the + * dm_execute_dmub_cmd submission instead of the "wake" helpers. + */ + dc_dmub_srv->idle_allowed = false; + } else { + /* Consider idle as notified prior to the actual submission to + * prevent multiple entries. */ + dc_dmub_srv->idle_allowed = true; + dc_dmub_srv_notify_idle(dc, allow_idle); + } } bool dc_wake_and_execute_dmub_cmd(const struct dc_context *ctx, union dmub_rb_cmd *cmd, -- 2.43.0