From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vinod Koul <vkoul@kernel.org>,
Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org, broonie@kernel.org,
bard.liao@intel.com, "Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH 3/4] soundwire: intel: exit clock stop mode on system suspend
Date: Mon, 2 Aug 2021 09:24:12 -0500 [thread overview]
Message-ID: <792f70bd-b4ae-e3a1-c37e-ba2913018d0b@linux.intel.com> (raw)
In-Reply-To: <YQd1C0QQMDNtzfAq@matsya>
>> +static int __maybe_unused intel_pm_prepare(struct device *dev)
>> +{
>> + struct sdw_cdns *cdns = dev_get_drvdata(dev);
>> + struct sdw_intel *sdw = cdns_to_intel(cdns);
>> + struct sdw_bus *bus = &cdns->bus;
>> + u32 clock_stop_quirks;
>> + int ret = 0;
>> +
>> + if (bus->prop.hw_disabled || !sdw->startup_done) {
>> + dev_dbg(dev, "SoundWire master %d is disabled or not-started, ignoring\n",
>> + bus->link_id);
>> + return 0;
>> + }
>> +
>> + clock_stop_quirks = sdw->link_res->clock_stop_quirks;
>> +
>> + if ((clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) ||
>> + !clock_stop_quirks) {
>> + /*
>> + * Try to resume the entire bus (parent + child devices) to exit
>> + * the clock stop mode. If this fails, we keep going since we don't want
>> + * to prevent system suspend from happening and errors should be recoverable
>> + * on resume.
>> + */
>> + ret = device_for_each_child(bus->dev, NULL, intel_resume_child_device);
>> +
>> + if (ret < 0)
>> + dev_err(dev, "%s: intel_resume_child_device failed: %d\n", __func__, ret);
>> +
>> + /*
>> + * in the case where a link was started but does not have anything connected,
>> + * we still need to resume to keep link power up/down sequences balanced.
>> + * This is a no-op if a child device was present, since resuming the child
>> + * device would also resume the parent
>> + */
>> + ret = pm_request_resume(dev);
>
> I am not sure of this patch yet, maybe I am comprehending it..
>
> 1. In above you are calling resume of child devices first and then intel
> device, which sounds reverse, should you not resume intel device first
> and then child (codec devices) ?
>
> 2. What about when resume is invoked by the core for the child devices.
> That would be called in the PM resume flow, so why do it here?
I realize it's a complicated sequence, it took us multiple phases to get
it right. There are multiple layers between power domain, bus and driver.
The .prepare phase happens before the system suspend phase. Unlike
suspend, which progresses from children to parents, the .prepare is
handled parent first.
When we do a request_resume of the child device, by construction that
also resumes the parent. In other words, if we have multiple codecs on a
link, the first iteration of device_for_each_child() will already resume
the parent and the first device, and the second iteration will only
resume the second device.
What this step does is make sure than when the codec .suspend routine is
invoked, the entire bus is already back to full power. I did check
privately with Rafael (CC:ed) if this sequence was legit.
We did consider modifying the system suspend callback in codec drivers,
so that we would do a pm_runtime resume(). This is functionally
equivalent to what we are suggesting here, but we decided not to do so
for two main reasons
a) lots of code changes across all codecs for an Intel-specific issue
b) we would need to add a flag so that codec drivers would know in which
Intel-specific clock-stop mode the bus was configured. That's not so
good either.
It seemed simpler to use to add this .prepare step and test on the Intel
clock stop mode before doing a pm_runtime_resume for all codecs.
>
>> + if (ret < 0)
>> + dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> static int __maybe_unused intel_suspend(struct device *dev)
>> {
>> struct sdw_cdns *cdns = dev_get_drvdata(dev);
>> @@ -1923,6 +1987,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
>> }
>>
>> static const struct dev_pm_ops intel_pm = {
>> + .prepare = intel_pm_prepare,
>> SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
>> SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
>> };
>> --
>> 2.17.1
>
next prev parent reply other threads:[~2021-08-02 14:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 5:56 [PATCH 0/4] soundwire: intel: exit clock-stop mode before system suspend Bard Liao
2021-07-27 5:56 ` [PATCH 1/4] soundwire: intel: fix potential race condition during power down Bard Liao
2021-07-27 5:56 ` [PATCH 2/4] soundwire: intel: skip suspend/resume/wake when link was not started Bard Liao
2021-08-02 4:02 ` Vinod Koul
2021-08-02 13:59 ` Pierre-Louis Bossart
2021-08-06 13:24 ` Vinod Koul
2021-08-06 15:57 ` Pierre-Louis Bossart
2021-07-27 5:56 ` [PATCH 3/4] soundwire: intel: exit clock stop mode on system suspend Bard Liao
2021-08-02 4:31 ` Vinod Koul
2021-08-02 14:24 ` Pierre-Louis Bossart [this message]
2021-08-02 16:28 ` Pierre-Louis Bossart
2021-08-06 13:31 ` Vinod Koul
2021-08-06 16:03 ` Pierre-Louis Bossart
2021-07-27 5:56 ` [PATCH 4/4] soundwire: intel: simplify pm_runtime handling in suspend/resume Bard Liao
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=792f70bd-b4ae-e3a1-c37e-ba2913018d0b@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bard.liao@intel.com \
--cc=broonie@kernel.org \
--cc=rafael@kernel.org \
--cc=tiwai@suse.de \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.