disp: msm: use pm_runtime_resume_and_get instead of pm_runtime_get_sync

pm_runtime_get_sync increases the usage_count refcount immaterial of
success/failure of the call, leading to invalid refcount on failures.
Use pm_runtime_resume_and_get instead, which takes care of reducing the
refcount on failure cases before returning from the function.

Change-Id: Ib96050d5d7ecbd717e58b8a0dde2d03312444e15
Signed-off-by: Veera Sundaram Sankaran <quic_veeras@quicinc.com>
This commit is contained in:
Veera Sundaram Sankaran
2021-12-14 11:26:15 -08:00
parent e7c09f0092
commit 56862f8118
11 changed files with 75 additions and 46 deletions

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
*/ */
@@ -784,9 +785,9 @@ static int dp_power_init(struct dp_power *dp_power, bool flip)
goto err_gpio; goto err_gpio;
} }
rc = pm_runtime_get_sync(dp_power->drm_dev->dev); rc = pm_runtime_resume_and_get(dp_power->drm_dev->dev);
if (rc < 0) { if (rc < 0) {
DP_ERR("Power resource enable failed\n"); DP_ERR("failed to enable power resource %d\n", rc);
goto err_sde_power; goto err_sde_power;
} }

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
*/ */
@@ -1117,10 +1118,10 @@ static int dsi_ctrl_enable_supplies(struct dsi_ctrl *dsi_ctrl, bool enable)
int rc = 0; int rc = 0;
if (enable) { if (enable) {
rc = pm_runtime_get_sync(dsi_ctrl->drm_dev->dev); rc = pm_runtime_resume_and_get(dsi_ctrl->drm_dev->dev);
if (rc < 0) { if (rc < 0) {
DSI_CTRL_ERR(dsi_ctrl, DSI_CTRL_ERR(dsi_ctrl, "failed to enable power resource %d\n", rc);
"Power resource enable failed, rc=%d\n", rc); SDE_EVT32(rc, SDE_EVTLOG_ERROR);
goto error; goto error;
} }
@@ -3392,9 +3393,10 @@ int dsi_ctrl_transfer_prepare(struct dsi_ctrl *dsi_ctrl, u32 flags)
SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY, dsi_ctrl->cell_index, flags); SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY, dsi_ctrl->cell_index, flags);
/* Vote for clocks, gdsc, enable command engine, mask overflow */ /* Vote for clocks, gdsc, enable command engine, mask overflow */
rc = pm_runtime_get_sync(dsi_ctrl->drm_dev->dev); rc = pm_runtime_resume_and_get(dsi_ctrl->drm_dev->dev);
if (rc < 0) { if (rc < 0) {
DSI_CTRL_ERR(dsi_ctrl, "failed gdsc voting\n"); DSI_CTRL_ERR(dsi_ctrl, "failed to enable power resource %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR);
return rc; return rc;
} }

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
*/ */
@@ -5283,10 +5284,10 @@ int dsi_display_cont_splash_config(void *dsi_display)
return -EINVAL; return -EINVAL;
} }
rc = pm_runtime_get_sync(display->drm_dev->dev); rc = pm_runtime_resume_and_get(display->drm_dev->dev);
if (rc < 0) { if (rc < 0) {
DSI_ERR("failed to vote gdsc for continuous splash, rc=%d\n", DSI_ERR("failed to enable power resource %d\n", rc);
rc); SDE_EVT32(rc, SDE_EVTLOG_ERROR);
return rc; return rc;
} }

View File

