From mboxrd@z Thu Jan 1 00:00:00 1970 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 1FCAD2676C2; Mon, 24 Feb 2025 11:18:58 +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=1740395938; cv=none; b=OGAtUHz19n3lkljJCFv4nORER5coxTbDUALl699aavG0QxBhbMc380f/hefJv0vPDoVVM1pmf2124Emf/Jt3xLd+pxF5AIvl79NEuu2f7E49j7xN6SwOYSMn6Ymrth3s6XWDOR2sPLFsku06C1L+15bz2Utb3i36F9OLobzIFcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740395938; c=relaxed/simple; bh=MGspm5DkfuJ8cOn1jAlLcD2S6HvAO9CO4XO1ZQufBmk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tk7G/JU1rFSrYEwFqLIBIZ2KDiPCTiFboS5WQO+oD4MljEgqg6eHlSBtdBelIlSjYyqtpsGQWuEFb+ao80gzdqOnL/w8pDYKWa5xUbKIxE7x+rRtpEyZAnap0F+VUFA1PD4lGe5mJ8SA8ZKR5uFqsWiIeJ4XPApmzwkKCK/2ikY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bvn9fdSa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bvn9fdSa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34FD7C4CED6; Mon, 24 Feb 2025 11:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740395938; bh=MGspm5DkfuJ8cOn1jAlLcD2S6HvAO9CO4XO1ZQufBmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bvn9fdSa1IRA3kj72lLuHL3L0VAt8Z3/z6RFXqp9EzK7WlIjJ5C69wd18Au+zVV0H 84Qbu/3Qkw3ExLOQg7PwQKbTpfNFcoWgj+h2cuVO7ursqIAKcuYScd2kpOXfPks5UN KowA6gjQbfKrGUzqX1Z0Ke3FEyqPw5lNHz+NYQpB+0O5nRdixct2HplkB/l0AtvLTy Mkl4wCxmB/caszRVeV/AHPoIRzSixGdnKls0Ubo5Ud5RM488v80DebfJJRmlmbnRo2 RnxEiK+Fb2IJLY+bqULV2ejgDzkRZZDLcWUQ5K0+ZpZv/G10LD9JGqttEtzya21NFP XZRrLT3jbZRNw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cristian Ciocaltea , Mark Brown , 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, perex@perex.cz, tiwai@suse.com, venkataprasad.potturu@amd.com, peterz@infradead.org, gregkh@linuxfoundation.org, sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 18/28] ASoC: SOF: amd: Handle IPC replies before FW_BOOT_COMPLETE Date: Mon, 24 Feb 2025 06:17:49 -0500 Message-Id: <20250224111759.2213772-18-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250224111759.2213772-1-sashal@kernel.org> References: <20250224111759.2213772-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.12.16 Content-Transfer-Encoding: 8bit From: Cristian Ciocaltea [ Upstream commit ac84ca815adb4171a4276b1d44096b75f6a150b7 ] In some cases, e.g. during resuming from suspend, there is a possibility that some IPC reply messages get received by the host while the DSP firmware has not yet reached the complete boot state. Detect when this happens and do not attempt to process the unexpected replies from DSP. Instead, provide proper debugging support. Signed-off-by: Cristian Ciocaltea Link: https://patch.msgid.link/20250207-sof-vangogh-fixes-v1-3-67824c1e4c9a@collabora.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/amd/acp-ipc.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sound/soc/sof/amd/acp-ipc.c b/sound/soc/sof/amd/acp-ipc.c index b44b1b1adb6ed..cf3994a705f94 100644 --- a/sound/soc/sof/amd/acp-ipc.c +++ b/sound/soc/sof/amd/acp-ipc.c @@ -167,6 +167,7 @@ irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context) if (sdev->first_boot && sdev->fw_state != SOF_FW_BOOT_COMPLETE) { acp_mailbox_read(sdev, sdev->dsp_box.offset, &status, sizeof(status)); + if ((status & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) { snd_sof_dsp_panic(sdev, sdev->dsp_box.offset + sizeof(status), true); @@ -188,13 +189,21 @@ irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context) dsp_ack = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack_write); if (dsp_ack) { - spin_lock_irq(&sdev->ipc_lock); - /* handle immediate reply from DSP core */ - acp_dsp_ipc_get_reply(sdev); - snd_sof_ipc_reply(sdev, 0); - /* set the done bit */ - acp_dsp_ipc_dsp_done(sdev); - spin_unlock_irq(&sdev->ipc_lock); + if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) { + spin_lock_irq(&sdev->ipc_lock); + + /* handle immediate reply from DSP core */ + acp_dsp_ipc_get_reply(sdev); + snd_sof_ipc_reply(sdev, 0); + /* set the done bit */ + acp_dsp_ipc_dsp_done(sdev); + + spin_unlock_irq(&sdev->ipc_lock); + } else { + dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_BOOT_COMPLETE: %#x\n", + dsp_ack); + } + ipc_irq = true; } -- 2.39.5