* [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
@ 2020-05-21 7:05 ` Dinghao Liu
0 siblings, 0 replies; 8+ messages in thread
From: Dinghao Liu @ 2020-05-21 7:05 UTC (permalink / raw)
To: dinghao.liu, kjlu
Cc: Pierre-Yves MORDRET, Maxime Coquelin, Alexandre Torgue,
linux-i2c, linux-stm32, linux-arm-kernel, linux-kernel
pm_runtime_get_sync() increments the runtime PM usage counter even
the call returns an error code. Thus a pairing decrement is needed
on the error handling path to keep the counter balanced.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 330ffed011e0..602cf35649c8 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
return ret;
ret = pm_runtime_get_sync(dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_autosuspend(dev);
return ret;
+ }
if (!stm32f7_i2c_is_slave_registered(i2c_dev))
stm32f7_i2c_enable_wakeup(i2c_dev, true);
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
@ 2020-05-21 7:05 ` Dinghao Liu
0 siblings, 0 replies; 8+ messages in thread
From: Dinghao Liu @ 2020-05-21 7:05 UTC (permalink / raw)
To: dinghao.liu, kjlu
Cc: Alexandre Torgue, linux-kernel, Pierre-Yves MORDRET, linux-i2c,
Maxime Coquelin, linux-stm32, linux-arm-kernel
pm_runtime_get_sync() increments the runtime PM usage counter even
the call returns an error code. Thus a pairing decrement is needed
on the error handling path to keep the counter balanced.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 330ffed011e0..602cf35649c8 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
return ret;
ret = pm_runtime_get_sync(dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_autosuspend(dev);
return ret;
+ }
if (!stm32f7_i2c_is_slave_registered(i2c_dev))
stm32f7_i2c_enable_wakeup(i2c_dev, true);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
2020-05-21 7:05 ` Dinghao Liu
@ 2020-05-26 8:34 ` Alain Volmat
-1 siblings, 0 replies; 8+ messages in thread
From: Alain Volmat @ 2020-05-26 8:34 UTC (permalink / raw)
To: Dinghao Liu
Cc: kjlu, Pierre-Yves MORDRET, Maxime Coquelin, Alexandre Torgue,
linux-i2c, linux-stm32, linux-arm-kernel, linux-kernel
Hi Dinghao,
Thanks for the patch. Indeed, this should be fixed.
Overall, there are several other calls to pm_runtime_get_sync within this
driver, would you like to fix them all at once ?
On Thu, May 21, 2020 at 03:05:07PM +0800, Dinghao Liu wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> the call returns an error code. Thus a pairing decrement is needed
> on the error handling path to keep the counter balanced.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 330ffed011e0..602cf35649c8 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
> return ret;
>
> ret = pm_runtime_get_sync(dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_autosuspend(dev);
Considering that if we fail here there is a very good chance that this is due
to the resume failing, pm_runtime_put_noidle would probably make more sense
since pm_runtime_put_autosuspend will most probably fail as well.
> return ret;
> + }
>
> if (!stm32f7_i2c_is_slave_registered(i2c_dev))
> stm32f7_i2c_enable_wakeup(i2c_dev, true);
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
@ 2020-05-26 8:34 ` Alain Volmat
0 siblings, 0 replies; 8+ messages in thread
From: Alain Volmat @ 2020-05-26 8:34 UTC (permalink / raw)
To: Dinghao Liu
Cc: Alexandre Torgue, kjlu, linux-kernel, Pierre-Yves MORDRET,
linux-i2c, Maxime Coquelin, linux-stm32, linux-arm-kernel
Hi Dinghao,
Thanks for the patch. Indeed, this should be fixed.
Overall, there are several other calls to pm_runtime_get_sync within this
driver, would you like to fix them all at once ?
On Thu, May 21, 2020 at 03:05:07PM +0800, Dinghao Liu wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> the call returns an error code. Thus a pairing decrement is needed
> on the error handling path to keep the counter balanced.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 330ffed011e0..602cf35649c8 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
> return ret;
>
> ret = pm_runtime_get_sync(dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_autosuspend(dev);
Considering that if we fail here there is a very good chance that this is due
to the resume failing, pm_runtime_put_noidle would probably make more sense
since pm_runtime_put_autosuspend will most probably fail as well.
> return ret;
> + }
>
> if (!stm32f7_i2c_is_slave_registered(i2c_dev))
> stm32f7_i2c_enable_wakeup(i2c_dev, true);
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re: [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
2020-05-26 8:34 ` Alain Volmat
@ 2020-05-26 13:00 ` dinghao.liu
-1 siblings, 0 replies; 8+ messages in thread
From: dinghao.liu @ 2020-05-26 13:00 UTC (permalink / raw)
To: Alain Volmat
Cc: kjlu, Pierre-Yves MORDRET, Maxime Coquelin, Alexandre Torgue,
linux-i2c, linux-stm32, linux-arm-kernel, linux-kernel
> Overall, there are several other calls to pm_runtime_get_sync within this
> driver, would you like to fix them all at once ?
>
Sure, I will send a new patch to merge them all.
> On Thu, May 21, 2020 at 03:05:07PM +0800, Dinghao Liu wrote:
> > pm_runtime_get_sync() increments the runtime PM usage counter even
> > the call returns an error code. Thus a pairing decrement is needed
> > on the error handling path to keep the counter balanced.
> >
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> > drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> > index 330ffed011e0..602cf35649c8 100644
> > --- a/drivers/i2c/busses/i2c-stm32f7.c
> > +++ b/drivers/i2c/busses/i2c-stm32f7.c
> > @@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
> > return ret;
> >
> > ret = pm_runtime_get_sync(dev);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put_autosuspend(dev);
>
> Considering that if we fail here there is a very good chance that this is due
> to the resume failing, pm_runtime_put_noidle would probably make more sense
> since pm_runtime_put_autosuspend will most probably fail as well.
>
Agree. Thank you for your advice!
Regards.
Dinghao
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re: [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
@ 2020-05-26 13:00 ` dinghao.liu
0 siblings, 0 replies; 8+ messages in thread
From: dinghao.liu @ 2020-05-26 13:00 UTC (permalink / raw)
To: Alain Volmat
Cc: Alexandre Torgue, kjlu, linux-kernel, Pierre-Yves MORDRET,
linux-i2c, Maxime Coquelin, linux-stm32, linux-arm-kernel
> Overall, there are several other calls to pm_runtime_get_sync within this
> driver, would you like to fix them all at once ?
>
Sure, I will send a new patch to merge them all.
> On Thu, May 21, 2020 at 03:05:07PM +0800, Dinghao Liu wrote:
> > pm_runtime_get_sync() increments the runtime PM usage counter even
> > the call returns an error code. Thus a pairing decrement is needed
> > on the error handling path to keep the counter balanced.
> >
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> > drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> > index 330ffed011e0..602cf35649c8 100644
> > --- a/drivers/i2c/busses/i2c-stm32f7.c
> > +++ b/drivers/i2c/busses/i2c-stm32f7.c
> > @@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
> > return ret;
> >
> > ret = pm_runtime_get_sync(dev);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put_autosuspend(dev);
>
> Considering that if we fail here there is a very good chance that this is due
> to the resume failing, pm_runtime_put_noidle would probably make more sense
> since pm_runtime_put_autosuspend will most probably fail as well.
>
Agree. Thank you for your advice!
Regards.
Dinghao
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re: [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
2020-05-26 13:00 ` dinghao.liu
@ 2020-05-26 13:25 ` Alain Volmat
-1 siblings, 0 replies; 8+ messages in thread
From: Alain Volmat @ 2020-05-26 13:25 UTC (permalink / raw)
To: dinghao.liu
Cc: kjlu, Pierre-Yves MORDRET, Maxime Coquelin, Alexandre Torgue,
linux-i2c, linux-stm32, linux-arm-kernel, linux-kernel
On Tue, May 26, 2020 at 09:00:23PM +0800, dinghao.liu@zju.edu.cn wrote:
>
> > Overall, there are several other calls to pm_runtime_get_sync within this
> > driver, would you like to fix them all at once ?
> >
>
> Sure, I will send a new patch to merge them all.
Thanks, you might want to add a Fixes: tag in your commit message as well.
>
> > On Thu, May 21, 2020 at 03:05:07PM +0800, Dinghao Liu wrote:
> > > pm_runtime_get_sync() increments the runtime PM usage counter even
> > > the call returns an error code. Thus a pairing decrement is needed
> > > on the error handling path to keep the counter balanced.
> > >
> > > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > > ---
> > > drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> > > index 330ffed011e0..602cf35649c8 100644
> > > --- a/drivers/i2c/busses/i2c-stm32f7.c
> > > +++ b/drivers/i2c/busses/i2c-stm32f7.c
> > > @@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
> > > return ret;
> > >
> > > ret = pm_runtime_get_sync(dev);
> > > - if (ret < 0)
> > > + if (ret < 0) {
> > > + pm_runtime_put_autosuspend(dev);
> >
> > Considering that if we fail here there is a very good chance that this is due
> > to the resume failing, pm_runtime_put_noidle would probably make more sense
> > since pm_runtime_put_autosuspend will most probably fail as well.
> >
>
> Agree. Thank you for your advice!
>
> Regards.
> Dinghao
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re: [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave
@ 2020-05-26 13:25 ` Alain Volmat
0 siblings, 0 replies; 8+ messages in thread
From: Alain Volmat @ 2020-05-26 13:25 UTC (permalink / raw)
To: dinghao.liu
Cc: Alexandre Torgue, kjlu, linux-kernel, Pierre-Yves MORDRET,
linux-i2c, Maxime Coquelin, linux-stm32, linux-arm-kernel
On Tue, May 26, 2020 at 09:00:23PM +0800, dinghao.liu@zju.edu.cn wrote:
>
> > Overall, there are several other calls to pm_runtime_get_sync within this
> > driver, would you like to fix them all at once ?
> >
>
> Sure, I will send a new patch to merge them all.
Thanks, you might want to add a Fixes: tag in your commit message as well.
>
> > On Thu, May 21, 2020 at 03:05:07PM +0800, Dinghao Liu wrote:
> > > pm_runtime_get_sync() increments the runtime PM usage counter even
> > > the call returns an error code. Thus a pairing decrement is needed
> > > on the error handling path to keep the counter balanced.
> > >
> > > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > > ---
> > > drivers/i2c/busses/i2c-stm32f7.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> > > index 330ffed011e0..602cf35649c8 100644
> > > --- a/drivers/i2c/busses/i2c-stm32f7.c
> > > +++ b/drivers/i2c/busses/i2c-stm32f7.c
> > > @@ -1767,8 +1767,10 @@ static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
> > > return ret;
> > >
> > > ret = pm_runtime_get_sync(dev);
> > > - if (ret < 0)
> > > + if (ret < 0) {
> > > + pm_runtime_put_autosuspend(dev);
> >
> > Considering that if we fail here there is a very good chance that this is due
> > to the resume failing, pm_runtime_put_noidle would probably make more sense
> > since pm_runtime_put_autosuspend will most probably fail as well.
> >
>
> Agree. Thank you for your advice!
>
> Regards.
> Dinghao
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-05-26 13:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 7:05 [PATCH] i2c: stm32f7: Fix runtime PM imbalance in stm32f7_i2c_reg_slave Dinghao Liu
2020-05-21 7:05 ` Dinghao Liu
2020-05-26 8:34 ` Alain Volmat
2020-05-26 8:34 ` Alain Volmat
2020-05-26 13:00 ` dinghao.liu
2020-05-26 13:00 ` dinghao.liu
2020-05-26 13:25 ` Alain Volmat
2020-05-26 13:25 ` Alain Volmat
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.