Commit 5e93b820 authored by Hersen Wu's avatar Hersen Wu Committed by Dave Airlie

drm/dp/mst: move GUID storage from mgr, port to only mst branch

Previous implementation does not handle case below: boot up one MST branch
to DP connector of ASIC. After boot up, hot plug 2nd MST branch to DP output
of 1st MST, GUID is not created for 2nd MST branch. When downstream port of
2nd MST branch send upstream request, it fails because 2nd MST branch GUID
is not available.

New Implementation: only create GUID for MST branch and save it within Branch.
Signed-off-by: default avatarHersen Wu <hersenxs.wu@amd.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Cc: stable@vger.kernel.org
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent cfcfa086
...@@ -1018,18 +1018,27 @@ static bool drm_dp_port_setup_pdt(struct drm_dp_mst_port *port) ...@@ -1018,18 +1018,27 @@ static bool drm_dp_port_setup_pdt(struct drm_dp_mst_port *port)
return send_link; return send_link;
} }
static void drm_dp_check_port_guid(struct drm_dp_mst_branch *mstb, static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid)
struct drm_dp_mst_port *port)
{ {
int ret; int ret;
if (port->dpcd_rev >= 0x12) {
port->guid_valid = drm_dp_validate_guid(mstb->mgr, port->guid); memcpy(mstb->guid, guid, 16);
if (!port->guid_valid) {
ret = drm_dp_send_dpcd_write(mstb->mgr, if (!drm_dp_validate_guid(mstb->mgr, mstb->guid)) {
port, if (mstb->port_parent) {
ret = drm_dp_send_dpcd_write(
mstb->mgr,
mstb->port_parent,
DP_GUID,
16,
mstb->guid);
} else {
ret = drm_dp_dpcd_write(
mstb->mgr->aux,
DP_GUID, DP_GUID,
16, port->guid); mstb->guid,
port->guid_valid = true; 16);
} }
} }
} }
...@@ -1086,7 +1095,6 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, ...@@ -1086,7 +1095,6 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
port->dpcd_rev = port_msg->dpcd_revision; port->dpcd_rev = port_msg->dpcd_revision;
port->num_sdp_streams = port_msg->num_sdp_streams; port->num_sdp_streams = port_msg->num_sdp_streams;
port->num_sdp_stream_sinks = port_msg->num_sdp_stream_sinks; port->num_sdp_stream_sinks = port_msg->num_sdp_stream_sinks;
memcpy(port->guid, port_msg->peer_guid, 16);
/* manage mstb port lists with mgr lock - take a reference /* manage mstb port lists with mgr lock - take a reference
for this list */ for this list */
...@@ -1099,11 +1107,9 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, ...@@ -1099,11 +1107,9 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
if (old_ddps != port->ddps) { if (old_ddps != port->ddps) {
if (port->ddps) { if (port->ddps) {
drm_dp_check_port_guid(mstb, port);
if (!port->input) if (!port->input)
drm_dp_send_enum_path_resources(mstb->mgr, mstb, port); drm_dp_send_enum_path_resources(mstb->mgr, mstb, port);
} else { } else {
port->guid_valid = false;
port->available_pbn = 0; port->available_pbn = 0;
} }
} }
...@@ -1161,9 +1167,7 @@ static void drm_dp_update_port(struct drm_dp_mst_branch *mstb, ...@@ -1161,9 +1167,7 @@ static void drm_dp_update_port(struct drm_dp_mst_branch *mstb,
if (old_ddps != port->ddps) { if (old_ddps != port->ddps) {
dowork = true; dowork = true;
if (port->ddps) { if (port->ddps) {
drm_dp_check_port_guid(mstb, port);
} else { } else {
port->guid_valid = false;
port->available_pbn = 0; port->available_pbn = 0;
} }
} }
...@@ -1220,13 +1224,14 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper( ...@@ -1220,13 +1224,14 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
struct drm_dp_mst_branch *found_mstb; struct drm_dp_mst_branch *found_mstb;
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
if (memcmp(mstb->guid, guid, 16) == 0)
return mstb;
list_for_each_entry(port, &mstb->ports, next) { list_for_each_entry(port, &mstb->ports, next) {
if (!port->mstb) if (!port->mstb)
continue; continue;
if (port->guid_valid && memcmp(port->guid, guid, 16) == 0)
return port->mstb;
found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid); found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid);
if (found_mstb) if (found_mstb)
...@@ -1245,9 +1250,6 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device_by_guid( ...@@ -1245,9 +1250,6 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device_by_guid(
/* find the port by iterating down */ /* find the port by iterating down */
mutex_lock(&mgr->lock); mutex_lock(&mgr->lock);
if (mgr->guid_valid && memcmp(mgr->guid, guid, 16) == 0)
mstb = mgr->mst_primary;
else
mstb = get_mst_branch_device_by_guid_helper(mgr->mst_primary, guid); mstb = get_mst_branch_device_by_guid_helper(mgr->mst_primary, guid);
if (mstb) if (mstb)
...@@ -1566,6 +1568,9 @@ static void drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr, ...@@ -1566,6 +1568,9 @@ static void drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
txmsg->reply.u.link_addr.ports[i].num_sdp_streams, txmsg->reply.u.link_addr.ports[i].num_sdp_streams,
txmsg->reply.u.link_addr.ports[i].num_sdp_stream_sinks); txmsg->reply.u.link_addr.ports[i].num_sdp_stream_sinks);
} }
drm_dp_check_mstb_guid(mstb, txmsg->reply.u.link_addr.guid);
for (i = 0; i < txmsg->reply.u.link_addr.nports; i++) { for (i = 0; i < txmsg->reply.u.link_addr.nports; i++) {
drm_dp_add_port(mstb, mgr->dev, &txmsg->reply.u.link_addr.ports[i]); drm_dp_add_port(mstb, mgr->dev, &txmsg->reply.u.link_addr.ports[i]);
} }
...@@ -2006,20 +2011,6 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms ...@@ -2006,20 +2011,6 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
goto out_unlock; goto out_unlock;
} }
/* sort out guid */
ret = drm_dp_dpcd_read(mgr->aux, DP_GUID, mgr->guid, 16);
if (ret != 16) {
DRM_DEBUG_KMS("failed to read DP GUID %d\n", ret);
goto out_unlock;
}
mgr->guid_valid = drm_dp_validate_guid(mgr, mgr->guid);
if (!mgr->guid_valid) {
ret = drm_dp_dpcd_write(mgr->aux, DP_GUID, mgr->guid, 16);
mgr->guid_valid = true;
}
queue_work(system_long_wq, &mgr->work); queue_work(system_long_wq, &mgr->work);
ret = 0; ret = 0;
...@@ -2241,6 +2232,7 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr) ...@@ -2241,6 +2232,7 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
} }
drm_dp_update_port(mstb, &msg.u.conn_stat); drm_dp_update_port(mstb, &msg.u.conn_stat);
DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type); DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type);
} else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) { } else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) {
drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false); drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false);
......
...@@ -44,8 +44,6 @@ struct drm_dp_vcpi { ...@@ -44,8 +44,6 @@ struct drm_dp_vcpi {
/** /**
* struct drm_dp_mst_port - MST port * struct drm_dp_mst_port - MST port
* @kref: reference count for this port. * @kref: reference count for this port.
* @guid_valid: for DP 1.2 devices if we have validated the GUID.
* @guid: guid for DP 1.2 device on this port.
* @port_num: port number * @port_num: port number
* @input: if this port is an input port. * @input: if this port is an input port.
* @mcs: message capability status - DP 1.2 spec. * @mcs: message capability status - DP 1.2 spec.
...@@ -70,10 +68,6 @@ struct drm_dp_vcpi { ...@@ -70,10 +68,6 @@ struct drm_dp_vcpi {
struct drm_dp_mst_port { struct drm_dp_mst_port {
struct kref kref; struct kref kref;
/* if dpcd 1.2 device is on this port - its GUID info */
bool guid_valid;
u8 guid[16];
u8 port_num; u8 port_num;
bool input; bool input;
bool mcs; bool mcs;
...@@ -110,10 +104,12 @@ struct drm_dp_mst_port { ...@@ -110,10 +104,12 @@ struct drm_dp_mst_port {
* @tx_slots: transmission slots for this device. * @tx_slots: transmission slots for this device.
* @last_seqno: last sequence number used to talk to this. * @last_seqno: last sequence number used to talk to this.
* @link_address_sent: if a link address message has been sent to this device yet. * @link_address_sent: if a link address message has been sent to this device yet.
* @guid: guid for DP 1.2 branch device. port under this branch can be
* identified by port #.
* *
* This structure represents an MST branch device, there is one * This structure represents an MST branch device, there is one
* primary branch device at the root, along with any others connected * primary branch device at the root, along with any other branches connected
* to downstream ports * to downstream port of parent branches.
*/ */
struct drm_dp_mst_branch { struct drm_dp_mst_branch {
struct kref kref; struct kref kref;
...@@ -132,6 +128,9 @@ struct drm_dp_mst_branch { ...@@ -132,6 +128,9 @@ struct drm_dp_mst_branch {
struct drm_dp_sideband_msg_tx *tx_slots[2]; struct drm_dp_sideband_msg_tx *tx_slots[2];
int last_seqno; int last_seqno;
bool link_address_sent; bool link_address_sent;
/* global unique identifier to identify branch devices */
u8 guid[16];
}; };
...@@ -406,11 +405,9 @@ struct drm_dp_payload { ...@@ -406,11 +405,9 @@ struct drm_dp_payload {
* @conn_base_id: DRM connector ID this mgr is connected to. * @conn_base_id: DRM connector ID this mgr is connected to.
* @down_rep_recv: msg receiver state for down replies. * @down_rep_recv: msg receiver state for down replies.
* @up_req_recv: msg receiver state for up requests. * @up_req_recv: msg receiver state for up requests.
* @lock: protects mst state, primary, guid, dpcd. * @lock: protects mst state, primary, dpcd.
* @mst_state: if this manager is enabled for an MST capable port. * @mst_state: if this manager is enabled for an MST capable port.
* @mst_primary: pointer to the primary branch device. * @mst_primary: pointer to the primary branch device.
* @guid_valid: GUID valid for the primary branch device.
* @guid: GUID for primary port.
* @dpcd: cache of DPCD for primary port. * @dpcd: cache of DPCD for primary port.
* @pbn_div: PBN to slots divisor. * @pbn_div: PBN to slots divisor.
* *
...@@ -432,13 +429,11 @@ struct drm_dp_mst_topology_mgr { ...@@ -432,13 +429,11 @@ struct drm_dp_mst_topology_mgr {
struct drm_dp_sideband_msg_rx up_req_recv; struct drm_dp_sideband_msg_rx up_req_recv;
/* pointer to info about the initial MST device */ /* pointer to info about the initial MST device */
struct mutex lock; /* protects mst_state + primary + guid + dpcd */ struct mutex lock; /* protects mst_state + primary + dpcd */
bool mst_state; bool mst_state;
struct drm_dp_mst_branch *mst_primary; struct drm_dp_mst_branch *mst_primary;
/* primary MST device GUID */
bool guid_valid;
u8 guid[16];
u8 dpcd[DP_RECEIVER_CAP_SIZE]; u8 dpcd[DP_RECEIVER_CAP_SIZE];
u8 sink_count; u8 sink_count;
int pbn_div; int pbn_div;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment