From patchwork Thu Oct 12 19:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 733726 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 7D840CDB47E for ; Thu, 12 Oct 2023 19:21:31 +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 85853DEC; Thu, 12 Oct 2023 21:20:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 85853DEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697138489; bh=BRnHlyoq7yAJKhSu9/5yVO9C4zmQi49Pg9h69jtLTV0=; 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=WBAjSYUoXoyfvqW46DlHZK3DBtFjpYq0nhk1RZyce1PjeZ97sFsuS9yT6ju9Fu8R4 dO3eNtEHn0XAhdbQltpmfPPvjtf5CEruXAuCZ/2jDfdTy8p4kkrUyFti9+rOt1oTIo eWT1m4ekRjFLsnC2OKZgAUkiDHkm21PDslO0Erag= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BCF33F80587; Thu, 12 Oct 2023 21:19:28 +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 4C90DF80587; Thu, 12 Oct 2023 21:19:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DF62FF802BE; Thu, 12 Oct 2023 21:19:19 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A8405F8019B for ; Thu, 12 Oct 2023 21:19:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A8405F8019B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Z1sK9QmL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697138356; x=1728674356; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BRnHlyoq7yAJKhSu9/5yVO9C4zmQi49Pg9h69jtLTV0=; b=Z1sK9QmL/du0dqHCOseRAOgTlIw69YYprQv5Nwv32K/it3tX1qvglEkP qHtTzJG3jvMc9ZEJPA7anyrVhwwTlyhKPk/WCL5JcDDXRU2Esea3b7OsE jN1SYGmgUKaXtMXVcxkbdRzjIL+2nRghUfuTJmh80FewNXuhShYBOGIhM 40BfMwU4uUTeJTNUy3TJKPMgyQhmJh1yjHlsxQjOGJsk/4gteJJrlW8NZ BifeF/1rDlC604PuIANfo+AHwec+M7x/yvYUECo/xdNQvrzs3306iFA4s qVCOS8hCXWkG6Qz3/xaqwtXx/Zen1o3lUxcneq2X+aQZfAiTMg6KG10Xs g==; X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="383875357" X-IronPort-AV: E=Sophos;i="6.03,219,1694761200"; d="scan'208";a="383875357" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 12:19:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="1001628005" X-IronPort-AV: E=Sophos;i="6.03,219,1694761200"; d="scan'208";a="1001628005" Received: from gchoudha-mobl.amr.corp.intel.com (HELO pbossart-mobl3.hsd1.md.comcast.net) ([10.212.114.241]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 12:19:00 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Peter Ujfalusi , Guennadi Liakhovetski , Pierre-Louis Bossart Subject: [PATCH 2/4] ASoC: SOF: Intel: hda-dsp: Make sure that no irq handler is pending before suspend Date: Thu, 12 Oct 2023 15:18:48 -0400 Message-Id: <20231012191850.147140-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012191850.147140-1-pierre-louis.bossart@linux.intel.com> References: <20231012191850.147140-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: Q7ONY7ZD7LUWC6FPV6ASUZSXEAY53CT5 X-Message-ID-Hash: Q7ONY7ZD7LUWC6FPV6ASUZSXEAY53CT5 X-MailFrom: pierre-louis.bossart@linux.intel.com 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: Peter Ujfalusi In the existing IPC support, the reply to each IPC message is handled in an IRQ thread. The assumption is that the IRQ thread is scheduled without significant delays. On an experimental (iow, buggy) kernel, the IRQ thread dealing with the reply to the last IPC message before powering-down the DSP can be delayed by several seconds. The IRQ thread will proceed with register accesses after the DSP is powered-down which results in a kernel crash. While the bug which causes the delay is not in the audio stack, we must handle such cases with defensive programming to avoid such crashes. Call synchronize_irq() before proceeding to power down the DSP to make sure that no irq thread is pending execution. Closes: https://github.com/thesofproject/linux/issues/4608 Reviewed-by: Guennadi Liakhovetski Signed-off-by: Peter Ujfalusi Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/intel/hda-dsp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index 44f39a520bb3..2445ae7f6b2e 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -699,6 +699,9 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) if (ret < 0) return ret; + /* make sure that no irq handler is pending before shutdown */ + synchronize_irq(sdev->ipc_irq); + hda_codec_jack_wake_enable(sdev, runtime_suspend); /* power down all hda links */