drm/nouveau/kms: A bunch of runtime_pm fixes
Subsystems (4)
cover drm/nouveau/kms: A bunch of runtime_pm fixes
While working on refactoring how we handle connector hotplugging/probing
+ a bunch of misc DP stuff, I found a bunch of runtime_pm errors that were mostly introduced by me at one point. Oops. A lot of these aren't triggered consistently on a lot of systems, so it's not terribly surprising these got swept under the rug.
Lyude Paul (9):
drm/nouveau/kms: Handle -EINPROGRESS in nouveau_connector_hotplug() drm/nouveau/kms: Fix rpm leak in nouveau_connector_hotplug() drm/nouveau/kms/fbcon: Correct pm_runtime calls in
nouveau_fbcon_release()
drm/nouveau/kms/fbcon: Fix pm_runtime calls in
nouveau_fbcon_output_poll_changed()
drm/nouveau/kms/fbcon: Use pm_runtime_put_autosuspend() in suspend
work
drm/nouveau/kms: Use pm_runtime_put_autosuspend() in hpd_work drm/nouveau/kms: Invert conditionals in nouveau_display_acpi_ntfy() drm/nouveau/kms: Fix runtime PM leak in nouveau_display_acpi_ntfy() drm/nouveau/kms: Handle -EINPROGRESS in nouveau_display_acpi_ntfy()
drivers/gpu/drm/nouveau/nouveau_connector.c | 5 +- drivers/gpu/drm/nouveau/nouveau_display.c | 52 ++++++++++----------- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 18 ++++--- 3 files changed, 41 insertions(+), 34 deletions(-)
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 1/9 drm/nouveau/kms: Handle -EINPROGRESS in nouveau_connector_hotplug()
Looks like that we forgot to handle -EINPROGRESS being returned by pm_runtime_get(), which can happen if multiple callers try to asynchronously resume the GPU before it wakes up. This is perfectly normal and OK, so fix this by treating -EINPROGRESS as success.
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
@@ -1173,7 +1173,7 @@ nouveau_connector_hotplug(struct nvif_notify *notify) } ret =pm_runtime_get (drm->dev->dev); -if (ret ==0 ) { +if (ret ==0 || ret == -EINPROGRESS ) {/* We can't block here if there's a pending PM request * running, as we'll deadlock nouveau_display_fini() when it * calls nvif_put() on our nvif_notify struct. So, simply
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 2/9 drm/nouveau/kms: Fix rpm leak in nouveau_connector_hotplug()
In reply to Lyude PaulFound another one, we forget to drop the runtime PM reference we grab here in the event of a failure. So, do that.
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +3 -0
@@ -1188,6 +1188,9 @@ nouveau_connector_hotplug(struct nvif_notify *notify) }else if (ret !=1 && ret != -EACCES ) {NV_WARN (drm,"HPD on %s dropped due to RPM failure: %d\n" , name, ret); + +pm_runtime_mark_last_busy (drm->dev->dev); +pm_runtime_put_autosuspend (drm->dev->dev);return NVIF_NOTIFY_DROP ; }
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 3/9 drm/nouveau/kms/fbcon: Correct pm_runtime calls in nouveau_fbcon_release()
In reply to Lyude PaulWe want to update the last busy timer for our device and use pm_runtime_put_autosuspend() here instead so that our GPU can autosuspend when we're done.
--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +5 -2
@@ -200,8 +200,11 @@ static int nouveau_fbcon_release(struct fb_info *info, int user) {struct nouveau_fbdev *fbcon = info->par; -struct nouveau_drm *drm =nouveau_drm (fbcon->helper.dev); -pm_runtime_put (drm->dev->dev); +struct drm_device *dev = fbcon->helper.dev; + +pm_runtime_mark_last_busy (dev->dev); +pm_runtime_put_autosuspend (dev->dev); +return 0 ; }
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 4/9 drm/nouveau/kms/fbcon: Fix pm_runtime calls in nouveau_fbcon_output_poll_changed()
In reply to Lyude PaulNoticed two problems here:
* We're not dropping our runtime PM refs after getting an error
* We're not backing off when pm_runtime_get() indicates that there's already a resume in progress (-EINPROGRESS) (after which any delayed fbcon events will get handled anyway)
So, let's fix those.
--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +5 -4
@@ -503,10 +503,7 @@ nouveau_fbcon_output_poll_changed(struct drm_device *dev) ret =pm_runtime_get (dev->dev);if (ret ==1 || ret == -EACCES ) {drm_fb_helper_hotplug_event (&fbcon->helper); - -pm_runtime_mark_last_busy (dev->dev); -pm_runtime_put_autosuspend (dev->dev); - }else if (ret ==0 ) { + }else if (ret ==0 || ret == -EINPROGRESS ) {/* If the GPU was already in the process of suspending before * this event happened, then we can't block here as we'll * deadlock the runtime pmops since they wait for us to
@@ -516,11 +513,15 @@ nouveau_fbcon_output_poll_changed(struct drm_device *dev)NV_DEBUG (drm,"fbcon HPD event deferred until runtime resume\n" ); fbcon->hotplug_waiting = true;pm_runtime_put_noidle (drm->dev->dev); + goto out; }else {DRM_WARN ("fbcon HPD event lost due to RPM failure: %d\n" , ret); } +pm_runtime_mark_last_busy (dev->dev); +pm_runtime_put_autosuspend (dev->dev); +out:mutex_unlock (&fbcon->hotplug_lock); }
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 5/9 drm/nouveau/kms/fbcon: Use pm_runtime_put_autosuspend() in suspend work
In reply to Lyude PaulWhile I don't know of any problems this has caused, it's definitely not a great idea for us to potentially block in nouveau_fbcon_set_suspend_work(). We don't really need to anyway, and want to simply trigger the autosuspend timer instead.
--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -468,7 +468,7 @@ nouveau_fbcon_set_suspend_work(struct work_struct *work)if (state ==FBINFO_STATE_RUNNING ) {nouveau_fbcon_hotplug_resume (drm->fbcon);pm_runtime_mark_last_busy (drm->dev->dev); -pm_runtime_put_sync (drm->dev->dev); +pm_runtime_put_autosuspend (drm->dev->dev); } }
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 6/9 drm/nouveau/kms: Use pm_runtime_put_autosuspend() in hpd_work
In reply to Lyude PaulAgain, we don't have any need to suspend the device synchronously here, and doing so could in theory lead to a deadlock (although it's unlikely since we've called pm_runtime_mark_last_busy() before-hand).
--- drivers/gpu/drm/nouveau/nouveau_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_display.c +1 -1
@@ -444,7 +444,7 @@ nouveau_display_hpd_work(struct work_struct *work)drm_helper_hpd_irq_event (drm->dev);pm_runtime_mark_last_busy (drm->dev->dev); -pm_runtime_put_sync (drm->dev->dev); +pm_runtime_put_autosuspend (drm->dev->dev); }#ifdef CONFIG_ACPI
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 7/9 drm/nouveau/kms: Invert conditionals in nouveau_display_acpi_ntfy()
In reply to Lyude PaulNo functional changes here, just a drive-by cleanup.
--- drivers/gpu/drm/nouveau/nouveau_display.c | 50 +++++++++++------------ 1 file changed, 24 insertions(+), 26 deletions(-)
drivers/gpu/drm/nouveau/nouveau_display.c +24 -26
@@ -457,34 +457,32 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,struct acpi_bus_event *info = data;int ret; -if (!strcmp (info->device_class,ACPI_VIDEO_CLASS )) { -if (info->type ==ACPI_VIDEO_NOTIFY_PROBE ) { - ret =pm_runtime_get (drm->dev->dev); -if (ret ==1 || ret == -EACCES ) { -/* If the GPU is already awake, or in a state -* where we can't wake it up, it can handle -* it's own hotplug events. -*/ -pm_runtime_put_autosuspend (drm->dev->dev); - }else if (ret ==0 ) { -/* This may be the only indication we receive -* of a connector hotplug on a runtime -* suspended GPU, schedule hpd_work to check. -*/ -NV_DEBUG (drm,"ACPI requested connector reprobe\n" ); -schedule_work (&drm->hpd_work); -pm_runtime_put_noidle (drm->dev->dev); - }else { -NV_WARN (drm,"Dropped ACPI reprobe event due to RPM error: %d\n" , - ret); - } - -/* acpi-video should not generate keypresses for this */ -return NOTIFY_BAD ; - } +if (strcmp (info->device_class,ACPI_VIDEO_CLASS ) || + info->type !=ACPI_VIDEO_NOTIFY_PROBE ) +return NOTIFY_DONE ; + + ret =pm_runtime_get (drm->dev->dev); +if (ret ==1 || ret == -EACCES ) { +/* If the GPU is already awake, or in a state +* where we can't wake it up, it can handle +* it's own hotplug events. +*/ +pm_runtime_put_autosuspend (drm->dev->dev); + }else if (ret ==0 ) { +/* This may be the only indication we receive +* of a connector hotplug on a runtime +* suspended GPU, schedule hpd_work to check. +*/ +NV_DEBUG (drm,"ACPI requested connector reprobe\n" ); +schedule_work (&drm->hpd_work); +pm_runtime_put_noidle (drm->dev->dev); + }else { +NV_WARN (drm,"Dropped ACPI reprobe event due to RPM error: %d\n" , + ret); } - return NOTIFY_DONE; +/* acpi-video should not generate keypresses for this */ + return NOTIFY_BAD; }#endif
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 8/9 drm/nouveau/kms: Fix runtime PM leak in nouveau_display_acpi_ntfy()
In reply to Lyude Paul--- drivers/gpu/drm/nouveau/nouveau_display.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nouveau_display.c +2 -0
@@ -479,6 +479,8 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val, }else {NV_WARN (drm,"Dropped ACPI reprobe event due to RPM error: %d\n" , ret); +pm_runtime_mark_last_busy (drm->dev->dev); +pm_runtime_put_autosuspend (drm->dev->dev); }/* acpi-video should not generate keypresses for this */
Signature · 1 line
2.26.2
Lyude Paul
maintainerPATCH 9/9 drm/nouveau/kms: Handle -EINPROGRESS in nouveau_display_acpi_ntfy()
In reply to Lyude PaulThis isn't an error, this just means there's multiple asynchronous resume requests going at the same time. Treat it like a success.
--- drivers/gpu/drm/nouveau/nouveau_display.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_display.c +4 -4
@@ -462,10 +462,10 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; ret =pm_runtime_get (drm->dev->dev); -if (ret ==1 || ret == -EACCES ) { -/* If the GPU is already awake, or in a state -* where we can't wake it up, it can handle -* it's own hotplug events. +if (ret ==1 || ret == -EACCES || ret == -EINPROGRESS ) { +/* If the GPU is already awake, is waking up, or is in a state +* where we can't wake it up, it can handle its own hotplug +* events. */ pm_runtime_put_autosuspend (drm->dev->dev); }else if (ret ==0 ) {
Signature · 1 line
2.26.2