Skip to contentSkip to conversation

drm/dp/mst: Sideband message transaction to power up/down nodes

PATCH Superseded Dhinakaran Pandiyan 6 participants 23 messages Sep 6, 2017 – Sep 13, 2017

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

PATCH 1/2 drm/dp/mst: Sideband message transaction to power up/down nodes

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an ACK, we can be sure that a downstream sink has enough time to respond to a power up/down request.

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 73 +++++++++++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  2 +
 2 files changed, 75 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +73 -0
index 41b492f99955..a9f12708a046 100644
@@ -294,6 +294,12 @@ static void drm_dp_encode_sideband_req(struct drm_dp_sideband_msg_req_body *req,
 		memcpy(&buf[idx], req->u.i2c_write.bytes, req->u.i2c_write.num_bytes);
 		idx += req->u.i2c_write.num_bytes;
 		break;
+
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		buf[idx] = (req->u.port_num.port_number & 0xf) << 4;
+		idx++;
+		break;
 	}
 	raw->cur_len = idx;
 }
@@ -538,6 +544,22 @@ static bool drm_dp_sideband_parse_query_payload_ack(struct drm_dp_sideband_msg_r
 	return false;
 }
 
+
+static bool drm_dp_sideband_parse_power_updown_phy_ack(struct drm_dp_sideband_msg_rx *raw,
+						       struct drm_dp_sideband_msg_reply_body *repmsg)
+{
+	int idx = 1;
+
+	repmsg->u.port_number.port_number = (raw->msg[idx] >> 4) & 0xf;
+	idx++;
+	if (idx > raw->curlen) {
+		DRM_DEBUG_KMS("power up/down phy parse length fail %d %d\n",
+			      idx, raw->curlen);
+		return false;
+	}
+	return true;
+}
+
 static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw,
 					struct drm_dp_sideband_msg_reply_body *msg)
 {
@@ -567,6 +589,9 @@ static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw,
 		return drm_dp_sideband_parse_enum_path_resources_ack(raw, msg);
 	case DP_ALLOCATE_PAYLOAD:
 		return drm_dp_sideband_parse_allocate_payload_ack(raw, msg);
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		return drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);
 	default:
 		DRM_ERROR("Got unknown reply 0x%02x\n", msg->req_type);
 		return false;
@@ -693,6 +718,22 @@ static int build_allocate_payload(struct drm_dp_sideband_msg_tx *msg, int port_n
 	return 0;
 }
 
+static int build_power_updown_phy(struct drm_dp_sideband_msg_tx *msg,
+				  int port_num, bool power_up)
+{
+	struct drm_dp_sideband_msg_req_body req;
+
+	if (power_up)
+		req.req_type = DP_POWER_UP_PHY;
+	else
+		req.req_type = DP_POWER_DOWN_PHY;
+
+	req.u.port_num.port_number = port_num;
+	drm_dp_encode_sideband_req(&req, msg);
+	msg->path_msg = true;
+	return 0;
+}
+
 static int drm_dp_mst_assign_payload_id(struct drm_dp_mst_topology_mgr *mgr,
 					struct drm_dp_vcpi *vcpi)
 {
@@ -1724,6 +1765,38 @@ static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr,
 	return ret;
 }
 
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
+				 struct drm_dp_mst_port *port, bool power_up)
+{
+	struct drm_dp_sideband_msg_tx *txmsg;
+	int len, ret;
+
+	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+	if (!txmsg)
+		return -ENOMEM;
+
+	port = drm_dp_get_validated_port_ref(mgr, port);
+	if (!port)
+		return -EINVAL;
+
+	txmsg->dst = port->parent;
+	len = build_power_updown_phy(txmsg, port->port_num, power_up);
+	drm_dp_queue_down_tx(mgr, txmsg);
+
+	ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+	if (ret > 0) {
+		if (txmsg->reply.reply_type == 1)
+			ret = -EINVAL;
+		else
+			ret = 0;
+	}
+	kfree(txmsg);
+	drm_dp_put_port(port);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_dp_send_power_updown_phy);
+
 static int drm_dp_create_payload_step1(struct drm_dp_mst_topology_mgr *mgr,
 				       int id,
 				       struct drm_dp_payload *payload)
include/drm/drm_dp_mst_helper.h +2 -0
index d55abb75f29a..7f78d26a0766 100644
@@ -631,5 +631,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
 int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				     struct drm_dp_mst_topology_mgr *mgr,
 				     int slots);
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
+				 struct drm_dp_mst_port *port, bool power_up);
 
 #endif
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 drm/i915/mst: Use MST sideband message transaction for dpms

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +4 -2
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
 	}
 
 	val = I915_READ(DDI_BUF_CTL(port));
drivers/gpu/drm/i915/intel_dp_mst.c +4 -4
index 8e3aad0ea60b..81e63724e24b 100644
@@ -167,12 +167,11 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
 	intel_dp->active_mst_links--;
 
 	intel_mst->connector = NULL;
-	if (intel_dp->active_mst_links == 0) {
+	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.post_disable(&intel_dig_port->base,
 						  NULL, NULL);
-
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
-	}
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port,
+				     false);
 }
 
 static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
@@ -197,6 +196,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
 
 	DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
 	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.pre_enable(&intel_dig_port->base,
 						pipe_config, NULL);
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tested-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 5 lines · Dhinakaran Pandiyan

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

Quoted 8 lines
$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

In reply to Dhinakaran Pandiyan
Quoted 33 lines · Dhinakaran Pandiyan

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	}
 
 	val = I915_READ(DDI_BUF_CTL(port));
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
index 8e3aad0ea60b..81e63724e24b 100644
@@ -167,12 +167,11 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
 	intel_dp->active_mst_links--;
 

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_post_disable_dp(struct intel_encoder *encoder, · line 174

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +3 -4
 	intel_mst->connector = NULL;
-	if (intel_dp->active_mst_links == 0) {
+	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.post_disable(&intel_dig_port->base,
 						  NULL, NULL);
-
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
-	}
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port,
+				     false);

One thing that bothers me here is whether we'll start getting bogus link training requests during shutdown since we'll do the D3 only after the stream has been stopped. If you'll look at commit 7618138d8b40 ("drm/i915/ddi: Avoid long delays during system suspend / eDP disabling") Imre explicitly moved the D3 earlier for SST to avoid this.

Hmm. Actually by the time we call mst_post_disable() we should have deallocated the VC etc. so the current stream should be already terminated at that point. So I think we should be able to do the PHY_POWER_DOWN before we shut down the link, just like we do for SST.

Quoted 13 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
 }
 
 static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
@@ -197,6 +196,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
 
 	DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
 	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.pre_enable(&intel_dig_port->base,
 						pipe_config, NULL);
