LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] PM / runtime: Drop usage count for suppliers at device link removal
@ 2018-05-24 8:33 Ulf Hansson
2018-05-27 10:18 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2018-05-24 8:33 UTC (permalink / raw)
To: Rafael J . Wysocki, Greg Kroah-Hartman, linux-pm
Cc: Ulf Hansson, Viresh Kumar, Vincent Guittot, Todor Tomov,
Rajendra Nayak, Jon Hunter, linux-kernel, linux-arm-kernel
In the case consumer device is runtime resumed, while the link to the
supplier is removed, the earlier call to pm_runtime_get_sync() made from
rpm_get_suppliers() does not get properly balanced with a corresponding
call to pm_runtime_put(). This leads to that suppliers remains to be
runtime resumed forever, while they don't need to.
Let's fix the behaviour by calling rpm_put_suppliers() when dropping a
device link. Not that, since rpm_put_suppliers() checks the
link->rpm_active flag, we can correctly avoid to call pm_runtime_put() in
cases when we shouldn't.
Reported-by: Todor Tomov <todor.tomov@linaro.org>
Fixes: 21d5c57b3726 ("PM / runtime: Use device links")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Rafael, I am not sure if this is safe from locking point of view. The device
link write lock has been taken when pm_runtime_drop_link() is called, hence I
assume calling rpm_put_suppliers() should be fine!? If not, can you please
advise how to change?
Kind regards
Uffe
---
drivers/base/power/runtime.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 8bef3cb..beb85c3 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1607,6 +1607,8 @@ void pm_runtime_new_link(struct device *dev)
void pm_runtime_drop_link(struct device *dev)
{
+ rpm_put_suppliers(dev);
+
spin_lock_irq(&dev->power.lock);
WARN_ON(dev->power.links_count == 0);
dev->power.links_count--;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PM / runtime: Drop usage count for suppliers at device link removal
2018-05-24 8:33 [PATCH] PM / runtime: Drop usage count for suppliers at device link removal Ulf Hansson
@ 2018-05-27 10:18 ` Rafael J. Wysocki
2018-05-29 8:40 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2018-05-27 10:18 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J . Wysocki, Greg Kroah-Hartman, Linux PM, Viresh Kumar,
Vincent Guittot, Todor Tomov, Rajendra Nayak, Jon Hunter,
Linux Kernel Mailing List, Linux ARM
On Thu, May 24, 2018 at 10:33 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> In the case consumer device is runtime resumed, while the link to the
> supplier is removed, the earlier call to pm_runtime_get_sync() made from
> rpm_get_suppliers() does not get properly balanced with a corresponding
> call to pm_runtime_put(). This leads to that suppliers remains to be
> runtime resumed forever, while they don't need to.
>
> Let's fix the behaviour by calling rpm_put_suppliers() when dropping a
> device link. Not that, since rpm_put_suppliers() checks the
> link->rpm_active flag, we can correctly avoid to call pm_runtime_put() in
> cases when we shouldn't.
>
> Reported-by: Todor Tomov <todor.tomov@linaro.org>
> Fixes: 21d5c57b3726 ("PM / runtime: Use device links")
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>
> Rafael, I am not sure if this is safe from locking point of view. The device
> link write lock has been taken when pm_runtime_drop_link() is called, hence I
> assume calling rpm_put_suppliers() should be fine!? If not, can you please
> advise how to change?
Holding the lock should be sufficient for the list to be stable, so
AFAICS it is OK.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PM / runtime: Drop usage count for suppliers at device link removal
2018-05-27 10:18 ` Rafael J. Wysocki
@ 2018-05-29 8:40 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2018-05-29 8:40 UTC (permalink / raw)
To: Ulf Hansson
Cc: Greg Kroah-Hartman, Linux PM, Viresh Kumar, Vincent Guittot,
Todor Tomov, Rajendra Nayak, Jon Hunter,
Linux Kernel Mailing List, Linux ARM
On Sunday, May 27, 2018 12:18:05 PM CEST Rafael J. Wysocki wrote:
> On Thu, May 24, 2018 at 10:33 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > In the case consumer device is runtime resumed, while the link to the
> > supplier is removed, the earlier call to pm_runtime_get_sync() made from
> > rpm_get_suppliers() does not get properly balanced with a corresponding
> > call to pm_runtime_put(). This leads to that suppliers remains to be
> > runtime resumed forever, while they don't need to.
> >
> > Let's fix the behaviour by calling rpm_put_suppliers() when dropping a
> > device link. Not that, since rpm_put_suppliers() checks the
> > link->rpm_active flag, we can correctly avoid to call pm_runtime_put() in
> > cases when we shouldn't.
> >
> > Reported-by: Todor Tomov <todor.tomov@linaro.org>
> > Fixes: 21d5c57b3726 ("PM / runtime: Use device links")
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > ---
> >
> > Rafael, I am not sure if this is safe from locking point of view. The device
> > link write lock has been taken when pm_runtime_drop_link() is called, hence I
> > assume calling rpm_put_suppliers() should be fine!? If not, can you please
> > advise how to change?
>
> Holding the lock should be sufficient for the list to be stable, so
> AFAICS it is OK.
So the patch has been applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-29 8:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24 8:33 [PATCH] PM / runtime: Drop usage count for suppliers at device link removal Ulf Hansson
2018-05-27 10:18 ` Rafael J. Wysocki
2018-05-29 8:40 ` Rafael J. Wysocki
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).