* Re: [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled [not found] ` <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com> @ 2019-07-26 18:08 ` Pierre-Louis Bossart 2019-07-26 18:25 ` [alsa-devel] " Guennadi Liakhovetski 2019-07-26 19:08 ` Andy Shevchenko 0 siblings, 2 replies; 9+ messages in thread From: Pierre-Louis Bossart @ 2019-07-26 18:08 UTC (permalink / raw) To: alsa-devel Cc: linux-kernel, tiwai, broonie, vkoul, gregkh, jank, srinivas.kandagatla, slawomir.blauciak, Sanyog Kale, Rafael J. Wysocki, Andy Shevchenko, linux-pm 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? Thanks Pierre ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-26 18:08 ` [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled Pierre-Louis Bossart @ 2019-07-26 18:25 ` Guennadi Liakhovetski 2019-07-26 19:11 ` Andy Shevchenko 2019-07-26 19:08 ` Andy Shevchenko 1 sibling, 1 reply; 9+ messages in thread From: Guennadi Liakhovetski @ 2019-07-26 18:25 UTC (permalink / raw) To: Pierre-Louis Bossart Cc: alsa-devel, Rafael J. Wysocki, tiwai, gregkh, linux-pm, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale, Andy Shevchenko 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-26 18:25 ` [alsa-devel] " Guennadi Liakhovetski @ 2019-07-26 19:11 ` Andy Shevchenko 0 siblings, 0 replies; 9+ messages in thread From: Andy Shevchenko @ 2019-07-26 19:11 UTC (permalink / raw) To: Guennadi Liakhovetski Cc: Pierre-Louis Bossart, alsa-devel, Rafael J. Wysocki, tiwai, gregkh, linux-pm, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale On Fri, Jul 26, 2019 at 08:25:35PM +0200, Guennadi Liakhovetski wrote: > On Fri, Jul 26, 2019 at 01:08:57PM -0500, Pierre-Louis Bossart wrote: > > 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. > > 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; > 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 And at least we have examples in the kernel drivers/gpu/drm/radeon/radeon_fb.c:57: if (ret < 0 && ret != -EACCES) { -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-26 18:08 ` [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled Pierre-Louis Bossart 2019-07-26 18:25 ` [alsa-devel] " Guennadi Liakhovetski @ 2019-07-26 19:08 ` Andy Shevchenko 2019-07-29 22:07 ` [alsa-devel] " Pierre-Louis Bossart 1 sibling, 1 reply; 9+ messages in thread From: Andy Shevchenko @ 2019-07-26 19:08 UTC (permalink / raw) To: Pierre-Louis Bossart Cc: alsa-devel, linux-kernel, tiwai, broonie, vkoul, gregkh, jank, srinivas.kandagatla, slawomir.blauciak, Sanyog Kale, Rafael J. Wysocki, linux-pm 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. Just a side note below... > > - ret = pm_runtime_get_sync(slave->bus->dev); > > - if (ret < 0) Here... > > - return ret; > > + if (pm_runtime_enabled(slave->bus->dev)) { > > + ret = pm_runtime_get_sync(slave->bus->dev); > > + if (ret < 0) ...and thus here... > > + 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) ...and here, the pm_runtime_put_noidle() call is missed. > 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? -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-26 19:08 ` Andy Shevchenko @ 2019-07-29 22:07 ` Pierre-Louis Bossart 2019-07-30 11:21 ` Andy Shevchenko 0 siblings, 1 reply; 9+ messages in thread From: Pierre-Louis Bossart @ 2019-07-29 22:07 UTC (permalink / raw) To: Andy Shevchenko Cc: alsa-devel, Rafael J. Wysocki, tiwai, gregkh, linux-pm, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale On 7/26/19 2:08 PM, Andy Shevchenko wrote: > 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. > > Just a side note below... > >>> - ret = pm_runtime_get_sync(slave->bus->dev); >>> - if (ret < 0) > > Here... > >>> - return ret; >>> + if (pm_runtime_enabled(slave->bus->dev)) { >>> + ret = pm_runtime_get_sync(slave->bus->dev); >>> + if (ret < 0) > > ...and thus here... > >>> + 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) > > ...and here, the pm_runtime_put_noidle() call is missed. yes but in the example you provided, they actually do more work than just decrement the device usage counter: static int radeonfb_open(struct fb_info *info, int user) { struct radeon_fbdev *rfbdev = info->par; struct radeon_device *rdev = rfbdev->rdev; int ret = pm_runtime_get_sync(rdev->ddev->dev); if (ret < 0 && ret != -EACCES) { pm_runtime_mark_last_busy(rdev->ddev->dev); pm_runtime_put_autosuspend(rdev->ddev->dev); return ret; } return 0; } unless I am missing something pm_runtime_put_noidle() and _put_autosuspend() are not equivalent, are they? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-29 22:07 ` [alsa-devel] " Pierre-Louis Bossart @ 2019-07-30 11:21 ` Andy Shevchenko 2019-07-30 12:57 ` Pierre-Louis Bossart 0 siblings, 1 reply; 9+ messages in thread From: Andy Shevchenko @ 2019-07-30 11:21 UTC (permalink / raw) To: Pierre-Louis Bossart Cc: alsa-devel, Rafael J. Wysocki, tiwai, gregkh, linux-pm, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale On Mon, Jul 29, 2019 at 05:07:39PM -0500, Pierre-Louis Bossart wrote: > On 7/26/19 2:08 PM, Andy Shevchenko wrote: > > On Fri, Jul 26, 2019 at 01:08:57PM -0500, Pierre-Louis Bossart wrote: > > > - if (ret < 0) > > > + if (ret < 0 && ret != -EACCES) > > > > ...and here, the pm_runtime_put_noidle() call is missed. > > yes but in the example you provided, they actually do more work than just > decrement the device usage counter: In their case they would like to do that. You decide what is appropriate call in your case. My point is, that reference counter in case of error handling should be returned back to its value. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-30 11:21 ` Andy Shevchenko @ 2019-07-30 12:57 ` Pierre-Louis Bossart 2019-07-30 15:58 ` Andy Shevchenko 0 siblings, 1 reply; 9+ messages in thread From: Pierre-Louis Bossart @ 2019-07-30 12:57 UTC (permalink / raw) To: Andy Shevchenko Cc: alsa-devel, linux-pm, tiwai, gregkh, Rafael J. Wysocki, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale On 7/30/19 6:21 AM, Andy Shevchenko wrote: > On Mon, Jul 29, 2019 at 05:07:39PM -0500, Pierre-Louis Bossart wrote: >> On 7/26/19 2:08 PM, Andy Shevchenko wrote: >>> On Fri, Jul 26, 2019 at 01:08:57PM -0500, Pierre-Louis Bossart wrote: > >>>> - if (ret < 0) >>>> + if (ret < 0 && ret != -EACCES) >>> >>> ...and here, the pm_runtime_put_noidle() call is missed. >> >> yes but in the example you provided, they actually do more work than just >> decrement the device usage counter: > > In their case they would like to do that. You decide what is appropriate call > in your case. > > My point is, that reference counter in case of error handling should be > returned back to its value. Agree on the reference count. I am however not clear on the next step and 'what is appropriate'. If pm_runtime_get_sync() failed, then technically the device was not resumed so marking it as last_busy+autosuspend, or using a plain vanilla put() will not result in any action. I must be missing something here. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-30 12:57 ` Pierre-Louis Bossart @ 2019-07-30 15:58 ` Andy Shevchenko 2019-07-30 15:59 ` Andy Shevchenko 0 siblings, 1 reply; 9+ messages in thread From: Andy Shevchenko @ 2019-07-30 15:58 UTC (permalink / raw) To: Pierre-Louis Bossart Cc: alsa-devel, linux-pm, tiwai, gregkh, Rafael J. Wysocki, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale On Tue, Jul 30, 2019 at 07:57:46AM -0500, Pierre-Louis Bossart wrote: > On 7/30/19 6:21 AM, Andy Shevchenko wrote: > > On Mon, Jul 29, 2019 at 05:07:39PM -0500, Pierre-Louis Bossart wrote: > > > On 7/26/19 2:08 PM, Andy Shevchenko wrote: > > > > On Fri, Jul 26, 2019 at 01:08:57PM -0500, Pierre-Louis Bossart wrote: > > > > > > > - if (ret < 0) > > > > > + if (ret < 0 && ret != -EACCES) > > > > > > > > ...and here, the pm_runtime_put_noidle() call is missed. > > > > > > yes but in the example you provided, they actually do more work than just > > > decrement the device usage counter: > > > > In their case they would like to do that. You decide what is appropriate call > > in your case. > > > > My point is, that reference counter in case of error handling should be > > returned back to its value. > > Agree on the reference count. > I am however not clear on the next step and 'what is appropriate'. > > If pm_runtime_get_sync() failed, then technically the device was not resumed Not so straight. It depends on reference count. It might be true (most cases I think), or not true, if device had been resumed previously by other call. > so marking it as last_busy+autosuspend, or using a plain vanilla put() will > not result in any action. I must be missing something here. put_noidle(). Because if it failed on the first call and was resumed, put() will try to shut it down (since reference count goes to no-user base). -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [alsa-devel] [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled 2019-07-30 15:58 ` Andy Shevchenko @ 2019-07-30 15:59 ` Andy Shevchenko 0 siblings, 0 replies; 9+ messages in thread From: Andy Shevchenko @ 2019-07-30 15:59 UTC (permalink / raw) To: Pierre-Louis Bossart Cc: alsa-devel, linux-pm, tiwai, gregkh, Rafael J. Wysocki, linux-kernel, vkoul, broonie, srinivas.kandagatla, jank, slawomir.blauciak, Sanyog Kale On Tue, Jul 30, 2019 at 06:58:09PM +0300, Andy Shevchenko wrote: > On Tue, Jul 30, 2019 at 07:57:46AM -0500, Pierre-Louis Bossart wrote: > > On 7/30/19 6:21 AM, Andy Shevchenko wrote: > > > On Mon, Jul 29, 2019 at 05:07:39PM -0500, Pierre-Louis Bossart wrote: > > > > On 7/26/19 2:08 PM, Andy Shevchenko wrote: > > so marking it as last_busy+autosuspend, or using a plain vanilla put() will > > not result in any action. I must be missing something here. > > put_noidle(). Because if it failed on the first call and was resumed, put() > will try to shut it down (since reference count goes to no-user base). Sorry, this has to be read as (was -> wasn't) > put_noidle(). Because if it failed on the first call and wasn't resumed, put() > will try to shut it down (since reference count goes to no-user base). -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-07-30 15:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com>
[not found] ` <20190725234032.21152-18-pierre-louis.bossart@linux.intel.com>
2019-07-26 18:08 ` [RFC PATCH 17/40] soundwire: bus: use runtime_pm_get_sync/pm when enabled Pierre-Louis Bossart
2019-07-26 18:25 ` [alsa-devel] " Guennadi Liakhovetski
2019-07-26 19:11 ` Andy Shevchenko
2019-07-26 19:08 ` Andy Shevchenko
2019-07-29 22:07 ` [alsa-devel] " Pierre-Louis Bossart
2019-07-30 11:21 ` Andy Shevchenko
2019-07-30 12:57 ` Pierre-Louis Bossart
2019-07-30 15:58 ` Andy Shevchenko
2019-07-30 15:59 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).