From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
tiwai@suse.com, Piotr Maziarz <piotrx.maziarz@linux.intel.com>,
pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com,
amadeuszx.slawinski@linux.intel.com
Subject: [PATCH 6/8] ASoC: Intel: avs: Standby power-state support
Date: Wed, 19 Oct 2022 19:53:15 +0200 [thread overview]
Message-ID: <20221019175317.1540919-7-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221019175317.1540919-1-cezary.rojewski@intel.com>
From: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Introduce avs_suspend_standby() and avs_resume_standby() to support S0iX
streaming. The AudioDSP is not shutdown during such scenario and the PCI
device is armed for possible wake operation through an audio event.
Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/core.c | 75 ++++++++++++++++++++++++++++++++++----
1 file changed, 68 insertions(+), 7 deletions(-)
diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c
index d067ce951afc..841bc9fa0d3b 100644
--- a/sound/soc/intel/avs/core.c
+++ b/sound/soc/intel/avs/core.c
@@ -534,12 +534,30 @@ static void avs_pci_remove(struct pci_dev *pci)
pm_runtime_get_noresume(&pci->dev);
}
-static int __maybe_unused avs_suspend_common(struct avs_dev *adev)
+static int avs_suspend_standby(struct avs_dev *adev)
+{
+ struct hdac_bus *bus = &adev->base.core;
+ struct pci_dev *pci = adev->base.pci;
+
+ if (bus->cmd_dma_state)
+ snd_hdac_bus_stop_cmd_io(bus);
+
+ snd_hdac_ext_bus_link_power_down_all(bus);
+
+ enable_irq_wake(pci->irq);
+ pci_save_state(pci);
+
+ return 0;
+}
+
+static int __maybe_unused avs_suspend_common(struct avs_dev *adev, bool low_power)
{
struct hdac_bus *bus = &adev->base.core;
int ret;
flush_work(&adev->probe_work);
+ if ((acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) && low_power && adev->num_lp_paths)
+ return avs_suspend_standby(adev);
snd_hdac_ext_bus_link_power_down_all(bus);
@@ -577,11 +595,30 @@ static int __maybe_unused avs_suspend_common(struct avs_dev *adev)
return 0;
}
-static int __maybe_unused avs_resume_common(struct avs_dev *adev, bool purge)
+static int avs_resume_standby(struct avs_dev *adev)
+{
+ struct hdac_bus *bus = &adev->base.core;
+ struct pci_dev *pci = adev->base.pci;
+
+ pci_restore_state(pci);
+ disable_irq_wake(pci->irq);
+
+ snd_hdac_ext_bus_link_power_up_all(bus);
+
+ if (bus->cmd_dma_state)
+ snd_hdac_bus_init_cmd_io(bus);
+
+ return 0;
+}
+
+static int __maybe_unused avs_resume_common(struct avs_dev *adev, bool low_power, bool purge)
{
struct hdac_bus *bus = &adev->base.core;
int ret;
+ if ((acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) && low_power && adev->num_lp_paths)
+ return avs_resume_standby(adev);
+
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
avs_hdac_bus_init_chip(bus, true);
@@ -599,26 +636,50 @@ static int __maybe_unused avs_resume_common(struct avs_dev *adev, bool purge)
static int __maybe_unused avs_suspend(struct device *dev)
{
- return avs_suspend_common(to_avs_dev(dev));
+ return avs_suspend_common(to_avs_dev(dev), true);
}
static int __maybe_unused avs_resume(struct device *dev)
{
- return avs_resume_common(to_avs_dev(dev), true);
+ return avs_resume_common(to_avs_dev(dev), true, true);
}
static int __maybe_unused avs_runtime_suspend(struct device *dev)
{
- return avs_suspend_common(to_avs_dev(dev));
+ return avs_suspend_common(to_avs_dev(dev), true);
}
static int __maybe_unused avs_runtime_resume(struct device *dev)
{
- return avs_resume_common(to_avs_dev(dev), true);
+ return avs_resume_common(to_avs_dev(dev), true, false);
+}
+
+static int __maybe_unused avs_freeze(struct device *dev)
+{
+ return avs_suspend_common(to_avs_dev(dev), false);
+}
+static int __maybe_unused avs_thaw(struct device *dev)
+{
+ return avs_resume_common(to_avs_dev(dev), false, true);
+}
+
+static int __maybe_unused avs_poweroff(struct device *dev)
+{
+ return avs_suspend_common(to_avs_dev(dev), false);
+}
+
+static int __maybe_unused avs_restore(struct device *dev)
+{
+ return avs_resume_common(to_avs_dev(dev), false, true);
}
static const struct dev_pm_ops avs_dev_pm = {
- SET_SYSTEM_SLEEP_PM_OPS(avs_suspend, avs_resume)
+ .suspend = avs_suspend,
+ .resume = avs_resume,
+ .freeze = avs_freeze,
+ .thaw = avs_thaw,
+ .poweroff = avs_poweroff,
+ .restore = avs_restore,
SET_RUNTIME_PM_OPS(avs_runtime_suspend, avs_runtime_resume, NULL)
};
--
2.25.1
next prev parent reply other threads:[~2022-10-19 17:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 17:53 [PATCH 0/8] ASoC: Intel: avs: PCM power management Cezary Rojewski
2022-10-19 17:53 ` [PATCH 1/8] ASoC: Intel: avs: Split pcm pages freeing operation from hw_free() Cezary Rojewski
2022-10-19 17:53 ` [PATCH 2/8] ASoC: Intel: avs: Introduce PCM power management routines Cezary Rojewski
2022-10-19 18:02 ` Pierre-Louis Bossart
2022-10-20 7:56 ` Cezary Rojewski
2022-10-20 14:14 ` Pierre-Louis Bossart
2022-10-19 17:53 ` [PATCH 3/8] ASoC: Intel: avs: Handle SUSPEND and RESUME triggers Cezary Rojewski
2022-10-19 17:53 ` [PATCH 4/8] ASoC: Intel: avs: Restart instead of resuming HDA capture streams Cezary Rojewski
2022-10-19 17:53 ` [PATCH 5/8] ASoC: Intel: avs: Count low power streams Cezary Rojewski
2022-10-19 17:53 ` Cezary Rojewski [this message]
2022-10-20 8:09 ` [PATCH 6/8] ASoC: Intel: avs: Standby power-state support kernel test robot
2022-10-19 17:53 ` [PATCH 7/8] ASoC: Intel: avs: Power and clock gating policy overriding Cezary Rojewski
2022-10-19 17:53 ` [PATCH 8/8] ASoC: Intel: avs: Enact power gating policy Cezary Rojewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221019175317.1540919-7-cezary.rojewski@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=piotrx.maziarz@linux.intel.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox