From patchwork Fri May 12 10:46:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13239117 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 5EED2C77B7C for ; Fri, 12 May 2023 10:47:12 +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 CF8561CF; Fri, 12 May 2023 12:46:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CF8561CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683888429; bh=7Yburk4J7kP1O6+ALrvVlE7BSY6UOZt+Xvv4X6uRyHw=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=HG9Nu9SD4lqrwjTKfkkGlrDW6t4MDc1MTFRmIp6P8r62W8OzSG3u3spUxDMrqyDTi XkgMnvn9BN++tXI43wvsqOJIn5BuIHKXP23q74UA3awRK2Uzg3RYDSDbE1zUazuYSl /p8CuXxvgotG/FuE8u1X05Tp8goS/u6e8rxfcCt4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 77AFFF80542; Fri, 12 May 2023 12:45:57 +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 1F45FF80087; Fri, 12 May 2023 12:45:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 210A0F8052E; Fri, 12 May 2023 12:45:53 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 05168F802E8 for ; Fri, 12 May 2023 12:45:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05168F802E8 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=SGxP3JpR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683888351; x=1715424351; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7Yburk4J7kP1O6+ALrvVlE7BSY6UOZt+Xvv4X6uRyHw=; b=SGxP3JpRzxEOZGKCDAEXd7p37+PXVi7MwtXnFgWY40ezhNtu8hJBWqLx kqnC+wamgO8HhJeWY+GknD9GlEAhV1Lbiio3MEABX9s3bjurr0m1TCEr1 b77qjO5oSQZiP1PYQuee3S27iZ+/QhzMLZIehNPXBOiGkuWmdw7I1dzmK nkBZSMbvJqKYn3zG/phqipGDoZVqXqAB53MgGzTfjS8+xJRdjEedCn3aI 2DIqo8R3PDdZwrNoxsr7xZtM4rlkns4EgXX9YU1EcdmS6x1gohwKL0RfC ANWUISfpTARQVJ59BnK7V6urqhPHcH2tiAnQzsIsF4qZQjLFcifH/LkSn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="416392873" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="416392873" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 03:45:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="733004371" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="733004371" Received: from nhanph1x-mobl.amr.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.249.38.84]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 03:45:44 -0700 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, cujomalainey@chromium.org Subject: [PATCH] ASoC: SOF: pm: save io region state in case of errors in resume Date: Fri, 12 May 2023 13:46:38 +0300 Message-Id: <20230512104638.21376-1-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Message-ID-Hash: SIMKOX2LWQVKAAU3T4TEW27MZBAFZF7Z X-Message-ID-Hash: SIMKOX2LWQVKAAU3T4TEW27MZBAFZF7Z X-MailFrom: peter.ujfalusi@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: Kai Vehmanen If there are failures in DSP runtime resume, the device state will not reach active and this makes it impossible e.g. to retrieve a possible DSP panic dump via "exception" debugfs node. If CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE=y is set, the data in cache is stale. If debugfs cache is not used, the region simply cannot be read. To allow debugging these scenarios, update the debugfs cache contents in resume error handler. User-space can then later retrieve DSP panic and other state via debugfs (requires SOF debugfs cache to be enabled in build). Reported-by: Curtis Malainey Link: https://github.com/thesofproject/linux/issues/4274 Signed-off-by: Kai Vehmanen Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Curtis Malainey Reviewed-by: Péter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/pm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index 2fdbc53ca715..2b232442e84b 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -164,7 +164,7 @@ static int sof_resume(struct device *dev, bool runtime_resume) ret = tplg_ops->set_up_all_pipelines(sdev, false); if (ret < 0) { dev_err(sdev->dev, "Failed to restore pipeline after resume %d\n", ret); - return ret; + goto setup_fail; } } @@ -178,6 +178,18 @@ static int sof_resume(struct device *dev, bool runtime_resume) dev_err(sdev->dev, "ctx_restore IPC error during resume: %d\n", ret); } +setup_fail: +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) + if (ret < 0) { + /* + * Debugfs cannot be read in runtime suspend, so cache + * the contents upon failure. This allows to capture + * possible DSP coredump information. + */ + sof_cache_debugfs(sdev); + } +#endif + return ret; }