Signature · 1 line
2.11.0
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 71 lines · Ville Syrjälä
Quoted 33 lines · Dhinakaran Pandiyan

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	}
 
 	val = I915_READ(DDI_BUF_CTL(port));
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
index 8e3aad0ea60b..81e63724e24b 100644
@@ -167,12 +167,11 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
 	intel_dp->active_mst_links--;
 

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_post_disable_dp(struct intel_encoder *encoder, · line 174

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +3 -4
 	intel_mst->connector = NULL;
-	if (intel_dp->active_mst_links == 0) {
+	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.post_disable(&intel_dig_port->base,
 						  NULL, NULL);
-
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
-	}
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port,
+				     false);

One thing that bothers me here is whether we'll start getting bogus link training requests during shutdown since we'll do the D3 only after the stream has been stopped. If you'll look at commit 7618138d8b40 ("drm/i915/ddi: Avoid long delays during system suspend / eDP disabling") Imre explicitly moved the D3 earlier for SST to avoid this.

Quoted 4 lines

Hmm. Actually by the time we call mst_post_disable() we should have deallocated the VC etc. so the current stream should be already terminated at that point. So I think we should be able to do the PHY_POWER_DOWN before we shut down the link, just like we do for SST.

Might also be nice to add comments near all the D3 calls to document that the order we use is there to prevent the sink from complaining about link loss when we shut down the link. Otherwise someone might get tempted to reorder things as a cleanup or something.

Quoted 22 lines
Quoted 14 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
 }
 
 static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
@@ -197,6 +196,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
 
 	DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
 	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.pre_enable(&intel_dig_port->base,
 						pipe_config, NULL);
Signature · 1 line
2.11.0
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 64 lines · Ville Syrjälä
Quoted 63 lines · Ville Syrjälä
Quoted 33 lines · Dhinakaran Pandiyan

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

Quoted 19 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	}
 
 	val = I915_READ(DDI_BUF_CTL(port));
drivers/gpu/drm/i915/intel_dp_mst.c +2 -4
index 8e3aad0ea60b..81e63724e24b 100644
@@ -167,12 +167,11 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
 	intel_dp->active_mst_links--;
 
 	intel_mst->connector = NULL;
-	if (intel_dp->active_mst_links == 0) {
+	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.post_disable(&intel_dig_port->base,
 						  NULL, NULL);
-
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
-	}
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port,
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_post_disable_dp(struct intel_encoder *encoder, · line 174

Quoted 1 line
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
+				     false);

One thing that bothers me here is whether we'll start getting bogus link training requests during shutdown since we'll do the D3 only after the stream has been stopped. If you'll look at commit 7618138d8b40 ("drm/i915/ddi: Avoid long delays during system suspend / eDP disabling") Imre explicitly moved the D3 earlier for SST to avoid this.

Interesting, that patch makes a lot of sense.

Quoted 10 lines
Quoted 4 lines

Hmm. Actually by the time we call mst_post_disable() we should have deallocated the VC etc. so the current stream should be already terminated at that point. So I think we should be able to do the PHY_POWER_DOWN before we shut down the link, just like we do for SST.

Might also be nice to add comments near all the D3 calls to document that the order we use is there to prevent the sink from complaining about link loss when we shut down the link. Otherwise someone might get tempted to reorder things as a cleanup or something.

Sure.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
 }
 
 static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
@@ -197,6 +196,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
 
 	DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
Quoted 15 lines
Quoted 14 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
 	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.pre_enable(&intel_dig_port->base,
 						pipe_config, NULL);
Signature · 1 line
2.11.0
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

#6 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 39 lines · Dhinakaran
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Ville Syrjälä
Quoted 36 lines · Dhinakaran Pandiyan

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

Quoted 66 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	}
 
 	val = I915_READ(DDI_BUF_CTL(port));
drivers/gpu/drm/i915/intel_dp_mst.c +2 -4
index 8e3aad0ea60b..81e63724e24b 100644
@@ -167,12 +167,11 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
 	intel_dp->active_mst_links--;
 
 	intel_mst->connector = NULL;
-	if (intel_dp->active_mst_links == 0) {
+	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.post_disable(&intel_dig_port->base,
 						  NULL, NULL);
-
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
-	}
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port,
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_post_disable_dp(struct intel_encoder *encoder, · line 174

Quoted 1 line
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
+				     false);

One thing that bothers me here is whether we'll start getting bogus link training requests during shutdown since we'll do the D3 only after the stream has been stopped. If you'll look at commit 7618138d8b40 ("drm/i915/ddi: Avoid long delays during system suspend / eDP disabling") Imre explicitly moved the D3 earlier for SST to avoid this.

Interesting, that patch makes a lot of sense.

Quoted 10 lines
Quoted 4 lines

Hmm. Actually by the time we call mst_post_disable() we should have deallocated the VC etc. so the current stream should be already terminated at that point. So I think we should be able to do the PHY_POWER_DOWN before we shut down the link, just like we do for SST.

Might also be nice to add comments near all the D3 calls to document that the order we use is there to prevent the sink from complaining about link loss when we shut down the link. Otherwise someone might get tempted to reorder things as a cleanup or something.

Sure.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
 }
 
 static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
@@ -197,6 +196,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
 
 	DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
Quoted 15 lines
Quoted 14 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
 	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.pre_enable(&intel_dig_port->base,
 						pipe_config, NULL);
Signature · 1 line
2.11.0
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines

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

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

#7 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Op 12-09-17 om 22:11 schreef Pandiyan, Dhinakaran:

Quoted 51 lines · Dhinakaran
Quoted 39 lines · Ville Syrjälä
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

Quoted 7 lines

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

I think checking for NULL crtc_state is enough, in case we ever decide to pass the real connector state.
For clarity, I would add something like bool is_dsp_mst = !crtc_state; /* When enabling the link for MST, this connector is never bound to a crtc */.

Quoted 61 lines
Quoted 61 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	}
 
 	val = I915_READ(DDI_BUF_CTL(port));
drivers/gpu/drm/i915/intel_dp_mst.c +0 -0
index 8e3aad0ea60b..81e63724e24b 100644
@@ -167,12 +167,11 @@ static void intel_mst_post_disable_dp(struct intel_encoder *encoder,
 	intel_dp->active_mst_links--;
 
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1 -3
 	intel_mst->connector = NULL;
-	if (intel_dp->active_mst_links == 0) {
+	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.post_disable(&intel_dig_port->base,
 						  NULL, NULL);
-
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
Quoted 9 lines

drivers/gpu/drm/i915/intel_dp_mst.c static void intel_mst_post_disable_dp(struct intel_encoder *encoder, · line 174

Quoted 3 lines
drivers/gpu/drm/i915/intel_dp_mst.c +2 -1
-	}
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port,
+				     false);

One thing that bothers me here is whether we'll start getting bogus link training requests during shutdown since we'll do the D3 only after the stream has been stopped. If you'll look at commit 7618138d8b40 ("drm/i915/ddi: Avoid long delays during system suspend / eDP disabling") Imre explicitly moved the D3 earlier for SST to avoid this.

Interesting, that patch makes a lot of sense.

Quoted 9 lines
Quoted 4 lines

Hmm. Actually by the time we call mst_post_disable() we should have deallocated the VC etc. so the current stream should be already terminated at that point. So I think we should be able to do the PHY_POWER_DOWN before we shut down the link, just like we do for SST.

Might also be nice to add comments near all the D3 calls to document that the order we use is there to prevent the sink from complaining about link loss when we shut down the link. Otherwise someone might get tempted to reorder things as a cleanup or something.

Sure.

Quoted 20 lines
Quoted 20 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1 -0
 }
 
 static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
