lkml.org 
[lkml]   [2019]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled
On Fri, Jul 26, 2019 at 01:08:57PM -0500, Pierre-Louis Bossart wrote:
> This thread became unreadable with interleaved top-posting, allow me restate
> the options and ask PM folks what they think
>
> On 7/25/19 6:40 PM, Pierre-Louis Bossart wrote:
> > Not all platforms support runtime_pm for now, let's use runtime_pm
> > only when enabled.
> >
> > Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > ---
> > drivers/soundwire/bus.c | 25 ++++++++++++++++---------
> > 1 file changed, 16 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> > index 5ad4109dc72f..0a45dc5713df 100644
> > --- a/drivers/soundwire/bus.c
> > +++ b/drivers/soundwire/bus.c
> > @@ -332,12 +332,16 @@ int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
> > if (ret < 0)
> > return ret;
> > - ret = pm_runtime_get_sync(slave->bus->dev);
> > - if (ret < 0)
> > - return ret;
> > + if (pm_runtime_enabled(slave->bus->dev)) {
> > + ret = pm_runtime_get_sync(slave->bus->dev);
> > + if (ret < 0)
> > + return ret;
> > + }
> > ret = sdw_transfer(slave->bus, &msg);
> > - pm_runtime_put(slave->bus->dev);
> > +
> > + if (pm_runtime_enabled(slave->bus->dev))
> > + pm_runtime_put(slave->bus->dev);
>
> This is option1: we explicitly test if pm_runtime is enabled before calling
> _get_sync() and _put()
>
> option2 (suggested by Jan Kotas): catch the -EACCESS error code
>
> ret = pm_runtime_get_sync(slave->bus->dev);
> - if (ret < 0)
> + if (ret < 0 && ret != -EACCES)
> return ret;
>
> option3: ignore the return value as done in quite a few drivers
>
> Are there any other options? I am personally surprised this is not handled
> in the pm_runtime core, not sure why users need to test for this?

option 4: fix this in runtime PM :-) This seems like the best option to me,
but probably not the easiest one. Otherwise I'd go with (2), I think, since
that's also the official purpose of the -EACCESS return code:

https://lists.linuxfoundation.org/pipermail/linux-pm/2011-June/031930.html

Thanks
Guennadi

\
 
 \ /
  Last update: 2019-07-26 20:26    [W:0.152 / U:7.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site