@@ -1,4 +1,5 @@
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
@@ -858,9 +859,9 @@ static int msm_drm_device_init(struct platform_device *pdev,
pm_runtime_enable(dev); pm_runtime_enable(dev);
ret = pm_runtime_get_sync(dev); ret = pm_runtime_resume_and_get(dev);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "resource enable failed: %d\n", ret); dev_err(dev, "failed to enable power resource %d\n", ret);
goto pm_runtime_error; goto pm_runtime_error;
} }
@@ -943,7 +944,12 @@ static int msm_drm_component_init(struct device *dev)
drm_crtc_vblank_reset(crtc); drm_crtc_vblank_reset(crtc);
if (kms) { if (kms) {
pm_runtime_get_sync(dev); ret = pm_runtime_resume_and_get(dev);
if (ret < 0) {
dev_err(dev, "failed to enable power resource %d\n", ret);
goto fail;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
ret = msm_irq_install(ddev, platform_get_irq(pdev, 0)); ret = msm_irq_install(ddev, platform_get_irq(pdev, 0));
#else #else
@@ -1653,7 +1659,7 @@ int msm_ioctl_power_ctrl(struct drm_device *dev, void *data,
if (vote_req) { if (vote_req) {
if (power_ctrl->enable) if (power_ctrl->enable)
rc = pm_runtime_get_sync(dev->dev); rc = pm_runtime_resume_and_get(dev->dev);
else else
pm_runtime_put_sync(dev->dev); pm_runtime_put_sync(dev->dev);

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
*/ */
@@ -3481,7 +3482,7 @@ static void _sde_cp_notify_ad_event(struct drm_crtc *crtc_drm, void *arg)
} }
priv = kms->dev->dev_private; priv = kms->dev->dev_private;
ret = pm_runtime_get_sync(kms->dev->dev); ret = pm_runtime_resume_and_get(kms->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret); SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR); SDE_EVT32(ret, SDE_EVTLOG_ERROR);
@@ -3719,7 +3720,7 @@ static void _sde_cp_notify_hist_event(struct drm_crtc *crtc_drm, void *arg)
spin_unlock_irqrestore(&crtc->spin_lock, flags); spin_unlock_irqrestore(&crtc->spin_lock, flags);
DRM_DEBUG_DRIVER("cannot find histogram event node in crtc\n"); DRM_DEBUG_DRIVER("cannot find histogram event node in crtc\n");
/* unlock histogram */ /* unlock histogram */
ret = pm_runtime_get_sync(kms->dev->dev); ret = pm_runtime_resume_and_get(kms->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret); SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR); SDE_EVT32(ret, SDE_EVTLOG_ERROR);
@@ -3744,9 +3745,9 @@ static void _sde_cp_notify_hist_event(struct drm_crtc *crtc_drm, void *arg)
irq_idx, ret); irq_idx, ret);
spin_unlock_irqrestore(&node->state_lock, state_flags); spin_unlock_irqrestore(&node->state_lock, state_flags);
spin_unlock_irqrestore(&crtc->spin_lock, flags); spin_unlock_irqrestore(&crtc->spin_lock, flags);
ret = pm_runtime_get_sync(kms->dev->dev); ret = pm_runtime_resume_and_get(kms->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable power %d\n", ret); SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR); SDE_EVT32(ret, SDE_EVTLOG_ERROR);
return; return;
} }
@@ -3769,7 +3770,7 @@ static void _sde_cp_notify_hist_event(struct drm_crtc *crtc_drm, void *arg)
if (!crtc->hist_blob) if (!crtc->hist_blob)
return; return;
ret = pm_runtime_get_sync(kms->dev->dev); ret = pm_runtime_resume_and_get(kms->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret); SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR); SDE_EVT32(ret, SDE_EVTLOG_ERROR);

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
*/ */
@@ -436,7 +437,7 @@ void sde_core_irq_preinstall(struct sde_kms *sde_kms)
} }
if (!sde_in_trusted_vm(sde_kms)) { if (!sde_in_trusted_vm(sde_kms)) {
rc = pm_runtime_get_sync(sde_kms->dev->dev); rc = pm_runtime_resume_and_get(sde_kms->dev->dev);
if (rc < 0) { if (rc < 0) {
SDE_ERROR("failed to enable power resource %d\n", rc); SDE_ERROR("failed to enable power resource %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR); SDE_EVT32(rc, SDE_EVTLOG_ERROR);
@@ -489,7 +490,7 @@ void sde_core_irq_uninstall(struct sde_kms *sde_kms)
return; return;
} }
rc = pm_runtime_get_sync(sde_kms->dev->dev); rc = pm_runtime_resume_and_get(sde_kms->dev->dev);
if (rc < 0) { if (rc < 0) {
SDE_ERROR("failed to enable power resource %d\n", rc); SDE_ERROR("failed to enable power resource %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR); SDE_EVT32(rc, SDE_EVTLOG_ERROR);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2014-2021 The Linux Foundation. All rights reserved. * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
@@ -4226,9 +4226,12 @@ static int _sde_crtc_vblank_enable(
if (enable) { if (enable) {
int ret; int ret;
ret = pm_runtime_get_sync(crtc->dev->dev); ret = pm_runtime_resume_and_get(crtc->dev->dev);
if (ret < 0) if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR);
return ret; return ret;
}
mutex_lock(&sde_crtc->crtc_lock); mutex_lock(&sde_crtc->crtc_lock);
drm_for_each_encoder_mask(enc, crtc->dev, sde_crtc->cached_encoder_mask) { drm_for_each_encoder_mask(enc, crtc->dev, sde_crtc->cached_encoder_mask) {
@@ -6627,9 +6630,11 @@ static ssize_t _sde_crtc_misr_read(struct file *file,
if (!sde_kms) if (!sde_kms)
return -EINVAL; return -EINVAL;
rc = pm_runtime_get_sync(crtc->dev->dev); rc = pm_runtime_resume_and_get(crtc->dev->dev);
if (rc < 0) if (rc < 0) {
SDE_ERROR("failed to enable power resource %d\n", rc);
return rc; return rc;
}
sde_vm_lock(sde_kms); sde_vm_lock(sde_kms);
if (!sde_vm_owns_hw(sde_kms)) { if (!sde_vm_owns_hw(sde_kms)) {
@@ -7441,8 +7446,9 @@ static int _sde_crtc_event_enable(struct sde_kms *kms,
ret = 0; ret = 0;
if (crtc_drm->enabled) { if (crtc_drm->enabled) {
ret = pm_runtime_get_sync(crtc_drm->dev->dev); ret = pm_runtime_resume_and_get(crtc_drm->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR); SDE_EVT32(ret, SDE_EVTLOG_ERROR);
kfree(node); kfree(node);
return ret; return ret;
@@ -7509,7 +7515,7 @@ static int _sde_crtc_event_disable(struct sde_kms *kms,
kfree(node); kfree(node);
return 0; return 0;
} }
ret = pm_runtime_get_sync(crtc_drm->dev->dev); ret = pm_runtime_resume_and_get(crtc_drm->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret); SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR); SDE_EVT32(ret, SDE_EVTLOG_ERROR);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
@@ -1708,7 +1708,7 @@ static int _sde_encoder_resource_control_helper(struct drm_encoder *drm_enc,
if (enable) { if (enable) {
/* enable SDE core clks */ /* enable SDE core clks */
rc = pm_runtime_get_sync(drm_enc->dev->dev); rc = pm_runtime_resume_and_get(drm_enc->dev->dev);
if (rc < 0) { if (rc < 0) {
SDE_ERROR("failed to enable power resource %d\n", rc); SDE_ERROR("failed to enable power resource %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR); SDE_EVT32(rc, SDE_EVTLOG_ERROR);
@@ -4785,9 +4785,12 @@ static ssize_t _sde_encoder_misr_read(struct file *file,
} }
drm_enc = &sde_enc->base; drm_enc = &sde_enc->base;
rc = pm_runtime_get_sync(drm_enc->dev->dev); rc = pm_runtime_resume_and_get(drm_enc->dev->dev);
if (rc < 0) if (rc < 0) {
SDE_ERROR("failed to enable power resource %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR);
return rc; return rc;
}
sde_vm_lock(sde_kms); sde_vm_lock(sde_kms);
if (!sde_vm_owns_hw(sde_kms)) { if (!sde_vm_owns_hw(sde_kms)) {

View File

@@ -1,4 +1,5 @@
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
@@ -497,9 +498,10 @@ static int _sde_kms_sui_misr_ctrl(struct sde_kms *sde_kms,
int ret; int ret;
if (enable) { if (enable) {
ret = pm_runtime_get_sync(sde_kms->dev->dev); ret = pm_runtime_resume_and_get(sde_kms->dev->dev);
if (ret < 0) { if (ret < 0) {
SDE_ERROR("failed to enable resource, ret:%d\n", ret); SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR);
return ret; return ret;
} }
@@ -1160,7 +1162,7 @@ static void sde_kms_prepare_commit(struct msm_kms *kms,
priv = dev->dev_private; priv = dev->dev_private;
SDE_ATRACE_BEGIN("prepare_commit"); SDE_ATRACE_BEGIN("prepare_commit");
rc = pm_runtime_get_sync(sde_kms->dev->dev); rc = pm_runtime_resume_and_get(sde_kms->dev->dev);
if (rc < 0) { if (rc < 0) {
SDE_ERROR("failed to enable power resources %d\n", rc); SDE_ERROR("failed to enable power resources %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR); SDE_EVT32(rc, SDE_EVTLOG_ERROR);
@@ -4336,9 +4338,8 @@ static int sde_kms_pd_enable(struct generic_pm_domain *genpd)
SDE_DEBUG("\n"); SDE_DEBUG("\n");
rc = pm_runtime_get_sync(sde_kms->dev->dev); rc = pm_runtime_resume_and_get(sde_kms->dev->dev);
if (rc > 0) rc = (rc > 0) ? 0 : rc;
rc = 0;
SDE_EVT32(rc, genpd->device_count); SDE_EVT32(rc, genpd->device_count);
@@ -5065,7 +5066,12 @@ int sde_kms_vm_trusted_resource_init(struct sde_kms *sde_kms,
* fill-in vote for the continuous splash hanodff path, which will be * fill-in vote for the continuous splash hanodff path, which will be
* removed on the successful first commit. * removed on the successful first commit.
*/ */
pm_runtime_get_sync(sde_kms->dev->dev); ret = pm_runtime_resume_and_get(sde_kms->dev->dev);
if (ret < 0) {
SDE_ERROR("failed to enable power resource %d\n", ret);
SDE_EVT32(ret, SDE_EVTLOG_ERROR);
goto error;
}
return 0; return 0;

View File

@@ -1,4 +1,5 @@
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (C) 2014-2021 The Linux Foundation. All rights reserved. * Copyright (C) 2014-2021 The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
@@ -420,7 +421,7 @@ int sde_plane_danger_signal_ctrl(struct drm_plane *plane, bool enable)
if (!psde->is_rt_pipe) if (!psde->is_rt_pipe)
goto end; goto end;
rc = pm_runtime_get_sync(plane->dev->dev); rc = pm_runtime_resume_and_get(plane->dev->dev);
if (rc < 0) { if (rc < 0) {
SDE_ERROR("failed to enable power resource %d\n", rc); SDE_ERROR("failed to enable power resource %d\n", rc);
SDE_EVT32(rc, SDE_EVTLOG_ERROR); SDE_EVT32(rc, SDE_EVTLOG_ERROR);

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2009-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved.
*/ */
@@ -1160,9 +1161,9 @@ static void _sde_dump_array(bool do_panic, const char *name, bool dump_secure, u
sde_evtlog_dump_all(dbg_base->evtlog); sde_evtlog_dump_all(dbg_base->evtlog);
if (!skip_power) { if (!skip_power) {
rc = pm_runtime_get_sync(dbg_base->dev); rc = pm_runtime_resume_and_get(dbg_base->dev);
if (rc < 0) { if (rc < 0) {
pr_err("failed to enable power %d\n", rc); pr_err("failed to enable power resource %d\n", rc);
return; return;
} }
} }
@@ -2099,9 +2100,9 @@ static ssize_t sde_dbg_reg_base_reg_write(struct file *file,
} }
} }
rc = pm_runtime_get_sync(sde_dbg_base.dev); rc = pm_runtime_resume_and_get(sde_dbg_base.dev);
if (rc < 0) { if (rc < 0) {
pr_err("failed to enable power %d\n", rc); pr_err("failed to enable power resource %d\n", rc);
count = rc; count = rc;
goto end; goto end;
} }
@@ -2174,9 +2175,9 @@ static ssize_t sde_dbg_reg_base_reg_read(struct file *file,
ptr = dbg->base + dbg->off; ptr = dbg->base + dbg->off;
tot = 0; tot = 0;
rc = pm_runtime_get_sync(sde_dbg_base.dev); rc = pm_runtime_resume_and_get(sde_dbg_base.dev);
if (rc < 0) { if (rc < 0) {
pr_err("failed to enable power %d\n", rc); pr_err("failed to enable power resource %d\n", rc);
len = rc; len = rc;
goto end; goto end;
} }