Skip to contentSkip to conversation

ASoC: SOF: enable S0ix support for Intel platforms

PATCH In review Pierre-Louis Bossart 4 participants 61 messages Oct 25, 2019 – Oct 29, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: SOF: enable S0ix support for Intel platforms

In S0ix (aka S0 Idle), the audio DSP can enter the D0i3 substate and keep some of the pipelines and processing active for e.g. Hotwording and other acoustic event detection while optimizing power consumption. This patchset mainly adds flags and state machines to track which streams may remain active (tagged as such in the topology file), and keep them active when the ALSA core tries to suspend everything.

The Intel specific parts are limited to the changes in the IPC, where instead of using an SRAM window, the IPC commands needed to enter and exit D0i3 are sent in a compressed form using IPC registers themselves.

This patchset is made of 26 patches, which is rather large, but each change is rather small and contained. The code was initially reviewed on GitHub, with 165+ comments provided and no regressions found [1]. The S0ix mode was tested on a CometLake platform.

Future improvements will consist in an additional idle detection so that the D0i3 mode can be entered even on devices where S0ix is not enabled.

[1] https://github.com/thesofproject/linux/pull/1337

Keyon Jie (26):
ASoC: SOF: add a field to store the current D0 substate of DSP
ASoC: SOF: reset default d0_substate at probe() and resume()
ASoC: SOF: add set_power_state() to dsp_ops for power state update
ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate
ASoC: SOF: Intel: CNL: add set_power_state() ops
ASoC: SOF: Intel: APL: add set_power_state() ops
ASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible stream
ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate
ASoC: SOF: topology: parse and store d0i3_compatible flag
ASoC: SOF: Intel: hda-dsp: align the comments for D0I3C update
ASoC: SOF: Intel: HDA: use macro for register polling retry count
ASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc
ASoC: SOF: ipc: introduce message for DSP power gating
ASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE reply
ASoC: SOF: Intel: HDA: add cAVS specific compact IPC header file
ASoC: SOF: configure D0ix IPC flags in set_power_state
ASoC: SOF: PM: add helpers for setting D0 substate for ADSP
ASoC: SOF: Intel: CNL: add support for sending compact IPC
ASoC: SOF: add a flag to indicate the system suspend target
ASoC: SOF: add a flag suspend_ignored for sof stream
ASoC: SOF: PM: implement prepare/complete callbacks
ASoC: SOF: ignore suspend/resume for D0ix compatible streams
ASoC: SOF: Intel: hda-dsp: implement suspend/resume for S0ix<->S0
transition
ASoC: SOF: return -ENOTSUPP if D0I3 is not supported
ASoC: SOF: PM: Add support for DSP D0i3 state when entering S0ix
ASoC: SOF: pci: Add prepare/complete PM callbacks

 include/sound/sof/header.h      |  1 +
 include/sound/sof/pm.h          |  8 +++
 include/uapi/sound/sof/tokens.h |  4 ++
 sound/soc/sof/core.c            |  3 ++
 sound/soc/sof/intel/apl.c       |  1 +
 sound/soc/sof/intel/cnl.c       | 43 +++++++++++++--
 sound/soc/sof/intel/hda-dsp.c   | 91 +++++++++++++++++++++++++++++++
 sound/soc/sof/intel/hda-ipc.c   |  6 ++-
 sound/soc/sof/intel/hda-ipc.h   | 51 ++++++++++++++++++
 sound/soc/sof/intel/hda.h       | 12 +++++
 sound/soc/sof/ops.h             | 10 ++++
 sound/soc/sof/pcm.c             | 31 +++++++++++
 sound/soc/sof/pm.c              | 95 +++++++++++++++++++++++++++++++--
 sound/soc/sof/sof-pci-dev.c     |  2 +
 sound/soc/sof/sof-priv.h        | 23 ++++++++
 sound/soc/sof/topology.c        | 43 ++++++++++++++-
 16 files changed, 413 insertions(+), 11 deletions(-)
 create mode 100644 sound/soc/sof/intel/hda-ipc.h
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw

PATCH 1/26 ASoC: SOF: add a field to store the current D0 substate of DSP

From: Keyon Jie <[email protected]>

Add field d0_substate to struct snd_sof_dev to store the current DSP D0 sub-state(only meaningful when DSP in D0), which could be D0I0 or D0I3.

---
 sound/soc/sof/sof-priv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
sound/soc/sof/sof-priv.h +9 -0
index 2d40de5ee285..481dfe4ee2d0 100644
@@ -68,6 +68,12 @@ extern int sof_core_debug;
 
 #define DMA_CHAN_INVALID	0xFFFFFFFF
 
+/* DSP D0ix sub-state */
+enum sof_d0_substate {
+	SOF_DSP_D0I0 = 0,	/* DSP default D0 substate */
+	SOF_DSP_D0I3,		/* DSP D0i3(low power) substate*/
+};
+
 struct snd_sof_dev;
 struct snd_sof_ipc_msg;
 struct snd_sof_ipc;
@@ -387,6 +393,9 @@ struct snd_sof_dev {
 	 */
 	struct snd_soc_component_driver plat_drv;
 
+	/* power states related */
+	enum sof_d0_substate d0_substate;
+
 	/* DSP firmware boot */
 	wait_queue_head_t boot_wait;
 	u32 boot_complete;
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#2 lore raw

[alsa-devel] Applied "ASoC: SOF: add a field to store the current D0 substate of DSP" to the asoc tree

The patch

ASoC: SOF: add a field to store the current D0 substate of DSP

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 4c19030c511fd6eab029bae838f736256d2f43cd Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:40:57 -0500
Subject: [PATCH] ASoC: SOF: add a field to store the current D0 substate of
DSP

Add field d0_substate to struct snd_sof_dev to store the current DSP D0 sub-state(only meaningful when DSP in D0), which could be D0I0 or D0I3.

---
 sound/soc/sof/sof-priv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
sound/soc/sof/sof-priv.h +9 -0
index 2d40de5ee285..481dfe4ee2d0 100644
@@ -68,6 +68,12 @@ extern int sof_core_debug;
 
 #define DMA_CHAN_INVALID	0xFFFFFFFF
 
+/* DSP D0ix sub-state */
+enum sof_d0_substate {
+	SOF_DSP_D0I0 = 0,	/* DSP default D0 substate */
+	SOF_DSP_D0I3,		/* DSP D0i3(low power) substate*/
+};
+
 struct snd_sof_dev;
 struct snd_sof_ipc_msg;
 struct snd_sof_ipc;
@@ -387,6 +393,9 @@ struct snd_sof_dev {
 	 */
 	struct snd_soc_component_driver plat_drv;
 
+	/* power states related */
+	enum sof_d0_substate d0_substate;
+
 	/* DSP firmware boot */
 	wait_queue_head_t boot_wait;
 	u32 boot_complete;
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#3 lore raw

Re: [alsa-devel] [PATCH 01/26] ASoC: SOF: add a field to store the current D0 substate of DSP

In reply to Pierre-Louis Bossart

sound/soc/sof/sof-priv.h extern int sof_core_debug; · line 75

Quoted 5 lines · Pierre-Louis Bossart
sound/soc/sof/sof-priv.h +5 -0
+/* DSP D0ix sub-state */
+enum sof_d0_substate {
+	SOF_DSP_D0I0 = 0,	/* DSP default D0 substate */
+	SOF_DSP_D0I3,		/* DSP D0i3(low power) substate*/
+};

Name of the type states: "d0 substate" while description "D0ix sub-state". Why was not this named D0ix from the get-go? Goes into the same the same naming bucket as S0ix.

On the further note, adding D0ix patch within "enable S0ix support for Intel platforms" is misleading. S-states != D-states. D0ix is especially orthogonal. It is these to further reduce power consumption when system and device are in S0 and D0 respectively and idle time between IPC communication is long enough for DSP to be power gated.

Czarek
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw

Re: [alsa-devel] [PATCH 01/26] ASoC: SOF: add a field to store the current D0 substate of DSP

Quoted 8 lines · Cezary Rojewski

sound/soc/sof/sof-priv.h extern int sof_core_debug; · line 75

Quoted 5 lines · Pierre-Louis Bossart
sound/soc/sof/sof-priv.h +5 -0
+/* DSP D0ix sub-state */
+enum sof_d0_substate {
+    SOF_DSP_D0I0 = 0,    /* DSP default D0 substate */
+    SOF_DSP_D0I3,        /* DSP D0i3(low power) substate*/
+};

Name of the type states: "d0 substate" while description "D0ix sub-state". Why was not this named D0ix from the get-go? Goes into the same the same naming bucket as S0ix.

The definition is correct, from the pm_runtime perspective the device is 'active' i.e. D0. D0ix is a substate of D0.

Quoted 2 lines

On the further note, adding D0ix patch within "enable S0ix support for Intel platforms" is misleading. S-states != D-states. D0ix is especially orthogonal. It is these to further reduce power consumption when system and device are in S0 and D0 respectively and idle time between IPC communication is long enough for DSP to be power gated.

there are well-defined requirements and dependencies between S and D states:

S0: device can be in D0, D0ix, D3
S0ix: device can be in D0ix, D3
S3: device can be in D3

That's hardly orthogonal.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw

PATCH 2/26 ASoC: SOF: reset default d0_substate at probe() and resume()

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

We initialize/reset d0_substate to default d0i0 value when doing transition D3-->D0, e.g. at success of probing and resuming.

---
 sound/soc/sof/core.c | 3 +++
 sound/soc/sof/pm.c   | 3 +++
 2 files changed, 6 insertions(+)
sound/soc/sof/core.c +3 -0
index 5998861a9002..8661c2cca76b 100644
@@ -458,6 +458,9 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
 	/* initialize sof device */
 	sdev->dev = dev;
 
+	/* initialize default D0 sub-state */
+	sdev->d0_substate = SOF_DSP_D0I0;
+
 	sdev->pdata = plat_data;
 	sdev->first_boot = true;
 	dev_set_drvdata(dev, sdev);
sound/soc/sof/pm.c +3 -0
index e23beaeefe00..81e623dfc7e5 100644
@@ -326,6 +326,9 @@ static int sof_resume(struct device *dev, bool runtime_resume)
 			"error: ctx_restore ipc error during resume %d\n",
 			ret);
 
+	/* initialize default D0 sub-state */
+	sdev->d0_substate = SOF_DSP_D0I0;
+
 	return ret;
 }
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#6 lore raw

[alsa-devel] Applied "ASoC: SOF: reset default d0_substate at probe() and resume()" to the asoc tree

The patch

ASoC: SOF: reset default d0_substate at probe() and resume()

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 09fe6b528886c0d07ce539b837749edcc46618d0 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:40:58 -0500
Subject: [PATCH] ASoC: SOF: reset default d0_substate at probe() and resume()

We initialize/reset d0_substate to default d0i0 value when doing transition D3-->D0, e.g. at success of probing and resuming.

---
 sound/soc/sof/core.c | 3 +++
 sound/soc/sof/pm.c   | 3 +++
 2 files changed, 6 insertions(+)
sound/soc/sof/core.c +3 -0
index 5998861a9002..8661c2cca76b 100644
@@ -458,6 +458,9 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
 	/* initialize sof device */
 	sdev->dev = dev;
 
+	/* initialize default D0 sub-state */
+	sdev->d0_substate = SOF_DSP_D0I0;
+
 	sdev->pdata = plat_data;
 	sdev->first_boot = true;
 	dev_set_drvdata(dev, sdev);
sound/soc/sof/pm.c +3 -0
index e23beaeefe00..81e623dfc7e5 100644
@@ -326,6 +326,9 @@ static int sof_resume(struct device *dev, bool runtime_resume)
 			"error: ctx_restore ipc error during resume %d\n",
 			ret);
 
+	/* initialize default D0 sub-state */
+	sdev->d0_substate = SOF_DSP_D0I0;
+
 	return ret;
 }
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#7 lore raw

PATCH 3/26 ASoC: SOF: add set_power_state() to dsp_ops for power state update

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

D0i3 is a platform-defined substate of D0, so we need a platform-specific callback in dsp_ops to handle the relevant configurations.

---
 sound/soc/sof/ops.h      | 9 +++++++++
 sound/soc/sof/sof-priv.h | 2 ++
 2 files changed, 11 insertions(+)
sound/soc/sof/ops.h +9 -0
index 824d36fe59fd..d7c8fc06f961 100644
@@ -193,6 +193,15 @@ static inline int snd_sof_dsp_set_clk(struct snd_sof_dev *sdev, u32 freq)
 	return 0;
 }
 
+static inline int snd_sof_dsp_set_power_state(struct snd_sof_dev *sdev,
+					      enum sof_d0_substate substate)
+{
+	if (sof_ops(sdev)->set_power_state)
+		return sof_ops(sdev)->set_power_state(sdev, substate);
+
+	return 0;
+}
+
 /* debug */
 static inline void snd_sof_dsp_dbg_dump(struct snd_sof_dev *sdev, u32 flags)
 {
sound/soc/sof/sof-priv.h +2 -0
index 481dfe4ee2d0..e9902e4e8e55 100644
@@ -189,6 +189,8 @@ struct snd_sof_dsp_ops {
 	int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */
 	int (*runtime_idle)(struct snd_sof_dev *sof_dev); /* optional */
 	int (*set_hw_params_upon_resume)(struct snd_sof_dev *sdev); /* optional */
+	int (*set_power_state)(struct snd_sof_dev *sdev,
+			       enum sof_d0_substate d0_substate); /* optional */
 
 	/* DSP clocking */
 	int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#8 lore raw

[alsa-devel] Applied "ASoC: SOF: add set_power_state() to dsp_ops for power state update" to the asoc tree

The patch

ASoC: SOF: add set_power_state() to dsp_ops for power state update

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From e8f112d8c29f44ded83f97828c104bf0904871ec Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:40:59 -0500
Subject: [PATCH] ASoC: SOF: add set_power_state() to dsp_ops for power state
update

D0i3 is a platform-defined substate of D0, so we need a platform-specific callback in dsp_ops to handle the relevant configurations.

---
 sound/soc/sof/ops.h      | 9 +++++++++
 sound/soc/sof/sof-priv.h | 2 ++
 2 files changed, 11 insertions(+)
sound/soc/sof/ops.h +9 -0
index 824d36fe59fd..d7c8fc06f961 100644
@@ -193,6 +193,15 @@ static inline int snd_sof_dsp_set_clk(struct snd_sof_dev *sdev, u32 freq)
 	return 0;
 }
 
+static inline int snd_sof_dsp_set_power_state(struct snd_sof_dev *sdev,
+					      enum sof_d0_substate substate)
+{
+	if (sof_ops(sdev)->set_power_state)
+		return sof_ops(sdev)->set_power_state(sdev, substate);
+
+	return 0;
+}
+
 /* debug */
 static inline void snd_sof_dsp_dbg_dump(struct snd_sof_dev *sdev, u32 flags)
 {
sound/soc/sof/sof-priv.h +2 -0
index 481dfe4ee2d0..e9902e4e8e55 100644
@@ -189,6 +189,8 @@ struct snd_sof_dsp_ops {
 	int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */
 	int (*runtime_idle)(struct snd_sof_dev *sof_dev); /* optional */
 	int (*set_hw_params_upon_resume)(struct snd_sof_dev *sdev); /* optional */
+	int (*set_power_state)(struct snd_sof_dev *sdev,
+			       enum sof_d0_substate d0_substate); /* optional */
 
 	/* DSP clocking */
 	int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#9 lore raw

PATCH 4/26 ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Adding helper to implement setting dsp to d0i3 or d0i0 status, this will be needed for driver D0ix support.

---
 sound/soc/sof/intel/hda-dsp.c | 46 +++++++++++++++++++++++++++++++++++
 sound/soc/sof/intel/hda.h     | 10 ++++++++
 2 files changed, 56 insertions(+)
sound/soc/sof/intel/hda-dsp.c +46 -0
index 3ea401646e0c..fa2f1f66c72c 100644
@@ -306,6 +306,52 @@ void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev)
 			HDA_DSP_REG_HIPCCTL_BUSY | HDA_DSP_REG_HIPCCTL_DONE, 0);
 }
 
+static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry)
+{
+	struct hdac_bus *bus = sof_to_bus(sdev);
+
+	while (snd_hdac_chip_readb(bus, VS_D0I3C) & SOF_HDA_VS_D0I3C_CIP) {
+		if (!retry--)
+			return -ETIMEDOUT;
+		usleep_range(10, 15);
+	}
+
+	return 0;
+}
+
+int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate)
+{
+	struct hdac_bus *bus = sof_to_bus(sdev);
+	int retry = 50;
+	int ret;
+	u8 value;
+
+	/* Write to D0I3C after Command-In-Progress bit is cleared */
+	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	if (ret < 0) {
+		dev_err(bus->dev, "CIP timeout before update D0I3C!\n");
+		return ret;
+	}
+
+	/* Update D0I3C register */
+	value = d0_substate == SOF_DSP_D0I3 ? SOF_HDA_VS_D0I3C_I3 : 0;
+	snd_hdac_chip_updateb(bus, VS_D0I3C, SOF_HDA_VS_D0I3C_I3, value);
+
+	/* Wait for cmd in progress to be cleared before exiting the function */
+	retry = 50;
+	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	if (ret < 0) {
+		dev_err(bus->dev, "CIP timeout after D0I3C updated!\n");
+		return ret;
+	}
+
+	dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
+		 snd_hdac_chip_readb(bus, VS_D0I3C));
+
+	return 0;
+}
+
 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
 {
 	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
sound/soc/sof/intel/hda.h +10 -0
index ea02bf40cb25..0e7c366b8f71 100644
@@ -64,6 +64,13 @@
 #define SOF_HDA_PPCTL_PIE		BIT(31)
 #define SOF_HDA_PPCTL_GPROCEN		BIT(30)
 
+/*Vendor Specific Registers*/
+#define SOF_HDA_VS_D0I3C		0x104A
+
+/* D0I3C Register fields */
+#define SOF_HDA_VS_D0I3C_CIP		BIT(0) /* Command-In-Progress */
+#define SOF_HDA_VS_D0I3C_I3		BIT(2) /* D0i3 enable bit */
+
 /* DPIB entry size: 8 Bytes = 2 DWords */
 #define SOF_HDA_DPIB_ENTRY_SIZE	0x8
 
@@ -455,6 +462,9 @@ int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
 
+int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate);
+
 int hda_dsp_suspend(struct snd_sof_dev *sdev);
 int hda_dsp_resume(struct snd_sof_dev *sdev);
 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#10 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate" to the asoc tree

The patch

ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 62f8f76604623980d41cf73691ca45288871efd9 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:00 -0500
Subject: [PATCH] ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix
substate

Adding helper to implement setting dsp to d0i3 or d0i0 status, this will be needed for driver D0ix support.

---
 sound/soc/sof/intel/hda-dsp.c | 46 +++++++++++++++++++++++++++++++++++
 sound/soc/sof/intel/hda.h     | 10 ++++++++
 2 files changed, 56 insertions(+)
sound/soc/sof/intel/hda-dsp.c +46 -0
index 3ea401646e0c..fa2f1f66c72c 100644
@@ -306,6 +306,52 @@ void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev)
 			HDA_DSP_REG_HIPCCTL_BUSY | HDA_DSP_REG_HIPCCTL_DONE, 0);
 }
 
+static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry)
+{
+	struct hdac_bus *bus = sof_to_bus(sdev);
+
+	while (snd_hdac_chip_readb(bus, VS_D0I3C) & SOF_HDA_VS_D0I3C_CIP) {
+		if (!retry--)
+			return -ETIMEDOUT;
+		usleep_range(10, 15);
+	}
+
+	return 0;
+}
+
+int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate)
+{
+	struct hdac_bus *bus = sof_to_bus(sdev);
+	int retry = 50;
+	int ret;
+	u8 value;
+
+	/* Write to D0I3C after Command-In-Progress bit is cleared */
+	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	if (ret < 0) {
+		dev_err(bus->dev, "CIP timeout before update D0I3C!\n");
+		return ret;
+	}
+
+	/* Update D0I3C register */
+	value = d0_substate == SOF_DSP_D0I3 ? SOF_HDA_VS_D0I3C_I3 : 0;
+	snd_hdac_chip_updateb(bus, VS_D0I3C, SOF_HDA_VS_D0I3C_I3, value);
+
+	/* Wait for cmd in progress to be cleared before exiting the function */
+	retry = 50;
+	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	if (ret < 0) {
+		dev_err(bus->dev, "CIP timeout after D0I3C updated!\n");
+		return ret;
+	}
+
+	dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
+		 snd_hdac_chip_readb(bus, VS_D0I3C));
+
+	return 0;
+}
+
 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
 {
 	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
sound/soc/sof/intel/hda.h +10 -0
index ea02bf40cb25..0e7c366b8f71 100644
@@ -64,6 +64,13 @@
 #define SOF_HDA_PPCTL_PIE		BIT(31)
 #define SOF_HDA_PPCTL_GPROCEN		BIT(30)
 
+/*Vendor Specific Registers*/
+#define SOF_HDA_VS_D0I3C		0x104A
+
+/* D0I3C Register fields */
+#define SOF_HDA_VS_D0I3C_CIP		BIT(0) /* Command-In-Progress */
+#define SOF_HDA_VS_D0I3C_I3		BIT(2) /* D0i3 enable bit */
+
 /* DPIB entry size: 8 Bytes = 2 DWords */
 #define SOF_HDA_DPIB_ENTRY_SIZE	0x8
 
@@ -455,6 +462,9 @@ int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
 
+int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate);
+
 int hda_dsp_suspend(struct snd_sof_dev *sdev);
 int hda_dsp_resume(struct snd_sof_dev *sdev);
 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#11 lore raw

Re: [alsa-devel] [PATCH 04/26] ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate

In reply to Pierre-Louis Bossart
Quoted 28 lines · Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Adding helper to implement setting dsp to d0i3 or d0i0 status, this will be needed for driver D0ix support.

sound/soc/sof/intel/hda-dsp.c +20 -0
+static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry)
+{
+	struct hdac_bus *bus = sof_to_bus(sdev);
+
+	while (snd_hdac_chip_readb(bus, VS_D0I3C) & SOF_HDA_VS_D0I3C_CIP) {
+		if (!retry--)
+			return -ETIMEDOUT;
+		usleep_range(10, 15);
+	}
+
+	return 0;
+}
+
+int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate)
+{
+	struct hdac_bus *bus = sof_to_bus(sdev);
+	int retry = 50;
+	int ret;
+	u8 value;

sound/soc/sof/intel/hda-dsp.c void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) · line 338

Quoted 10 lines
sound/soc/sof/intel/hda-dsp.c +10 -0
+
+	/* Write to D0I3C after Command-In-Progress bit is cleared */
+	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	if (ret < 0) {
+		dev_err(bus->dev, "CIP timeout before update D0I3C!\n");
+		return ret;
+	}
+
+	/* Update D0I3C register */
+	value = d0_substate == SOF_DSP_D0I3 ? SOF_HDA_VS_D0I3C_I3 : 0;

Some indentation or parenthesis would make this cleaner.

Quoted 6 lines
sound/soc/sof/intel/hda-dsp.c +6 -0
+	snd_hdac_chip_updateb(bus, VS_D0I3C, SOF_HDA_VS_D0I3C_I3, value);
+
+	/* Wait for cmd in progress to be cleared before exiting the function */
+	retry = 50;
+	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	if (ret < 0) {

sound/soc/sof/intel/hda-dsp.c void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) · line 354

Quoted 10 lines
sound/soc/sof/intel/hda-dsp.c +10 -0
+		dev_err(bus->dev, "CIP timeout after D0I3C updated!\n");
+		return ret;
+	}
+
+	dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
+		 snd_hdac_chip_readb(bus, VS_D0I3C));
+
+	return 0;
+}
+

I believe hda_dsp_wait_d0i3c_done function could have had its argument list simplified. "retry" is passed externally and it is always set to 50. One could put the "retry" right inside _done function. This or allow the caller to modify the sleep period. Another option is to replace "retry" with "timeout period" (total timeout, that is) entirely.

In regard to maintenance, both ret checks (resulting in dev_errs) assume -ETIMEOUT outcome on _done failure. If said function gets updated in the future, these implicit checks might cause problems.

sound/soc/sof/intel/hda.h line 67

Quoted 12 lines
  static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
  {
  	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
sound/soc/sof/intel/hda.h +1 -0
index ea02bf40cb25..0e7c366b8f71 100644
@@ -64,6 +64,13 @@
  #define SOF_HDA_PPCTL_PIE		BIT(31)
  #define SOF_HDA_PPCTL_GPROCEN		BIT(30)
 
+/*Vendor Specific Registers*/

Missing spaces.

sound/soc/sof/intel/hda.h line 68

Quoted 1 line
sound/soc/sof/intel/hda.h +1 -0
+#define SOF_HDA_VS_D0I3C		0x104A

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#12 lore raw

Re: [alsa-devel] [PATCH 04/26] ASoC: SOF: Intel: hda-dsp: Add helper for setting DSP D0ix substate

Quoted 58 lines · Cezary Rojewski
Quoted 7 lines · Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Adding helper to implement setting dsp to d0i3 or d0i0 status, this will be needed for driver D0ix support.

Signed-off-by Pierre-Louis Bossart <

[email protected]>

Quoted 20 lines
sound/soc/sof/intel/hda-dsp.c +20 -0
+static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry)
+{
+     struct hdac_bus *bus = sof_to_bus(sdev);
+
+     while (snd_hdac_chip_readb(bus, VS_D0I3C) & SOF_HDA_VS_D0I3C_CIP) {
+             if (!retry--)
+                     return -ETIMEDOUT;
+             usleep_range(10, 15);
+     }
+
+     return 0;
+}
+
+int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+                         enum sof_d0_substate d0_substate)
+{
+     struct hdac_bus *bus = sof_to_bus(sdev);
+     int retry = 50;
+     int ret;
+     u8 value;

sound/soc/sof/intel/hda-dsp.c void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev) · line 338

Quoted 10 lines
sound/soc/sof/intel/hda-dsp.c +10 -0
+
+     /* Write to D0I3C after Command-In-Progress bit is cleared */
+     ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+     if (ret < 0) {
+             dev_err(bus->dev, "CIP timeout before update D0I3C!\n");
+             return ret;
+     }
+
+     /* Update D0I3C register */
+     value = d0_substate == SOF_DSP_D0I3 ? SOF_HDA_VS_D0I3C_I3 : 0;

Some indentation or parenthesis would make this cleaner.

sound/soc/sof/intel/hda-dsp.c void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev)

Quoted 3 lines
sound/soc/sof/intel/hda-dsp.c +3 -0
+     snd_hdac_chip_updateb(bus, VS_D0I3C, SOF_HDA_VS_D0I3C_I3, value);
+
+     /* Wait for cmd in progress to be cleared before exiting the

function */

