drm/msm: Fix double pm_runtime_disable() call
Subsystems (4)
PATCH 1/1 drm/msm: Fix double pm_runtime_disable() call
Following commit 17e822f7591f ("drm/msm: fix unbalanced pm_runtime_enable in adreno_gpu_{init, cleanup}"), any call to adreno_unbind() will disable runtime PM twice, as indicated by the call trees below:
adreno_unbind()
-> pm_runtime_force_suspend()
-> pm_runtime_disable()
adreno_unbind()
-> gpu->funcs->destroy() [= aNxx_destroy()]
-> adreno_gpu_cleanup()
-> pm_runtime_disable()
Note that pm_runtime_force_suspend() is called right before gpu->funcs->destroy() and both functions are called unconditionally.
With recent addition of the eDP AUX bus code, this problem manifests itself when the eDP panel cannot be found yet and probing is deferred. On the first probe attempt, we disable runtime PM twice as described above. This then causes any later probe attempt to fail with
[drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13
preventing the driver from loading.
As there seem to be scenarios where the aNxx_destroy() functions are not called from adreno_unbind(), simply removing pm_runtime_disable() from inside adreno_unbind() does not seem to be the proper fix. This is what commit 17e822f7591f ("drm/msm: fix unbalanced pm_runtime_enable in adreno_gpu_{init, cleanup}") intended to fix. Therefore, instead check whether runtime PM is still enabled, and only disable it in that case.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +2 -1
@@ -1057,7 +1057,8 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)for (i =0 ; i <ARRAY_SIZE (adreno_gpu->info->fw); i++)release_firmware (adreno_gpu->fw[i]); -pm_runtime_disable (&priv->gpu_pdev->dev); +if (pm_runtime_enabled (&priv->gpu_pdev->dev)) +pm_runtime_disable (&priv->gpu_pdev->dev);msm_gpu_cleanup (&adreno_gpu->base); }
Signature · 1 line
2.36.1
Quoted 26 lines · Maximilian Luz
Following commit
17e822f7591f("drm/msm: fix unbalancedpm_runtime_enablein adreno_gpu_{init, cleanup}"), any call toadreno_unbind()will disable runtime PM twice, as indicated by the call trees below:
adreno_unbind()
->pm_runtime_force_suspend()
->pm_runtime_disable()
adreno_unbind()
->gpu->funcs->destroy()[=aNxx_destroy()]
->adreno_gpu_cleanup()
->pm_runtime_disable()Note that
pm_runtime_force_suspend()is called right beforegpu->funcs->destroy()and both functions are called unconditionally.With recent addition of the eDP AUX bus code, this problem manifests itself when the eDP panel cannot be found yet and probing is deferred. On the first probe attempt, we disable runtime PM twice as described above. This then causes any later probe attempt to fail with
[drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13
preventing the driver from loading.
Quoted 8 lines
As there seem to be scenarios where the
aNxx_destroy()functions are not called fromadreno_unbind(), simply removingpm_runtime_disable()from insideadreno_unbind()does not seem to be the proper fix. This is what commit17e822f7591f("drm/msm: fix unbalancedpm_runtime_enablein adreno_gpu_{init, cleanup}") intended to fix. Therefore, instead check whether runtime PM is still enabled, and only disable it in that case.Fixes 17e822f7591f ("drm/msm: fix unbalanced pm_runtime_enable in adreno_gpu_{init, cleanup}")
Quoted 22 lines
Signed-off-by Maximilian Luz <[email protected]>--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/adreno_gpu.c +2
-1@@ -1057,7 +1057,8 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)for (i =0 ; i <ARRAY_SIZE (adreno_gpu->info->fw); i++)release_firmware (adreno_gpu->fw[i]); -pm_runtime_disable (&priv->gpu_pdev->dev); +if (pm_runtime_enabled (&priv->gpu_pdev->dev)) +pm_runtime_disable (&priv->gpu_pdev->dev);msm_gpu_cleanup (&adreno_gpu->base); }Signature · 1 line
2.36.1
Quoted 34 lines · Maximilian Luz
Following commit
17e822f7591f("drm/msm: fix unbalancedpm_runtime_enablein adreno_gpu_{init, cleanup}"), any call toadreno_unbind()will disable runtime PM twice, as indicated by the call trees below:
adreno_unbind()
->pm_runtime_force_suspend()
->pm_runtime_disable()
adreno_unbind()
->gpu->funcs->destroy()[=aNxx_destroy()]
->adreno_gpu_cleanup()
->pm_runtime_disable()Note that
pm_runtime_force_suspend()is called right beforegpu->funcs->destroy()and both functions are called unconditionally.With recent addition of the eDP AUX bus code, this problem manifests itself when the eDP panel cannot be found yet and probing is deferred. On the first probe attempt, we disable runtime PM twice as described above. This then causes any later probe attempt to fail with
[drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13
preventing the driver from loading.
As there seem to be scenarios where the
aNxx_destroy()functions are not called fromadreno_unbind(), simply removingpm_runtime_disable()from insideadreno_unbind()does not seem to be the proper fix. This is what commit17e822f7591f("drm/msm: fix unbalancedpm_runtime_enablein adreno_gpu_{init, cleanup}") intended to fix. Therefore, instead check whether runtime PM is still enabled, and only disable it in that case.
Quoted 2 lines
Fixes 17e822f7591f ("drm/msm: fix unbalanced pm_runtime_enable in adreno_gpu_{init, cleanup}")Signed-off-by Maximilian Luz <[email protected]>
Quoted 21 lines
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/msm/adreno/adreno_gpu.c +2
-2@@ -1057,7 +1057,8 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)for (i =0 ; i <ARRAY_SIZE (adreno_gpu->info->fw); i++)release_firmware (adreno_gpu->fw[i]); -pm_runtime_disable (&priv->gpu_pdev->dev); +if (pm_runtime_enabled (&priv->gpu_pdev->dev)) +pm_runtime_disable (&priv->gpu_pdev->dev);msm_gpu_cleanup (&adreno_gpu->base); } --2.36.1