linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: cyapa - Fix rumtime PM imbalance on error
@ 2021-04-07  4:07 Dinghao Liu
  2021-04-08  6:19 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2021-04-07  4:07 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Dmitry Torokhov, Fuqian Huang, Benson Leung,
	Andrzej Pietrasiewicz, Lee Jones, linux-input, linux-kernel

When mutex_lock_interruptible() fails, a pairing PM usage
counter decrement is needed to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/input/mouse/cyapa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 77cc653edca2..e411ab45a218 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -904,8 +904,10 @@ static ssize_t cyapa_update_rt_suspend_scanrate(struct device *dev,
 	pm_runtime_get_sync(dev);
 
 	error = mutex_lock_interruptible(&cyapa->state_sync_lock);
-	if (error)
+	if (error) {
+		pm_runtime_put_noidle(dev);
 		return error;
+	}
 
 	cyapa->runtime_suspend_sleep_time = min_t(u16, time, 1000);
 	cyapa->runtime_suspend_power_mode =
-- 
2.17.1


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

* Re: [PATCH] Input: cyapa - Fix rumtime PM imbalance on error
  2021-04-07  4:07 [PATCH] Input: cyapa - Fix rumtime PM imbalance on error Dinghao Liu
@ 2021-04-08  6:19 ` Dmitry Torokhov
  2021-04-08  6:29   ` dinghao.liu
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2021-04-08  6:19 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Fuqian Huang, Benson Leung, Andrzej Pietrasiewicz,
	Lee Jones, linux-input, linux-kernel

Hi Dinghao,

On Wed, Apr 07, 2021 at 12:07:38PM +0800, Dinghao Liu wrote:
> When mutex_lock_interruptible() fails, a pairing PM usage
> counter decrement is needed to keep the counter balanced.

Thank you for the patch.

> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/input/mouse/cyapa.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> index 77cc653edca2..e411ab45a218 100644
> --- a/drivers/input/mouse/cyapa.c
> +++ b/drivers/input/mouse/cyapa.c
> @@ -904,8 +904,10 @@ static ssize_t cyapa_update_rt_suspend_scanrate(struct device *dev,
>  	pm_runtime_get_sync(dev);
>  
>  	error = mutex_lock_interruptible(&cyapa->state_sync_lock);
> -	if (error)
> +	if (error) {
> +		pm_runtime_put_noidle(dev);

Why "noidle" and not pm_runtime_put_sync_autosuspend() like we do in
case of normal flow?

>  		return error;
> +	}
>  
>  	cyapa->runtime_suspend_sleep_time = min_t(u16, time, 1000);
>  	cyapa->runtime_suspend_power_mode =
> -- 
> 2.17.1
> 

Thanks.

-- 
Dmitry

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

* Re: Re: [PATCH] Input: cyapa - Fix rumtime PM imbalance on error
  2021-04-08  6:19 ` Dmitry Torokhov
@ 2021-04-08  6:29   ` dinghao.liu
  0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2021-04-08  6:29 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: kjlu, Fuqian Huang, Benson Leung, Andrzej Pietrasiewicz,
	Lee Jones, linux-input, linux-kernel

> Hi Dinghao,
> 
> On Wed, Apr 07, 2021 at 12:07:38PM +0800, Dinghao Liu wrote:
> > When mutex_lock_interruptible() fails, a pairing PM usage
> > counter decrement is needed to keep the counter balanced.
> 
> Thank you for the patch.
> 
> > 
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> >  drivers/input/mouse/cyapa.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
> > index 77cc653edca2..e411ab45a218 100644
> > --- a/drivers/input/mouse/cyapa.c
> > +++ b/drivers/input/mouse/cyapa.c
> > @@ -904,8 +904,10 @@ static ssize_t cyapa_update_rt_suspend_scanrate(struct device *dev,
> >  	pm_runtime_get_sync(dev);
> >  
> >  	error = mutex_lock_interruptible(&cyapa->state_sync_lock);
> > -	if (error)
> > +	if (error) {
> > +		pm_runtime_put_noidle(dev);
> 
> Why "noidle" and not pm_runtime_put_sync_autosuspend() like we do in
> case of normal flow?
> 

pm_runtime_put_noidle() only decrease the refcount, while 
pm_runtime_put_sync_autosuspend() will execute an extra
pm_runtime_autosuspend(). I'm not sure if the autosuspend is necessary
in this error handling path, so I only balance the counter.

Regards,
Dinghao

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

end of thread, other threads:[~2021-04-08  6:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07  4:07 [PATCH] Input: cyapa - Fix rumtime PM imbalance on error Dinghao Liu
2021-04-08  6:19 ` Dmitry Torokhov
2021-04-08  6:29   ` dinghao.liu

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