Quoted 11 lines
sound/soc/sof/intel/hda-dsp.c +11 -0
+     retry = 50;
+     ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+     if (ret < 0) {
+             dev_err(bus->dev, "CIP timeout after D0I3C updated!\n");
+             return ret;
+     }
+
+     dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
+              snd_hdac_chip_readb(bus, VS_D0I3C));
+
+     return 0;
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

I believe hda_dsp_wait_d0i3c_done function could have had its argument list simplified. "retry" is passed externally and it is always set to
50. One could put the "retry" right inside _done function. This or allow the caller to modify the sleep period. Another option is to replace "retry" with "timeout period" (total timeout, that is) entirely.

Cezary,

This has been fixed later in the series to use
the HDA_DSP_REG_POLL_RETRY_COUNT but I agree that this can further be simplified to just use the macro inside the hda_dsp_wait_d0i3c_done() instead of passing the argument.

Quoted 5 lines

In regard to maintenance, both ret checks (resulting in dev_errs) assume -ETIMEOUT outcome on _done failure. If said function gets updated in the future, these implicit checks might cause problems.

Possibly, but at the moment -ETIMEOUT looks like the correct error to be reported.

Thanks,
Ranjani

Quoted 16 lines

sound/soc/sof/intel/hda.h line 67

Quoted 13 lines
  static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
  {
      struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
sound/soc/sof/intel/hda.h +1 -0
index ea02bf40cb25..0e7c366b8f71 100644
@@ -64,6 +64,13 @@
  #define SOF_HDA_PPCTL_PIE           BIT(31)
  #define SOF_HDA_PPCTL_GPROCEN               BIT(30)
 
+/*Vendor Specific Registers*/

Missing spaces.

Quoted 6 lines

sound/soc/sof/intel/hda.h line 68

Quoted 1 line
sound/soc/sof/intel/hda.h +1 -0
+#define SOF_HDA_VS_D0I3C             0x104A

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#13 lore raw

PATCH 5/26 ASoC: SOF: Intel: CNL: add set_power_state() ops

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Using hda_dsp_set_power_state() as set_power_state() ops for cnl to do d0ix platform configuration updates.

---
 sound/soc/sof/intel/cnl.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/intel/cnl.c +1 -0
index e9cdcc040fb5..982b81a0b13a 100644
@@ -255,6 +255,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
 	.runtime_resume		= hda_dsp_runtime_resume,
 	.runtime_idle		= hda_dsp_runtime_idle,
 	.set_hw_params_upon_resume = hda_dsp_set_hw_params_upon_resume,
+	.set_power_state	= hda_dsp_set_power_state,
 
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#14 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: CNL: add set_power_state() ops" to the asoc tree

The patch

ASoC: SOF: Intel: CNL: add set_power_state() ops

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 73b51957122dc47a40325a5359b44ef337cbf217 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:01 -0500
Subject: [PATCH] ASoC: SOF: Intel: CNL: add set_power_state() ops

Using hda_dsp_set_power_state() as set_power_state() ops for cnl to do d0ix platform configuration updates.

---
 sound/soc/sof/intel/cnl.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/intel/cnl.c +1 -0
index e9cdcc040fb5..982b81a0b13a 100644
@@ -255,6 +255,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
 	.runtime_resume		= hda_dsp_runtime_resume,
 	.runtime_idle		= hda_dsp_runtime_idle,
 	.set_hw_params_upon_resume = hda_dsp_set_hw_params_upon_resume,
+	.set_power_state	= hda_dsp_set_power_state,
 
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#15 lore raw

PATCH 6/26 ASoC: SOF: Intel: APL: add set_power_state() ops

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Using hda_dsp_set_power_state() as set_power_state() ops for apl to do d0ix platform configuration updates.

---
 sound/soc/sof/intel/apl.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/intel/apl.c +1 -0
index 15d26e8d90a9..7daa8eb456c8 100644
@@ -97,6 +97,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
 	.runtime_resume		= hda_dsp_runtime_resume,
 	.runtime_idle		= hda_dsp_runtime_idle,
 	.set_hw_params_upon_resume = hda_dsp_set_hw_params_upon_resume,
+	.set_power_state	= hda_dsp_set_power_state,
 
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#16 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: APL: add set_power_state() ops" to the asoc tree

The patch

ASoC: SOF: Intel: APL: add set_power_state() ops

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 35c930ba6025964ac71f041065ae212a0fcc7cca Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:02 -0500
Subject: [PATCH] ASoC: SOF: Intel: APL: add set_power_state() ops

Using hda_dsp_set_power_state() as set_power_state() ops for apl to do d0ix platform configuration updates.

---
 sound/soc/sof/intel/apl.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/intel/apl.c +1 -0
index 15d26e8d90a9..7daa8eb456c8 100644
@@ -97,6 +97,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
 	.runtime_resume		= hda_dsp_runtime_resume,
 	.runtime_idle		= hda_dsp_runtime_idle,
 	.set_hw_params_upon_resume = hda_dsp_set_hw_params_upon_resume,
+	.set_power_state	= hda_dsp_set_power_state,
 
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#17 lore raw

PATCH 7/26 ASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible stream

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add flag d0i3_compatible to struct snd_sof_pcm_stream to denote if the stream can tolerate a transition to the D0i3 substate while opened (thus seen as 'active' by pm_runtime).

---
 sound/soc/sof/sof-priv.h | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/sof-priv.h +1 -0
index e9902e4e8e55..7a21a45d3635 100644
@@ -310,6 +310,7 @@ struct snd_sof_pcm_stream {
 	struct sof_ipc_stream_posn posn;
 	struct snd_pcm_substream *substream;
 	struct work_struct period_elapsed_work;
+	bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
 };
 
 /* ALSA SOF PCM device */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#18 lore raw

[alsa-devel] Applied "ASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible stream" to the asoc tree

The patch

ASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible stream

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From e5c97e88084b8dca6850eba5d2937716b88306c1 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:03 -0500
Subject: [PATCH] ASoC: SOF: add flag to snd_sof_pcm_stream for D0i3 compatible
stream

Add flag d0i3_compatible to struct snd_sof_pcm_stream to denote if the stream can tolerate a transition to the D0i3 substate while opened (thus seen as 'active' by pm_runtime).

---
 sound/soc/sof/sof-priv.h | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/sof-priv.h +1 -0
index e9902e4e8e55..7a21a45d3635 100644
@@ -310,6 +310,7 @@ struct snd_sof_pcm_stream {
 	struct sof_ipc_stream_posn posn;
 	struct snd_pcm_substream *substream;
 	struct work_struct period_elapsed_work;
+	bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
 };
 
 /* ALSA SOF PCM device */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#19 lore raw

PATCH 8/26 ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add stream token SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 and SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 to denote if the stream can be opened at low power d0i3 status or not.

---
 include/uapi/sound/sof/tokens.h |  4 ++++
 sound/soc/sof/topology.c        | 10 ++++++++++
 2 files changed, 14 insertions(+)
include/uapi/sound/sof/tokens.h +4 -0
index d65406f34361..76883e6fb750 100644
@@ -113,6 +113,10 @@
 /* ESAI */
 #define SOF_TKN_IMX_ESAI_MCLK_ID		1100
 
+/* Stream */
+#define SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3	1200
+#define SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3	1201
+
 /* Led control for mute switches */
 #define SOF_TKN_MUTE_LED_USE			1300
 #define SOF_TKN_MUTE_LED_DIRECTION		1301
sound/soc/sof/topology.c +10 -0
index b3ab6f23fc93..121e5d6f8477 100644
@@ -567,6 +567,16 @@ static const struct sof_topology_token pcm_tokens[] = {
 		offsetof(struct sof_ipc_comp_host, dmac_config), 0},
 };
 
