From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E721C7EE2C for ; Thu, 25 May 2023 18:35:50 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 47FA83E8; Thu, 25 May 2023 20:34:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 47FA83E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685039743; bh=mfi9pA8TtpQSlQKzzbalZaPXkKkmtsGD+l1SjdXJ0yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KA8GMJs6YVGKiEhmBrhROzhKio17Ldg2Xgg/ZW84wjt31OEwyuT89xfGhagycOORo Oz8RVrKYp7JmFwjtbzhJyCsQY3djzvanqaPsxpMF4X541GKz1/pfyfpzWB2HKjdq/7 td4otclbGxPBR0OAwsJSmeIC1DeZ4gItXeL2z20g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D02B8F80553; Thu, 25 May 2023 20:34:11 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 0BAEAF80553; Thu, 25 May 2023 20:34:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 14636F80544; Thu, 25 May 2023 20:34:07 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DE4B0F80007; Thu, 25 May 2023 20:34:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DE4B0F80007 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=jMmhHDXj 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 D0A2E60BA8; Thu, 25 May 2023 18:34:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFCD1C43446; Thu, 25 May 2023 18:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685039641; bh=mfi9pA8TtpQSlQKzzbalZaPXkKkmtsGD+l1SjdXJ0yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMmhHDXjlkRpJASzSF9KjbU/al7RDFy/oyrMSzeH1lXy5Kta8j08ftqGGluFT3xiw 4bMz1s7XsoNB5qunFzwSiLF7PFzc58qGSGC488/gbO/gCDVna6b3JNuIotmQzle4/a 5DvPMTwLufzddSPZQT58eX+a09KYKL9l61nJIIIHWJjOOEEyBWvx4c4KZcv4AHe1m4 093WFaYrXtq8QFoO6Lx5Ex0+T5My4Y2D9HyhId4uPZDh4r42/5xqXO0m2GHlhIT9ge K4nazGzymsbPEr7m+Wh6wcaIODFsrSJpk4DfYnIwpIiwXQe+bjCsEUOxRALnSEWR1V a8cDifdUxrw8g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Sasha Levin , lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, sound-open-firmware@alsa-project.org, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 6.3 31/67] ASoC: SOF: debug: conditionally bump runtime_pm counter on exceptions Date: Thu, 25 May 2023 14:31:08 -0400 Message-Id: <20230525183144.1717540-31-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525183144.1717540-1-sashal@kernel.org> References: <20230525183144.1717540-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Message-ID-Hash: BTBYHCE6LTI2G7KMJQTF5WCGV4ILW6NV X-Message-ID-Hash: BTBYHCE6LTI2G7KMJQTF5WCGV4ILW6NV X-MailFrom: sashal@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart [ Upstream commit 3de975862f985f1c9e225a0d13aa3d501373f7c3 ] When a firmware IPC error happens during a pm_runtime suspend, we ignore the error and suspend anyways. However, the code unconditionally increases the runtime_pm counter. This results in a confusing configuration where the code will suspend, resume but never suspend again due to the use of pm_runtime_get_noresume(). The intent of the counter increase was to prevent entry in D3, but if that transition to D3 is already started it cannot be stopped. In addition, there's no point in that case in trying to prevent anything, the firmware error is handled and the next resume will re-initialize the firmware completely. This patch changes the logic to prevent suspend when the device is pm_runtime active and has a use_count > 0. Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c index ade0507328af4..5042312b1b98d 100644 --- a/sound/soc/sof/debug.c +++ b/sound/soc/sof/debug.c @@ -437,8 +437,8 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev, const char *msg) /* should we prevent DSP entering D3 ? */ if (!sdev->ipc_dump_printed) dev_info(sdev->dev, - "preventing DSP entering D3 state to preserve context\n"); - pm_runtime_get_noresume(sdev->dev); + "Attempting to prevent DSP from entering D3 state to preserve context\n"); + pm_runtime_get_if_in_use(sdev->dev); } /* dump vital information to the logs */ -- 2.39.2