linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/2] fix PM usage counter unbalance
@ 2022-09-22 13:21 Zhang Qilong
  2022-09-22 13:21 ` [PATCH -next 1/2] drm/rockchip: vop: fix PM usage counter unbalance in vop ops Zhang Qilong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zhang Qilong @ 2022-09-22 13:21 UTC (permalink / raw)
  To: heiko, hjc, airlied, daniel, dri-devel, linux-rockchip

pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
We fix it by replacing it with the newest pm_runtime_resume_and_get
to keep usage counter balanced.

Zhang Qilong (2):
  drm/rockchip: vop: fix PM usage counter unbalance in vop ops
  drm/rockchip: fix PM usage counter unbalance in poweron

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  4 ++--
 drivers/gpu/drm/rockchip/rockchip_lvds.c    | 10 +++++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.25.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH -next 1/2] drm/rockchip: vop: fix PM usage counter unbalance in vop ops
  2022-09-22 13:21 [PATCH -next 0/2] fix PM usage counter unbalance Zhang Qilong
@ 2022-09-22 13:21 ` Zhang Qilong
  2022-09-22 13:21 ` [PATCH -next 2/2] drm/rockchip: fix PM usage counter unbalance in poweron Zhang Qilong
  2022-10-29 22:08 ` (subset) [PATCH -next 0/2] fix PM usage counter unbalance Heiko Stuebner
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang Qilong @ 2022-09-22 13:21 UTC (permalink / raw)
  To: heiko, hjc, airlied, daniel, dri-devel, linux-rockchip

pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
We fix it by replacing it with the newest pm_runtime_resume_and_get
to keep usage counter balanced.

Fixes:5e570373c015b ("drm/rockchip: vop: Enable pm domain before vop_initial")
Fixes:604be85547ce4 ("drm/rockchip: Add VOP2 driver")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index c356de5dd220..fa1f4ee6d195 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -602,7 +602,7 @@ static int vop_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
 	struct vop *vop = to_vop(crtc);
 	int ret, i;
 
-	ret = pm_runtime_get_sync(vop->dev);
+	ret = pm_runtime_resume_and_get(vop->dev);
 	if (ret < 0) {
 		DRM_DEV_ERROR(vop->dev, "failed to get pm runtime: %d\n", ret);
 		return ret;
@@ -1983,7 +1983,7 @@ static int vop_initial(struct vop *vop)
 		return PTR_ERR(vop->dclk);
 	}
 
-	ret = pm_runtime_get_sync(vop->dev);
+	ret = pm_runtime_resume_and_get(vop->dev);
 	if (ret < 0) {
 		DRM_DEV_ERROR(vop->dev, "failed to get pm runtime: %d\n", ret);
 		return ret;
-- 
2.25.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH -next 2/2] drm/rockchip: fix PM usage counter unbalance in poweron
  2022-09-22 13:21 [PATCH -next 0/2] fix PM usage counter unbalance Zhang Qilong
  2022-09-22 13:21 ` [PATCH -next 1/2] drm/rockchip: vop: fix PM usage counter unbalance in vop ops Zhang Qilong
@ 2022-09-22 13:21 ` Zhang Qilong
  2022-10-29 22:08 ` (subset) [PATCH -next 0/2] fix PM usage counter unbalance Heiko Stuebner
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang Qilong @ 2022-09-22 13:21 UTC (permalink / raw)
  To: heiko, hjc, airlied, daniel, dri-devel, linux-rockchip

pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
We fix it by replacing it with the newest pm_runtime_resume_and_get
to keep usage counter balanced.

Fixes:34cc0aa254560 ("drm/rockchip: Add support for Rockchip Soc LVDS")
Fixes:cca1705c3d895 ("drm/rockchip: lvds: Add PX30 support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/gpu/drm/rockchip/rockchip_lvds.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
index 5a284332ec49..68f6ebb33460 100644
--- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -152,7 +152,7 @@ static int rk3288_lvds_poweron(struct rockchip_lvds *lvds)
 		DRM_DEV_ERROR(lvds->dev, "failed to enable lvds pclk %d\n", ret);
 		return ret;
 	}
-	ret = pm_runtime_get_sync(lvds->dev);
+	ret = pm_runtime_resume_and_get(lvds->dev);
 	if (ret < 0) {
 		DRM_DEV_ERROR(lvds->dev, "failed to get pm runtime: %d\n", ret);
 		clk_disable(lvds->pclk);
@@ -336,16 +336,20 @@ static int px30_lvds_poweron(struct rockchip_lvds *lvds)
 {
 	int ret;
 
-	ret = pm_runtime_get_sync(lvds->dev);
+	ret = pm_runtime_resume_and_get(lvds->dev);
 	if (ret < 0) {
 		DRM_DEV_ERROR(lvds->dev, "failed to get pm runtime: %d\n", ret);
 		return ret;
 	}
 
 	/* Enable LVDS mode */
-	return regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1,
+	ret = regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1,
 				  PX30_LVDS_MODE_EN(1) | PX30_LVDS_P2S_EN(1),
 				  PX30_LVDS_MODE_EN(1) | PX30_LVDS_P2S_EN(1));
+	if (ret)
+		pm_runtime_put(lvds->dev);
+
+	return ret;
 }
 
 static void px30_lvds_poweroff(struct rockchip_lvds *lvds)
-- 
2.25.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: (subset) [PATCH -next 0/2] fix PM usage counter unbalance
  2022-09-22 13:21 [PATCH -next 0/2] fix PM usage counter unbalance Zhang Qilong
  2022-09-22 13:21 ` [PATCH -next 1/2] drm/rockchip: vop: fix PM usage counter unbalance in vop ops Zhang Qilong
  2022-09-22 13:21 ` [PATCH -next 2/2] drm/rockchip: fix PM usage counter unbalance in poweron Zhang Qilong
@ 2022-10-29 22:08 ` Heiko Stuebner
  2 siblings, 0 replies; 4+ messages in thread
From: Heiko Stuebner @ 2022-10-29 22:08 UTC (permalink / raw)
  To: daniel, linux-rockchip, airlied, Zhang Qilong, dri-devel, hjc
  Cc: Heiko Stuebner

On Thu, 22 Sep 2022 21:21:05 +0800, Zhang Qilong wrote:
> pm_runtime_get_sync will increment pm usage counter even it failed.
> Forgetting to putting operation will result in reference leak here.
> We fix it by replacing it with the newest pm_runtime_resume_and_get
> to keep usage counter balanced.
> 
> Zhang Qilong (2):
>   drm/rockchip: vop: fix PM usage counter unbalance in vop ops
>   drm/rockchip: fix PM usage counter unbalance in poweron
> 
> [...]

Applied, thanks!

[2/2] drm/rockchip: fix PM usage counter unbalance in poweron
      commit: 4dba27f1a14592ac4cf71c3bc1cc1fd05dea8015

I've ignored patch1 here, as your Huawei-collegue Yuan Can
did sent a different one that catches some more occurences.


Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2022-10-29 22:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 13:21 [PATCH -next 0/2] fix PM usage counter unbalance Zhang Qilong
2022-09-22 13:21 ` [PATCH -next 1/2] drm/rockchip: vop: fix PM usage counter unbalance in vop ops Zhang Qilong
2022-09-22 13:21 ` [PATCH -next 2/2] drm/rockchip: fix PM usage counter unbalance in poweron Zhang Qilong
2022-10-29 22:08 ` (subset) [PATCH -next 0/2] fix PM usage counter unbalance Heiko Stuebner

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