[alsa-devel] [PATCH] soundwire: fix pm_runtime_get_sync return code checks

Jan Kotas jank at cadence.com
Fri Apr 12 10:29:04 CEST 2019



On 8 Apr 2019, at 19:43, Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com<mailto:pierre-louis.bossart at linux.intel.com>> wrote:


On 4/8/19 2:12 AM, Jan Kotas wrote:
On 5 Apr 2019, at 17:04, Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com<mailto:pierre-louis.bossart at linux.intel.com>> wrote:

On 4/5/19 2:26 AM, Jan Kotas wrote:

    ret = pm_runtime_get_sync(slave->bus->dev);
- if (ret < 0)
+ if (ret < 0 && ret != -EACCES)

There was a patch submitted on 3/28 by Srinivas Kandagatla who suggested an alternate solution for exactly the same code.

+ if (pm_runtime_enabled(slave->bus->dev)) {
+ ret = pm_runtime_get_sync(slave->bus->dev);
+ if (ret < 0)
+ return ret;

I am far from an expert on pm_runtime but Srinivas' solution looks more elegant to me.
Hello Pierre,
Please take a look at this patch, that was my inspiration:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.linuxfoundation.org_pipermail_linux-2Dpm_2011-2DJune_031930.html&d=DwICaQ&c=aUq983L2pue2FqKFoP6PGHMJQyoJ7kl3s3GZ-_haXqY&r=g7GAQENVXx_RQdyXHInPMg&m=b7F0tj3iL_iqMB1g24oSHfiZEXr_vcDI2gftqq5H2Mg&s=cSeJz3M34TGYdAbUvh0Crqkw7INgGc8Z2uaIStHArQY&e=

The two patches seems to be identical:

static inline bool pm_runtime_enabled(struct device *dev)
{
return !dev->power.disable_depth;
}

static int rpm_resume()
[...]
else if (dev->power.disable_depth > 0)
retval = -EACCES;


However I am still not clear on why this might fail.

I can only think of one possible explanation: there is no explicit pm_runtime_enable() in the soundwire code, so maybe the expectation is that the pm_runtime status is inherited from the parent (in the intel case the PCI driver), and that's missing in non-intel configurations?

The PM implementation for soundwire seems to be incomplete.
I think it relies on either PCIe or some other Intel-specific code.
There are just a few pm_ function calls in the entire
drivers/soundwire directory.
I’m testing SoundWire as a platform, with an arm64 CPU,
and it doesn’t seem to be working in its current form.


I also took a look, and it seems the value returned by
pm_runtime_get_syncis simply ignored in a lot of places,
so checking its value may be excessive.
But not checking seems careless at best…
I’m not an expert on pm, just looked in the sources.
It may be best to consult it with the pm maintainers.

Jan



More information about the Alsa-devel mailing list