+/* PCM */
+static const struct sof_topology_token stream_tokens[] = {
+	{SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3,
+		SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
+		offsetof(struct snd_sof_pcm, stream[0].d0i3_compatible), 0},
+	{SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3,
+		SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
+		offsetof(struct snd_sof_pcm, stream[1].d0i3_compatible), 0},
+};
+
 /* Generic components */
 static const struct sof_topology_token comp_tokens[] = {
 	{SOF_TKN_COMP_PERIOD_SINK_COUNT,
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#20 lore raw

[alsa-devel] Applied "ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate" to the asoc tree

The patch

ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 4a94940988cc44adeb383401dea0beeac4abbe63 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:04 -0500
Subject: [PATCH] ASoC: SOF: token: add tokens for PCM compatible with D0i3
substate

Add stream token SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 and SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 to denote if the stream can be opened at low power d0i3 status or not.

---
 include/uapi/sound/sof/tokens.h |  4 ++++
 sound/soc/sof/topology.c        | 10 ++++++++++
 2 files changed, 14 insertions(+)
include/uapi/sound/sof/tokens.h +4 -0
index d65406f34361..76883e6fb750 100644
@@ -113,6 +113,10 @@
 /* ESAI */
 #define SOF_TKN_IMX_ESAI_MCLK_ID		1100
 
+/* Stream */
+#define SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3	1200
+#define SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3	1201
+
 /* Led control for mute switches */
 #define SOF_TKN_MUTE_LED_USE			1300
 #define SOF_TKN_MUTE_LED_DIRECTION		1301
sound/soc/sof/topology.c +10 -0
index b3ab6f23fc93..121e5d6f8477 100644
@@ -567,6 +567,16 @@ static const struct sof_topology_token pcm_tokens[] = {
 		offsetof(struct sof_ipc_comp_host, dmac_config), 0},
 };
 
+/* PCM */
+static const struct sof_topology_token stream_tokens[] = {
+	{SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3,
+		SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
+		offsetof(struct snd_sof_pcm, stream[0].d0i3_compatible), 0},
+	{SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3,
+		SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
+		offsetof(struct snd_sof_pcm, stream[1].d0i3_compatible), 0},
+};
+
 /* Generic components */
 static const struct sof_topology_token comp_tokens[] = {
 	{SOF_TKN_COMP_PERIOD_SINK_COUNT,
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#21 lore raw

Re: [alsa-devel] [PATCH 08/26] ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate

In reply to Pierre-Louis Bossart
Quoted 8 lines · Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add stream token SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 and SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 to denote if the stream can be opened at low power d0i3 status or not.

By any chance, can stream be playback D0ix incompatible but capture D0ix compatible? Single token would suffice, no?
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#22 lore raw

Re: [alsa-devel] [PATCH 08/26] ASoC: SOF: token: add tokens for PCM compatible with D0i3 substate

Quoted 11 lines · Cezary Rojewski
Quoted 8 lines · Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add stream token SOF_TKN_STREAM_PLAYBACK_COMPATIBLE_D0I3 and SOF_TKN_STREAM_CAPTURE_COMPATIBLE_D0I3 to denote if the stream can be opened at low power d0i3 status or not.

By any chance, can stream be playback D0ix incompatible but capture D0ix compatible? Single token would suffice, no?

we discussed this on github. If we generalize this to low-power streaming, it's possible to have a case where the buffering is not suitable on capture but suitable on playback, or vice-versa, so we added two tokens.
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#23 lore raw

PATCH 9/26 ASoC: SOF: topology: parse and store d0i3_compatible flag

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Parses the token from tplg file and store it to snd_sof_pcm_stream d0i3_compatible flag, which can be used later for d0ix transition management.

---
 sound/soc/sof/topology.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
sound/soc/sof/topology.c +16 -0
index 121e5d6f8477..cc138ac6a8eb 100644
@@ -2307,6 +2307,7 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 {
 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
 	struct snd_soc_tplg_stream_caps *caps;
+	struct snd_soc_tplg_private *private = &pcm->priv;
 	struct snd_sof_pcm *spcm;
 	int stream = SNDRV_PCM_STREAM_PLAYBACK;
 	int ret = 0;
@@ -2329,10 +2330,22 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 	dai_drv->dobj.private = spcm;
 	list_add(&spcm->list, &sdev->pcm_list);
 
+	ret = sof_parse_tokens(scomp, spcm, stream_tokens,
+			       ARRAY_SIZE(stream_tokens), private->array,
+			       le32_to_cpu(private->size));
+	if (ret) {
+		dev_err(sdev->dev, "error: parse stream tokens failed %d\n",
+			le32_to_cpu(private->size));
+		return ret;
+	}
+
 	/* do we need to allocate playback PCM DMA pages */
 	if (!spcm->pcm.playback)
 		goto capture;
 
+	dev_vdbg(sdev->dev, "tplg: pcm %s stream tokens: playback d0i3:%d\n",
+		 spcm->pcm.pcm_name, spcm->stream[0].d0i3_compatible);
+
 	caps = &spcm->pcm.caps[stream];
 
 	/* allocate playback page table buffer */
@@ -2360,6 +2373,9 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 	if (!spcm->pcm.capture)
 		return ret;
 
+	dev_vdbg(sdev->dev, "tplg: pcm %s stream tokens: capture d0i3:%d\n",
+		 spcm->pcm.pcm_name, spcm->stream[1].d0i3_compatible);
+
 	caps = &spcm->pcm.caps[stream];
 
 	/* allocate capture page table buffer */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#24 lore raw

[alsa-devel] Applied "ASoC: SOF: topology: parse and store d0i3_compatible flag" to the asoc tree

The patch

ASoC: SOF: topology: parse and store d0i3_compatible flag

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From c5232c0171428f005a3204e1c264231fb5999b28 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:05 -0500
Subject: [PATCH] ASoC: SOF: topology: parse and store d0i3_compatible flag

Parses the token from tplg file and store it to snd_sof_pcm_stream d0i3_compatible flag, which can be used later for d0ix transition management.

---
 sound/soc/sof/topology.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
sound/soc/sof/topology.c +16 -0
index 121e5d6f8477..cc138ac6a8eb 100644
@@ -2307,6 +2307,7 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 {
 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
 	struct snd_soc_tplg_stream_caps *caps;
+	struct snd_soc_tplg_private *private = &pcm->priv;
 	struct snd_sof_pcm *spcm;
 	int stream = SNDRV_PCM_STREAM_PLAYBACK;
 	int ret = 0;
@@ -2329,10 +2330,22 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 	dai_drv->dobj.private = spcm;
 	list_add(&spcm->list, &sdev->pcm_list);
 
+	ret = sof_parse_tokens(scomp, spcm, stream_tokens,
+			       ARRAY_SIZE(stream_tokens), private->array,
+			       le32_to_cpu(private->size));
+	if (ret) {
+		dev_err(sdev->dev, "error: parse stream tokens failed %d\n",
+			le32_to_cpu(private->size));
+		return ret;
+	}
+
 	/* do we need to allocate playback PCM DMA pages */
 	if (!spcm->pcm.playback)
 		goto capture;
 
+	dev_vdbg(sdev->dev, "tplg: pcm %s stream tokens: playback d0i3:%d\n",
+		 spcm->pcm.pcm_name, spcm->stream[0].d0i3_compatible);
+
 	caps = &spcm->pcm.caps[stream];
 
 	/* allocate playback page table buffer */
@@ -2360,6 +2373,9 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 	if (!spcm->pcm.capture)
 		return ret;
 
+	dev_vdbg(sdev->dev, "tplg: pcm %s stream tokens: capture d0i3:%d\n",
+		 spcm->pcm.pcm_name, spcm->stream[1].d0i3_compatible);
+
 	caps = &spcm->pcm.caps[stream];
 
 	/* allocate capture page table buffer */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#25 lore raw

PATCH 10/26 ASoC: SOF: Intel: hda-dsp: align the comments for D0I3C update

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Align the logs for CIP timeout at D0I3C.I3 updating.

---
 sound/soc/sof/intel/hda-dsp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/hda-dsp.c +2 -2
index fa2f1f66c72c..74805a066183 100644
@@ -330,7 +330,7 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	/* Write to D0I3C after Command-In-Progress bit is cleared */
 	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
 	if (ret < 0) {
-		dev_err(bus->dev, "CIP timeout before update D0I3C!\n");
+		dev_err(bus->dev, "CIP timeout before D0I3C update!\n");
 		return ret;
 	}
 
@@ -342,7 +342,7 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	retry = 50;
 	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
 	if (ret < 0) {
-		dev_err(bus->dev, "CIP timeout after D0I3C updated!\n");
+		dev_err(bus->dev, "CIP timeout after D0I3C update!\n");
 		return ret;
 	}
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#26 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: hda-dsp: align the comments for D0I3C update" to the asoc tree

The patch

ASoC: SOF: Intel: hda-dsp: align the comments for D0I3C update

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From aae7c82d01219bf568a7b12f5839d7ca52b17d59 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:06 -0500
Subject: [PATCH] ASoC: SOF: Intel: hda-dsp: align the comments for D0I3C
update

Align the logs for CIP timeout at D0I3C.I3 updating.

---
 sound/soc/sof/intel/hda-dsp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/hda-dsp.c +2 -2
index fa2f1f66c72c..74805a066183 100644
@@ -330,7 +330,7 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	/* Write to D0I3C after Command-In-Progress bit is cleared */
 	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
 	if (ret < 0) {
-		dev_err(bus->dev, "CIP timeout before update D0I3C!\n");
+		dev_err(bus->dev, "CIP timeout before D0I3C update!\n");
 		return ret;
 	}
 
@@ -342,7 +342,7 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	retry = 50;
 	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
 	if (ret < 0) {
-		dev_err(bus->dev, "CIP timeout after D0I3C updated!\n");
+		dev_err(bus->dev, "CIP timeout after D0I3C update!\n");
 		return ret;
 	}
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#27 lore raw

PATCH 11/26 ASoC: SOF: Intel: HDA: use macro for register polling retry count

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Define macro and use it for the register polling retry count.

---
 sound/soc/sof/intel/hda-dsp.c | 6 ++----
 sound/soc/sof/intel/hda.h     | 1 +
 2 files changed, 3 insertions(+), 4 deletions(-)
sound/soc/sof/intel/hda-dsp.c +2 -4
index 74805a066183..936361bd25e9 100644
@@ -323,12 +323,11 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 			    enum sof_d0_substate d0_substate)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
-	int retry = 50;
 	int ret;
 	u8 value;
 
 	/* Write to D0I3C after Command-In-Progress bit is cleared */
-	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	ret = hda_dsp_wait_d0i3c_done(sdev, HDA_DSP_REG_POLL_RETRY_COUNT);
 	if (ret < 0) {
 		dev_err(bus->dev, "CIP timeout before D0I3C update!\n");
 		return ret;
@@ -339,8 +338,7 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	snd_hdac_chip_updateb(bus, VS_D0I3C, SOF_HDA_VS_D0I3C_I3, value);
 
 	/* Wait for cmd in progress to be cleared before exiting the function */
-	retry = 50;
-	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	ret = hda_dsp_wait_d0i3c_done(sdev, HDA_DSP_REG_POLL_RETRY_COUNT);
 	if (ret < 0) {
 		dev_err(bus->dev, "CIP timeout after D0I3C update!\n");
 		return ret;
sound/soc/sof/intel/hda.h +1 -0
index 0e7c366b8f71..99ec60218c16 100644
@@ -214,6 +214,7 @@
 #define HDA_DSP_CTRL_RESET_TIMEOUT		100
 #define HDA_DSP_WAIT_TIMEOUT		500	/* 500 msec */
 #define HDA_DSP_REG_POLL_INTERVAL_US		500	/* 0.5 msec */
+#define HDA_DSP_REG_POLL_RETRY_COUNT		50
 
 #define HDA_DSP_ADSPIC_IPC			1
 #define HDA_DSP_ADSPIS_IPC			1
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#28 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: HDA: use macro for register polling retry count" to the asoc tree

The patch

ASoC: SOF: Intel: HDA: use macro for register polling retry count

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 92f4beb718d76e93b76343a3ba872df6cb210672 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:07 -0500
Subject: [PATCH] ASoC: SOF: Intel: HDA: use macro for register polling retry
count

Define macro and use it for the register polling retry count.

---
 sound/soc/sof/intel/hda-dsp.c | 6 ++----
 sound/soc/sof/intel/hda.h     | 1 +
 2 files changed, 3 insertions(+), 4 deletions(-)
sound/soc/sof/intel/hda-dsp.c +2 -4
index 74805a066183..936361bd25e9 100644
@@ -323,12 +323,11 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 			    enum sof_d0_substate d0_substate)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
-	int retry = 50;
 	int ret;
 	u8 value;
 
 	/* Write to D0I3C after Command-In-Progress bit is cleared */
-	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	ret = hda_dsp_wait_d0i3c_done(sdev, HDA_DSP_REG_POLL_RETRY_COUNT);
 	if (ret < 0) {
 		dev_err(bus->dev, "CIP timeout before D0I3C update!\n");
 		return ret;
@@ -339,8 +338,7 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	snd_hdac_chip_updateb(bus, VS_D0I3C, SOF_HDA_VS_D0I3C_I3, value);
 
 	/* Wait for cmd in progress to be cleared before exiting the function */
-	retry = 50;
-	ret = hda_dsp_wait_d0i3c_done(sdev, retry);
+	ret = hda_dsp_wait_d0i3c_done(sdev, HDA_DSP_REG_POLL_RETRY_COUNT);
 	if (ret < 0) {
 		dev_err(bus->dev, "CIP timeout after D0I3C update!\n");
 		return ret;
sound/soc/sof/intel/hda.h +1 -0
index 0e7c366b8f71..99ec60218c16 100644
@@ -214,6 +214,7 @@
 #define HDA_DSP_CTRL_RESET_TIMEOUT		100
 #define HDA_DSP_WAIT_TIMEOUT		500	/* 500 msec */
 #define HDA_DSP_REG_POLL_INTERVAL_US		500	/* 0.5 msec */
+#define HDA_DSP_REG_POLL_RETRY_COUNT		50
 
 #define HDA_DSP_ADSPIC_IPC			1
 #define HDA_DSP_ADSPIS_IPC			1
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#29 lore raw

PATCH 12/26 ASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

The helper sof_send_pm_ipc() is only suitable for context save/restore IPCs' sending, so rename it to sof_send_pm_ctx_ipc here.

---
 sound/soc/sof/pm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/pm.c +3 -3
index 81e623dfc7e5..ac900fb3379e 100644
@@ -197,7 +197,7 @@ static int sof_restore_pipelines(struct snd_sof_dev *sdev)
 	return ret;
 }
 
-static int sof_send_pm_ipc(struct snd_sof_dev *sdev, int cmd)
+static int sof_send_pm_ctx_ipc(struct snd_sof_dev *sdev, int cmd)
 {
 	struct sof_ipc_pm_ctx pm_ctx;
 	struct sof_ipc_reply reply;
@@ -320,7 +320,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
 	}
 
 	/* notify DSP of system resume */
-	ret = sof_send_pm_ipc(sdev, SOF_IPC_PM_CTX_RESTORE);
+	ret = sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_RESTORE);
 	if (ret < 0)
 		dev_err(sdev->dev,
 			"error: ctx_restore ipc error during resume %d\n",
@@ -361,7 +361,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
 		sof_cache_debugfs(sdev);
 #endif
 	/* notify DSP of upcoming power down */
-	ret = sof_send_pm_ipc(sdev, SOF_IPC_PM_CTX_SAVE);
+	ret = sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_SAVE);
 	if (ret == -EBUSY || ret == -EAGAIN) {
 		/*
 		 * runtime PM has logic to handle -EBUSY/-EAGAIN so
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#30 lore raw

[alsa-devel] Applied "ASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc" to the asoc tree

The patch

ASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 7c7eba2402c11137d1fa1d3fb964a2c6fc1ded3e Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:08 -0500
Subject: [PATCH] ASoC: SOF: PM: rename sof_send_pm_ipc to sof_send_pm_ctx_ipc

The helper sof_send_pm_ipc() is only suitable for context save/restore IPCs' sending, so rename it to sof_send_pm_ctx_ipc here.

---
 sound/soc/sof/pm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/pm.c +3 -3
index 81e623dfc7e5..ac900fb3379e 100644
@@ -197,7 +197,7 @@ static int sof_restore_pipelines(struct snd_sof_dev *sdev)
 	return ret;
 }
 
-static int sof_send_pm_ipc(struct snd_sof_dev *sdev, int cmd)
+static int sof_send_pm_ctx_ipc(struct snd_sof_dev *sdev, int cmd)
 {
 	struct sof_ipc_pm_ctx pm_ctx;
 	struct sof_ipc_reply reply;
@@ -320,7 +320,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
 	}
 
 	/* notify DSP of system resume */
-	ret = sof_send_pm_ipc(sdev, SOF_IPC_PM_CTX_RESTORE);
+	ret = sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_RESTORE);
 	if (ret < 0)
 		dev_err(sdev->dev,
 			"error: ctx_restore ipc error during resume %d\n",
@@ -361,7 +361,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
 		sof_cache_debugfs(sdev);
 #endif
 	/* notify DSP of upcoming power down */
-	ret = sof_send_pm_ipc(sdev, SOF_IPC_PM_CTX_SAVE);
+	ret = sof_send_pm_ctx_ipc(sdev, SOF_IPC_PM_CTX_SAVE);
 	if (ret == -EBUSY || ret == -EAGAIN) {
 		/*
 		 * runtime PM has logic to handle -EBUSY/-EAGAIN so
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#31 lore raw

PATCH 13/26 ASoC: SOF: ipc: introduce message for DSP power gating

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add new ipc messages which will be sent from driver to FW, to ask FW to enter specific power saving state.

---
 include/sound/sof/header.h | 1 +
 include/sound/sof/pm.h     | 8 ++++++++
 2 files changed, 9 insertions(+)
include/sound/sof/header.h +1 -0
index 332143ff7278..bf3edd9c08b4 100644
@@ -75,6 +75,7 @@
 #define SOF_IPC_PM_CLK_GET			SOF_CMD_TYPE(0x005)
 #define SOF_IPC_PM_CLK_REQ			SOF_CMD_TYPE(0x006)
 #define SOF_IPC_PM_CORE_ENABLE			SOF_CMD_TYPE(0x007)
+#define SOF_IPC_PM_GATE				SOF_CMD_TYPE(0x008)
 
 /* component runtime config - multiple different types */
 #define SOF_IPC_COMP_SET_VALUE			SOF_CMD_TYPE(0x001)
include/sound/sof/pm.h +8 -0
index 003879401d63..3cf2e0f39d94 100644
@@ -45,4 +45,12 @@ struct sof_ipc_pm_core_config {
 	uint32_t enable_mask;
 } __packed;
 
+struct sof_ipc_pm_gate {
+	struct sof_ipc_cmd_hdr hdr;
+	uint32_t flags;	/* platform specific */
+
+	/* reserved for future use */
+	uint32_t reserved[5];
+} __packed;
+
 #endif
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#32 lore raw

[alsa-devel] Applied "ASoC: SOF: ipc: introduce message for DSP power gating" to the asoc tree

The patch

ASoC: SOF: ipc: introduce message for DSP power gating

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 10992004e1e960c7e256ec70c7ab22895a7003d7 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:09 -0500
Subject: [PATCH] ASoC: SOF: ipc: introduce message for DSP power gating

Add new ipc messages which will be sent from driver to FW, to ask FW to enter specific power saving state.

---
 include/sound/sof/header.h | 1 +
 include/sound/sof/pm.h     | 8 ++++++++
 2 files changed, 9 insertions(+)
include/sound/sof/header.h +1 -0
index 332143ff7278..bf3edd9c08b4 100644
@@ -75,6 +75,7 @@
 #define SOF_IPC_PM_CLK_GET			SOF_CMD_TYPE(0x005)
 #define SOF_IPC_PM_CLK_REQ			SOF_CMD_TYPE(0x006)
 #define SOF_IPC_PM_CORE_ENABLE			SOF_CMD_TYPE(0x007)
+#define SOF_IPC_PM_GATE				SOF_CMD_TYPE(0x008)
 
 /* component runtime config - multiple different types */
 #define SOF_IPC_COMP_SET_VALUE			SOF_CMD_TYPE(0x001)
include/sound/sof/pm.h +8 -0
index 003879401d63..3cf2e0f39d94 100644
@@ -45,4 +45,12 @@ struct sof_ipc_pm_core_config {
 	uint32_t enable_mask;
 } __packed;
 
+struct sof_ipc_pm_gate {
+	struct sof_ipc_cmd_hdr hdr;
+	uint32_t flags;	/* platform specific */
+
+	/* reserved for future use */
+	uint32_t reserved[5];
+} __packed;
+
 #endif
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#33 lore raw

PATCH 14/26 ASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE reply

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Memory windows could be powered off before receiving PM_GATE IPC reply from FW, we can't read the mailbox to get reply.

---
 sound/soc/sof/intel/hda-ipc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/sof/intel/hda-ipc.c +4 -2
index 6aae6f18b3dc..0fd2153c1769 100644
@@ -83,10 +83,12 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
 	}
 
 	hdr = msg->msg_data;
-	if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE)) {
+	if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE) ||
+	    hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE)) {
 		/*
 		 * memory windows are powered off before sending IPC reply,
-		 * so we can't read the mailbox for CTX_SAVE reply.
+		 * so we can't read the mailbox for CTX_SAVE and PM_GATE
+		 * replies.
 		 */
 		reply.error = 0;
 		reply.hdr.cmd = SOF_IPC_GLB_REPLY;
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#34 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE reply" to the asoc tree

The patch

ASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE reply

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 463fbf6dc03aff41e973602bbad6cb135fa6d48a Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:10 -0500
Subject: [PATCH] ASoC: SOF: Intel: hda-ipc: Don't read mailbox for PM_GATE
reply

Memory windows could be powered off before receiving PM_GATE IPC reply from FW, we can't read the mailbox to get reply.

---
 sound/soc/sof/intel/hda-ipc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/sof/intel/hda-ipc.c +4 -2
index 6aae6f18b3dc..0fd2153c1769 100644
@@ -83,10 +83,12 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
 	}
 
 	hdr = msg->msg_data;
-	if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE)) {
+	if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE) ||
+	    hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE)) {
 		/*
 		 * memory windows are powered off before sending IPC reply,
-		 * so we can't read the mailbox for CTX_SAVE reply.
+		 * so we can't read the mailbox for CTX_SAVE and PM_GATE
+		 * replies.
 		 */
 		reply.error = 0;
 		reply.hdr.cmd = SOF_IPC_GLB_REPLY;
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#35 lore raw

PATCH 15/26 ASoC: SOF: Intel: HDA: add cAVS specific compact IPC header file

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

On cAVS platforms, some IPCs are required to be sent via IPC registers only(e.g. when in D0i3, mailbox is unaccessible), add hda-ipc.h to hold definition of those compact IPCs.

---
 sound/soc/sof/intel/hda-ipc.h | 51 +++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 sound/soc/sof/intel/hda-ipc.h
sound/soc/sof/intel/hda-ipc.h new file +51 -0
new file mode 100644
index 000000000000..aef0ceac9803
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * Copyright(c) 2019 Intel Corporation. All rights reserved.
+ *
+ * Author: Keyon Jie <[email protected]>
+ */
+
+#ifndef __SOF_INTEL_HDA_IPC_H
+#define __SOF_INTEL_HDA_IPC_H
+
+/*
+ * Primary register, mapped to
+ * - DIPCTDR (HIPCIDR) in sideband IPC (cAVS 1.8+)
+ * - DIPCT in cAVS 1.5 IPC
+ *
+ * Secondary register, mapped to:
+ * - DIPCTDD (HIPCIDD) in sideband IPC (cAVS 1.8+)
+ * - DIPCTE in cAVS 1.5 IPC
+ */
+
+/* Common bits in primary register */
+
+/* Reserved for doorbell */
+#define HDA_IPC_RSVD_31		BIT(31)
+/* Target, 0 - normal message, 1 - compact message(cAVS compatible) */
+#define HDA_IPC_MSG_COMPACT	BIT(30)
+/* Direction, 0 - request, 1 - response */
+#define HDA_IPC_RSP		BIT(29)
+
+#define HDA_IPC_TYPE_SHIFT	24
+#define HDA_IPC_TYPE_MASK	GENMASK(28, 24)
+#define HDA_IPC_TYPE(x)		((x) << HDA_IPC_TYPE_SHIFT)
+
+#define HDA_IPC_PM_GATE		HDA_IPC_TYPE(0x8U)
+
+/* Command specific payload bits in secondary register */
+
+/* Disable DMA tracing (0 - keep tracing, 1 - to disable DMA trace) */
+#define HDA_PM_NO_DMA_TRACE	BIT(4)
+/* Prevent clock gating (0 - cg allowed, 1 - DSP clock always on) */
+#define HDA_PM_PCG		BIT(3)
+/* Prevent power gating (0 - deep power state transitions allowed) */
+#define HDA_PM_PPG		BIT(2)
+/* Indicates whether streaming is active */
+#define HDA_PM_PG_STREAMING	BIT(1)
+#define HDA_PM_PG_RSVD		BIT(0)
+
+#endif
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#36 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: HDA: add cAVS specific compact IPC header file" to the asoc tree

The patch

ASoC: SOF: Intel: HDA: add cAVS specific compact IPC header file

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 5056193d4d1a8b73087145add21141c46027d6a2 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:11 -0500
Subject: [PATCH] ASoC: SOF: Intel: HDA: add cAVS specific compact IPC header
file

On cAVS platforms, some IPCs are required to be sent via IPC registers only(e.g. when in D0i3, mailbox is unaccessible), add hda-ipc.h to hold definition of those compact IPCs.

---
 sound/soc/sof/intel/hda-ipc.h | 51 +++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 sound/soc/sof/intel/hda-ipc.h
sound/soc/sof/intel/hda-ipc.h new file +51 -0
new file mode 100644
index 000000000000..aef0ceac9803
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * Copyright(c) 2019 Intel Corporation. All rights reserved.
+ *
+ * Author: Keyon Jie <[email protected]>
+ */
+
+#ifndef __SOF_INTEL_HDA_IPC_H
+#define __SOF_INTEL_HDA_IPC_H
+
+/*
+ * Primary register, mapped to
+ * - DIPCTDR (HIPCIDR) in sideband IPC (cAVS 1.8+)
+ * - DIPCT in cAVS 1.5 IPC
+ *
+ * Secondary register, mapped to:
+ * - DIPCTDD (HIPCIDD) in sideband IPC (cAVS 1.8+)
+ * - DIPCTE in cAVS 1.5 IPC
+ */
+
+/* Common bits in primary register */
+
+/* Reserved for doorbell */
+#define HDA_IPC_RSVD_31		BIT(31)
+/* Target, 0 - normal message, 1 - compact message(cAVS compatible) */
+#define HDA_IPC_MSG_COMPACT	BIT(30)
+/* Direction, 0 - request, 1 - response */
+#define HDA_IPC_RSP		BIT(29)
+
+#define HDA_IPC_TYPE_SHIFT	24
+#define HDA_IPC_TYPE_MASK	GENMASK(28, 24)
+#define HDA_IPC_TYPE(x)		((x) << HDA_IPC_TYPE_SHIFT)
+
+#define HDA_IPC_PM_GATE		HDA_IPC_TYPE(0x8U)
+
+/* Command specific payload bits in secondary register */
+
+/* Disable DMA tracing (0 - keep tracing, 1 - to disable DMA trace) */
+#define HDA_PM_NO_DMA_TRACE	BIT(4)
+/* Prevent clock gating (0 - cg allowed, 1 - DSP clock always on) */
+#define HDA_PM_PCG		BIT(3)
+/* Prevent power gating (0 - deep power state transitions allowed) */
+#define HDA_PM_PPG		BIT(2)
+/* Indicates whether streaming is active */
+#define HDA_PM_PG_STREAMING	BIT(1)
+#define HDA_PM_PG_RSVD		BIT(0)
+
+#endif
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#37 lore raw

PATCH 16/26 ASoC: SOF: configure D0ix IPC flags in set_power_state

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

The configuration for D0ix in FW is platform specific, let's do this and send IPC in the platform set_power_state() ops.

---
 sound/soc/sof/intel/hda-dsp.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
sound/soc/sof/intel/hda-dsp.c +31 -1
index 936361bd25e9..b5070409a5e3 100644
@@ -19,6 +19,7 @@
 #include <sound/hda_register.h>
 #include "../ops.h"
 #include "hda.h"
+#include "hda-ipc.h"
 
 /*
  * DSP Core control.
@@ -319,10 +320,28 @@ static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry)
 	return 0;
 }
 
+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;
+
+	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(sdev->ipc, pm_gate.hdr.cmd, &pm_gate,
+				  sizeof(pm_gate), &reply, sizeof(reply));
+}
+
 int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 			    enum sof_d0_substate d0_substate)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
+	u32 flags;
 	int ret;
 	u8 value;
 
@@ -347,7 +366,18 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
 		 snd_hdac_chip_readb(bus, VS_D0I3C));
 
-	return 0;
+	if (d0_substate == SOF_DSP_D0I0)
+		flags = HDA_PM_PPG;/* prevent power gating in D0 */
+	else
+		flags = HDA_PM_NO_DMA_TRACE;/* disable DMA trace in D0I3*/
+
+	/* sending pm_gate IPC */
+	ret = hda_dsp_send_pm_gate_ipc(sdev, flags);
+	if (ret < 0)
+		dev_err(sdev->dev,
+			"error: PM_GATE ipc error %d\n", ret);
+
+	return ret;
 }
 
 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#38 lore raw

