All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: fix issue by messing up runpm usage_counter
@ 2015-11-07  9:42 Karol Herbst
       [not found] ` <1446889328-2764-1-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Karol Herbst @ 2015-11-07  9:42 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

I have the issue when loading nouveau with runpm=0 set, that further nouveau
loads without runpm set or runpm=1 don't put the card into sleep state.

This is caused by calling pm_runtime_get_sync in drm_device.unload when the
usage_counter isn't 0. pm_runtime_get_sync always increases the suage_counter
and so the usage_counter gets increased allthough runpm=0 is set, meaning
nouveau leaves the device with a +1 usage_counter after unload.

This patch fixes that allowing me to load nouveau later with runpm=1 so, that
the device is put into sleep state.

---
 drm/nouveau/nouveau_drm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drm/nouveau/nouveau_drm.c b/drm/nouveau/nouveau_drm.c
index 5b1746b..2aaf9fe 100644
--- a/drm/nouveau/nouveau_drm.c
+++ b/drm/nouveau/nouveau_drm.c
@@ -481,7 +481,8 @@ nouveau_drm_unload(struct drm_device *dev)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
 
-	pm_runtime_get_sync(dev->dev);
+	if (atomic_read(&dev->dev->power.usage_count) == 0)
+		pm_runtime_get_sync(dev->dev);
 	nouveau_fbcon_fini(dev);
 	nouveau_accel_fini(drm);
 	nouveau_hwmon_fini(dev);
-- 
2.6.3

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm: fix issue by messing up runpm usage_counter
       [not found] ` <1446889328-2764-1-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
@ 2015-11-07 15:25   ` Lukas Wunner
  0 siblings, 0 replies; 2+ messages in thread
From: Lukas Wunner @ 2015-11-07 15:25 UTC (permalink / raw)
  To: Karol Herbst; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi Karol,

On Sat, Nov 07, 2015 at 10:42:08AM +0100, Karol Herbst wrote:
> I have the issue when loading nouveau with runpm=0 set, that further nouveau
> loads without runpm set or runpm=1 don't put the card into sleep state.
> 
> This is caused by calling pm_runtime_get_sync in drm_device.unload when the
> usage_counter isn't 0. pm_runtime_get_sync always increases the suage_counter
> and so the usage_counter gets increased allthough runpm=0 is set, meaning
> nouveau leaves the device with a +1 usage_counter after unload.

Apparently the card needs to be turned on for some of the subsequent
functions to work, hence the pm_runtime_get_sync().

Rather than calling pm_runtime_get_sync() conditionally you need to
add
	pm_runtime_mark_last_busy(dev->dev);
	pm_runtime_put_autosuspend(dev->dev);
further down in the function (after whatever needs the card to be
powered up has finished) to avoid leaking the ref.

Best regards,

Lukas

> 
> This patch fixes that allowing me to load nouveau later with runpm=1 so, that
> the device is put into sleep state.
> 
> ---
>  drm/nouveau/nouveau_drm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drm/nouveau/nouveau_drm.c b/drm/nouveau/nouveau_drm.c
> index 5b1746b..2aaf9fe 100644
> --- a/drm/nouveau/nouveau_drm.c
> +++ b/drm/nouveau/nouveau_drm.c
> @@ -481,7 +481,8 @@ nouveau_drm_unload(struct drm_device *dev)
>  {
>  	struct nouveau_drm *drm = nouveau_drm(dev);
>  
> -	pm_runtime_get_sync(dev->dev);
> +	if (atomic_read(&dev->dev->power.usage_count) == 0)
> +		pm_runtime_get_sync(dev->dev);
>  	nouveau_fbcon_fini(dev);
>  	nouveau_accel_fini(drm);
>  	nouveau_hwmon_fini(dev);
> -- 
> 2.6.3
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-07 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-07  9:42 [PATCH] drm: fix issue by messing up runpm usage_counter Karol Herbst
     [not found] ` <1446889328-2764-1-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2015-11-07 15:25   ` Lukas Wunner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.