All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soundwire: fix pm_runtime_get_sync return code checks
@ 2019-04-05  7:26 ` Jan Kotas
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kotas @ 2019-04-05  7:26 UTC (permalink / raw)
  To: vkoul, sanyog.r.kale, pierre-louis.bossart
  Cc: alsa-devel, linux-kernel, Jan Kotas

When PM is disabled it returns -EACCES, which is currently
threated as an error, and prevents accessing the slave's
registers.

This patch ignores the -EACCES return value from
pm_runtime_get_sync() to let the SoundWire work in systems
without runtime PM.

Signed-off-by: Jan Kotas <jank@cadence.com>
---
 drivers/soundwire/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 1cbfedfc2..6567ff439 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -328,7 +328,7 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
 		return ret;
 
 	ret = pm_runtime_get_sync(slave->bus->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = sdw_transfer(slave->bus, &msg);
@@ -356,7 +356,7 @@ int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
 		return ret;
 
 	ret = pm_runtime_get_sync(slave->bus->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = sdw_transfer(slave->bus, &msg);
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] soundwire: fix pm_runtime_get_sync return code checks
@ 2019-04-05  7:26 ` Jan Kotas
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kotas @ 2019-04-05  7:26 UTC (permalink / raw)
  To: vkoul, sanyog.r.kale, pierre-louis.bossart
  Cc: alsa-devel, linux-kernel, Jan Kotas

When PM is disabled it returns -EACCES, which is currently
threated as an error, and prevents accessing the slave's
registers.

This patch ignores the -EACCES return value from
pm_runtime_get_sync() to let the SoundWire work in systems
without runtime PM.

Signed-off-by: Jan Kotas <jank@cadence.com>
---
 drivers/soundwire/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 1cbfedfc2..6567ff439 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -328,7 +328,7 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
 		return ret;
 
 	ret = pm_runtime_get_sync(slave->bus->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = sdw_transfer(slave->bus, &msg);
@@ -356,7 +356,7 @@ int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
 		return ret;
 
 	ret = pm_runtime_get_sync(slave->bus->dev);
-	if (ret < 0)
+	if (ret < 0 && ret != -EACCES)
 		return ret;
 
 	ret = sdw_transfer(slave->bus, &msg);
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] soundwire: fix pm_runtime_get_sync return code checks
  2019-04-05  7:26 ` Jan Kotas
  (?)
@ 2019-04-05 15:04 ` Pierre-Louis Bossart
  2019-04-08  7:12   ` Jan Kotas
  -1 siblings, 1 reply; 7+ messages in thread
From: Pierre-Louis Bossart @ 2019-04-05 15:04 UTC (permalink / raw)
  To: Jan Kotas, vkoul, sanyog.r.kale
  Cc: alsa-devel, Srinivas Kandagatla, linux-kernel


On 4/5/19 2:26 AM, Jan Kotas wrote:
> When PM is disabled it returns -EACCES, which is currently
> threated as an error, and prevents accessing the slave's
> registers.
>
> This patch ignores the -EACCES return value from
> pm_runtime_get_sync() to let the SoundWire work in systems
> without runtime PM.
>
> Signed-off-by: Jan Kotas <jank@cadence.com>
> ---
>   drivers/soundwire/bus.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index 1cbfedfc2..6567ff439 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -328,7 +328,7 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
>   		return ret;
>   
>   	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.
-Pierre

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] soundwire: fix pm_runtime_get_sync return code checks
  2019-04-05 15:04 ` Pierre-Louis Bossart
@ 2019-04-08  7:12   ` Jan Kotas
  2019-04-08 17:43     ` [alsa-devel] " Pierre-Louis Bossart
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kotas @ 2019-04-08  7:12 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Jan Kotas, vkoul, sanyog.r.kale, alsa-devel, linux-kernel,
	Srinivas Kandagatla



> On 5 Apr 2019, at 17:04, Pierre-Louis Bossart <pierre-louis.bossart@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://lists.linuxfoundation.org/pipermail/linux-pm/2011-June/031930.html

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.

Regards,
Jan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] soundwire: fix pm_runtime_get_sync return code checks
  2019-04-08  7:12   ` Jan Kotas
@ 2019-04-08 17:43     ` Pierre-Louis Bossart
  2019-04-12  8:29       ` Jan Kotas
  2019-04-14 10:26       ` [alsa-devel] " Vinod Koul
  0 siblings, 2 replies; 7+ messages in thread
From: Pierre-Louis Bossart @ 2019-04-08 17:43 UTC (permalink / raw)
  To: Jan Kotas
  Cc: alsa-devel, linux-kernel, vkoul, Srinivas Kandagatla, sanyog.r.kale



On 4/8/19 2:12 AM, Jan Kotas wrote:
> 
> 
>> On 5 Apr 2019, at 17:04, Pierre-Louis Bossart <pierre-louis.bossart@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://lists.linuxfoundation.org/pipermail/linux-pm/2011-June/031930.html

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?

> 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...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] soundwire: fix pm_runtime_get_sync return code checks
  2019-04-08 17:43     ` [alsa-devel] " Pierre-Louis Bossart
@ 2019-04-12  8:29       ` Jan Kotas
  2019-04-14 10:26       ` [alsa-devel] " Vinod Koul
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Kotas @ 2019-04-12  8:29 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, linux-kernel, vkoul, Srinivas Kandagatla, Jan Kotas,
	sanyog.r.kale



On 8 Apr 2019, at 19:43, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com<mailto:pierre-louis.bossart@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@linux.intel.com<mailto:pierre-louis.bossart@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

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] soundwire: fix pm_runtime_get_sync return code checks
  2019-04-08 17:43     ` [alsa-devel] " Pierre-Louis Bossart
  2019-04-12  8:29       ` Jan Kotas
@ 2019-04-14 10:26       ` Vinod Koul
  1 sibling, 0 replies; 7+ messages in thread
From: Vinod Koul @ 2019-04-14 10:26 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Jan Kotas, alsa-devel, linux-kernel, Srinivas Kandagatla, sanyog.r.kale

On 08-04-19, 12:43, Pierre-Louis Bossart wrote:
> 
> 
> On 4/8/19 2:12 AM, Jan Kotas wrote:
> > 
> > 
> > > On 5 Apr 2019, at 17:04, Pierre-Louis Bossart <pierre-louis.bossart@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://lists.linuxfoundation.org/pipermail/linux-pm/2011-June/031930.html
> 
> 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?

IIRC that needs to be called by the Intel driver and those patches were
not upstreamed. So we dont have fully supported PM on upstream yet!

> 
> > 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...

-- 
~Vinod

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-14 10:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05  7:26 [PATCH] soundwire: fix pm_runtime_get_sync return code checks Jan Kotas
2019-04-05  7:26 ` Jan Kotas
2019-04-05 15:04 ` Pierre-Louis Bossart
2019-04-08  7:12   ` Jan Kotas
2019-04-08 17:43     ` [alsa-devel] " Pierre-Louis Bossart
2019-04-12  8:29       ` Jan Kotas
2019-04-14 10:26       ` [alsa-devel] " Vinod Koul

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.