[alsa-devel] Applied "ASoC: SOF: configure D0ix IPC flags in set_power_state" to the asoc tree

The patch

ASoC: SOF: configure D0ix IPC flags in set_power_state

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 534037fddd34b58be86a826d449a5a6635ecdbf5 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:12 -0500
Subject: [PATCH] ASoC: SOF: configure D0ix IPC flags in set_power_state

The configuration for D0ix in FW is platform specific, let's do this and send IPC in the platform set_power_state() ops.

---
 sound/soc/sof/intel/hda-dsp.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
sound/soc/sof/intel/hda-dsp.c +31 -1
index 936361bd25e9..b5070409a5e3 100644
@@ -19,6 +19,7 @@
 #include <sound/hda_register.h>
 #include "../ops.h"
 #include "hda.h"
+#include "hda-ipc.h"
 
 /*
  * DSP Core control.
@@ -319,10 +320,28 @@ static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry)
 	return 0;
 }
 
+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;
+
+	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(sdev->ipc, pm_gate.hdr.cmd, &pm_gate,
+				  sizeof(pm_gate), &reply, sizeof(reply));
+}
+
 int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 			    enum sof_d0_substate d0_substate)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
+	u32 flags;
 	int ret;
 	u8 value;
 
@@ -347,7 +366,18 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
 	dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
 		 snd_hdac_chip_readb(bus, VS_D0I3C));
 
-	return 0;
+	if (d0_substate == SOF_DSP_D0I0)
+		flags = HDA_PM_PPG;/* prevent power gating in D0 */
+	else
+		flags = HDA_PM_NO_DMA_TRACE;/* disable DMA trace in D0I3*/
+
+	/* sending pm_gate IPC */
+	ret = hda_dsp_send_pm_gate_ipc(sdev, flags);
+	if (ret < 0)
+		dev_err(sdev->dev,
+			"error: PM_GATE ipc error %d\n", ret);
+
+	return ret;
 }
 
 static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#39 lore raw

Re: [alsa-devel] [PATCH 16/26] ASoC: SOF: configure D0ix IPC flags in set_power_state

In reply to Pierre-Louis Bossart

sound/soc/sof/intel/hda-dsp.c static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev, int retry) · line 335

Quoted 13 lines · Pierre-Louis Bossart
sound/soc/sof/intel/hda-dsp.c +13 -0
+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;
+
+	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 */

Is this comment necessary?

Quoted 13 lines
sound/soc/sof/intel/hda-dsp.c +5 -0
+	return sof_ipc_tx_message(sdev->ipc, pm_gate.hdr.cmd, &pm_gate,
+				  sizeof(pm_gate), &reply, sizeof(reply));
+}
+
  int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
  			    enum sof_d0_substate d0_substate)
  {
  	struct hdac_bus *bus = sof_to_bus(sdev);
+	u32 flags;
  	int ret;
  	u8 value;

sound/soc/sof/intel/hda-dsp.c int hda_dsp_set_power_state(struct snd_sof_dev *sdev, · line 372

Quoted 8 lines
sound/soc/sof/intel/hda-dsp.c +4 -1
@@ -347,7 +366,18 @@ int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
  	dev_vdbg(bus->dev, "D0I3C updated, register = 0x%x\n",
  		 snd_hdac_chip_readb(bus, VS_D0I3C));
 
-	return 0;
+	if (d0_substate == SOF_DSP_D0I0)
+		flags = HDA_PM_PPG;/* prevent power gating in D0 */
+	else
+		flags = HDA_PM_NO_DMA_TRACE;/* disable DMA trace in D0I3*/

Missing spaces between code and comments.
Could you explain what DMA trace has to do with your flow?

sound/soc/sof/intel/hda-dsp.c int hda_dsp_set_power_state(struct snd_sof_dev *sdev, · line 379

Quoted 7 lines
sound/soc/sof/intel/hda-dsp.c +7 -0
+
+	/* sending pm_gate IPC */
+	ret = hda_dsp_send_pm_gate_ipc(sdev, flags);
+	if (ret < 0)
+		dev_err(sdev->dev,
+			"error: PM_GATE ipc error %d\n", ret);
+

Being so detailed within each ipc handler does not increase code readability. Having single "pipe" which all ipcs go through with common dev_err dumping fw error/ status and ipc's header is the better option IMHO. These are so many IPC handlers. Assume you change "error msg format". With current approach each and every handler with have to be updated.

sound/soc/sof/intel/hda-dsp.c int hda_dsp_set_power_state(struct snd_sof_dev *sdev, · line 383

Quoted 5 lines
sound/soc/sof/intel/hda-dsp.c +1 -0
+	return ret;
  }
 
  static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#40 lore raw

PATCH 17/26 ASoC: SOF: PM: add helpers for setting D0 substate for ADSP

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add snd_sof_set_d0_substate() helper for setting ADSP to a specific D0 substate, it will call into the platform specific implementation, and update the d0_substate at success.

---
 sound/soc/sof/pm.c       | 17 +++++++++++++++++
 sound/soc/sof/sof-priv.h |  2 ++
 2 files changed, 19 insertions(+)
sound/soc/sof/pm.c +17 -0
index ac900fb3379e..584241e9734a 100644
@@ -411,6 +411,23 @@ int snd_sof_runtime_resume(struct device *dev)
 }
 EXPORT_SYMBOL(snd_sof_runtime_resume);
 
+int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate)
+{
+	int ret;
+
+	/* do platform specific set_state */
+	ret = snd_sof_dsp_set_power_state(sdev, d0_substate);
+	if (ret < 0)
+		return ret;
+
+	/* update dsp D0 sub-state */
+	sdev->d0_substate = d0_substate;
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_sof_set_d0_substate);
+
 int snd_sof_resume(struct device *dev)
 {
 	return sof_resume(dev, false);
sound/soc/sof/sof-priv.h +2 -0
index 7a21a45d3635..2231c673c678 100644
@@ -485,6 +485,8 @@ int snd_sof_runtime_resume(struct device *dev);
 int snd_sof_runtime_idle(struct device *dev);
 int snd_sof_resume(struct device *dev);
 int snd_sof_suspend(struct device *dev);
+int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate);
 
 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#41 lore raw

[alsa-devel] Applied "ASoC: SOF: PM: add helpers for setting D0 substate for ADSP" to the asoc tree

The patch

ASoC: SOF: PM: add helpers for setting D0 substate for ADSP

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 601252869f50af6f5ab377e7f4846d7b09cc66c0 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:13 -0500
Subject: [PATCH] ASoC: SOF: PM: add helpers for setting D0 substate for ADSP

Add snd_sof_set_d0_substate() helper for setting ADSP to a specific D0 substate, it will call into the platform specific implementation, and update the d0_substate at success.

---
 sound/soc/sof/pm.c       | 17 +++++++++++++++++
 sound/soc/sof/sof-priv.h |  2 ++
 2 files changed, 19 insertions(+)
sound/soc/sof/pm.c +17 -0
index ac900fb3379e..584241e9734a 100644
@@ -411,6 +411,23 @@ int snd_sof_runtime_resume(struct device *dev)
 }
 EXPORT_SYMBOL(snd_sof_runtime_resume);
 
+int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate)
+{
+	int ret;
+
+	/* do platform specific set_state */
+	ret = snd_sof_dsp_set_power_state(sdev, d0_substate);
+	if (ret < 0)
+		return ret;
+
+	/* update dsp D0 sub-state */
+	sdev->d0_substate = d0_substate;
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_sof_set_d0_substate);
+
 int snd_sof_resume(struct device *dev)
 {
 	return sof_resume(dev, false);
sound/soc/sof/sof-priv.h +2 -0
index 7a21a45d3635..2231c673c678 100644
@@ -485,6 +485,8 @@ int snd_sof_runtime_resume(struct device *dev);
 int snd_sof_runtime_idle(struct device *dev);
 int snd_sof_resume(struct device *dev);
 int snd_sof_suspend(struct device *dev);
+int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate);
 
 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#42 lore raw

Re: [alsa-devel] [PATCH 17/26] ASoC: SOF: PM: add helpers for setting D0 substate for ADSP

In reply to Pierre-Louis Bossart
Quoted 6 lines · Pierre-Louis Bossart
sound/soc/sof/pm.c +6 -0
+int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
+			    enum sof_d0_substate d0_substate)
+{
+	int ret;
+
+	/* do platform specific set_state */

sound/soc/sof/pm.c int snd_sof_runtime_resume(struct device *dev) · line 429

Quoted 10 lines
sound/soc/sof/pm.c +10 -0
+	ret = snd_sof_dsp_set_power_state(sdev, d0_substate);
+	if (ret < 0)
+		return ret;
+
+	/* update dsp D0 sub-state */
+	sdev->d0_substate = d0_substate;
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_sof_set_d0_substate);

Are reason for not merging this directly with snd_sof_dsp_set_power_state?
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#43 lore raw

PATCH 18/26 ASoC: SOF: Intel: CNL: add support for sending compact IPC

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

For compact IPCs, we will send the IPC header/command via the HIPCIDR register and the first 32bit payload via the HIPCIDD register, no mailbox will be used.

---
 sound/soc/sof/intel/cnl.c | 42 ++++++++++++++++++++++++++++++++++-----
 sound/soc/sof/intel/hda.h |  1 +
 2 files changed, 38 insertions(+), 5 deletions(-)
sound/soc/sof/intel/cnl.c +37 -5
index 982b81a0b13a..0e1e265f3f3b 100644
@@ -17,6 +17,7 @@
 
 #include "../ops.h"
 #include "hda.h"
+#include "hda-ipc.h"
 
 static const struct snd_sof_debugfs_map cnl_dsp_debugfs[] = {
 	{"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS},
@@ -150,14 +151,45 @@ static void cnl_ipc_dsp_done(struct snd_sof_dev *sdev)
 				CNL_DSP_REG_HIPCCTL_DONE);
 }
 
+static bool cnl_compact_ipc_compress(struct snd_sof_ipc_msg *msg,
+				     u32 *dr, u32 *dd)
+{
+	struct sof_ipc_pm_gate *pm_gate;
+
+	if (msg->header == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE)) {
+		pm_gate = msg->msg_data;
+
+		/* send the compact message via the primary register */
+		*dr = HDA_IPC_MSG_COMPACT | HDA_IPC_PM_GATE;
+
+		/* send payload via the extended data register */
+		*dd = pm_gate->flags;
+
+		return true;
+	}
+
+	return false;
+}
+
 static int cnl_ipc_send_msg(struct snd_sof_dev *sdev,
 			    struct snd_sof_ipc_msg *msg)
 {
-	/* send the message */
-	sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
-			  msg->msg_size);
-	snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
-			  CNL_DSP_REG_HIPCIDR_BUSY);
+	u32 dr = 0;
+	u32 dd = 0;
+
+	if (cnl_compact_ipc_compress(msg, &dr, &dd)) {
+		/* send the message via IPC registers */
+		snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDD,
+				  dd);
+		snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
+				  CNL_DSP_REG_HIPCIDR_BUSY | dr);
+	} else {
+		/* send the message via mailbox */
+		sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
+				  msg->msg_size);
+		snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
+				  CNL_DSP_REG_HIPCIDR_BUSY);
+	}
 
 	return 0;
 }
sound/soc/sof/intel/hda.h +1 -0
index 99ec60218c16..52a87a47029d 100644
@@ -312,6 +312,7 @@
 #define CNL_DSP_REG_HIPCTDD		(CNL_DSP_IPC_BASE + 0x08)
 #define CNL_DSP_REG_HIPCIDR		(CNL_DSP_IPC_BASE + 0x10)
 #define CNL_DSP_REG_HIPCIDA		(CNL_DSP_IPC_BASE + 0x14)
+#define CNL_DSP_REG_HIPCIDD		(CNL_DSP_IPC_BASE + 0x18)
 #define CNL_DSP_REG_HIPCCTL		(CNL_DSP_IPC_BASE + 0x28)
 
 /*  HIPCI */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#44 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: CNL: add support for sending compact IPC" to the asoc tree

The patch

ASoC: SOF: Intel: CNL: add support for sending compact IPC

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 0267de58acfe5059ace739741f1533dd605ed22f Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:14 -0500
Subject: [PATCH] ASoC: SOF: Intel: CNL: add support for sending compact IPC

For compact IPCs, we will send the IPC header/command via the HIPCIDR register and the first 32bit payload via the HIPCIDD register, no mailbox will be used.

---
 sound/soc/sof/intel/cnl.c | 42 ++++++++++++++++++++++++++++++++++-----
 sound/soc/sof/intel/hda.h |  1 +
 2 files changed, 38 insertions(+), 5 deletions(-)
sound/soc/sof/intel/cnl.c +37 -5
index 982b81a0b13a..0e1e265f3f3b 100644
@@ -17,6 +17,7 @@
 
 #include "../ops.h"
 #include "hda.h"
+#include "hda-ipc.h"
 
 static const struct snd_sof_debugfs_map cnl_dsp_debugfs[] = {
 	{"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS},
@@ -150,14 +151,45 @@ static void cnl_ipc_dsp_done(struct snd_sof_dev *sdev)
 				CNL_DSP_REG_HIPCCTL_DONE);
 }
 
+static bool cnl_compact_ipc_compress(struct snd_sof_ipc_msg *msg,
+				     u32 *dr, u32 *dd)
+{
+	struct sof_ipc_pm_gate *pm_gate;
+
+	if (msg->header == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE)) {
+		pm_gate = msg->msg_data;
+
+		/* send the compact message via the primary register */
+		*dr = HDA_IPC_MSG_COMPACT | HDA_IPC_PM_GATE;
+
+		/* send payload via the extended data register */
+		*dd = pm_gate->flags;
+
+		return true;
+	}
+
+	return false;
+}
+
 static int cnl_ipc_send_msg(struct snd_sof_dev *sdev,
 			    struct snd_sof_ipc_msg *msg)
 {
-	/* send the message */
-	sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
-			  msg->msg_size);
-	snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
-			  CNL_DSP_REG_HIPCIDR_BUSY);
+	u32 dr = 0;
+	u32 dd = 0;
+
+	if (cnl_compact_ipc_compress(msg, &dr, &dd)) {
+		/* send the message via IPC registers */
+		snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDD,
+				  dd);
+		snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
+				  CNL_DSP_REG_HIPCIDR_BUSY | dr);
+	} else {
+		/* send the message via mailbox */
+		sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
+				  msg->msg_size);
+		snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
+				  CNL_DSP_REG_HIPCIDR_BUSY);
+	}
 
 	return 0;
 }
sound/soc/sof/intel/hda.h +1 -0
index 99ec60218c16..52a87a47029d 100644
@@ -312,6 +312,7 @@
 #define CNL_DSP_REG_HIPCTDD		(CNL_DSP_IPC_BASE + 0x08)
 #define CNL_DSP_REG_HIPCIDR		(CNL_DSP_IPC_BASE + 0x10)
 #define CNL_DSP_REG_HIPCIDA		(CNL_DSP_IPC_BASE + 0x14)
+#define CNL_DSP_REG_HIPCIDD		(CNL_DSP_IPC_BASE + 0x18)
 #define CNL_DSP_REG_HIPCCTL		(CNL_DSP_IPC_BASE + 0x28)
 
 /*  HIPCI */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#45 lore raw

PATCH 19/26 ASoC: SOF: add a flag to indicate the system suspend target

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add flag 's0_suspend' to indicate if the system is entering S0ix or not.

---
 sound/soc/sof/sof-priv.h | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/sof/sof-priv.h +2 -0
index 2231c673c678..e715673f20e5 100644
@@ -398,6 +398,8 @@ struct snd_sof_dev {
 
 	/* power states related */
 	enum sof_d0_substate d0_substate;
+	/* flag to track if the intended power target of suspend is S0ix */
+	bool s0_suspend;
 
 	/* DSP firmware boot */
 	wait_queue_head_t boot_wait;
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#46 lore raw

[alsa-devel] Applied "ASoC: SOF: add a flag to indicate the system suspend target" to the asoc tree

The patch

ASoC: SOF: add a flag to indicate the system suspend target

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 7367d3096b1443e55a2c730d1966f423b15d5cad Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:15 -0500
Subject: [PATCH] ASoC: SOF: add a flag to indicate the system suspend target

Add flag 's0_suspend' to indicate if the system is entering S0ix or not.

---
 sound/soc/sof/sof-priv.h | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/sof/sof-priv.h +2 -0
index 2231c673c678..e715673f20e5 100644
@@ -398,6 +398,8 @@ struct snd_sof_dev {
 
 	/* power states related */
 	enum sof_d0_substate d0_substate;
+	/* flag to track if the intended power target of suspend is S0ix */
+	bool s0_suspend;
 
 	/* DSP firmware boot */
 	wait_queue_head_t boot_wait;
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#47 lore raw

PATCH 20/26 ASoC: SOF: add a flag suspend_ignored for sof stream

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Add a suspend_ignored flag to snd_sof_pcm_stream that will be used to decide if the corresponding FW pipeline should be kept active to perform always on tasks when the system is entering the S0ix state.

---
 sound/soc/sof/sof-priv.h | 5 +++++
 1 file changed, 5 insertions(+)
sound/soc/sof/sof-priv.h +5 -0
index e715673f20e5..c2541d020bde 100644
@@ -311,6 +311,11 @@ struct snd_sof_pcm_stream {
 	struct snd_pcm_substream *substream;
 	struct work_struct period_elapsed_work;
 	bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
+	/*
+	 * flag to indicate that the DSP pipelines should be kept
+	 * active or not while suspending the stream
+	 */
+	bool suspend_ignored;
 };
 
 /* ALSA SOF PCM device */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#48 lore raw

[alsa-devel] Applied "ASoC: SOF: add a flag suspend_ignored for sof stream" to the asoc tree

The patch

ASoC: SOF: add a flag suspend_ignored for sof stream

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 4cd933abd4820da7eefe672ff439b32d199a07be Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:16 -0500
Subject: [PATCH] ASoC: SOF: add a flag suspend_ignored for sof stream

Add a suspend_ignored flag to snd_sof_pcm_stream that will be used to decide if the corresponding FW pipeline should be kept active to perform always on tasks when the system is entering the S0ix state.

---
 sound/soc/sof/sof-priv.h | 5 +++++
 1 file changed, 5 insertions(+)
sound/soc/sof/sof-priv.h +5 -0
index e715673f20e5..c2541d020bde 100644
@@ -311,6 +311,11 @@ struct snd_sof_pcm_stream {
 	struct snd_pcm_substream *substream;
 	struct work_struct period_elapsed_work;
 	bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
+	/*
+	 * flag to indicate that the DSP pipelines should be kept
+	 * active or not while suspending the stream
+	 */
+	bool suspend_ignored;
 };
 
 /* ALSA SOF PCM device */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#49 lore raw

PATCH 21/26 ASoC: SOF: PM: implement prepare/complete callbacks

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Implement the prepare() and complete() callbacks for power management, initialize s0_suspend flag at prepare(), and reset it at complete().

---
 sound/soc/sof/pm.c       | 23 +++++++++++++++++++++++
 sound/soc/sof/sof-priv.h |  2 ++
 2 files changed, 25 insertions(+)
sound/soc/sof/pm.c +23 -0
index 584241e9734a..99e4e6ffff74 100644
@@ -439,3 +439,26 @@ int snd_sof_suspend(struct device *dev)
 	return sof_suspend(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_suspend);
+
+int snd_sof_prepare(struct device *dev)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+
+#if defined(CONFIG_ACPI)
+	sdev->s0_suspend = acpi_target_system_state() == ACPI_STATE_S0;
+#else
+	/* will suspend to S3 by default */
+	sdev->s0_suspend = false;
+#endif
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_sof_prepare);
+
+void snd_sof_complete(struct device *dev)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+
+	sdev->s0_suspend = false;
+}
+EXPORT_SYMBOL(snd_sof_complete);
sound/soc/sof/sof-priv.h +2 -0
index c2541d020bde..6408ac88a3e5 100644
@@ -492,6 +492,8 @@ int snd_sof_runtime_resume(struct device *dev);
 int snd_sof_runtime_idle(struct device *dev);
 int snd_sof_resume(struct device *dev);
 int snd_sof_suspend(struct device *dev);
+int snd_sof_prepare(struct device *dev);
+void snd_sof_complete(struct device *dev);
 int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
 			    enum sof_d0_substate d0_substate);
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#50 lore raw

[alsa-devel] Applied "ASoC: SOF: PM: implement prepare/complete callbacks" to the asoc tree

The patch

ASoC: SOF: PM: implement prepare/complete callbacks

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 0b50b3b1c3bc2a2c9eeab418b3de3e60e0530cf4 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:17 -0500
Subject: [PATCH] ASoC: SOF: PM: implement prepare/complete callbacks

Implement the prepare() and complete() callbacks for power management, initialize s0_suspend flag at prepare(), and reset it at complete().

---
 sound/soc/sof/pm.c       | 23 +++++++++++++++++++++++
 sound/soc/sof/sof-priv.h |  2 ++
 2 files changed, 25 insertions(+)
sound/soc/sof/pm.c +23 -0
index 584241e9734a..99e4e6ffff74 100644
@@ -439,3 +439,26 @@ int snd_sof_suspend(struct device *dev)
 	return sof_suspend(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_suspend);
+
+int snd_sof_prepare(struct device *dev)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+
+#if defined(CONFIG_ACPI)
+	sdev->s0_suspend = acpi_target_system_state() == ACPI_STATE_S0;
+#else
+	/* will suspend to S3 by default */
+	sdev->s0_suspend = false;
+#endif
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_sof_prepare);
+
+void snd_sof_complete(struct device *dev)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+
+	sdev->s0_suspend = false;
+}
+EXPORT_SYMBOL(snd_sof_complete);
sound/soc/sof/sof-priv.h +2 -0
index c2541d020bde..6408ac88a3e5 100644
@@ -492,6 +492,8 @@ int snd_sof_runtime_resume(struct device *dev);
 int snd_sof_runtime_idle(struct device *dev);
 int snd_sof_resume(struct device *dev);
 int snd_sof_suspend(struct device *dev);
+int snd_sof_prepare(struct device *dev);
+void snd_sof_complete(struct device *dev);
 int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
 			    enum sof_d0_substate d0_substate);
 
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#51 lore raw

PATCH 22/26 ASoC: SOF: ignore suspend/resume for D0ix compatible streams

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

During system suspend, the PM framework will freeze all applications and the ALSA/ASoC core will suspend all RUNNING PCM streams.

However, D0ix-compatible PCM streams should keep the related pipelines active in the DSP when the system is entering S0ix. The TRIGGER_SUSPEND event is trapped in such cases to prevent the pipelines from being stopped. Likewise, the TRIGGER_RESUME/START events should not affect the pipeline state.

The SOF driver also triggers some DSP Firmware pipelines based on the DAPM widgets power events. In such cases, we also ignore PRE_PMU and POST_PMD events to keep the pipelines active.

---
 sound/soc/sof/pcm.c      | 31 +++++++++++++++++++++++++++++++
 sound/soc/sof/topology.c | 17 ++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)
sound/soc/sof/pcm.c +31 -0
index 9ba505cf5966..3d5cd1b445ba 100644
@@ -346,6 +346,16 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
 		stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_RELEASE;
 		break;
 	case SNDRV_PCM_TRIGGER_RESUME:
+		if (spcm->stream[substream->stream].suspend_ignored) {
+			/*
+			 * this case will be triggered when INFO_RESUME is
+			 * supported, no need to resume streams that remained
+			 * enabled in D0ix.
+			 */
+			spcm->stream[substream->stream].suspend_ignored = false;
+			return 0;
+		}
+
 		/* set up hw_params */
 		ret = sof_pcm_prepare(component, substream);
 		if (ret < 0) {
@@ -356,9 +366,30 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
 
 		/* fallthrough */
 	case SNDRV_PCM_TRIGGER_START:
+		if (spcm->stream[substream->stream].suspend_ignored) {
+			/*
+			 * This case will be triggered when INFO_RESUME is
+			 * not supported, no need to re-start streams that
+			 * remained enabled in D0ix.
+			 */
+			spcm->stream[substream->stream].suspend_ignored = false;
+			return 0;
+		}
 		stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_START;
 		break;
 	case SNDRV_PCM_TRIGGER_SUSPEND:
+		if (sdev->s0_suspend &&
+		    spcm->stream[substream->stream].d0i3_compatible) {
+			/*
+			 * trap the event, not sending trigger stop to
+			 * prevent the FW pipelines from being stopped,
+			 * and mark the flag to ignore the upcoming DAPM
+			 * PM events.
+			 */
+			spcm->stream[substream->stream].suspend_ignored = true;
+			return 0;
+		}
+		/* fallthrough */
 	case SNDRV_PCM_TRIGGER_STOP:
 		stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP;
 		ipc_first = true;
sound/soc/sof/topology.c +16 -1
index cc138ac6a8eb..e0e2ae734632 100644
@@ -135,7 +135,9 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 				  struct snd_kcontrol *k, int event)
 {
 	struct snd_sof_widget *swidget = w->dobj.private;
+	int stream = SNDRV_PCM_STREAM_CAPTURE;
 	struct snd_sof_dev *sdev;
+	struct snd_sof_pcm *spcm;
 	int ret = 0;
 
 	if (!swidget)
@@ -146,11 +148,19 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 	dev_dbg(sdev->dev, "received event %d for widget %s\n",
 		event, w->name);
 
+	/* get runtime PCM params using widget's stream name */
+	spcm = snd_sof_find_spcm_name(sdev, swidget->widget->sname);
+
 	/* process events */
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
+		if (spcm->stream[stream].suspend_ignored) {
+			dev_dbg(sdev->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n");
+			return 0;
+		}
+
 		/* set pcm params */
-		ret = ipc_pcm_params(swidget, SOF_IPC_STREAM_CAPTURE);
+		ret = ipc_pcm_params(swidget, stream);
 		if (ret < 0) {
 			dev_err(sdev->dev,
 				"error: failed to set pcm params for widget %s\n",
@@ -166,6 +176,11 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 				swidget->widget->name);
 		break;
 	case SND_SOC_DAPM_POST_PMD:
+		if (spcm->stream[stream].suspend_ignored) {
+			dev_dbg(sdev->dev, "POST_PMD even ignored, KWD pipeline will remain RUNNING\n");
+			return 0;
+		}
+
 		/* stop trigger */
 		ret = ipc_trigger(swidget, SOF_IPC_STREAM_TRIG_STOP);
 		if (ret < 0)
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#52 lore raw

[alsa-devel] Applied "ASoC: SOF: ignore suspend/resume for D0ix compatible streams" to the asoc tree

The patch

ASoC: SOF: ignore suspend/resume for D0ix compatible streams

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From ac8c046f19f94ec419c60d7a073af75a71386e97 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:18 -0500
Subject: [PATCH] ASoC: SOF: ignore suspend/resume for D0ix compatible streams

During system suspend, the PM framework will freeze all applications and the ALSA/ASoC core will suspend all RUNNING PCM streams.

However, D0ix-compatible PCM streams should keep the related pipelines active in the DSP when the system is entering S0ix. The TRIGGER_SUSPEND event is trapped in such cases to prevent the pipelines from being stopped. Likewise, the TRIGGER_RESUME/START events should not affect the pipeline state.

The SOF driver also triggers some DSP Firmware pipelines based on the DAPM widgets power events. In such cases, we also ignore PRE_PMU and POST_PMD events to keep the pipelines active.

---
 sound/soc/sof/pcm.c      | 31 +++++++++++++++++++++++++++++++
 sound/soc/sof/topology.c | 17 ++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)
sound/soc/sof/pcm.c +31 -0
index 9ba505cf5966..3d5cd1b445ba 100644
@@ -346,6 +346,16 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
 		stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_RELEASE;
 		break;
 	case SNDRV_PCM_TRIGGER_RESUME:
+		if (spcm->stream[substream->stream].suspend_ignored) {
+			/*
+			 * this case will be triggered when INFO_RESUME is
+			 * supported, no need to resume streams that remained
+			 * enabled in D0ix.
+			 */
+			spcm->stream[substream->stream].suspend_ignored = false;
+			return 0;
+		}
+
 		/* set up hw_params */
 		ret = sof_pcm_prepare(component, substream);
 		if (ret < 0) {
@@ -356,9 +366,30 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
 
 		/* fallthrough */
 	case SNDRV_PCM_TRIGGER_START:
+		if (spcm->stream[substream->stream].suspend_ignored) {
+			/*
+			 * This case will be triggered when INFO_RESUME is
+			 * not supported, no need to re-start streams that
+			 * remained enabled in D0ix.
+			 */
+			spcm->stream[substream->stream].suspend_ignored = false;
+			return 0;
+		}
 		stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_START;
 		break;
 	case SNDRV_PCM_TRIGGER_SUSPEND:
+		if (sdev->s0_suspend &&
+		    spcm->stream[substream->stream].d0i3_compatible) {
+			/*
+			 * trap the event, not sending trigger stop to
+			 * prevent the FW pipelines from being stopped,
+			 * and mark the flag to ignore the upcoming DAPM
+			 * PM events.
+			 */
+			spcm->stream[substream->stream].suspend_ignored = true;
+			return 0;
+		}
+		/* fallthrough */
 	case SNDRV_PCM_TRIGGER_STOP:
 		stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP;
 		ipc_first = true;
sound/soc/sof/topology.c +16 -1
index cc138ac6a8eb..e0e2ae734632 100644
@@ -135,7 +135,9 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 				  struct snd_kcontrol *k, int event)
 {
 	struct snd_sof_widget *swidget = w->dobj.private;
+	int stream = SNDRV_PCM_STREAM_CAPTURE;
 	struct snd_sof_dev *sdev;
+	struct snd_sof_pcm *spcm;
 	int ret = 0;
 
 	if (!swidget)
@@ -146,11 +148,19 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 	dev_dbg(sdev->dev, "received event %d for widget %s\n",
 		event, w->name);
 
+	/* get runtime PCM params using widget's stream name */
+	spcm = snd_sof_find_spcm_name(sdev, swidget->widget->sname);
+
 	/* process events */
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
+		if (spcm->stream[stream].suspend_ignored) {
+			dev_dbg(sdev->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n");
+			return 0;
+		}
+
 		/* set pcm params */
-		ret = ipc_pcm_params(swidget, SOF_IPC_STREAM_CAPTURE);
+		ret = ipc_pcm_params(swidget, stream);
 		if (ret < 0) {
 			dev_err(sdev->dev,
 				"error: failed to set pcm params for widget %s\n",
@@ -166,6 +176,11 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w,
 				swidget->widget->name);
 		break;
 	case SND_SOC_DAPM_POST_PMD:
+		if (spcm->stream[stream].suspend_ignored) {
+			dev_dbg(sdev->dev, "POST_PMD even ignored, KWD pipeline will remain RUNNING\n");
+			return 0;
+		}
+
 		/* stop trigger */
 		ret = ipc_trigger(swidget, SOF_IPC_STREAM_TRIG_STOP);
 		if (ret < 0)
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#53 lore raw

PATCH 23/26 ASoC: SOF: Intel: hda-dsp: implement suspend/resume for S0ix<->S0 transition

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Enable system wake up via IPC interrupt from DSP when the system is suspending to the S0ix state, and disable it in the corresponding resuming.

---
 sound/soc/sof/intel/hda-dsp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/soc/sof/intel/hda-dsp.c +17 -0
index b5070409a5e3..d23573d9e9c4 100644
@@ -477,6 +477,15 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume)
 
 int hda_dsp_resume(struct snd_sof_dev *sdev)
 {
+	struct pci_dev *pci = to_pci_dev(sdev->dev);
+
+	if (sdev->s0_suspend) {
+		/* restore and disable the system wakeup */
+		pci_restore_state(pci);
+		disable_irq_wake(pci->irq);
+		return 0;
+	}
+
 	/* init hda controller. DSP cores will be powered up during fw boot */
 	return hda_resume(sdev, false);
 }
@@ -509,8 +518,16 @@ int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev)
 int hda_dsp_suspend(struct snd_sof_dev *sdev)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
+	struct pci_dev *pci = to_pci_dev(sdev->dev);
 	int ret;
 
+	if (sdev->s0_suspend) {
+		/* enable the system waking up via IPC IRQ */
+		enable_irq_wake(pci->irq);
+		pci_save_state(pci);
+		return 0;
+	}
+
 	/* stop hda controller and power dsp off */
 	ret = hda_suspend(sdev, false);
 	if (ret < 0) {
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#54 lore raw

[alsa-devel] Applied "ASoC: SOF: Intel: hda-dsp: implement suspend/resume for S0ix<->S0 transition" to the asoc tree

The patch

ASoC: SOF: Intel: hda-dsp: implement suspend/resume for S0ix<->S0 transition

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 66e40876ddc325d892c493a6d83574bbba5770ce Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:19 -0500
Subject: [PATCH] ASoC: SOF: Intel: hda-dsp: implement suspend/resume for
S0ix<->S0 transition

Enable system wake up via IPC interrupt from DSP when the system is suspending to the S0ix state, and disable it in the corresponding resuming.

---
 sound/soc/sof/intel/hda-dsp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/soc/sof/intel/hda-dsp.c +17 -0
index b5070409a5e3..d23573d9e9c4 100644
@@ -477,6 +477,15 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume)
 
 int hda_dsp_resume(struct snd_sof_dev *sdev)
 {
+	struct pci_dev *pci = to_pci_dev(sdev->dev);
+
+	if (sdev->s0_suspend) {
+		/* restore and disable the system wakeup */
+		pci_restore_state(pci);
+		disable_irq_wake(pci->irq);
+		return 0;
+	}
+
 	/* init hda controller. DSP cores will be powered up during fw boot */
 	return hda_resume(sdev, false);
 }
@@ -509,8 +518,16 @@ int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev)
 int hda_dsp_suspend(struct snd_sof_dev *sdev)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
+	struct pci_dev *pci = to_pci_dev(sdev->dev);
 	int ret;
 
+	if (sdev->s0_suspend) {
+		/* enable the system waking up via IPC IRQ */
+		enable_irq_wake(pci->irq);
+		pci_save_state(pci);
+		return 0;
+	}
+
 	/* stop hda controller and power dsp off */
 	ret = hda_suspend(sdev, false);
 	if (ret < 0) {
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#55 lore raw

PATCH 24/26 ASoC: SOF: return -ENOTSUPP if D0I3 is not supported

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

No set_power_state ops means that the platform doesn't support D0i3, return -ENOTSUPP for the case.

---
 sound/soc/sof/ops.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sof/ops.h +2 -1
index d7c8fc06f961..93512dcbaacd 100644
@@ -199,7 +199,8 @@ static inline int snd_sof_dsp_set_power_state(struct snd_sof_dev *sdev,
 	if (sof_ops(sdev)->set_power_state)
 		return sof_ops(sdev)->set_power_state(sdev, substate);
 
-	return 0;
+	/* D0 substate is not supported */
+	return -ENOTSUPP;
 }
 
 /* debug */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#56 lore raw

[alsa-devel] Applied "ASoC: SOF: return -ENOTSUPP if D0I3 is not supported" to the asoc tree

The patch

ASoC: SOF: return -ENOTSUPP if D0I3 is not supported

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 5655ce660a6d3eec4a3ad37feb99fb228540d1a9 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:20 -0500
Subject: [PATCH] ASoC: SOF: return -ENOTSUPP if D0I3 is not supported

No set_power_state ops means that the platform doesn't support D0i3, return -ENOTSUPP for the case.

---
 sound/soc/sof/ops.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sof/ops.h +2 -1
index d7c8fc06f961..93512dcbaacd 100644
@@ -199,7 +199,8 @@ static inline int snd_sof_dsp_set_power_state(struct snd_sof_dev *sdev,
 	if (sof_ops(sdev)->set_power_state)
 		return sof_ops(sdev)->set_power_state(sdev, substate);
 
-	return 0;
+	/* D0 substate is not supported */
+	return -ENOTSUPP;
 }
 
 /* debug */
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#57 lore raw

PATCH 25/26 ASoC: SOF: PM: Add support for DSP D0i3 state when entering S0ix

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

When system is entering into S0ix, the PCI device may transition to the D0i3 substate instead of D3. In D0i3, some always-on functionality can be enabled, such as acoustic event detection, voice activity detection or hotwording. When an event is detected, the DSP firmware can wake-up the device for a transition to D0 with an interrupt.

---
 sound/soc/sof/pm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
sound/soc/sof/pm.c +46 -0
index 99e4e6ffff74..560a937e0484 100644
@@ -430,12 +430,58 @@ EXPORT_SYMBOL(snd_sof_set_d0_substate);
 
 int snd_sof_resume(struct device *dev)
 {
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	int ret;
+
+	if (sdev->s0_suspend) {
+		/* resume from D0I3 */
+		dev_dbg(sdev->dev, "DSP will exit from D0i3...\n");
+		ret = snd_sof_set_d0_substate(sdev, SOF_DSP_D0I0);
+		if (ret == -ENOTSUPP) {
+			/* fallback to resume from D3 */
+			dev_dbg(sdev->dev, "D0i3 not supported, fall back to resume from D3...\n");
+			goto d3_resume;
+		} else if (ret < 0) {
+			dev_err(sdev->dev, "error: failed to exit from D0I3 %d\n",
+				ret);
+			return ret;
+		}
+
+		/* platform-specific resume from D0i3 */
+		return snd_sof_dsp_resume(sdev);
+	}
+
+d3_resume:
+	/* resume from D3 */
 	return sof_resume(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_resume);
 
 int snd_sof_suspend(struct device *dev)
 {
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	int ret;
+
+	if (sdev->s0_suspend) {
+		/* suspend to D0i3 */
+		dev_dbg(sdev->dev, "DSP is trying to enter D0i3...\n");
+		ret = snd_sof_set_d0_substate(sdev, SOF_DSP_D0I3);
+		if (ret == -ENOTSUPP) {
+			/* fallback to D3 suspend */
+			dev_dbg(sdev->dev, "D0i3 not supported, fall back to D3...\n");
+			goto d3_suspend;
+		} else if (ret < 0) {
+			dev_err(sdev->dev, "error: failed to enter D0I3, %d\n",
+				ret);
+			return ret;
+		}
+
+		/* platform-specific suspend to D0i3 */
+		return snd_sof_dsp_suspend(sdev);
+	}
+
+d3_suspend:
+	/* suspend to D3 */
 	return sof_suspend(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_suspend);
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#58 lore raw

[alsa-devel] Applied "ASoC: SOF: PM: Add support for DSP D0i3 state when entering S0ix" to the asoc tree

The patch

ASoC: SOF: PM: Add support for DSP D0i3 state when entering S0ix

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From c470fc3f61b25e955f8ba90fc9dc554881e4e72c Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:21 -0500
Subject: [PATCH] ASoC: SOF: PM: Add support for DSP D0i3 state when entering
S0ix

When system is entering into S0ix, the PCI device may transition to the D0i3 substate instead of D3. In D0i3, some always-on functionality can be enabled, such as acoustic event detection, voice activity detection or hotwording. When an event is detected, the DSP firmware can wake-up the device for a transition to D0 with an interrupt.

---
 sound/soc/sof/pm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
sound/soc/sof/pm.c +46 -0
index 99e4e6ffff74..560a937e0484 100644
@@ -430,12 +430,58 @@ EXPORT_SYMBOL(snd_sof_set_d0_substate);
 
 int snd_sof_resume(struct device *dev)
 {
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	int ret;
+
+	if (sdev->s0_suspend) {
+		/* resume from D0I3 */
+		dev_dbg(sdev->dev, "DSP will exit from D0i3...\n");
+		ret = snd_sof_set_d0_substate(sdev, SOF_DSP_D0I0);
+		if (ret == -ENOTSUPP) {
+			/* fallback to resume from D3 */
+			dev_dbg(sdev->dev, "D0i3 not supported, fall back to resume from D3...\n");
+			goto d3_resume;
+		} else if (ret < 0) {
+			dev_err(sdev->dev, "error: failed to exit from D0I3 %d\n",
+				ret);
+			return ret;
+		}
+
+		/* platform-specific resume from D0i3 */
+		return snd_sof_dsp_resume(sdev);
+	}
+
+d3_resume:
+	/* resume from D3 */
 	return sof_resume(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_resume);
 
 int snd_sof_suspend(struct device *dev)
 {
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	int ret;
+
+	if (sdev->s0_suspend) {
+		/* suspend to D0i3 */
+		dev_dbg(sdev->dev, "DSP is trying to enter D0i3...\n");
+		ret = snd_sof_set_d0_substate(sdev, SOF_DSP_D0I3);
+		if (ret == -ENOTSUPP) {
+			/* fallback to D3 suspend */
+			dev_dbg(sdev->dev, "D0i3 not supported, fall back to D3...\n");
+			goto d3_suspend;
+		} else if (ret < 0) {
+			dev_err(sdev->dev, "error: failed to enter D0I3, %d\n",
+				ret);
+			return ret;
+		}
+
+		/* platform-specific suspend to D0i3 */
+		return snd_sof_dsp_suspend(sdev);
+	}
+
+d3_suspend:
+	/* suspend to D3 */
 	return sof_suspend(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_suspend);
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#59 lore raw

PATCH 26/26 ASoC: SOF: pci: Add prepare/complete PM callbacks

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Use the new implemented snd_sof_prepare() and snd_sof_complete() as the power management callbacks for pci probing platforms.

---
 sound/soc/sof/sof-pci-dev.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/sof/sof-pci-dev.c +2 -0
index 4adbb27c76c5..487b1f29f84d 100644
@@ -264,6 +264,8 @@ static const struct sof_dev_desc jsl_desc = {
 #endif
 
 static const struct dev_pm_ops sof_pci_pm = {
+	.prepare = snd_sof_prepare,
+	.complete = snd_sof_complete,
 	SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume)
 	SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume,
 			   snd_sof_runtime_idle)
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#60 lore raw

[alsa-devel] Applied "ASoC: SOF: pci: Add prepare/complete PM callbacks" to the asoc tree

The patch

ASoC: SOF: pci: Add prepare/complete PM callbacks

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 6d407a39cc9619d0088b44333c6526924be00f8d Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 25 Oct 2019 17:41:22 -0500
Subject: [PATCH] ASoC: SOF: pci: Add prepare/complete PM callbacks

Use the new implemented snd_sof_prepare() and snd_sof_complete() as the power management callbacks for pci probing platforms.

---
 sound/soc/sof/sof-pci-dev.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/sof/sof-pci-dev.c +2 -0
index 4adbb27c76c5..487b1f29f84d 100644
@@ -264,6 +264,8 @@ static const struct sof_dev_desc jsl_desc = {
 #endif
 
 static const struct dev_pm_ops sof_pci_pm = {
+	.prepare = snd_sof_prepare,
+	.complete = snd_sof_complete,
 	SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume)
 	SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume,
 			   snd_sof_runtime_idle)
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel