[Nouveau] [PATCH] drm: fix issue by messing up runpm usage_counter
Lukas Wunner
lukas at wunner.de
Sat Nov 7 07:25:22 PST 2015
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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
More information about the Nouveau
mailing list