* RE: [PATCH] i2c: busses: Fix a reference count leak.
@ 2020-06-15 6:31 Aisheng Dong
2020-06-15 7:06 ` Wolfram Sang
0 siblings, 1 reply; 3+ messages in thread
From: Aisheng Dong @ 2020-06-15 6:31 UTC (permalink / raw)
To: Andy Duan, wu000273, kjlu, Ulf Hansson, rjw, khilman, linux-pm
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
dl-linux-imx, Wolfram Sang, linux-i2c, linux-arm-kernel,
linux-kernel
> From: Andy Duan <fugang.duan@nxp.com>
> Sent: Monday, June 15, 2020 10:49 AM
>
> From: wu000273@umn.edu <wu000273@umn.edu> Sent: Sunday, June 14,
> 2020 6:12 AM
> > From: Qiushi Wu <wu000273@umn.edu>
> >
> > pm_runtime_get_sync() increments the runtime PM usage counter even
> > when it returns an error code. Thus call pm_runtime_put_noidle() if
> > pm_runtime_get_sync() fails.
> >
> > Fixes: 13d6eb20fc79 ("i2c: imx-lpi2c: add runtime pm support")
> > Signed-off-by: Qiushi Wu <wu000273@umn.edu>
>
> Again, which case can trigger the issue ?
It's just error handling improvement because pm_runtime_get_sync() will increase the
reference count even it's failed.
I wonder if such de-reference can be better handled by pm runtime core code.
Copy pm guys to comment.
Regards
Aisheng
> > ---
> > drivers/i2c/busses/i2c-imx-lpi2c.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
> > b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > index 9db6ccded5e9..85b9c1fc7681 100644
> > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > @@ -260,8 +260,10 @@ static int lpi2c_imx_master_enable(struct
> > lpi2c_imx_struct *lpi2c_imx)
> > int ret;
> >
> > ret = pm_runtime_get_sync(lpi2c_imx->adapter.dev.parent);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put_noidle(lpi2c_imx->adapter.dev.parent);
> > return ret;
> > + }
> >
> > temp = MCR_RST;
> > writel(temp, lpi2c_imx->base + LPI2C_MCR);
> > --
> > 2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: busses: Fix a reference count leak.
2020-06-15 6:31 [PATCH] i2c: busses: Fix a reference count leak Aisheng Dong
@ 2020-06-15 7:06 ` Wolfram Sang
0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-06-15 7:06 UTC (permalink / raw)
To: Aisheng Dong
Cc: Andy Duan, wu000273, kjlu, Ulf Hansson, rjw, khilman, linux-pm,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
dl-linux-imx, linux-i2c, linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]
On Mon, Jun 15, 2020 at 06:31:28AM +0000, Aisheng Dong wrote:
> > From: Andy Duan <fugang.duan@nxp.com>
> > Sent: Monday, June 15, 2020 10:49 AM
> >
> > From: wu000273@umn.edu <wu000273@umn.edu> Sent: Sunday, June 14,
> > 2020 6:12 AM
> > > From: Qiushi Wu <wu000273@umn.edu>
> > >
> > > pm_runtime_get_sync() increments the runtime PM usage counter even
> > > when it returns an error code. Thus call pm_runtime_put_noidle() if
> > > pm_runtime_get_sync() fails.
> > >
> > > Fixes: 13d6eb20fc79 ("i2c: imx-lpi2c: add runtime pm support")
> > > Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> >
> > Again, which case can trigger the issue ?
>
> It's just error handling improvement because pm_runtime_get_sync() will increase the
> reference count even it's failed.
>
> I wonder if such de-reference can be better handled by pm runtime core code.
> Copy pm guys to comment.
I started a seperate thread:
https://lkml.org/lkml/2020/6/14/76
Still, on-going discussion if the proper fix is to remove the error
check.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] i2c: busses: Fix a reference count leak.
@ 2020-06-13 22:12 wu000273
0 siblings, 0 replies; 3+ messages in thread
From: wu000273 @ 2020-06-13 22:12 UTC (permalink / raw)
To: kjlu
Cc: wu000273, Dong Aisheng, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team,
Wolfram Sang, Fugang Duan, linux-i2c, linux-arm-kernel,
linux-kernel
From: Qiushi Wu <wu000273@umn.edu>
pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus call pm_runtime_put_noidle()
if pm_runtime_get_sync() fails.
Fixes: 13d6eb20fc79 ("i2c: imx-lpi2c: add runtime pm support")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 9db6ccded5e9..85b9c1fc7681 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -260,8 +260,10 @@ static int lpi2c_imx_master_enable(struct lpi2c_imx_struct *lpi2c_imx)
int ret;
ret = pm_runtime_get_sync(lpi2c_imx->adapter.dev.parent);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_noidle(lpi2c_imx->adapter.dev.parent);
return ret;
+ }
temp = MCR_RST;
writel(temp, lpi2c_imx->base + LPI2C_MCR);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-15 7:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 6:31 [PATCH] i2c: busses: Fix a reference count leak Aisheng Dong
2020-06-15 7:06 ` Wolfram Sang
-- strict thread matches above, loose matches on Subject: below --
2020-06-13 22:12 wu000273
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).