@@ -197,6 +196,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,
 
 	DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
+	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
 	if (intel_dp->active_mst_links == 0)
 		intel_dig_port->base.pre_enable(&intel_dig_port->base,
 						pipe_config, NULL);
Signature · 1 line
2.11.0
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines
Quoted 4 lines

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

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

#8 lore raw

Re: [Intel-gfx] [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 59 lines · Maarten Lankhorst

Op 12-09-17 om 22:11 schreef Pandiyan, Dhinakaran:

Quoted 51 lines · Dhinakaran
Quoted 39 lines · Ville Syrjälä
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

Quoted 7 lines

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

Quoted 2 lines

I think checking for NULL crtc_state is enough, in case we ever decide to pass the real connector state.
For clarity, I would add something like bool is_dsp_mst = !crtc_state; /* When enabling the link for MST, this connector is never bound to a crtc */.

The NULL state is rather ugly IMO. With a comment I might be able to stomach it. However, after another look I see that we already pass the crtc state to ddi_pre_enable() from the MST code, so even just from a symmetry POV it would make sense to pass it to ddi_post_disable as well.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [Intel-gfx] [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Op 13-09-17 om 12:37 schreef Ville Syrjälä:

Quoted 59 lines · Maarten Lankhorst
Quoted 58 lines

Op 12-09-17 om 22:11 schreef Pandiyan, Dhinakaran:

Quoted 57 lines · Dhinakaran
Quoted 39 lines · Ville Syrjälä
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

Quoted 7 lines
Quoted 2 lines

I think checking for NULL crtc_state is enough, in case we ever decide to pass the real connector state.
For clarity, I would add something like bool is_dsp_mst = !crtc_state; /* When enabling the link for MST, this connector is never bound to a crtc */.

The NULL state is rather ugly IMO. With a comment I might be able to stomach it. However, after another look I see that we already pass the crtc state to ddi_pre_enable() from the MST code, so even just from a symmetry POV it would make sense to pass it to ddi_post_disable as well.

It doesn't make sense to pass crtc_state, there's no guarantee that the crtc_state from the same crtc is passed into first MST enable, and last MST disable. To be sure we don't rely on it NULL was passed in, which is the only valid thing here.

~Maarten

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 62 lines · Maarten Lankhorst

Op 13-09-17 om 12:37 schreef Ville Syrjälä:

Quoted 61 lines · Maarten Lankhorst
Quoted 60 lines

Op 12-09-17 om 22:11 schreef Pandiyan, Dhinakaran:

Quoted 50 lines · Dhinakaran
Quoted 39 lines · Ville Syrjälä
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

Quoted 7 lines

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

I think checking for NULL crtc_state is enough, in case we ever decide to pass the real connector state.
For clarity, I would add something like bool is_dsp_mst = !crtc_state; /* When enabling the link for MST, this connector is never bound to a crtc */.

Quoted 7 lines
Quoted 5 lines

The NULL state is rather ugly IMO. With a comment I might be able to stomach it. However, after another look I see that we already pass the crtc state to ddi_pre_enable() from the MST code, so even just from a symmetry POV it would make sense to pass it to ddi_post_disable as well.

It doesn't make sense to pass crtc_state, there's no guarantee that the crtc_state from the same crtc is passed into first MST enable, and last MST disable.

Doesn't really matter. If they don't match sufficiently we've already messed up somewhere.

Ideally we should have some kind of separate state for the DP link, but since we don't atm we just abuse the crtc state to contain the link parameters.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Op 13-09-17 om 13:48 schreef Ville Syrjälä:

Quoted 67 lines · Maarten Lankhorst
Quoted 66 lines

Op 13-09-17 om 12:37 schreef Ville Syrjälä:

Quoted 65 lines · Maarten Lankhorst
Quoted 57 lines

Op 12-09-17 om 22:11 schreef Pandiyan, Dhinakaran:

Quoted 49 lines · Dhinakaran
Quoted 39 lines · Ville Syrjälä
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

Quoted 7 lines

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

Quoted 2 lines

I think checking for NULL crtc_state is enough, in case we ever decide to pass the real connector state.
For clarity, I would add something like bool is_dsp_mst = !crtc_state; /* When enabling the link for MST, this connector is never bound to a crtc */.

The NULL state is rather ugly IMO. With a comment I might be able to stomach it. However, after another look I see that we already pass the crtc state to ddi_pre_enable() from the MST code, so even just from a symmetry POV it would make sense to pass it to ddi_post_disable as well.

Quoted 8 lines
Quoted 2 lines

It doesn't make sense to pass crtc_state, there's no guarantee that the crtc_state from the same crtc is passed into first MST enable, and last MST disable.

Doesn't really matter. If they don't match sufficiently we've already messed up somewhere.

Ideally we should have some kind of separate state for the DP link, but since we don't atm we just abuse the crtc state to contain the link parameters.

Could we stuff it in the real DP's connector state, and then make sure we add the master connector state?

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

#12 lore raw

Re: [PATCH 2/2] drm/i915/mst: Use MST sideband message transaction for dpms

Quoted 70 lines · Maarten Lankhorst

Op 13-09-17 om 13:48 schreef Ville Syrjälä:

Quoted 69 lines · Maarten Lankhorst
Quoted 68 lines

Op 13-09-17 om 12:37 schreef Ville Syrjälä:

Quoted 58 lines · Maarten Lankhorst
Quoted 57 lines

Op 12-09-17 om 22:11 schreef Pandiyan, Dhinakaran:

Quoted 56 lines · Dhinakaran
Quoted 39 lines · Ville Syrjälä
Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines

Use the POWER_DOWN_PHY and POWER_UP_PHY sideband message trasactions to set power states for downstream sinks. Apart from giving us the ability to set power state for individual sinks, this fixes the below test for me

$ xrandr --display :0 --output DP-2-2-8 --off
$ xrandr --display :0 --output DP-2-2-1 --off
$ xrandr --display :0 --output DP-2-2-8 --auto #Black screen
$ xrandr --display :0 --output DP-2-2-1 --auto
---
 drivers/gpu/drm/i915/intel_ddi.c    | 6 ++++--
 drivers/gpu/drm/i915/intel_dp_mst.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +2 -1
index 1da3bb2cc4b4..8aebacc0aa31 100644
@@ -2161,7 +2161,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 		intel_prepare_dp_ddi_buffers(encoder);
 
 	intel_ddi_init_dp_buf_reg(encoder);
-	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
+	if (!link_mst)
+		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
 	intel_dp_start_link_train(intel_dp);
 	if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
 		intel_dp_stop_link_train(intel_dp);
@@ -2240,7 +2241,8 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder,
 	if (type == INTEL_OUTPUT_DP || type == INTEL_OUTPUT_EDP) {
 		struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_post_disable(struct intel_encoder *intel_encoder, · line 2245

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -1
-		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
+		if (old_crtc_state && old_conn_state)
+			intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);

I would make that
!intel_crtc_has_type(DP_MST)

old_crtc_state, which intel_crtc_has_type() needs, is NULL for MST and the reason Maarten provided in his commit is

" We also shouldn't pass crtc_state, because in that case the
disabling sequence may potentially be different depending on which crtc is disabled last. Nice way to introduce bugs.
"
I am not 100% sure I understand the concern. But since that change was intentional I guess we can use the NULL values, like I've done, to identify the mst sinks. I am open to ideas.

Quoted 7 lines
Quoted 2 lines

I think checking for NULL crtc_state is enough, in case we ever decide to pass the real connector state.
For clarity, I would add something like bool is_dsp_mst = !crtc_state; /* When enabling the link for MST, this connector is never bound to a crtc */.

The NULL state is rather ugly IMO. With a comment I might be able to stomach it. However, after another look I see that we already pass the crtc state to ddi_pre_enable() from the MST code, so even just from a symmetry POV it would make sense to pass it to ddi_post_disable as well.

It doesn't make sense to pass crtc_state, there's no guarantee that the crtc_state from the same crtc is passed into first MST enable, and last MST disable.

Quoted 8 lines
Quoted 6 lines

Doesn't really matter. If they don't match sufficiently we've already messed up somewhere.

Ideally we should have some kind of separate state for the DP link, but since we don't atm we just abuse the crtc state to contain the link parameters.

Could we stuff it in the real DP's connector state, and then make sure we add the master connector state?

Not sure we want a disabled connector to affect the entire thing. I was thinking that maybe we want some kind of encoder state thing. Not really sure.

At some point I did have the idea that maybe we could stick the main MST connector into the state, and actually use that to turn on the link, leaving the MST encoder hooks to only enable/disable the streams. But that would need careful ordering to make sure the main link gets enabled/disabled as needed. And it would probably hit the design issue in atomic that we'd end up leaking some of the main link state to user space. We'd also need some kind of fake crtc for the main link I suppose.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

✗ Fi.CI.BAT: warning for series starting with [1/2] drm/dp/mst: Sideband message transaction to power up/down nodes

In reply to Dhinakaran Pandiyan
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/dp/mst: Sideband message transaction to power up/down nodes
URL : https://patchwork.freedesktop.org/series/29853/
State : warning

== Summary ==

Series 29853v1 series starting with [1/2] drm/dp/mst: Sideband message transaction to power up/down nodes
https://patchwork.freedesktop.org/api/1.0/series/29853/revisions/1/mbox/

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215 +1
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                pass       -> SKIP       (fi-skl-x1585l) fdo#101781
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> SKIP       (fi-cfl-s)
Test drv_module_reload:
        Subgroup basic-reload-inject:
                dmesg-fail -> DMESG-WARN (fi-cfl-s) k.org#196765

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
k.org#196765 https://bugzilla.kernel.org/show_bug.cgi?id=196765

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:457s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:443s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:361s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:556s
fi-bwr-2160      total:289  pass:184  dwarn:0   dfail:0   fail:0   skip:105 time:255s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:521s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:519s
fi-byt-n2820     total:289  pass:250  dwarn:1   dfail:0   fail:0   skip:38  time:510s
fi-cfl-s         total:289  pass:249  dwarn:4   dfail:0   fail:0   skip:36  time:461s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:434s
fi-glk-2a        total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:610s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:457s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:424s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:428s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:500s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:473s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:517s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:598s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:601s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:533s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:474s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:529s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:512s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:440s
fi-skl-x1585l    total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:489s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:555s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:1   skip:39  time:409s

22fe7d7fe4c7a6e04c7f7f99d6b8985008616546 drm-tip: 2017y-09m-05d-19h-15m-06s UTC integration manifest f61f7362822c drm/i915/mst: Use MST sideband message transaction for dpms 4dd49840e139 drm/dp/mst: Sideband message transaction to power up/down nodes

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5589/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw
In reply to Dhinakaran Pandiyan
Quoted 123 lines · Dhinakaran Pandiyan

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow
the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the
MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an
ACK, we can be sure that a downstream sink has enough time to respond to a
power up/down request.

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 73
+++++++++++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  2 +
 2 files changed, 75 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
index 41b492f99955..a9f12708a046 100644
@@ -294,6 +294,12 @@ static void drm_dp_encode_sideband_req(struct
 drm_dp_sideband_msg_req_body *req,
 		memcpy(&buf[idx], req->u.i2c_write.bytes, req-
 >u.i2c_write.num_bytes);
 		idx += req->u.i2c_write.num_bytes;
 		break;
+
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		buf[idx] = (req->u.port_num.port_number & 0xf) << 4;
+		idx++;
+		break;
 	}
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	raw->cur_len = idx;
 }
@@ -538,6 +544,22 @@ static bool

drm_dp_sideband_parse_query_payload_ack(struct drm_dp_sideband_msg_r

drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
 	return false;
 }
 
+
+static bool drm_dp_sideband_parse_power_updown_phy_ack(struct

drm_dp_sideband_msg_rx *raw,

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
+						       struct

drm_dp_sideband_msg_reply_body *repmsg)

drivers/gpu/drm/drm_dp_mst_topology.c +4 -0
+{
+	int idx = 1;
+
+	repmsg->u.port_number.port_number = (raw->msg[idx] >> 4) &

0xf;

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+	idx++;
+	if (idx > raw->curlen) {
+		DRM_DEBUG_KMS("power up/down phy parse length fail

%d %d\n",

drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
+			      idx, raw->curlen);
+		return false;
+	}
+	return true;
+}
+
 static bool drm_dp_sideband_parse_reply(struct

drm_dp_sideband_msg_rx *raw,
struct
drm_dp_sideband_msg_reply_body *msg)
{

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
@@ -567,6 +589,9 @@ static bool drm_dp_sideband_parse_reply(struct
 drm_dp_sideband_msg_rx *raw,
 		return
 drm_dp_sideband_parse_enum_path_resources_ack(raw, msg);
 	case DP_ALLOCATE_PAYLOAD:
 		return
 drm_dp_sideband_parse_allocate_payload_ack(raw, msg);
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		return

drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	default:
 		DRM_ERROR("Got unknown reply 0x%02x\n", msg-
Quoted 1 line

req_type);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		return false;
@@ -693,6 +718,22 @@ static int build_allocate_payload(struct

drm_dp_sideband_msg_tx *msg, int port_n

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
 	return 0;
 }
 
+static int build_power_updown_phy(struct drm_dp_sideband_msg_tx

*msg,

drivers/gpu/drm/drm_dp_mst_topology.c +15 -0
+				  int port_num, bool power_up)
+{
+	struct drm_dp_sideband_msg_req_body req;
+
+	if (power_up)
+		req.req_type = DP_POWER_UP_PHY;
+	else
+		req.req_type = DP_POWER_DOWN_PHY;
+
+	req.u.port_num.port_number = port_num;
+	drm_dp_encode_sideband_req(&req, msg);
+	msg->path_msg = true;
+	return 0;
+}
+
 static int drm_dp_mst_assign_payload_id(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
 					struct drm_dp_vcpi *vcpi)
 {
@@ -1724,6 +1765,38 @@ static int drm_dp_payload_send_msg(struct
 drm_dp_mst_topology_mgr *mgr,
 	return ret;
 }
 
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr
 *mgr,
+				 struct drm_dp_mst_port *port, bool
 power_up)
+{

drivers/gpu/drm/drm_dp_mst_topology.c static int drm_dp_payload_send_msg(struct · line 1783

Quoted 10 lines
drivers/gpu/drm/drm_dp_mst_topology.c +10 -0
+	struct drm_dp_sideband_msg_tx *txmsg;
+	int len, ret;
+
+	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+	if (!txmsg)
+		return -ENOMEM;
+
+	port = drm_dp_get_validated_port_ref(mgr, port);
+	if (!port)
+		return -EINVAL;

if (!port), then you leak memory by not freeing txmsg

Quoted 41 lines
drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+
+	txmsg->dst = port->parent;
+	len = build_power_updown_phy(txmsg, port->port_num,

power_up);

drivers/gpu/drm/drm_dp_mst_topology.c +16 -0
+	drm_dp_queue_down_tx(mgr, txmsg);
+
+	ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+	if (ret > 0) {
+		if (txmsg->reply.reply_type == 1)
+			ret = -EINVAL;
+		else
+			ret = 0;
+	}
+	kfree(txmsg);
+	drm_dp_put_port(port);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_dp_send_power_updown_phy);
+
 static int drm_dp_create_payload_step1(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 				       int id,
 				       struct drm_dp_payload

*payload)

include/drm/drm_dp_mst_helper.h +1 -0
index d55abb75f29a..7f78d26a0766 100644
@@ -631,5 +631,7 @@ int drm_dp_atomic_find_vcpi_slots(struct
 drm_atomic_state *state,
 int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				     struct drm_dp_mst_topology_mgr
 *mgr,
 				     int slots);
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr

*mgr,

include/drm/drm_dp_mst_helper.h +1 -0
+				 struct drm_dp_mst_port *port, bool

power_up);

Quoted 1 line

#endif

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw
Quoted 119 lines · Lyude Paul
Quoted 118 lines · Dhinakaran Pandiyan

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow
the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the
MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an
ACK, we can be sure that a downstream sink has enough time to respond to a
power up/down request.

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 73
+++++++++++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  2 +
 2 files changed, 75 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
index 41b492f99955..a9f12708a046 100644
@@ -294,6 +294,12 @@ static void drm_dp_encode_sideband_req(struct
 drm_dp_sideband_msg_req_body *req,
 		memcpy(&buf[idx], req->u.i2c_write.bytes, req-
 >u.i2c_write.num_bytes);
 		idx += req->u.i2c_write.num_bytes;
 		break;
+
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		buf[idx] = (req->u.port_num.port_number & 0xf) << 4;
+		idx++;
+		break;
 	}
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	raw->cur_len = idx;
 }
@@ -538,6 +544,22 @@ static bool

drm_dp_sideband_parse_query_payload_ack(struct drm_dp_sideband_msg_r

drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
 	return false;
 }
 
+
+static bool drm_dp_sideband_parse_power_updown_phy_ack(struct

drm_dp_sideband_msg_rx *raw,

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
+						       struct

drm_dp_sideband_msg_reply_body *repmsg)

drivers/gpu/drm/drm_dp_mst_topology.c +4 -0
+{
+	int idx = 1;
+
+	repmsg->u.port_number.port_number = (raw->msg[idx] >> 4) &

0xf;

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+	idx++;
+	if (idx > raw->curlen) {
+		DRM_DEBUG_KMS("power up/down phy parse length fail

%d %d\n",

drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
+			      idx, raw->curlen);
+		return false;
+	}
+	return true;
+}
+
 static bool drm_dp_sideband_parse_reply(struct

drm_dp_sideband_msg_rx *raw,
struct
drm_dp_sideband_msg_reply_body *msg)
{

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
@@ -567,6 +589,9 @@ static bool drm_dp_sideband_parse_reply(struct
 drm_dp_sideband_msg_rx *raw,
 		return
 drm_dp_sideband_parse_enum_path_resources_ack(raw, msg);
 	case DP_ALLOCATE_PAYLOAD:
 		return
 drm_dp_sideband_parse_allocate_payload_ack(raw, msg);
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		return

drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	default:
 		DRM_ERROR("Got unknown reply 0x%02x\n", msg-
Quoted 1 line

req_type);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		return false;
@@ -693,6 +718,22 @@ static int build_allocate_payload(struct

drm_dp_sideband_msg_tx *msg, int port_n

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
 	return 0;
 }
 
+static int build_power_updown_phy(struct drm_dp_sideband_msg_tx

*msg,

drivers/gpu/drm/drm_dp_mst_topology.c +15 -0
+				  int port_num, bool power_up)
+{
+	struct drm_dp_sideband_msg_req_body req;
+
+	if (power_up)
+		req.req_type = DP_POWER_UP_PHY;
+	else
+		req.req_type = DP_POWER_DOWN_PHY;
+
+	req.u.port_num.port_number = port_num;
+	drm_dp_encode_sideband_req(&req, msg);
+	msg->path_msg = true;
+	return 0;
+}
+
 static int drm_dp_mst_assign_payload_id(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 					struct drm_dp_vcpi *vcpi)
 {
@@ -1724,6 +1765,38 @@ static int drm_dp_payload_send_msg(struct
 drm_dp_mst_topology_mgr *mgr,
 	return ret;
 }
 
Quoted 16 lines
Quoted 5 lines
drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr
 *mgr,
+				 struct drm_dp_mst_port *port, bool
 power_up)
+{

drivers/gpu/drm/drm_dp_mst_topology.c static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr, · line 1780

Quoted 10 lines
drivers/gpu/drm/drm_dp_mst_topology.c +10 -0
+	struct drm_dp_sideband_msg_tx *txmsg;
+	int len, ret;
+
+	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+	if (!txmsg)
+		return -ENOMEM;
+
+	port = drm_dp_get_validated_port_ref(mgr, port);
+	if (!port)
+		return -EINVAL;

if (!port), then you leak memory by not freeing txmsg

Right, I'll fix that up in the next version. Thanks!

Quoted 41 lines
Quoted 41 lines
drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+
+	txmsg->dst = port->parent;
+	len = build_power_updown_phy(txmsg, port->port_num,

power_up);

drivers/gpu/drm/drm_dp_mst_topology.c +16 -0
+	drm_dp_queue_down_tx(mgr, txmsg);
+
+	ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+	if (ret > 0) {
+		if (txmsg->reply.reply_type == 1)
+			ret = -EINVAL;
+		else
+			ret = 0;
+	}
+	kfree(txmsg);
+	drm_dp_put_port(port);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_dp_send_power_updown_phy);
+
 static int drm_dp_create_payload_step1(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 				       int id,
 				       struct drm_dp_payload

*payload)

include/drm/drm_dp_mst_helper.h +1 -0
index d55abb75f29a..7f78d26a0766 100644
@@ -631,5 +631,7 @@ int drm_dp_atomic_find_vcpi_slots(struct
 drm_atomic_state *state,
 int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				     struct drm_dp_mst_topology_mgr
 *mgr,
 				     int slots);
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr

*mgr,

include/drm/drm_dp_mst_helper.h +1 -0
+				 struct drm_dp_mst_port *port, bool

power_up);

Quoted 5 lines
Quoted 1 line

#endif

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

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

#16 lore raw

PATCH v2 1/1 drm/dp/mst: Sideband message transaction to power up/down nodes

In reply to Lyude Paul

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an ACK, we can be sure that a downstream sink has enough time to respond to a power up/down request.

v2: Fix memory leak (Lyude)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 75 +++++++++++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  2 +
 2 files changed, 77 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +75 -0
index 41b492f99955..9bc5049e7e59 100644
@@ -294,6 +294,12 @@ static void drm_dp_encode_sideband_req(struct drm_dp_sideband_msg_req_body *req,
 		memcpy(&buf[idx], req->u.i2c_write.bytes, req->u.i2c_write.num_bytes);
 		idx += req->u.i2c_write.num_bytes;
 		break;
+
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		buf[idx] = (req->u.port_num.port_number & 0xf) << 4;
+		idx++;
+		break;
 	}
 	raw->cur_len = idx;
 }
@@ -538,6 +544,22 @@ static bool drm_dp_sideband_parse_query_payload_ack(struct drm_dp_sideband_msg_r
 	return false;
 }
 
+
+static bool drm_dp_sideband_parse_power_updown_phy_ack(struct drm_dp_sideband_msg_rx *raw,
+						       struct drm_dp_sideband_msg_reply_body *repmsg)
+{
+	int idx = 1;
+
+	repmsg->u.port_number.port_number = (raw->msg[idx] >> 4) & 0xf;
+	idx++;
+	if (idx > raw->curlen) {
+		DRM_DEBUG_KMS("power up/down phy parse length fail %d %d\n",
+			      idx, raw->curlen);
+		return false;
+	}
+	return true;
+}
+
 static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw,
 					struct drm_dp_sideband_msg_reply_body *msg)
 {
@@ -567,6 +589,9 @@ static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw,
 		return drm_dp_sideband_parse_enum_path_resources_ack(raw, msg);
 	case DP_ALLOCATE_PAYLOAD:
 		return drm_dp_sideband_parse_allocate_payload_ack(raw, msg);
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		return drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);
 	default:
 		DRM_ERROR("Got unknown reply 0x%02x\n", msg->req_type);
 		return false;
@@ -693,6 +718,22 @@ static int build_allocate_payload(struct drm_dp_sideband_msg_tx *msg, int port_n
 	return 0;
 }
 
+static int build_power_updown_phy(struct drm_dp_sideband_msg_tx *msg,
+				  int port_num, bool power_up)
+{
+	struct drm_dp_sideband_msg_req_body req;
+
+	if (power_up)
+		req.req_type = DP_POWER_UP_PHY;
+	else
+		req.req_type = DP_POWER_DOWN_PHY;
+
+	req.u.port_num.port_number = port_num;
+	drm_dp_encode_sideband_req(&req, msg);
+	msg->path_msg = true;
+	return 0;
+}
+
 static int drm_dp_mst_assign_payload_id(struct drm_dp_mst_topology_mgr *mgr,
 					struct drm_dp_vcpi *vcpi)
 {
@@ -1724,6 +1765,40 @@ static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr,
 	return ret;
 }
 
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
+				 struct drm_dp_mst_port *port, bool power_up)
+{
+	struct drm_dp_sideband_msg_tx *txmsg;
+	int len, ret;
+
+	port = drm_dp_get_validated_port_ref(mgr, port);
+	if (!port)
+		return -EINVAL;
+
+	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+	if (!txmsg) {
+		drm_dp_put_port(port);
+		return -ENOMEM;
+	}
+
+	txmsg->dst = port->parent;
+	len = build_power_updown_phy(txmsg, port->port_num, power_up);
+	drm_dp_queue_down_tx(mgr, txmsg);
+
+	ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+	if (ret > 0) {
+		if (txmsg->reply.reply_type == 1)
+			ret = -EINVAL;
+		else
+			ret = 0;
+	}
+	kfree(txmsg);
+	drm_dp_put_port(port);
+
+	return ret;
+}
+EXPORT_SYMBOL(drm_dp_send_power_updown_phy);
+
 static int drm_dp_create_payload_step1(struct drm_dp_mst_topology_mgr *mgr,
 				       int id,
 				       struct drm_dp_payload *payload)
include/drm/drm_dp_mst_helper.h +2 -0
index d55abb75f29a..7f78d26a0766 100644
@@ -631,5 +631,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
 int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				     struct drm_dp_mst_topology_mgr *mgr,
 				     int slots);
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
+				 struct drm_dp_mst_port *port, bool power_up);
 
 #endif
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 1/1
#17 lore raw

Looks good to me.

Quoted 177 lines · Dhinakaran Pandiyan

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow
the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the
MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an
ACK, we can be sure that a downstream sink has enough time to respond to a
power up/down request.

v2: Fix memory leak (Lyude)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 75
+++++++++++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  2 +
 2 files changed, 77 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
index 41b492f99955..9bc5049e7e59 100644
@@ -294,6 +294,12 @@ static void drm_dp_encode_sideband_req(struct
 drm_dp_sideband_msg_req_body *req,
 		memcpy(&buf[idx], req->u.i2c_write.bytes, req-
 >u.i2c_write.num_bytes);
 		idx += req->u.i2c_write.num_bytes;
 		break;
+
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		buf[idx] = (req->u.port_num.port_number & 0xf) << 4;
+		idx++;
+		break;
 	}
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	raw->cur_len = idx;
 }
@@ -538,6 +544,22 @@ static bool

drm_dp_sideband_parse_query_payload_ack(struct drm_dp_sideband_msg_r

drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
 	return false;
 }
 
+
+static bool drm_dp_sideband_parse_power_updown_phy_ack(struct

drm_dp_sideband_msg_rx *raw,

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
+						       struct

drm_dp_sideband_msg_reply_body *repmsg)

drivers/gpu/drm/drm_dp_mst_topology.c +4 -0
+{
+	int idx = 1;
+
+	repmsg->u.port_number.port_number = (raw->msg[idx] >> 4) &

0xf;

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+	idx++;
+	if (idx > raw->curlen) {
+		DRM_DEBUG_KMS("power up/down phy parse length fail

%d %d\n",

drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
+			      idx, raw->curlen);
+		return false;
+	}
+	return true;
+}
+
 static bool drm_dp_sideband_parse_reply(struct

drm_dp_sideband_msg_rx *raw,
struct
drm_dp_sideband_msg_reply_body *msg)
{

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
@@ -567,6 +589,9 @@ static bool drm_dp_sideband_parse_reply(struct
 drm_dp_sideband_msg_rx *raw,
 		return
 drm_dp_sideband_parse_enum_path_resources_ack(raw, msg);
 	case DP_ALLOCATE_PAYLOAD:
 		return
 drm_dp_sideband_parse_allocate_payload_ack(raw, msg);
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		return

drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	default:
 		DRM_ERROR("Got unknown reply 0x%02x\n", msg-
Quoted 1 line

req_type);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		return false;
@@ -693,6 +718,22 @@ static int build_allocate_payload(struct

drm_dp_sideband_msg_tx *msg, int port_n

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
 	return 0;
 }
 
+static int build_power_updown_phy(struct drm_dp_sideband_msg_tx

*msg,

drivers/gpu/drm/drm_dp_mst_topology.c +15 -0
+				  int port_num, bool power_up)
+{
+	struct drm_dp_sideband_msg_req_body req;
+
+	if (power_up)
+		req.req_type = DP_POWER_UP_PHY;
+	else
+		req.req_type = DP_POWER_DOWN_PHY;
+
+	req.u.port_num.port_number = port_num;
+	drm_dp_encode_sideband_req(&req, msg);
+	msg->path_msg = true;
+	return 0;
+}
+
 static int drm_dp_mst_assign_payload_id(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +18 -0
 					struct drm_dp_vcpi *vcpi)
 {
@@ -1724,6 +1765,40 @@ static int drm_dp_payload_send_msg(struct
 drm_dp_mst_topology_mgr *mgr,
 	return ret;
 }
 
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr
 *mgr,
+				 struct drm_dp_mst_port *port, bool
 power_up)
+{
+	struct drm_dp_sideband_msg_tx *txmsg;
+	int len, ret;
+
+	port = drm_dp_get_validated_port_ref(mgr, port);
+	if (!port)
+		return -EINVAL;
+
+	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+	if (!txmsg) {
+		drm_dp_put_port(port);
+		return -ENOMEM;
+	}
+
+	txmsg->dst = port->parent;
+	len = build_power_updown_phy(txmsg, port->port_num,

power_up);

drivers/gpu/drm/drm_dp_mst_topology.c +16 -0
+	drm_dp_queue_down_tx(mgr, txmsg);
+
+	ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+	if (ret > 0) {
+		if (txmsg->reply.reply_type == 1)
+			ret = -EINVAL;
+		else
+			ret = 0;
+	}
+	kfree(txmsg);
+	drm_dp_put_port(port);
+
+	return ret;
+}
+EXPORT_SYMBOL(drm_dp_send_power_updown_phy);
+
 static int drm_dp_create_payload_step1(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 				       int id,
 				       struct drm_dp_payload

*payload)

include/drm/drm_dp_mst_helper.h +1 -0
index d55abb75f29a..7f78d26a0766 100644
@@ -631,5 +631,7 @@ int drm_dp_atomic_find_vcpi_slots(struct
 drm_atomic_state *state,
 int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				     struct drm_dp_mst_topology_mgr
 *mgr,
 				     int slots);
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr

*mgr,

include/drm/drm_dp_mst_helper.h +1 -0
+				 struct drm_dp_mst_port *port, bool

power_up);

Quoted 1 line

#endif

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

#18 lore raw
Quoted 4 lines · Lyude Paul

Looks good to me.

Thanks for the review.
-DK

Quoted 178 lines · Dhinakaran Pandiyan
Quoted 177 lines

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow
the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the
MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an
ACK, we can be sure that a downstream sink has enough time to respond to a
power up/down request.

v2: Fix memory leak (Lyude)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 75
+++++++++++++++++++++++++++++++++++
 include/drm/drm_dp_mst_helper.h       |  2 +
 2 files changed, 77 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
index 41b492f99955..9bc5049e7e59 100644
@@ -294,6 +294,12 @@ static void drm_dp_encode_sideband_req(struct
 drm_dp_sideband_msg_req_body *req,
 		memcpy(&buf[idx], req->u.i2c_write.bytes, req-
 >u.i2c_write.num_bytes);
 		idx += req->u.i2c_write.num_bytes;
 		break;
+
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		buf[idx] = (req->u.port_num.port_number & 0xf) << 4;
+		idx++;
+		break;
 	}
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	raw->cur_len = idx;
 }
@@ -538,6 +544,22 @@ static bool

drm_dp_sideband_parse_query_payload_ack(struct drm_dp_sideband_msg_r

drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
 	return false;
 }
 
+
+static bool drm_dp_sideband_parse_power_updown_phy_ack(struct

drm_dp_sideband_msg_rx *raw,

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
+						       struct

drm_dp_sideband_msg_reply_body *repmsg)

drivers/gpu/drm/drm_dp_mst_topology.c +4 -0
+{
+	int idx = 1;
+
+	repmsg->u.port_number.port_number = (raw->msg[idx] >> 4) &

0xf;

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
+	idx++;
+	if (idx > raw->curlen) {
+		DRM_DEBUG_KMS("power up/down phy parse length fail

%d %d\n",

drivers/gpu/drm/drm_dp_mst_topology.c +6 -0
+			      idx, raw->curlen);
+		return false;
+	}
+	return true;
+}
+
 static bool drm_dp_sideband_parse_reply(struct

drm_dp_sideband_msg_rx *raw,
struct
drm_dp_sideband_msg_reply_body *msg)
{

drivers/gpu/drm/drm_dp_mst_topology.c +3 -0
@@ -567,6 +589,9 @@ static bool drm_dp_sideband_parse_reply(struct
 drm_dp_sideband_msg_rx *raw,
 		return
 drm_dp_sideband_parse_enum_path_resources_ack(raw, msg);
 	case DP_ALLOCATE_PAYLOAD:
 		return
 drm_dp_sideband_parse_allocate_payload_ack(raw, msg);
+	case DP_POWER_DOWN_PHY:
+	case DP_POWER_UP_PHY:
+		return

drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 	default:
 		DRM_ERROR("Got unknown reply 0x%02x\n", msg-
Quoted 1 line

req_type);

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		return false;
@@ -693,6 +718,22 @@ static int build_allocate_payload(struct

drm_dp_sideband_msg_tx *msg, int port_n

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
 	return 0;
 }
 
+static int build_power_updown_phy(struct drm_dp_sideband_msg_tx

*msg,

drivers/gpu/drm/drm_dp_mst_topology.c +15 -0
+				  int port_num, bool power_up)
+{
+	struct drm_dp_sideband_msg_req_body req;
+
+	if (power_up)
+		req.req_type = DP_POWER_UP_PHY;
+	else
+		req.req_type = DP_POWER_DOWN_PHY;
+
+	req.u.port_num.port_number = port_num;
+	drm_dp_encode_sideband_req(&req, msg);
+	msg->path_msg = true;
+	return 0;
+}
+
 static int drm_dp_mst_assign_payload_id(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +18 -0
 					struct drm_dp_vcpi *vcpi)
 {
@@ -1724,6 +1765,40 @@ static int drm_dp_payload_send_msg(struct
 drm_dp_mst_topology_mgr *mgr,
 	return ret;
 }
 
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr
 *mgr,
+				 struct drm_dp_mst_port *port, bool
 power_up)
+{
+	struct drm_dp_sideband_msg_tx *txmsg;
+	int len, ret;
+
+	port = drm_dp_get_validated_port_ref(mgr, port);
+	if (!port)
+		return -EINVAL;
+
+	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+	if (!txmsg) {
+		drm_dp_put_port(port);
+		return -ENOMEM;
+	}
+
+	txmsg->dst = port->parent;
+	len = build_power_updown_phy(txmsg, port->port_num,

power_up);

drivers/gpu/drm/drm_dp_mst_topology.c +16 -0
+	drm_dp_queue_down_tx(mgr, txmsg);
+
+	ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+	if (ret > 0) {
+		if (txmsg->reply.reply_type == 1)
+			ret = -EINVAL;
+		else
+			ret = 0;
+	}
+	kfree(txmsg);
+	drm_dp_put_port(port);
+
+	return ret;
+}
+EXPORT_SYMBOL(drm_dp_send_power_updown_phy);
+
 static int drm_dp_create_payload_step1(struct

drm_dp_mst_topology_mgr *mgr,

drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 				       int id,
 				       struct drm_dp_payload

*payload)

include/drm/drm_dp_mst_helper.h +1 -0
index d55abb75f29a..7f78d26a0766 100644
@@ -631,5 +631,7 @@ int drm_dp_atomic_find_vcpi_slots(struct
 drm_atomic_state *state,
 int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
 				     struct drm_dp_mst_topology_mgr
 *mgr,
 				     int slots);
+int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr

*mgr,

include/drm/drm_dp_mst_helper.h +1 -0
+				 struct drm_dp_mst_port *port, bool

power_up);

Quoted 5 lines
Quoted 1 line

#endif

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#19 lore raw
In reply to Dhinakaran Pandiyan
Quoted 7 lines · Dhinakaran Pandiyan

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an ACK, we can be sure that a downstream sink has enough time to respond to a power up/down request.

I was a bit worried how this handles multiple streams going through the same MST device, but looks like the spec has accounted for this by having the device skip the D3 if any active streams are present.

I guess that also means we have to do this after we've turned off the stream, assuming we want things actually reach D3. Looks like that does match our current order of things.

Pushed this one to drm-misc-next. Thanks for the patch and review.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw
Quoted 13 lines · Ville Syrjälä
Quoted 7 lines · Dhinakaran Pandiyan

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an ACK, we can be sure that a downstream sink has enough time to respond to a power up/down request.

I was a bit worried how this handles multiple streams going through the same MST device, but looks like the spec has accounted for this by having the device skip the D3 if any active streams are present.

Quoted 6 lines

I guess that also means we have to do this after we've turned off the stream, assuming we want things actually reach D3. Looks like that does match our current order of things.

Pushed this one to drm-misc-next. Thanks for the patch and review.

Thanks, do you see any potential problems patch with Patch 2/2?
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#21 lore raw

✗ Fi.CI.BAT: failure for series starting with [v2] drm/dp/mst: Sideband message transaction to power up/down nodes (rev2)

In reply to Dhinakaran Pandiyan
== Series Details ==

== Series Details ==

Series: series starting with [v2] drm/dp/mst: Sideband message transaction to power up/down nodes (rev2)
URL : https://patchwork.freedesktop.org/series/29853/
State : failure

== Summary ==

Series 29853v2 series starting with [v2] drm/dp/mst: Sideband message transaction to power up/down nodes
https://patchwork.freedesktop.org/api/1.0/series/29853/revisions/2/mbox/

Test kms_cursor_legacy:

        Subgroup basic-busy-flip-before-cursor-legacy:
                fail       -> PASS       (fi-snb-2600) fdo#100215
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> SKIP       (fi-cfl-s) fdo#102294
Test drv_module_reload:
        Subgroup basic-reload-inject:
                pass       -> INCOMPLETE (fi-bwr-2160)

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#102294 https://bugs.freedesktop.org/show_bug.cgi?id=102294

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:456s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:439s
fi-blb-e6850     total:289  pass:224  dwarn:1   dfail:0   fail:0   skip:64  time:365s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:554s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:104
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:520s
fi-byt-j1900     total:289  pass:254  dwarn:1   dfail:0   fail:0   skip:34  time:524s
fi-byt-n2820     total:289  pass:250  dwarn:1   dfail:0   fail:0   skip:38  time:512s
fi-cfl-s         total:289  pass:249  dwarn:4   dfail:0   fail:0   skip:36  time:475s
fi-elk-e7500     total:289  pass:230  dwarn:0   dfail:0   fail:0   skip:59  time:431s
fi-glk-2a        total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:610s
fi-hsw-4770      total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:445s
fi-hsw-4770r     total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:426s
fi-ilk-650       total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:425s
fi-ivb-3520m     total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:506s
fi-ivb-3770      total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:476s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:516s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:608s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:597s
fi-pnv-d510      total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:530s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:476s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:533s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:512s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:450s
fi-skl-x1585l    total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:489s
fi-snb-2520m     total:289  pass:251  dwarn:0   dfail:0   fail:0   skip:38  time:558s
fi-snb-2600      total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:410s

d987a6e6aed64b97877546c110149c16bca64804 drm-tip: 2017y-09m-06d-23h-36m-35s UTC integration manifest 86fb8d256f2b drm/i915/mst: Use MST sideband message transaction for dpms f7f3476b4cfd drm/dp/mst: Sideband message transaction to power up/down nodes

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5601/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v1 1/2
#22 lore raw
In reply to Dhinakaran Pandiyan
Quoted 8 lines · Dhinakaran Pandiyan

The POWER_DOWN_PHY and POWER_UP_PHY sideband message transactions allow the source to reqest any node in a mst path or a whole path to be powered down or up. This allows drivers to target a specific sink in the MST topology, an improvement over just power managing the imediate downstream device. Secondly, since the request-reply protocol waits for an ACK, we can be sure that a downstream sink has enough time to respond to a power up/down request.

Quoted 4 lines
Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel