Skip to contentSkip to conversation

drm/i915: Update atomic state when removing mst connector.

PATCH In review Maarten Lankhorst 2 participants 3 messages Jul 21, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Update atomic state when removing mst connector.

---
 drivers/gpu/drm/i915/intel_dp_mst.c | 44 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp_mst.c +43 -1
index edd8fa41e85e..fb4f2715c96f 100644
@@ -449,6 +449,48 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	return connector;
 }
 
+static void intel_dp_unbind_mst_connector(struct drm_device *dev,
+				  struct drm_connector *connector)
+{
+	struct drm_atomic_state *state;
+	struct drm_connector_state *conn_state;
+	struct drm_crtc *crtc = connector->state->crtc;
+	int ret;
+
+	if (!crtc)
+		return;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return;
+
+	state->acquire_ctx = dev->mode_config.acquire_ctx;
+
+	conn_state = drm_atomic_get_connector_state(state, connector);
+	ret = PTR_ERR_OR_ZERO(conn_state);
+	if (!ret)
+		ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
+
+	if (!ret)
+		ret = drm_atomic_add_affected_connectors(state, crtc);
+
+	if (!ret && !drm_atomic_connectors_for_crtc(state, crtc)) {
+		struct drm_crtc_state *crtc_state =
+			drm_atomic_get_existing_crtc_state(state, crtc);
+
+		crtc_state->active = false;
+		ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
+	}
+
+	if (!ret)
+		ret = drm_atomic_commit(state);
+
+	if (ret)
+		drm_atomic_state_free(state);
+
+	I915_STATE_WARN_ON(ret);
+}
+
 static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 					   struct drm_connector *connector)
 {
@@ -456,7 +498,7 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 	struct drm_device *dev = connector->dev;
 
 	drm_modeset_lock_all(dev);
-	drm_atomic_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	intel_dp_unbind_mst_connector(dev, connector);
 	drm_modeset_unlock_all(dev);
 
 	intel_connector->unregister(intel_connector);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 33 lines · Maarten Lankhorst
---
 drivers/gpu/drm/i915/intel_dp_mst.c | 44 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp_mst.c +20 -0
index edd8fa41e85e..fb4f2715c96f 100644
@@ -449,6 +449,48 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	return connector;
 }
 
+static void intel_dp_unbind_mst_connector(struct drm_device *dev,
+				  struct drm_connector *connector)
+{
+	struct drm_atomic_state *state;
+	struct drm_connector_state *conn_state;
+	struct drm_crtc *crtc = connector->state->crtc;
+	int ret;
+
+	if (!crtc)
+		return;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return;
+
+	state->acquire_ctx = dev->mode_config.acquire_ctx;
+
+	conn_state = drm_atomic_get_connector_state(state, connector);
+	ret = PTR_ERR_OR_ZERO(conn_state);
+	if (!ret)

drivers/gpu/drm/i915/intel_dp_mst.c static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · line 481

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +10 -0
+		ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
+
+	if (!ret)
+		ret = drm_atomic_add_affected_connectors(state, crtc);
+
+	if (!ret && !drm_atomic_connectors_for_crtc(state, crtc)) {
+		struct drm_crtc_state *crtc_state =
+			drm_atomic_get_existing_crtc_state(state, crtc);
+
+		crtc_state->active = false;

The connector will completely disappear, and we don't support cloning. Which means there's still going to be state check failures. I think we need a

		crtc_state->enable = false;

here, plus cleaning out the connector_state->crtc link. -Daniel

Quoted 31 lines
drivers/gpu/drm/i915/intel_dp_mst.c +13 -1
+		ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
+	}
+
+	if (!ret)
+		ret = drm_atomic_commit(state);
+
+	if (ret)
+		drm_atomic_state_free(state);
+
+	I915_STATE_WARN_ON(ret);
+}
+
 static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 					   struct drm_connector *connector)
 {
@@ -456,7 +498,7 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 	struct drm_device *dev = connector->dev;
 
 	drm_modeset_lock_all(dev);
-	drm_atomic_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	intel_dp_unbind_mst_connector(dev, connector);
 	drm_modeset_unlock_all(dev);
 
 	intel_connector->unregister(intel_connector);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Op 21-07-15 om 11:09 schreef Daniel Vetter:

Quoted 27 lines · Maarten Lankhorst
Quoted 26 lines
---
 drivers/gpu/drm/i915/intel_dp_mst.c | 44 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp_mst.c +13 -0
index edd8fa41e85e..fb4f2715c96f 100644
@@ -449,6 +449,48 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	return connector;
 }
 
+static void intel_dp_unbind_mst_connector(struct drm_device *dev,
+				  struct drm_connector *connector)
+{
+	struct drm_atomic_state *state;
+	struct drm_connector_state *conn_state;
+	struct drm_crtc *crtc = connector->state->crtc;
+	int ret;
+
+	if (!crtc)
+		return;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
Quoted 8 lines

drivers/gpu/drm/i915/intel_dp_mst.c static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · line 472

Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +8 -0
+		return;
+
+	state->acquire_ctx = dev->mode_config.acquire_ctx;
+
+	conn_state = drm_atomic_get_connector_state(state, connector);
+	ret = PTR_ERR_OR_ZERO(conn_state);
+	if (!ret)
+		ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);

^^

Quoted 11 lines

drivers/gpu/drm/i915/intel_dp_mst.c static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · line 481

Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +8 -0
+	if (!ret)
+		ret = drm_atomic_add_affected_connectors(state, crtc);
+
+	if (!ret && !drm_atomic_connectors_for_crtc(state, crtc)) {
+		struct drm_crtc_state *crtc_state =
+			drm_atomic_get_existing_crtc_state(state, crtc);
+
+		crtc_state->active = false;

The connector will completely disappear, and we don't support cloning. Which means there's still going to be state check failures. I think we need a

Quoted 1 line
		crtc_state->enable = false;

Done below.

Quoted 1 line

here, plus cleaning out the connector_state->crtc link.

Done above.

Quoted 3 lines

-Daniel

drivers/gpu/drm/i915/intel_dp_mst.c static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo · line 482

Quoted 1 line
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
+		ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);

^^
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx