drm/msm/adreno: fix runtime PM imbalance at unbind
Subsystems (5)
v2 cover drm/msm/adreno: fix runtime PM imbalance at unbind
As reported by Bjorn, we can end up with an unbalanced runtime PM disable count if unbind() is called before the DRM device is opened (e.g. if component bind fails due to the panel driver not having been loaded yet).
As runtime PM must currently stay disabled until the firmware has been loaded, fix this by making the runtime PM disable call at unbind() conditional.
The rest of the series fixes further imbalances in the load_gpu() error paths and removes a bogus pm_runtime_set_active() call. Included is also a related indentation cleanup.
Johan
Changes in v2
- fix the runtime PM imbalance in the gpu load error paths (new)
- drop the patch removing the pm_runtime_disable() from adreno_gpu_cleanup() as this function can currently still be called with runtime PM enabled if suspending the scheduler in adreno_system_suspend() at unbind fails
Johan Hovold (4):
drm/msm/adreno: fix runtime PM imbalance at unbind drm/msm/adreno: fix runtime PM imbalance at gpu load drm/msm/adreno: drop bogus pm_runtime_set_active() drm/msm/adreno: clean up component ops indentation
drivers/gpu/drm/msm/adreno/adreno_device.c | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/4 drm/msm/adreno: fix runtime PM imbalance at unbind
A recent commit moved enabling of runtime PM from adreno_gpu_init() to adreno_load_gpu() (called on first open()), which means that unbind() may now be called with runtime PM disabled in case the device was never opened in between.
Make sure to only forcibly suspend and disable runtime PM at unbind() in case runtime PM has been enabled to prevent a disable count imbalance.
This specifically avoids leaving runtime PM disabled when the device is later opened after a successful bind:
msm_dpu ae01000.display-controller: [drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13
--- drivers/gpu/drm/msm/adreno/adreno_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +2 -1
@@ -558,7 +558,8 @@ static void adreno_unbind(struct device *dev, struct device *master,struct msm_drm_private *priv =dev_get_drvdata (master);struct msm_gpu *gpu =dev_to_gpu (dev); -WARN_ON_ONCE (adreno_system_suspend (dev)); +if (pm_runtime_enabled (dev)) +WARN_ON_ONCE (adreno_system_suspend (dev)); gpu->funcs->destroy (gpu); priv->gpu_pdev =NULL ;
Signature · 1 line
2.39.2
PATCH v2 2/4 drm/msm/adreno: fix runtime PM imbalance at gpu load
In reply to Johan HovoldA 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).
--- drivers/gpu/drm/msm/adreno/adreno_device.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +12 -4
@@ -443,20 +443,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);
@@ -465,6 +466,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 int find_chipid (struct device *dev,struct adreno_rev *rev)
Signature · 1 line
2.39.2
PATCH v2 3/4 drm/msm/adreno: drop bogus pm_runtime_set_active()
In reply to Johan HovoldThe runtime PM status can only be updated while runtime PM is disabled.
Drop the bogus pm_runtime_set_active() call that was made after enabling runtime PM and which (incidentally but correctly) left the runtime PM status set to 'suspended'.
--- drivers/gpu/drm/msm/adreno/adreno_device.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +0 -3
@@ -438,9 +438,6 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)*/ pm_runtime_enable (&pdev->dev); -/* Make sure pm runtime is active and reset any previous errors */ -pm_runtime_set_active (&pdev->dev); - ret =pm_runtime_get_sync (&pdev->dev);if (ret <0 ) {pm_runtime_put_noidle (&pdev->dev);
Signature · 1 line
2.39.2
PATCH v2 4/4 drm/msm/adreno: clean up component ops indentation
In reply to Johan HovoldClean up the component ops initialisers which were indented one level too far.
--- drivers/gpu/drm/msm/adreno/adreno_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +2 -2
@@ -571,8 +571,8 @@ static void adreno_unbind(struct device *dev, struct device *master, }static const struct component_ops a3xx_ops = { - .bind = adreno_bind, - .unbind = adreno_unbind, + .bind = adreno_bind, + .unbind = adreno_unbind, };static void adreno_device_register_headless (void )
Signature · 1 line
2.39.2
Quoted 5 lines · Johan Hovold
As reported by Bjorn, we can end up with an unbalanced runtime PM disable count if
unbind()is called before the DRM device is opened (e.g. if component bind fails due to the panel driver not having been loaded yet).
Quoted 7 lines
As runtime PM must currently stay disabled until the firmware has been loaded, fix this by making the runtime PM disable call at
unbind()conditional.The rest of the series fixes further imbalances in the
load_gpu()error paths and removes a boguspm_runtime_set_active()call. Included is also a related indentation cleanup.
I noticed that Rob picked up the first patch below from v1 of this series. Any comments to the remaining three?
Johan
Quoted 17 lines
Changes in v2
- fix the runtime PM imbalance in the gpu load error paths (new)- drop the patch removing the
pm_runtime_disable()fromadreno_gpu_cleanup()as this function can currently still be called with runtime PM enabled if suspending the scheduler inadreno_system_suspend()at unbind failsJohan Hovold (4):
drm/msm/adreno: fix runtime PM imbalance at unbind drm/msm/adreno: fix runtime PM imbalance at gpu load drm/msm/adreno: drop boguspm_runtime_set_active()drm/msm/adreno: clean up component ops indentationdrivers/gpu/drm/msm/adreno/adreno_device.c | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-)