Commit 0d997f95 authored by Johan Hovold's avatar Johan Hovold Committed by Rob Clark

drm/msm/adreno: fix runtime PM imbalance at gpu load

A recent commit moved enabling of runtime PM to GPU load time (first
open()) but failed to update the error paths so that runtime PM is
disabled if initialisation of the GPU fails. This would trigger a
warning about the unbalanced disable count on the next open() attempt.

Note that pm_runtime_put_noidle() is sufficient to balance the usage
count when pm_runtime_put_sync() fails (and is chosen over
pm_runtime_resume_and_get() for consistency reasons).

Fixes: 4b18299b ("drm/msm/adreno: Defer enabling runpm until hw_init()")
Cc: stable@vger.kernel.org      # 6.0
Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Patchwork: https://patchwork.freedesktop.org/patch/524971/
Link: https://lore.kernel.org/r/20230303164807.13124-3-johan+linaro@kernel.orgSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 8d260047
...@@ -443,20 +443,21 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) ...@@ -443,20 +443,21 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
ret = pm_runtime_get_sync(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) { if (ret < 0) {
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_noidle(&pdev->dev);
DRM_DEV_ERROR(dev->dev, "Couldn't power up the GPU: %d\n", ret); DRM_DEV_ERROR(dev->dev, "Couldn't power up the GPU: %d\n", ret);
return NULL; goto err_disable_rpm;
} }
mutex_lock(&gpu->lock); mutex_lock(&gpu->lock);
ret = msm_gpu_hw_init(gpu); ret = msm_gpu_hw_init(gpu);
mutex_unlock(&gpu->lock); mutex_unlock(&gpu->lock);
pm_runtime_put_autosuspend(&pdev->dev);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev->dev, "gpu hw init failed: %d\n", ret); DRM_DEV_ERROR(dev->dev, "gpu hw init failed: %d\n", ret);
return NULL; goto err_put_rpm;
} }
pm_runtime_put_autosuspend(&pdev->dev);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
if (gpu->funcs->debugfs_init) { if (gpu->funcs->debugfs_init) {
gpu->funcs->debugfs_init(gpu, dev->primary); gpu->funcs->debugfs_init(gpu, dev->primary);
...@@ -465,6 +466,13 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) ...@@ -465,6 +466,13 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
#endif #endif
return gpu; return gpu;
err_put_rpm:
pm_runtime_put_sync(&pdev->dev);
err_disable_rpm:
pm_runtime_disable(&pdev->dev);
return NULL;
} }
static int find_chipid(struct device *dev, struct adreno_rev *rev) static int find_chipid(struct device *dev, struct adreno_rev *rev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment