Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 523872f6 authored by Lukas Wunner's avatar Lukas Wunner Committed by Daniel Vetter
Browse files

drm/nouveau: Turn off CRTCs on driver unload



nouveau leaks a runtime pm ref if at least one CRTC is enabled on
unload. The ref is taken by nouveau_crtc_set_config() and held as long
as a CRTC is in use.

nv04_display_destroy() should solve this by turning off all CRTCs, but

(1) nv50_display_destroy() doesn't do the same and

(2) it's broken since commit d6bf2f37 ("drm/nouveau: run mode_config
    destructor before destroying internal display state") because the
    crtc structs are torn down by drm_mode_config_cleanup() before being
    turned off. Also, there's no locking.

Move the code to turn off all CRTCs from nv04_display_destroy() to
nouveau_display_destroy() so that it's called for both nv04 and nv50
and before drm_mode_config_cleanup(). Use drm_crtc_force_disable_all()
helper to save on code and have proper locking.

Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/66daa161322444bbde05d83cb0210b90a66988a4.1465392124.git.lukas@wunner.de
parent 6a0d9528
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -125,18 +125,8 @@ nv04_display_destroy(struct drm_device *dev)
	struct nv04_display *disp = nv04_display(dev);
	struct nouveau_drm *drm = nouveau_drm(dev);
	struct nouveau_encoder *encoder;
	struct drm_crtc *crtc;
	struct nouveau_crtc *nv_crtc;

	/* Turn every CRTC off. */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
		struct drm_mode_set modeset = {
			.crtc = crtc,
		};

		drm_mode_set_config_internal(&modeset);
	}

	/* Restore state */
	list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.base.head)
		encoder->enc_restore(&encoder->base.base);
+1 −0
Original line number Diff line number Diff line
@@ -554,6 +554,7 @@ nouveau_display_destroy(struct drm_device *dev)
	nouveau_display_vblank_fini(dev);

	drm_kms_helper_poll_fini(dev);
	drm_crtc_force_disable_all(dev);
	drm_mode_config_cleanup(dev);

	if (disp->dtor)