Browse Source

drm/atomic: clear plane's CRTC and FB when shutting down

Otherwise we'd still end up w/ the plane attached to the CRTC, and
seemingly active, but without an FB.  Which ends up going *boom*
in the drivers.

Slightly modified version of Daniel's irc suggestion.

Note that the big problem isn't drivers going *boom* here (since we
already have the situation of planes being left enabled when the crtc
goes down). The real issue is that the core assumes the primary plane
always goes down when calling ->set_config with a NULL mode. Ignoring
that assumption leads to the legacy state pointers plane->fb/crtc
getting out of sync with atomic, and that then leads to the subsequent
*boom* all over the place.

CC: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Rob Clark <robdclark@gmail.com>
[danvet: Drop my opinion of what's going sidewides here into the
commit message as a note.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Rob Clark 11 years ago
parent
commit
e5b5341c28
1 changed files with 13 additions and 6 deletions
  1. 13 6
      drivers/gpu/drm/drm_atomic_helper.c

+ 13 - 6
drivers/gpu/drm/drm_atomic_helper.c

@@ -1452,11 +1452,24 @@ retry:
 		goto fail;
 		goto fail;
 	}
 	}
 
 
+	primary_state = drm_atomic_get_plane_state(state, crtc->primary);
+	if (IS_ERR(primary_state)) {
+		ret = PTR_ERR(primary_state);
+		goto fail;
+	}
+
 	if (!set->mode) {
 	if (!set->mode) {
 		WARN_ON(set->fb);
 		WARN_ON(set->fb);
 		WARN_ON(set->num_connectors);
 		WARN_ON(set->num_connectors);
 
 
 		crtc_state->enable = false;
 		crtc_state->enable = false;
+
+		ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, NULL);
+		if (ret != 0)
+			goto fail;
+
+		drm_atomic_set_fb_for_plane(primary_state, NULL);
+
 		goto commit;
 		goto commit;
 	}
 	}
 
 
@@ -1466,12 +1479,6 @@ retry:
 	crtc_state->enable = true;
 	crtc_state->enable = true;
 	drm_mode_copy(&crtc_state->mode, set->mode);
 	drm_mode_copy(&crtc_state->mode, set->mode);
 
 
-	primary_state = drm_atomic_get_plane_state(state, crtc->primary);
-	if (IS_ERR(primary_state)) {
-		ret = PTR_ERR(primary_state);
-		goto fail;
-	}
-
 	ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc);
 	ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc);
 	if (ret != 0)
 	if (ret != 0)
 		goto fail;
 		goto fail;