Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp534045lqb; Thu, 29 Feb 2024 07:55:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpK2YFAWVC4Ywlvjfgfk+A5OFl6t8ViHWKAnjslxdzEt2w1zrPepkaknyjfi6O8aODMafGufDviUpGql7HWWSt5kgIOak/PxG9E7fxKA== X-Google-Smtp-Source: AGHT+IGlozxt+XJEbKGH/Y5neTHiwxF0Haf7UkWJF2eAK0stNRCVh5c1VdPwAdQVDkWekM2vNfnG X-Received: by 2002:a05:6870:8a13:b0:21f:2ab8:ee6a with SMTP id p19-20020a0568708a1300b0021f2ab8ee6amr2528297oaq.45.1709222130775; Thu, 29 Feb 2024 07:55:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709222130; cv=pass; d=google.com; s=arc-20160816; b=VNbfG3Ys/pkWdXCViHqc2Zi4xRprMGRcOILYb075j4K6uV5OK7kbfa70lbiW9LKgMw 3zbolW63p3P392UwSGqfL+DjdbCHs9EFY4eWCuKitV5pAdpkoA/8/GiShaYOaQCBgYA5 u6dEq+4pwiSq5gQHdBmZlDDhxWZhtuHosdRML3fTdi/ziud3//McPxp0fdWs+GUsVJ2W bkp+4Xe88ulBm/j+CkDpVsI4TWWh+nF+kpoy2AGRjHzqye3TtzN2/l4obdjcG36OhCIP rHT1iSoHe3V4BqS72/qaGrWkSdzrrL+KO2Icwopj9Dg3Dc07CrxAy4tIqt7LBvQziQdW NDGw== 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=kFWZw744EcQSGWgdv1pPA7RJmX/AlwGGMtko62dJPrU=; fh=bxtJd25u6R2H7hRjcRT0m8ncJ9sV0hPJnwt7JP23KjU=; b=weXzdQQ0O/7+iXdnM7/nQAaXzigK3MHsgrxfr7ix8P02X+E2cctkmxDt1Kg3mW2xTz huBQ/Ut1IspXKQsLe6dTfhTUWYI8zHjEBKkjCeTdSwDOQwurCRGnQetrlr+r4VXe6HEd AnxY4ZclKN1ZT+LY4YDGyU7sqOUz1dCTkzIQZq93cC521U2LucOfOrH0dgPxc6VU/ofd aly4wzmjfRx2vH5A403LMKLZaMNJNXTgny5bspMQ8WJvUldsU7yA6VEFpx6GgcxzeCug mI8RSZPaEHbn0yeai5mn55N+G0hoIm1sz24L9GKHWkRCs6NAxuWA59CvoZtUhcV7Auby FMTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qu+PETy8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86971-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86971-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ye2-20020a05620a3b8200b00787bd076607si1641742qkn.450.2024.02.29.07.55.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:55:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86971-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qu+PETy8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86971-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86971-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 80F911C21764 for ; Thu, 29 Feb 2024 15:55:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4AEC4AEFA; Thu, 29 Feb 2024 15:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qu+PETy8" 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 C1B744AEDC; Thu, 29 Feb 2024 15:49:33 +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=1709221773; cv=none; b=fqJKESXSIcCNhjuODLKpPHM7dbLZkoMbEIquuLf+idPMgpu7NOPhZMwmZSz7BVl2Y8tJy9/G1GGQFiWMXHDfjrxwC2mU+mmIA+NvK/6efK+nlbU6YQ8eQJ0f6nuJmku34vyJd+AchZsrnLyui0Rib+4Icd/oGOrnYiyLYr++HgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709221773; c=relaxed/simple; bh=I+vVsVM23mkEKCiSNKy8dYWHbX1Qn5lawkbweNDKI1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fcUi5ZtHpOmM8pnXmPcSeV1OiGtvFj9K+2ZHPBCoH/T5/idC+Osq50Ivvm1Dbrye0iDdelHYr99eJjfvlMA35aJTuJjMxHSz8scFYm6PGYmCbLuwHP166vRKsVEOSqqYnfEzYzyTaGEIx5mmAd3jhB0Z85eBDZqdIcp0J5QJE/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qu+PETy8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1343C43399; Thu, 29 Feb 2024 15:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709221773; bh=I+vVsVM23mkEKCiSNKy8dYWHbX1Qn5lawkbweNDKI1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qu+PETy8IjPRBrbkWj7WhHnzcR+SmhM2hBKCSasL1wdoIEvzUXHldgWYfIw8nt2Cn FD3Gl63jGYYhd9YZjprh1+43F47DeMbcDcfovwOQcFQcqP/vbxmeQOuzZAeTs4qXxD VKocXYHLdEyGEt9dNreOfe1cVeqTufQj3FrM95zT8zmj3MKt0LbZR/7ymuAGO75bxu /X9dbuKO28lEKcTX5c+wVBiJHOFfzZmRSwpKxgFBWqC7VW2yP5yr9uZeZueHuiwalj 3S7SRE7Cgm/YEzImKRKK2GJ6xuWGtYtMmoMqfrJg/06ARwIeu0Rz1FWxEaYJhfJz1y F9+RIL+UrJ5KA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Ujfalusi , Ranjani Sridharan , Pierre-Louis Bossart , Bard Liao , Mark Brown , Sasha Levin , lgirdwood@gmail.com, daniel.baluta@nxp.com, perex@perex.cz, tiwai@suse.com, sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org Subject: [PATCH AUTOSEL 6.7 23/26] ASoC: SOF: ipc4-pcm: Workaround for crashed firmware on system suspend Date: Thu, 29 Feb 2024 10:48:42 -0500 Message-ID: <20240229154851.2849367-23-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229154851.2849367-1-sashal@kernel.org> References: <20240229154851.2849367-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.7.6 Content-Transfer-Encoding: 8bit From: Peter Ujfalusi [ Upstream commit c40aad7c81e5fba34b70123ed7ce3397fa62a4d2 ] When the system is suspended while audio is active, the sof_ipc4_pcm_hw_free() is invoked to reset the pipelines since during suspend the DSP is turned off, streams will be re-started after resume. If the firmware crashes during while audio is running (or when we reset the stream before suspend) then the sof_ipc4_set_multi_pipeline_state() will fail with IPC error and the state change is interrupted. This will cause misalignment between the kernel and firmware state on next DSP boot resulting errors returned by firmware for IPC messages, eventually failing the audio resume. On stream close the errors are ignored so the kernel state will be corrected on the next DSP boot, so the second boot after the DSP panic. If sof_ipc4_trigger_pipelines() is called from sof_ipc4_pcm_hw_free() then state parameter is SOF_IPC4_PIPE_RESET and only in this case. Treat a forced pipeline reset similarly to how we treat a pcm_free by ignoring error on state sending to allow the kernel's state to be consistent with the state the firmware will have after the next boot. Link: https://github.com/thesofproject/sof/issues/8721 Signed-off-by: Peter Ujfalusi Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Link: https://msgid.link/r/20240213115233.15716-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/ipc4-pcm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c index 39039a647cca3..ea70c0d7cf75a 100644 --- a/sound/soc/sof/ipc4-pcm.c +++ b/sound/soc/sof/ipc4-pcm.c @@ -413,7 +413,18 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component, ret = sof_ipc4_set_multi_pipeline_state(sdev, state, trigger_list); if (ret < 0) { dev_err(sdev->dev, "failed to set final state %d for all pipelines\n", state); - goto free; + /* + * workaround: if the firmware is crashed while setting the + * pipelines to reset state we must ignore the error code and + * reset it to 0. + * Since the firmware is crashed we will not send IPC messages + * and we are going to see errors printed, but the state of the + * widgets will be correct for the next boot. + */ + if (sdev->fw_state != SOF_FW_CRASHED || state != SOF_IPC4_PIPE_RESET) + goto free; + + ret = 0; } /* update RUNNING/RESET state for all pipelines that were just triggered */ -- 2.43.0