]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/msm/adreno: fix runtime PM imbalance at gpu load
authorJohan Hovold <johan+linaro@kernel.org>
Fri, 3 Mar 2023 16:48:05 +0000 (17:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2023 09:50:27 +0000 (11:50 +0200)
[ Upstream commit 0d997f95b70f98987ae031a89677c13e0e223670 ]

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: 4b18299b3365 ("drm/msm/adreno: Defer enabling runpm until hw_init()")
Cc: stable@vger.kernel.org # 6.0
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Patchwork: https://patchwork.freedesktop.org/patch/524971/
Link: https://lore.kernel.org/r/20230303164807.13124-3-johan+linaro@kernel.org
Signed-off-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/adreno/adreno_device.c

index afdfa9edbea3df64cc0c8adf1a5ba5577ec3f242..7c3d80e78fb8bd60845e1008f60f0adf582b96b0 100644 (file)
@@ -406,20 +406,21 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
 
        ret = pm_runtime_get_sync(&pdev->dev);
        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);
-               return NULL;
+               goto err_disable_rpm;
        }
 
        mutex_lock(&gpu->lock);
        ret = msm_gpu_hw_init(gpu);
        mutex_unlock(&gpu->lock);
-       pm_runtime_put_autosuspend(&pdev->dev);
        if (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
        if (gpu->funcs->debugfs_init) {
                gpu->funcs->debugfs_init(gpu, dev->primary);
@@ -428,6 +429,13 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
 #endif
 
        return gpu;
+
+err_put_rpm:
+       pm_runtime_put_sync(&pdev->dev);
+err_disable_rpm:
+       pm_runtime_disable(&pdev->dev);
+
+       return NULL;
 }
 
 static void set_gpu_pdev(struct drm_device *dev,