Commit 6eebd6bb authored by Chris Wilson's avatar Chris Wilson Committed by Dave Airlie

drm: Fix lack of CRTC disable for drm_crtc_helper_set_config(.fb=NULL)

Disabling the CRTC by setting its framebuffer to NULL, as used by
drm_framebuffer_cleanup(), was failing to pass the current framebuffer
to the crtc_func->disable callback. This is because of the dance within
drm_crtc_helper_set_config to pass the new_fb (NULL in this case) to the
drm_crtc_helper_set_mode with the currently attached fb as a parameter.
drm_crtc_helper_set_mode treats this as a no-op and the encoder is still
enabled. And so the current fb is forgotten before the call to
drm_helper_disable_unused_functions.

This patch treats disabling the CRTC as a simple special case rather
than adding further complexity into the configuration logic.

This fixes a pin-leak of the fb bo on Xserver close.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 2ed4d9d6
...@@ -456,6 +456,30 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, ...@@ -456,6 +456,30 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
EXPORT_SYMBOL(drm_crtc_helper_set_mode); EXPORT_SYMBOL(drm_crtc_helper_set_mode);
static int
drm_crtc_helper_disable(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct drm_connector *connector;
struct drm_encoder *encoder;
/* Decouple all encoders and their attached connectors from this crtc */
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc != crtc)
continue;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
if (connector->encoder != encoder)
continue;
connector->encoder = NULL;
}
}
drm_helper_disable_unused_functions(dev);
return 0;
}
/** /**
* drm_crtc_helper_set_config - set a new config from userspace * drm_crtc_helper_set_config - set a new config from userspace
* @crtc: CRTC to setup * @crtc: CRTC to setup
...@@ -510,8 +534,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -510,8 +534,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
(int)set->num_connectors, set->x, set->y); (int)set->num_connectors, set->x, set->y);
} else { } else {
DRM_DEBUG_KMS("[CRTC:%d] [NOFB]\n", set->crtc->base.id); DRM_DEBUG_KMS("[CRTC:%d] [NOFB]\n", set->crtc->base.id);
set->mode = NULL; return drm_crtc_helper_disable(set->crtc);
set->num_connectors = 0;
} }
dev = set->crtc->dev; dev = set->crtc->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment