Re: [Intel-gfx] [PATCH v4 13/14] drm/mst: Add support for QUERY_STREAM_ENCRYPTION_STATUS MST sideband message
Hey - I've got a good bit of stuff on my plate right now since I just got back from PTO and am going through my backlog of stuff, but I'll try to get this reviewed first chance I get On Tue, 2020-02-18 at 17:02 -0500, Sean Paul wrote: > From: Sean Paul > > Used to query whether an MST stream is encrypted or not. > > Cc: Lyude Paul > Signed-off-by: Sean Paul > > Changes in v4: > -Added to the set > --- > drivers/gpu/drm/drm_dp_mst_topology.c | 117 ++ > include/drm/drm_dp_helper.h | 3 + > include/drm/drm_dp_mst_helper.h | 44 ++ > 3 files changed, 164 insertions(+) > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c > b/drivers/gpu/drm/drm_dp_mst_topology.c > index a811247cecfef..30b6dc6ce54c2 100644 > --- a/drivers/gpu/drm/drm_dp_mst_topology.c > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -418,6 +419,22 @@ drm_dp_encode_sideband_req(const 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_QUERY_STREAM_ENC_STATUS: { > + const struct drm_dp_query_stream_enc_status *msg; > + > + msg = &req->u.enc_status; > + buf[idx] = msg->stream_id; > + idx++; > + memcpy(&buf[idx], msg->client_id, sizeof(msg->client_id)); > + idx += sizeof(msg->client_id); > + buf[idx] = 0; > + buf[idx] |= msg->stream_event & GENMASK(1, 0); > + buf[idx] |= msg->valid_stream_event ? BIT(2) : 0; > + buf[idx] |= (msg->stream_behavior & GENMASK(1, 0)) << 3; > + buf[idx] |= msg->valid_stream_behavior ? BIT(5) : 0; > + idx++; > + } > + break; > } > raw->cur_len = idx; > } > @@ -926,6 +943,34 @@ static bool > drm_dp_sideband_parse_power_updown_phy_ack(struct drm_dp_sideband_ms > return true; > } > > +static bool > +drm_dp_sideband_parse_query_stream_enc_status( > + struct drm_dp_sideband_msg_rx *raw, > + struct drm_dp_sideband_msg_reply_body *repmsg) > +{ > + struct drm_dp_query_stream_enc_status_ack_reply *reply; > + > + reply = &repmsg->u.enc_status; > + > + reply->stream_id = raw->msg[3]; > + > + reply->reply_signed = raw->msg[2] & BIT(0); > + > + reply->hdcp_1x_device_present = raw->msg[2] & BIT(3); > + reply->hdcp_2x_device_present = raw->msg[2] & BIT(4); > + > + reply->query_capable_device_present = raw->msg[2] & BIT(5); > + reply->legacy_device_present = raw->msg[2] & BIT(6); > + reply->unauthorizable_device_present = raw->msg[2] & BIT(7); > + > + reply->auth_completed = !!(raw->msg[1] & BIT(3)); > + reply->encryption_enabled = !!(raw->msg[1] & BIT(4)); > + reply->repeater_present = !!(raw->msg[1] & BIT(5)); > + reply->state = (raw->msg[1] & GENMASK(7, 6)) >> 6; > + > + return true; > +} > + > static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw, > struct drm_dp_sideband_msg_reply_body > *msg) > { > @@ -960,6 +1005,8 @@ static bool drm_dp_sideband_parse_reply(struct > drm_dp_sideband_msg_rx *raw, > return drm_dp_sideband_parse_power_updown_phy_ack(raw, msg); > case DP_CLEAR_PAYLOAD_ID_TABLE: > return true; /* since there's nothing to parse */ > + case DP_QUERY_STREAM_ENC_STATUS: > + return drm_dp_sideband_parse_query_stream_enc_status(raw, > msg); > default: > DRM_ERROR("Got unknown reply 0x%02x (%s)\n", msg->req_type, > drm_dp_mst_req_type_str(msg->req_type)); > @@ -1113,6 +1160,25 @@ static int build_power_updown_phy(struct > drm_dp_sideband_msg_tx *msg, > return 0; > } > > +static int > +build_query_stream_enc_status(struct drm_dp_sideband_msg_tx *msg, u8 > stream_id, > + u8 *q_id) > +{ > + struct drm_dp_sideband_msg_req_body req; > + > + req.req_type = DP_QUERY_STREAM_ENC_STATUS; > + req.u.enc_status.stream_id = stream_id; > + memcpy(req.u.enc_status.client_id, q_id, > +sizeof(req.u.enc_status.client_id)); > + req.u.enc_status.stream_event = 0; > + req.u.enc_status.valid_stream_event = false; > + req.u.enc_status.stream_behavior = 0; > + req.u.enc_status.valid_stream_behavior = false; > + > + drm_dp_encode_sideband_req(&req, msg); > + return 0; > +} > + > static int drm_dp_mst_assign_payload_id(struct drm_dp_mst_topology_mgr > *mgr, > struct drm_dp_vcpi *vcpi) > { > @@ -3154,6 +3220,57 @@ int drm_dp_send_power_updown_phy(struct > drm_dp_mst_topology_mgr *mgr, > } > EXPORT_SYMBOL(drm_dp_send_power_updown_phy); > > +int dr
[Intel-gfx] [PATCH v4 13/14] drm/mst: Add support for QUERY_STREAM_ENCRYPTION_STATUS MST sideband message
From: Sean Paul Used to query whether an MST stream is encrypted or not. Cc: Lyude Paul Signed-off-by: Sean Paul Changes in v4: -Added to the set --- drivers/gpu/drm/drm_dp_mst_topology.c | 117 ++ include/drm/drm_dp_helper.h | 3 + include/drm/drm_dp_mst_helper.h | 44 ++ 3 files changed, 164 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index a811247cecfef..30b6dc6ce54c2 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -418,6 +419,22 @@ drm_dp_encode_sideband_req(const 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_QUERY_STREAM_ENC_STATUS: { + const struct drm_dp_query_stream_enc_status *msg; + + msg = &req->u.enc_status; + buf[idx] = msg->stream_id; + idx++; + memcpy(&buf[idx], msg->client_id, sizeof(msg->client_id)); + idx += sizeof(msg->client_id); + buf[idx] = 0; + buf[idx] |= msg->stream_event & GENMASK(1, 0); + buf[idx] |= msg->valid_stream_event ? BIT(2) : 0; + buf[idx] |= (msg->stream_behavior & GENMASK(1, 0)) << 3; + buf[idx] |= msg->valid_stream_behavior ? BIT(5) : 0; + idx++; + } + break; } raw->cur_len = idx; } @@ -926,6 +943,34 @@ static bool drm_dp_sideband_parse_power_updown_phy_ack(struct drm_dp_sideband_ms return true; } +static bool +drm_dp_sideband_parse_query_stream_enc_status( + struct drm_dp_sideband_msg_rx *raw, + struct drm_dp_sideband_msg_reply_body *repmsg) +{ + struct drm_dp_query_stream_enc_status_ack_reply *reply; + + reply = &repmsg->u.enc_status; + + reply->stream_id = raw->msg[3]; + + reply->reply_signed = raw->msg[2] & BIT(0); + + reply->hdcp_1x_device_present = raw->msg[2] & BIT(3); + reply->hdcp_2x_device_present = raw->msg[2] & BIT(4); + + reply->query_capable_device_present = raw->msg[2] & BIT(5); + reply->legacy_device_present = raw->msg[2] & BIT(6); + reply->unauthorizable_device_present = raw->msg[2] & BIT(7); + + reply->auth_completed = !!(raw->msg[1] & BIT(3)); + reply->encryption_enabled = !!(raw->msg[1] & BIT(4)); + reply->repeater_present = !!(raw->msg[1] & BIT(5)); + reply->state = (raw->msg[1] & GENMASK(7, 6)) >> 6; + + return true; +} + static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw, struct drm_dp_sideband_msg_reply_body *msg) { @@ -960,6 +1005,8 @@ static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw, return drm_dp_sideband_parse_power_updown_phy_ack(raw, msg); case DP_CLEAR_PAYLOAD_ID_TABLE: return true; /* since there's nothing to parse */ + case DP_QUERY_STREAM_ENC_STATUS: + return drm_dp_sideband_parse_query_stream_enc_status(raw, msg); default: DRM_ERROR("Got unknown reply 0x%02x (%s)\n", msg->req_type, drm_dp_mst_req_type_str(msg->req_type)); @@ -1113,6 +1160,25 @@ static int build_power_updown_phy(struct drm_dp_sideband_msg_tx *msg, return 0; } +static int +build_query_stream_enc_status(struct drm_dp_sideband_msg_tx *msg, u8 stream_id, + u8 *q_id) +{ + struct drm_dp_sideband_msg_req_body req; + + req.req_type = DP_QUERY_STREAM_ENC_STATUS; + req.u.enc_status.stream_id = stream_id; + memcpy(req.u.enc_status.client_id, q_id, + sizeof(req.u.enc_status.client_id)); + req.u.enc_status.stream_event = 0; + req.u.enc_status.valid_stream_event = false; + req.u.enc_status.stream_behavior = 0; + req.u.enc_status.valid_stream_behavior = false; + + drm_dp_encode_sideband_req(&req, msg); + return 0; +} + static int drm_dp_mst_assign_payload_id(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_vcpi *vcpi) { @@ -3154,6 +3220,57 @@ int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr, } EXPORT_SYMBOL(drm_dp_send_power_updown_phy); +int drm_dp_send_query_stream_enc_status(struct drm_dp_mst_topology_mgr *mgr, + struct drm_dp_mst_port *port, + struct drm_dp_query_stream_enc_status_ack_reply *status) +{ + struct drm_dp_sideband_msg_tx *txmsg; + u8 nonce[7]; + int len, ret; + + txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL); + if (!txmsg) + return -