2022-01-17 17:12:48

by Yongzhi Liu

[permalink] [raw]
Subject: [PATCH] driver core: Add missing pm_runtime_put_noidle

pm_runtime_get_noresume() in device_shutdown increments the
runtime PM usage counter, thus a matching decrement is needed
to keep the counter balanced.

Signed-off-by: Yongzhi Liu <[email protected]>
---
drivers/base/core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index fd034d7..29950bd 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4523,6 +4523,8 @@ void device_shutdown(void)
dev->driver->shutdown(dev);
}

+ pm_runtime_put_noidle(dev);
+
device_unlock(dev);
if (parent)
device_unlock(parent);
--
2.7.4


2022-01-18 02:29:06

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] driver core: Add missing pm_runtime_put_noidle

On Mon, Jan 17, 2022 at 12:08 PM Yongzhi Liu <[email protected]> wrote:
>
> pm_runtime_get_noresume() in device_shutdown increments the
> runtime PM usage counter,

This is on purpose, to prevent devices from being runtime-suspended
after their shutdown callbacks have run.

> thus a matching decrement is needed

No, it is not, AFAICS.

> to keep the counter balanced.
>
> Signed-off-by: Yongzhi Liu <[email protected]>
> ---
> drivers/base/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index fd034d7..29950bd 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4523,6 +4523,8 @@ void device_shutdown(void)
> dev->driver->shutdown(dev);
> }
>
> + pm_runtime_put_noidle(dev);
> +
> device_unlock(dev);
> if (parent)
> device_unlock(parent);
> --
> 2.7.4
>

2022-01-20 07:07:18

by Yongzhi Liu

[permalink] [raw]
Subject: Re: Re: [PATCH] driver core: Add missing pm_runtime_put_noidle

> -----原始邮件-----
> 发件人: "Rafael J. Wysocki" <[email protected]>
> 发送时间: 2022-01-17 22:01:54 (星期一)
> 收件人: "Yongzhi Liu" <[email protected]>
> 抄送: "Greg Kroah-Hartman" <[email protected]>, "Rafael J. Wysocki" <[email protected]>, "Linux Kernel Mailing List" <[email protected]>
> 主题: Re: [PATCH] driver core: Add missing pm_runtime_put_noidle
>
> On Mon, Jan 17, 2022 at 12:08 PM Yongzhi Liu <[email protected]> wrote:
> >
> > pm_runtime_get_noresume() in device_shutdown increments the
> > runtime PM usage counter,
>
> This is on purpose, to prevent devices from being runtime-suspended
> after their shutdown callbacks have run.
>
> > thus a matching decrement is needed
>
> No, it is not, AFAICS.
>
> > to keep the counter balanced.
> >
> > Signed-off-by: Yongzhi Liu <[email protected]>
> > ---
> > drivers/base/core.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index fd034d7..29950bd 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -4523,6 +4523,8 @@ void device_shutdown(void)
> > dev->driver->shutdown(dev);
> > }
> >
> > + pm_runtime_put_noidle(dev);
> > +
> > device_unlock(dev);
> > if (parent)
> > device_unlock(parent);
> > --
> > 2.7.4
> >
Yes, thanks for your reply.