Skip to content

Commit

Permalink
drm/rockchip: lvds: fix PM usage counter unbalance in poweron
Browse files Browse the repository at this point in the history
[ Upstream commit 4dba27f ]

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: 34cc0aa ("drm/rockchip: Add support for Rockchip Soc LVDS")
Fixes: cca1705 ("drm/rockchip: lvds: Add PX30 support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220922132107.105419-3-zhangqilong3@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Zhang Qilong authored and gregkh committed Dec 31, 2022
1 parent 2734b3e commit 12a9b4c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/gpu/drm/rockchip/rockchip_lvds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 12a9b4c

Please sign in to comment.