From patchwork Tue Feb 14 10:33:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13139823 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 67350C05027 for ; Tue, 14 Feb 2023 10:36:23 +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 A56E583D; Tue, 14 Feb 2023 11:35:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A56E583D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1676370980; bh=5VEJ6MXEP5XiVLpv57NzbmlsX2XekypFLVobUf4A1QQ=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=OEIvmxt5AEHtqw+VVesHK3jDyFenx1pMl7DqMvSPW6KLr8b7DBhH44u0nofXyl3W0 rjS1VM5VpHUIvLc+Cca+vOqWB/tXFkEoRNDCbF7DI6lWq96ZRI3Ibrfx2atQV8ouzy 7LidLj20QkgX20DZazuZ0yqCNMLvTu+HcSiUoJp8= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 499F9F80548; Tue, 14 Feb 2023 11:33:59 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CECB2F8052D; Tue, 14 Feb 2023 11:33:53 +0100 (CET) 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 AE51CF8001E for ; Tue, 14 Feb 2023 11:33:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AE51CF8001E 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=CjkIyfK8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676370826; x=1707906826; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5VEJ6MXEP5XiVLpv57NzbmlsX2XekypFLVobUf4A1QQ=; b=CjkIyfK8hWmgshmHCdw8mtRcQ5TAezoXe5iI0Nk4zeVAKIqJ2T9SYDFL xDMzXU26QUEtdRCkIUwtX1MY4/aiL5fhln21WkMaReAjng0gi7alYA2RL UkndAlB0H4EKUK8s9LaXkTUQ3T3hS4xzeN1IBd3/zyfhMrOF1ReTAYg0T 1BoliWBanW3Gj2nd091n1VKMwY0rkFW2E5K09bAlQBrAHtb28M9dy11x7 b6k1/v1aya3rP3Myp1mC6HhlsAfqmkxKUcIxA9dbPI/VDXKsTpGtZ8Ubu Yw3JgJ1ZS5lBurFZXmaeROaVED2O8OYRziaC6YN6bt9TuXpbNxARvb+ct A==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="395745409" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="395745409" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:36 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="811971897" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="811971897" Received: from unknown (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.18.43]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:34 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Subject: [PATCH 1/5] ASoC: SOF: Introduce a new set_pm_gate() IPC PM op Date: Tue, 14 Feb 2023 12:33:41 +0200 Message-Id: <20230214103345.30669-2-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> References: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 5GSPE4WZY6QCNCMRY462GPSYEYDTROHE X-Message-ID-Hash: 5GSPE4WZY6QCNCMRY462GPSYEYDTROHE 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 CC: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, rander.wang@intel.com 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: Rander Wang Set_pm_gate depends on ipc version. This patch defines the ops for both IPC3 and IPC4. Signed-off-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc3.c | 18 ++++++++++++++++++ sound/soc/sof/ipc4.c | 13 +++++++++++++ sound/soc/sof/sof-priv.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/sound/soc/sof/ipc3.c b/sound/soc/sof/ipc3.c index 8e936353c1c0..3de64ea2dc9a 100644 --- a/sound/soc/sof/ipc3.c +++ b/sound/soc/sof/ipc3.c @@ -1077,10 +1077,28 @@ static int sof_ipc3_ctx_restore(struct snd_sof_dev *sdev) return sof_ipc3_ctx_ipc(sdev, SOF_IPC_PM_CTX_RESTORE); } +static int sof_ipc3_set_pm_gate(struct snd_sof_dev *sdev, u32 flags) +{ + struct sof_ipc_pm_gate pm_gate; + struct sof_ipc_reply reply; + + memset(&pm_gate, 0, sizeof(pm_gate)); + + /* configure pm_gate ipc message */ + pm_gate.hdr.size = sizeof(pm_gate); + pm_gate.hdr.cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE; + pm_gate.flags = flags; + + /* send pm_gate ipc to dsp */ + return sof_ipc_tx_message_no_pm(sdev->ipc, &pm_gate, sizeof(pm_gate), + &reply, sizeof(reply)); +} + static const struct sof_ipc_pm_ops ipc3_pm_ops = { .ctx_save = sof_ipc3_ctx_save, .ctx_restore = sof_ipc3_ctx_restore, .set_core_state = sof_ipc3_set_core_state, + .set_pm_gate = sof_ipc3_set_pm_gate, }; const struct sof_ipc_ops ipc3_ops = { diff --git a/sound/soc/sof/ipc4.c b/sound/soc/sof/ipc4.c index f3c0c839d177..b27ec16ebdfa 100644 --- a/sound/soc/sof/ipc4.c +++ b/sound/soc/sof/ipc4.c @@ -656,9 +656,22 @@ static int sof_ipc4_ctx_save(struct snd_sof_dev *sdev) return sof_ipc4_set_core_state(sdev, SOF_DSP_PRIMARY_CORE, false); } +static int sof_ipc4_set_pm_gate(struct snd_sof_dev *sdev, u32 flags) +{ + struct sof_ipc4_msg msg = {{0}}; + + msg.primary = SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_MOD_SET_D0IX); + msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); + msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG); + msg.extension = flags; + + return sof_ipc4_tx_msg(sdev, &msg, 0, NULL, 0, true); +} + static const struct sof_ipc_pm_ops ipc4_pm_ops = { .ctx_save = sof_ipc4_ctx_save, .set_core_state = sof_ipc4_set_core_state, + .set_pm_gate = sof_ipc4_set_pm_gate, }; static int sof_ipc4_init(struct snd_sof_dev *sdev) diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 14f7adb2dc12..5f919162a555 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -425,11 +425,13 @@ struct sof_ipc_fw_tracing_ops { * @ctx_save: Optional function pointer for context save * @ctx_restore: Optional function pointer for context restore * @set_core_state: Optional function pointer for turning on/off a DSP core + * @set_pm_gate: Optional function pointer for pm gate settings */ struct sof_ipc_pm_ops { int (*ctx_save)(struct snd_sof_dev *sdev); int (*ctx_restore)(struct snd_sof_dev *sdev); int (*set_core_state)(struct snd_sof_dev *sdev, int core_idx, bool on); + int (*set_pm_gate)(struct snd_sof_dev *sdev, u32 flags); }; /** From patchwork Tue Feb 14 10:33:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13139820 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 5303CC61DA4 for ; Tue, 14 Feb 2023 10:35:33 +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 B2CA574C; Tue, 14 Feb 2023 11:34:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B2CA574C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1676370930; bh=hQPg55Q3ODAvxY9tx/1PrJXLg3JGg4VzaZVnmlcD7to=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FvMzTzJwbECxFtYgkQIWUsJt2ihy8L438Xn193aQqadTzNDgwkAbfhWDgTwLStPfn j9SObNJUkfaxKbQ2+3+F85b3HhMetwpgQHAe3h3JSnaqYI1P+Sx1mAS1oW8dv/4Yya dy59wl6GDZ3/I2xRGyZmJ6I7+LtC1M3QnIzrmp40= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 27A03F80526; Tue, 14 Feb 2023 11:33:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CDBC6F800E4; Tue, 14 Feb 2023 11:33:46 +0100 (CET) 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 B122FF800E4 for ; Tue, 14 Feb 2023 11:33:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B122FF800E4 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=fGp6ergp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676370820; x=1707906820; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hQPg55Q3ODAvxY9tx/1PrJXLg3JGg4VzaZVnmlcD7to=; b=fGp6ergp4FH7HxUfiQefhv/Ob9ADMBfqZFuxDhOqXYN2jlgIdSgLwil1 jX0kAddXMvWQnB5QQ3856DTCpv8tci+L3GJnazQyH3HBJtQNZ7lcQ0Yhh kRr5DZDLZG/E55qtqiaF2zd6dlKOOnuby1X8bT890/uB3tTfELvZ3IgSf uCX4sPBKpUMwfiKpIYUefOAn2LznqygEXeU8OKxd/hI+ETDTluHlgNxW4 GwUkevSoy4RPg34MSkaiiKKH9+50xkoYQhn+EL4nSI6L99PpE9rTVw827 eRSRcWObkHLP8MMrkudQaiZTdjI7553qFx9sSyNzipG6Ls6xU12kgarzf g==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="395745421" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="395745421" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="811971902" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="811971902" Received: from unknown (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.18.43]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:37 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Subject: [PATCH 2/5] ASoC: SOF: Intel: hda-dsp: use set_pm_gate according to ipc version Date: Tue, 14 Feb 2023 12:33:42 +0200 Message-Id: <20230214103345.30669-3-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> References: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: PVGHCDB322MQUKJMFXPYMQXHCMXFOHMN X-Message-ID-Hash: PVGHCDB322MQUKJMFXPYMQXHCMXFOHMN 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 CC: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, rander.wang@intel.com 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: Rander Wang Use set_pm_gate to unify pm gate setting for different ipc version. Signed-off-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/hda-dsp.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index b4eacae8564c..e34fe0c9bcde 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -364,19 +364,12 @@ static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev) static int hda_dsp_send_pm_gate_ipc(struct snd_sof_dev *sdev, u32 flags) { - struct sof_ipc_pm_gate pm_gate; - struct sof_ipc_reply reply; + const struct sof_ipc_pm_ops *pm_ops = sof_ipc_get_ops(sdev, pm); - memset(&pm_gate, 0, sizeof(pm_gate)); + if (pm_ops && pm_ops->set_pm_gate) + return pm_ops->set_pm_gate(sdev, flags); - /* configure pm_gate ipc message */ - pm_gate.hdr.size = sizeof(pm_gate); - pm_gate.hdr.cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE; - pm_gate.flags = flags; - - /* send pm_gate ipc to dsp */ - return sof_ipc_tx_message_no_pm(sdev->ipc, &pm_gate, sizeof(pm_gate), - &reply, sizeof(reply)); + return 0; } static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) From patchwork Tue Feb 14 10:33:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13139821 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 B56E1C05027 for ; Tue, 14 Feb 2023 10:35:41 +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 CF36184D; Tue, 14 Feb 2023 11:34:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CF36184D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1676370939; bh=Jb/5D9CNBPsYmzXsESctFqxPLV4ldnW34RK779GuQ1s=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rRkeA2bkV5XEZvTUhuPzzYqrzs2QOkeVtWl2LR6zN0jm0rq7bM7usP7EqBkDArVom zqU/R4pd/x4t0aB0O1Qf00oRdH4ipXfWwAfxYAFdoW/I5dVzEuYRCb2h3/cJnNQv9A 3FOrO9XWZxrF4KWIuzrpNTtG7A4Elo5ejH1i1lLc= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 10654F8052D; Tue, 14 Feb 2023 11:33:55 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 81810F804B2; Tue, 14 Feb 2023 11:33:48 +0100 (CET) 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 0CA92F800F0 for ; Tue, 14 Feb 2023 11:33:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0CA92F800F0 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=ZWlT557p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676370823; x=1707906823; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jb/5D9CNBPsYmzXsESctFqxPLV4ldnW34RK779GuQ1s=; b=ZWlT557pCZmB2vzLorDX62LjkyifQZl1VjvQzD6sxs4RN7h2i+TR4HSB MHwPZmIJbBoUXnBVtMD3GunIXatMMV/DIjXcBk52nbMWm7o57ZRqFn3Iw exw+RrA4+fbF7FRNGl2yGWjHvprUIIXZL3MMDzT527GUf2ZQyX+o7heba XjNpd0Kh/DQHhCSWKd1FWowI49QBDmPeCG3lcRZsDmZyyLgXlAqzu/pnq +gukmp5B5FOATUNOZz7f2o5DPupmTb0gu1xwNw2SgBg5Jkzc75ICE0lvK zp+XpFvaCLomU2KOGcbVYbTk3CH593XQ+JVSdh/oslwcLSCoG8NI4lzNl Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="395745433" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="395745433" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:41 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="811971908" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="811971908" Received: from unknown (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.18.43]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:39 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Subject: [PATCH 3/5] ASoC: SOF: ipc4: Wake up dsp core before sending ipc msg Date: Tue, 14 Feb 2023 12:33:43 +0200 Message-Id: <20230214103345.30669-4-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> References: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: LVUYEZPEUQGK2FOJ5BGBOIEBAL3KRYP2 X-Message-ID-Hash: LVUYEZPEUQGK2FOJ5BGBOIEBAL3KRYP2 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 CC: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, rander.wang@intel.com 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: Rander Wang The driver shall update the power state to D0i0 before sending a generic IPC. Power-related IPCs are the exception to the rule, they may be sent even when the power-state is D0i3 Signed-off-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc4.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/sof/ipc4.c b/sound/soc/sof/ipc4.c index b27ec16ebdfa..8ede4b952997 100644 --- a/sound/soc/sof/ipc4.c +++ b/sound/soc/sof/ipc4.c @@ -370,6 +370,17 @@ static int sof_ipc4_tx_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_ if (!msg_data) return -EINVAL; + if (!no_pm) { + const struct sof_dsp_power_state target_state = { + .state = SOF_DSP_PM_D0, + }; + + /* ensure the DSP is in D0i0 before sending a new IPC */ + ret = snd_sof_dsp_set_power_state(sdev, &target_state); + if (ret < 0) + return ret; + } + /* Serialise IPC TX */ mutex_lock(&ipc->tx_mutex); From patchwork Tue Feb 14 10:33:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13139822 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 E1BFCC61DA4 for ; Tue, 14 Feb 2023 10:35:59 +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 8AD7A20F; Tue, 14 Feb 2023 11:35:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8AD7A20F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1676370957; bh=EV3KUHudqsxWRyx9RPZgbwJYDSg6T1d0WVQDenLg5co=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HkpLzr5QCw2vh5RsrrgtFHlz0xcBbZasN4iUqb2apw/C+jtCYsv2iSt4oi8K648eT t+NtOLeOoPStvBzrkgHrJlgC/xYXBhpEJG/KA2wJEqnil5S40yWkkTFTU+tcFXQNii 2Z6ba/fxjRJJtqF70/+NygUnlbXEznUwHew39QrY= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C282EF8053B; Tue, 14 Feb 2023 11:33:57 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CC3E1F80526; Tue, 14 Feb 2023 11:33:51 +0100 (CET) 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 2613BF801C0 for ; Tue, 14 Feb 2023 11:33:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2613BF801C0 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=FSYjFUA5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676370825; x=1707906825; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EV3KUHudqsxWRyx9RPZgbwJYDSg6T1d0WVQDenLg5co=; b=FSYjFUA5paVNYLtkQT+pLiBk2vrxQk+izkeO8taI7qN58gCsa7dgd2cc 2g2PHp5qrP4fmGGmwfl/vRqN4hp8aEPbFrxPZKpmjg/Pv4RbEmYcQI/Eq PGXwm8uz0EDB+7NMsZJhh+7Fr+lz9MsidKnI+qplRcjphcnf/3/K8dao3 iVswPmHk0REojOoM/xPMYCmMI+Hjruiv861WbDqw4/rOtzpVWj1iad/Kl hgaymSG6zZ6u5kbNNOhmDfpxOCixlhJEoIH0ujQKbswMgKCCmTwGr84nZ wTPQUDdA9++M3oA1FZDqpf1q4ufRCyZAgNzKfpaK/P3xeGUjPftJ9sF4F g==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="395745439" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="395745439" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:43 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="811971916" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="811971916" Received: from unknown (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.18.43]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:41 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Subject: [PATCH 4/5] ASoC: SOF: Intel: Enable d0i3 work for ipc4 Date: Tue, 14 Feb 2023 12:33:44 +0200 Message-Id: <20230214103345.30669-5-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> References: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: J67ZU4M7L32IHIWGXQEZ5NCLQGG23MYN X-Message-ID-Hash: J67ZU4M7L32IHIWGXQEZ5NCLQGG23MYN 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 CC: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, rander.wang@intel.com 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: Rander Wang Schedule a delayed work for d0i3 entry after every non-pm ipc msg. Signed-off-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/cnl.c | 2 ++ sound/soc/sof/intel/hda-ipc.c | 28 ++++++++++++++++++++++++++++ sound/soc/sof/intel/hda.h | 2 ++ sound/soc/sof/intel/mtl.c | 2 ++ 4 files changed, 34 insertions(+) diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 6b075bbe5bfb..a08a77fa946b 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -280,6 +280,8 @@ int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR, msg_data->primary | CNL_DSP_REG_HIPCIDR_BUSY); + hda_dsp_ipc4_schedule_d0i3_work(hdev, msg); + return 0; } diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c index d7e16e6b6f52..df541b22b2d2 100644 --- a/sound/soc/sof/intel/hda-ipc.c +++ b/sound/soc/sof/intel/hda-ipc.c @@ -67,6 +67,32 @@ int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) return 0; } +static inline bool hda_dsp_ipc4_pm_msg(u32 primary) +{ + /* pm setting is only supported by module msg */ + if (SOF_IPC4_MSG_IS_MODULE_MSG(primary) != SOF_IPC4_MODULE_MSG) + return false; + + if (SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_DX || + SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_D0IX) + return true; + + return false; +} + +void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev, + struct snd_sof_ipc_msg *msg) +{ + struct sof_ipc4_msg *msg_data = msg->msg_data; + + /* Schedule a delayed work for d0i3 entry after sending non-pm ipc msg */ + if (hda_dsp_ipc4_pm_msg(msg_data->primary)) + return; + + mod_delayed_work(system_wq, &hdev->d0i3_work, + msecs_to_jiffies(SOF_HDA_D0I3_WORK_DELAY_MS)); +} + int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) { struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; @@ -88,6 +114,8 @@ int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI, msg_data->primary | HDA_DSP_REG_HIPCI_BUSY); + hda_dsp_ipc4_schedule_d0i3_work(hdev, msg); + return 0; } diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index b3080b82ca25..45f9d4248f14 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -919,6 +919,8 @@ irqreturn_t cnl_ipc4_irq_thread(int irq, void *context); int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg); irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context); bool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev); +void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev, + struct snd_sof_ipc_msg *msg); int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg); void hda_ipc4_dump(struct snd_sof_dev *sdev); extern struct sdw_intel_ops sdw_callback; diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c index 67b8ccbc2e94..307faad2ecf4 100644 --- a/sound/soc/sof/intel/mtl.c +++ b/sound/soc/sof/intel/mtl.c @@ -110,6 +110,8 @@ static int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *ms snd_sof_dsp_write(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDR, msg_data->primary | MTL_DSP_REG_HFIPCXIDR_BUSY); + hda_dsp_ipc4_schedule_d0i3_work(hdev, msg); + return 0; } From patchwork Tue Feb 14 10:33:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13139824 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 9DB79C61DA4 for ; Tue, 14 Feb 2023 10:36:32 +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 EF5F5832; Tue, 14 Feb 2023 11:35:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF5F5832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1676370990; bh=wIu3wPgBRSgY9K5G+IWQTk6DTGmTl6qy6al+3EgL0Cw=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ABazMfoxfbMepVc9HQLBcuACOQrsxh0fnLrfBdN2kmC9iMeoBJ0I4ouuQD7an91AU 8t6DLm2f9vivZ929DN9/NZLW0htGuK0DM7xnpqQzzh6viiAoRStAX7PbmAWDTrGpJz kwkN+wLnF2ylvBjYieLWr+M7AQUzoEz4gi8E1+b4= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9EC8FF80553; Tue, 14 Feb 2023 11:34:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2E908F8053B; Tue, 14 Feb 2023 11:33:55 +0100 (CET) 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 61E0AF8047C for ; Tue, 14 Feb 2023 11:33:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 61E0AF8047C 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=cssxkaVl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676370827; x=1707906827; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wIu3wPgBRSgY9K5G+IWQTk6DTGmTl6qy6al+3EgL0Cw=; b=cssxkaVlyopOYxRX0hw/ivLFgLSAXOpnEjOkncnkii+u1qJ+7qLorC+C UkteqixjgLKTyKiHoUN3UPqk2CSoQXFjxpj0cPz22kM3gKtyTgaW68AFK uM17Typ4xKPpOWRcaDubJbiNM++32vgOXp31fSC6wFA5b+anDtfoztKyg vi551+qaVp42kekU6WaweWIP08rvXRCCH5p9xXRYwW4HoKyr5W1nD6zS/ B8ZhTTLcHNhOVJK3R9zsua9YvZ+KIOijJ3Ik8O6sCuFYkIRFK9MCxmGe0 wDmp4Brk+p6N1XH8fkthGLroxfGwitEIvQ6RxonGdnwAaKpin4JX81KpV w==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="395745445" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="395745445" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:45 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="811971920" X-IronPort-AV: E=Sophos;i="5.97,296,1669104000"; d="scan'208";a="811971920" Received: from unknown (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.18.43]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2023 02:33:43 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Subject: [PATCH 5/5] ASoC: SOF: Intel: hda-dsp: Set streaming flag for d0i3 Date: Tue, 14 Feb 2023 12:33:45 +0200 Message-Id: <20230214103345.30669-6-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> References: <20230214103345.30669-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: EBSHJKKIC3EGNKDZJNHLISJ5M3R7XIKT X-Message-ID-Hash: EBSHJKKIC3EGNKDZJNHLISJ5M3R7XIKT 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 CC: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, rander.wang@intel.com 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: Rander Wang Enable d0i3 streaming if all the active streams can work in d0i3 state and playback is enabled. Signed-off-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/hda-dsp.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index e34fe0c9bcde..68eb06f13a1f 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -405,6 +405,34 @@ static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value) return 0; } +/* + * d0i3 streaming is enabled if all the active streams can + * work in d0i3 state and playback is enabled + */ +static bool hda_dsp_d0i3_streaming_applicable(struct snd_sof_dev *sdev) +{ + struct snd_pcm_substream *substream; + struct snd_sof_pcm *spcm; + bool playback_active = false; + int dir; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + for_each_pcm_streams(dir) { + substream = spcm->stream[dir].substream; + if (!substream || !substream->runtime) + continue; + + if (!spcm->stream[dir].d0i3_compatible) + return false; + + if (dir == SNDRV_PCM_STREAM_PLAYBACK) + playback_active = true; + } + } + + return playback_active; +} + static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, const struct sof_dsp_power_state *target_state) { @@ -446,6 +474,9 @@ static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev, !hda_enable_trace_D0I3_S0 || sdev->system_suspend_target != SOF_SUSPEND_NONE) flags = HDA_PM_NO_DMA_TRACE; + + if (hda_dsp_d0i3_streaming_applicable(sdev)) + flags |= HDA_PM_PG_STREAMING; } else { /* prevent power gating in D0I0 */ flags = HDA_PM_PPG;